-
Notifications
You must be signed in to change notification settings - Fork 280
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
New fields for Arepo and Gadget frontends #3258
Conversation
…ements actually are.
pre-commit.ci autofix |
I added more doc edits--it turns out we had a number of things in Gadget and Arepo data that needed explaining in the docs. For the tests to pass this needs the dataset which will be part of https://yt-project.org/data once PR yt-project/website#96 is merged (ping @Xarthisius) and I upload new answers. |
@@ -124,3 +125,25 @@ def test_bigendian_field_access(): | |||
ds = data_dir_load(BE_Gadget) | |||
data = ds.all_data() | |||
data["Halo", "Velocities"] | |||
|
|||
|
|||
mag_fields = OrderedDict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick note: since Python 3.6, builtin dict objects are also ordered. At the time it was deemed an implementation detail, but it's been embraced as a feature since.
Some minor differences persist (see https://stackoverflow.com/questions/34305003/difference-between-dictionary-and-ordereddict), but it's doubtful we need them here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you look at the top of the file:
yt/yt/frontends/gadget/tests/test_outputs.py
Lines 27 to 35 in 0c0ad20
# This maps from field names to weight field names to use for projections | |
iso_fields = OrderedDict( | |
[ | |
(("gas", "density"), None), | |
(("gas", "temperature"), None), | |
(("gas", "temperature"), ("gas", "density")), | |
(("gas", "velocity_magnitude"), None), | |
] | |
) |
We have another one of these in there, which I copied to make the new one below. For some reason there are two ("gas","temperature")
entries in here--OrderedDict
simply replaces the first one with the second one silently without complaining. When I tried to change this to a dict
the pre-commit bot complained.
So the real question is if sph_answer
is expecting us to try projections with and without the weight field for ("gas","temperature")
. Does anyone know (I can look myself, but if anyone knows please comment)? @matthewturk @brittonsmith @chummels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me taking an unweighted projection of ("gas", "temperature")
would be useless and non-sensical, so I don't think sph_answer
should do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably is expecting that. A non-weighted temperature projection is generally not useful, but it can also serve as a proxy for testing in situations where the temperature itself is a derived field (rather than intrinsic) and we want to test the machinery of unweighted temperature projections. I don't know that we need to keep it in this instance, but I don't think we should always require that answer tests always map 1:1 to useful quantities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; @jzuhone what is pending still?
@matthewturk need to fix the pre-commit issue, update test answers |
@Xarthisius it looks like I screwed up the answer testing--can we remove |
@yt-fido test this please |
@Xarthisius thanks! |
This is finally ready. |
@@ -259,6 +259,15 @@ | |||
"load_name": "plt00015", | |||
"url": "https://yt-project.org/data/Laser.tar.gz" | |||
}, | |||
"MagneticumCluster.tar.gz": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order for this to integrate with yt.load_sample, you'll need to update https://github.com/yt-project/website/blob/master/data/datafiles.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neutrinoceros This was done already (you looked at the PR): yt-project/website#96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realise it was the same one. In any case I've tested this branch and it currently doesn't work
import yt
yt.load_sample("MagneticumCluster")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a traceback or something for more information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, this is what the traceback looked like (rather cryptic if you ask me) I made it much more informative for next time this kind of accident happens in #3277
Co-authored-by: Clément Robert <cr52@protonmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks good; I have just a few comments inline. Thanks for putting some love into the AREPO/Gadget frontends. It's good that they're getting a bit more attention with the yt4 refactor.
and aliased to fields with the naming convention ``"PassiveScalars_XX"`` where | ||
``XX`` is the number of the passive scalar array, e.g. ``"00"``, ``"01"``, etc. | ||
|
||
HDF5 snapshots will be detected as Arepo data if they have the ``"GFM_Metals"`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for including this, @jzuhone !
This gets used with the magneticum_box2_hr format | ||
as defined in the gadget_field_specs in frontends/gadget/definitions.py | ||
""" | ||
metal_names = ["He", "C", "Ca", "O", "N", "Ne", "Mg", "S", "Si", "Fe", "Ej"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's Ej
? Is that ejected metals or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct--that's the name that the magneticum folks use for it.
) | ||
|
||
# hydrogen fraction and density | ||
def _h_fraction(field, data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is interesting, calculating the H fraction as the remainder when you take away all the other elements. I think this will only work if Ej
is distinct from all of the other elements present, though. Can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the way they are defined in magneticum.
|
||
def _temperature(field, data): | ||
# Assume cosmic abundances | ||
x_H = _primordial_mass_fraction["H"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to look on disk and see if there is already an H_fraction
field and use that instead of assuming primordial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. we need to think about this one a bit more carefully. I didn't change the field definition--I just moved it within a new if-then block. But I see what you mean. I'll try changing it, but I suspect it will break answer tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jzuhone pointed me to the TNG documentation where they themselves are calculating temperature using this formula, with primordial hydrogen abundances. So we should mimic that behavior and I retract my point above.
PR Summary
This PR adds new fields for both the Arepo and Gadget frontends.
"CosmicRaySpecificEnergy"
field and"PassiveScalars"
EDIT: This got more complicated. It turns out that if you naively run
sph_answer
on the Magneticum dataset that you get an error because you project a sphere at the domain center with no data in it (the data is confined to a small region of the domain). The error will need to be fixed in a separate PR.It would have been simple to set a bounding box around the data, but when I tried this it took forever to construct the index. So I did a simple (and probably useful in the future thing) and allowed the sphere in
sph_answer
andnbody_answer
to be set to some alternate center.PR Checklist