From 68f0d2b6e31b934c979bda673b04ea12c39a5d25 Mon Sep 17 00:00:00 2001 From: ladinesa <67910858+ladinesa@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:07:43 +0200 Subject: [PATCH] Update writing of hdf5 data (#105) * Update writing of hdf5 data * Fix gh actions * Fix test --- .github/workflows/python-actions.yaml | 2 +- atomisticparsers/gromacs/parser.py | 36 +++------------------------ 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/.github/workflows/python-actions.yaml b/.github/workflows/python-actions.yaml index e9bb4c6c..92757120 100644 --- a/.github/workflows/python-actions.yaml +++ b/.github/workflows/python-actions.yaml @@ -12,9 +12,9 @@ jobs: - name: Install dependencies run: | pip install --upgrade pip + pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple # we need the latest nomad version for testing pip install nomad-lab[infrastructure]@git+https://github.com/nomad-coe/nomad.git@develop - pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple pip install coverage coveralls - name: mypy run: | diff --git a/atomisticparsers/gromacs/parser.py b/atomisticparsers/gromacs/parser.py index 9be1bf08..56faf077 100644 --- a/atomisticparsers/gromacs/parser.py +++ b/atomisticparsers/gromacs/parser.py @@ -55,7 +55,6 @@ ) from atomisticparsers.utils import MDAnalysisParser, MDParser from nomad.atomutils import get_bond_list_from_model_contributions -from nomad.parsing.parser import to_hdf5 re_float = r"[-+]?\d+\.*\d*(?:[Ee][-+]\d+)?" re_n = r"[\n\r]" @@ -1448,43 +1447,16 @@ def parse_workflow(self): self.parse_md_workflow(dict(method=method, results=results)) if flag_fe: - filename = os.path.join( - os.path.dirname(self.mainfile.split("/raw/")[-1]), - f"{os.path.basename(self.mainfile)}.archive.hdf5", - ) - if not os.path.isfile( - os.path.join(os.path.dirname(self.mainfile), filename) - ): - if self.archive.m_context: - with self.archive.m_context.raw_file(filename, "wb") as f: - pass sec_fe_parameters = ( self.archive.workflow2.method.free_energy_calculation_parameters[0] ) sec_fe = self.archive.workflow2.results.free_energy_calculations[0] sec_fe.method_ref = sec_fe_parameters if self.archive.m_context: - with self.archive.m_context.raw_file(filename, "r+b") as f: - sec_fe.value_total_energy_magnitude = to_hdf5( - columns[:, 0], - f, - f"{sec_fe.m_path()}/value_total_energy_magnitude", - ) - sec_fe.value_total_energy_derivative_magnitude = to_hdf5( - columns[:, 1], - f, - f"{sec_fe.m_path()}/value_total_energy_derivative_magnitude", - ) - sec_fe.value_total_energy_differences_magnitude = to_hdf5( - columns[:, 2:-1], - f, - f"{sec_fe.m_path()}/value_total_energy_differences_magnitude", - ) - sec_fe.value_PV_energy_magnitude = to_hdf5( - columns[:, -1], - f, - f"{sec_fe.m_path()}/value_PV_energy_magnitude", - ) + sec_fe.value_total_energy_magnitude = columns[:, 0] + sec_fe.value_total_energy_derivative_magnitude = columns[:, 1] + sec_fe.value_total_energy_differences_magnitude = columns[:, 2:-1] + sec_fe.value_PV_energy_magnitude = columns[:, -1] def parse_input(self): sec_run = self.archive.run[-1]