-
Notifications
You must be signed in to change notification settings - Fork 279
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
more SPH field improvements #4584
Conversation
units=self.ds.unit_system["density"], | ||
) | ||
|
||
return metal_names | ||
|
||
def _setup_eleven_metal_masses(self, ptype): | ||
def _make_fraction_functions(self, ptype, fname): |
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.
Is it possible at all to reuse the code in periodic_table.py
?
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'll try, but I actually don't think it works
yt/frontends/gadget/fields.py
Outdated
ret = mass / data[(ptype, "particle_mass")] | ||
return ret | ||
|
||
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.
Just to clarify, this is done this way because it doesn't track H specifically?
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.
That's right
What else are you thinking before moving to ready-to-review? |
@matthewturk tests and docs, sorry, got sidetracked |
This PR now depends on yt-project/website#122 and the corresponding file (already on dickenson) needs to be put on Jenkins (@Xarthisius) |
@yt-fido test this please |
Jenkins still needs the file, I believe, and then I will add the new answer test. Ping @Xarthisius for https://yt-project.org/data/magneticum_camels.tar.gz |
@Xarthisius just wanted to ping you again on the above ^^ (sorry for being a nuisance) |
Sorry I missed it! It's up now. |
Let's see if the new test passes here (it did on my laptop). If it does, we're ready to go here. |
@yt-fido test this please |
@Xarthisius Jenkins failures appear unrelated? |
@yt-fido test this please |
@yt-fido test this please |
This is ready to go. |
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.
This looks good! I have a few minor comments/questions.
yt/frontends/gadget/fields.py
Outdated
n_elem = len( | ||
[ | ||
fd | ||
for fd in self.ds.field_list | ||
if fd[0] == ptype and fd[1].startswith("MetalMasses") | ||
] | ||
) | ||
elem_names = { | ||
7: ["C", "N", "O", "Mg", "Si", "Fe", "Ej"], | ||
8: ["He", "C", "O", "Mg", "S", "Si", "Fe", "Ej"], | ||
11: ["He", "C", "Ca", "O", "N", "Ne", "Mg", "S", "Si", "Fe", "Ej"], | ||
15: [ | ||
"He", | ||
"C", | ||
"Ca", | ||
"O", | ||
"N", | ||
"Ne", | ||
"Mg", | ||
"S", | ||
"Si", | ||
"Fe", | ||
"Na", | ||
"Al", | ||
"Ar", | ||
"Ni", | ||
"Ej", | ||
], | ||
}[n_elem] | ||
no_He = "He" not in elem_names |
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 found the logic of this part a little bit confusing. But I don't have a good alternative suggestion.
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 agree with you--I can add some comments to explain what's going on.
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.
The new comments are helpful! Thank you for adding them.
yt/frontends/gadget/fields.py
Outdated
elem_names = { | ||
7: ["C", "N", "O", "Mg", "Si", "Fe", "Ej"], | ||
8: ["He", "C", "O", "Mg", "S", "Si", "Fe", "Ej"], | ||
11: ["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.
Out of curiosity, is there a possibility that an output will have both MetalMasses
and ElevenMetalMasses
fields?
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.
Not really--both are in fact somewhat arbitrary. ElevenMetalMasses
is a translation field name for Gadget binary datasets defined here. MetalMasses
is a convention I've seen used in Gadget HDF5, and (even worse) Mass of Metals
is one I saw used in another similar dataset.
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.
Ok, cool! Thanks for the clarification.
yt/frontends/gadget/fields.py
Outdated
if fd[0] == ptype and fd[1].startswith("MetalMasses") | ||
] | ||
) | ||
elem_names = { |
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 moving the elem_names
dict outside of both field defs and using the same list of elements elem_names[11]
for both ElevenMetalMasses
and MetalMasses
fields would reduce some of the redundancy in your code?
elems = [ | ||
"He", | ||
"C", | ||
"Ca", | ||
"O", | ||
"N", | ||
"Ne", | ||
"Mg", | ||
"S", | ||
"Si", | ||
"Fe", | ||
"Na", | ||
"Al", | ||
"Ar", | ||
"Ni", |
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 noticed your MetalMasses_
definition didn't include a definition for 14
. Did you want to add that too since that's the use case for your test?
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 14
has to be treated differently. It's not a real element, it's basically just the mass of the rest of the elements not specified in the list, and in the codes that use it it's called Ej
for "ejecta" (because it comes from supernovae explosions). We define an Ej_fraction
field, but the reason I can't stick it in the elem
list is that list the Ej_mass
field doesn't exist, as it's not a real element and it doesn't get passed through yt's species machinery (though maybe it should be defined on its own).
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.
Ok so your new commits do define it on its own now, is my understanding of that commit correct?
yt/frontends/gadget/fields.py
Outdated
15: [ | ||
"He", | ||
"C", | ||
"Ca", | ||
"O", | ||
"N", | ||
"Ne", | ||
"Mg", | ||
"S", | ||
"Si", | ||
"Fe", | ||
"Na", | ||
"Al", | ||
"Ar", | ||
"Ni", | ||
"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.
feels like a good place to use # fmt: skip
I meant to fill in as a reviewer but I'm happy to get behind @munkm's approval. |
@munkm @neutrinoceros see c8f4604 and 5156e29, thanks for the helpful suggestions that influenced these. |
This is ready. |
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 like the improvements you made. Thank you for the changes.
One thing I thought about overnight -- is there any possibility a file would have more than one grouping of n_elem
? (that is, that more than one option could be triggered by your logic) I can't think of a situation where that would happen, but if it does it it something we should add handling for?
elems = [ | ||
"He", | ||
"C", | ||
"Ca", | ||
"O", | ||
"N", | ||
"Ne", | ||
"Mg", | ||
"S", | ||
"Si", | ||
"Fe", | ||
"Na", | ||
"Al", | ||
"Ar", | ||
"Ni", |
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.
Ok so your new commits do define it on its own now, is my understanding of that commit correct?
yt/frontends/gadget/fields.py
Outdated
elem_names = { | ||
7: ["C", "N", "O", "Mg", "Si", "Fe", "Ej"], | ||
8: ["He", "C", "O", "Mg", "S", "Si", "Fe", "Ej"], | ||
11: ["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.
Ok, cool! Thanks for the clarification.
yt/frontends/gadget/fields.py
Outdated
n_elem = len( | ||
[ | ||
fd | ||
for fd in self.ds.field_list | ||
if fd[0] == ptype and fd[1].startswith("MetalMasses") | ||
] | ||
) | ||
elem_names = { | ||
7: ["C", "N", "O", "Mg", "Si", "Fe", "Ej"], | ||
8: ["He", "C", "O", "Mg", "S", "Si", "Fe", "Ej"], | ||
11: ["He", "C", "Ca", "O", "N", "Ne", "Mg", "S", "Si", "Fe", "Ej"], | ||
15: [ | ||
"He", | ||
"C", | ||
"Ca", | ||
"O", | ||
"N", | ||
"Ne", | ||
"Mg", | ||
"S", | ||
"Si", | ||
"Fe", | ||
"Na", | ||
"Al", | ||
"Ar", | ||
"Ni", | ||
"Ej", | ||
], | ||
}[n_elem] | ||
no_He = "He" not in elem_names |
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.
The new comments are helpful! Thank you for adding them.
PR Summary
Continuing to find improvements to be made to detection of SPH fields:
"ColdFraction"
,"CloudFraction"
, and"HotPhaseTemperature"
with yt-like aliases."cooling_rate"
and"cooling_time"
."local"
sampling_type
or"particle"
sampling_type
depending on if they are star or gas particles.Tests, and probably a bit of documentation about how metal fields are detected, are incoming.
PR Checklist