Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Store the Enzo-E version number in parameters attribute of EnzoEDataset #4097

Merged
merged 4 commits into from
Aug 26, 2022

Conversation

mabruzzo
Copy link
Contributor

More recent versions of Enzo-E record the version number in the outputs. This PR now stores that in the parameters attribute of EnzoEDataset instances (the value is associated with 'version_string').

The primary reason that Enzo-E now saves this version number is to make it easier to interpret the data, when the interpretation changes in newer versions.

At present, the version string only affects one thing: the distinction between particle masses and densities.

  • Several months back Enzo-E started to save particle masses such that they should be interpreted as masses (previously they were usually treated as densities).
  • At the time, to differentiate the interpretation of this data from outputs written by older code versions, we started to have Enzo-E append a parameter called "mass_is_mass" to the output copy of the parameter file (PR ENH: Update Enzo-E particle mass/density distinction #3914 started querying of this parameter).
  • Unfortunately, that approach introduced problems on certain platforms. Thus, we decided to record the version number as an attribute of output hdf5 files that could be used to make this distinction going forward (this will hopefully make any future changes in interpretations easier to handle as well)

Let me know if you need me to add any new tests for this PR.

More recent versions of Enzo-E record the version number in the outputs. This change now stores that in the parameters attribute of EnzoEDataset instances (the value is associated with 'version_string').

This change also updates the check for whether Enzo-E particle masses should be interpretted as masses or densities to always interpret them as masses if a version string is specified. The previous way Enzo-E specified this choice (i.e. by appending a parameter called "mass_is_mass" to the output copy of the parameter file) ended up causing some problems on certain platforms.
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution ! I have one comment that I would like to see addressed, and a question that may not be relevant. Otherwise, this looks good to me !

yt/frontends/enzo_e/data_structures.py Outdated Show resolved Hide resolved
# particle parameter
mass_flag = nested_dict_get(
self.ds.parameters, ("Particle", "mass_is_mass"), default=None
)
self._particle_mass_is_mass = mass_flag is not None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you haven't touched this line here but would it make more sense as follows ?

Suggested change
self._particle_mass_is_mass = mass_flag is not None
self._particle_mass_is_mass = bool(mass_flag)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it currently reads just checks for the existence of the parameter. For better or worse, the way that parameter historically got set was unsound and could set the parameter to a random value. This includes a value of zero. So I think we need to keep the current logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright that makes sense to me. If you have a minute to add this information as a comment I think that'd be very valuable :)

@neutrinoceros neutrinoceros added enhancement Making something better code frontends Things related to specific frontends labels Aug 25, 2022
… instance attribute of EnzoEDataset: "version_string" -> "version"
…ce of mass_is_mass parameter rather than checking the value.
@neutrinoceros
Copy link
Member

pre-commit.ci autofix

@neutrinoceros
Copy link
Member

Ran into a flaky test, let's run it again
@yt-fido test this please

@neutrinoceros
Copy link
Member

Same error. Third time's the charm ? @yt-fido test this please

@neutrinoceros neutrinoceros merged commit 5a5902c into yt-project:main Aug 26, 2022
@mabruzzo mabruzzo deleted the enzo-e-version-string branch August 26, 2022 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code frontends Things related to specific frontends enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants