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: Update Enzo-E particle mass/density distinction #3914

Merged
merged 10 commits into from
May 25, 2022

Conversation

brittonsmith
Copy link
Member

PR Summary

Enzo-E has been updated to include a new way of distinguishing whether particles are saved as masses or densities. This is done using the "mass" or "density" parameter in the parameter file. Previously, particle masses were to be considered as densities if the simulation was cosmological. To preserve backward compatibility, Enzo-E now uses an "is_gravitating" group name that I use to tell if the data was produced before or after this change.

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@brittonsmith brittonsmith added code frontends Things related to specific frontends enhancement Making something better labels May 9, 2022
@brittonsmith
Copy link
Member Author

pre-commit.ci autofix

@brittonsmith brittonsmith marked this pull request as draft May 17, 2022 15:14
@brittonsmith
Copy link
Member Author

pre-commit.ci autofix

@brittonsmith brittonsmith marked this pull request as ready for review May 18, 2022 15:32
@brittonsmith
Copy link
Member Author

This is now ready for review. @stefanarridge has kindly provided me with new Enzo-E datasets that can be used for testing. I'm happy to add those at some point, though I'm not sure when the best time to do that is.

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.

Here are a couple suggestions. Otherwise LGTM

@stefanarridge, feel free to explicitly approve this PR (or review it some more).
Thanks to both of you !

yt/frontends/enzo_e/fields.py Outdated Show resolved Hide resolved
yt/frontends/enzo_e/fields.py Outdated Show resolved Hide resolved
yt/frontends/enzo_e/fields.py Show resolved Hide resolved
mass_flag = nested_dict_get(
self.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 would prefer we avoid adding "optional" attributes. In this case the _particle_mass_is_mass attribute is only used in two places, so it seems preferable to just call nested_dict_get and fetch the parameter when needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a fair position with respect to attributes on the dataset class, but I'd rather not have to evaluate this over and over. Enzo-E datasets can tons of blocks. I'll hang this off the io handler, which is not meant to be user facing.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I like how you refactored it to avoid hasattr !

stefanarridge
stefanarridge previously approved these changes May 24, 2022
@brittonsmith
Copy link
Member Author

pre-commit.ci autofix

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.

Do we need another approval or is it ready to go ?

@matthewturk matthewturk changed the title Update Enzo-E particle mass/density distinction ENH: Update Enzo-E particle mass/density distinction May 25, 2022
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.

4 participants