Skip to content

Commit

Permalink
Update writing of hdf5 data (#105)
Browse files Browse the repository at this point in the history
* Update writing of hdf5 data

* Fix gh actions

* Fix test
  • Loading branch information
ladinesa authored Apr 19, 2024
1 parent c6fb75e commit 68f0d2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
36 changes: 4 additions & 32 deletions atomisticparsers/gromacs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 68f0d2b

Please sign in to comment.