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

Unpack the boxsize as a cosmo_array. #214

Merged
merged 3 commits into from
Dec 5, 2024
Merged

Conversation

kyleaoman
Copy link
Member

Closes #128

Finally got around to implementing this. It's set up to mimic the way units are applied to header fields.

One thing to consider is whether we're happy with how the non-cosmological case is handled. If the simulation is non-cosmological, then the scale_factor will default to 1.0 (because swiftsimio enforces that it exists). The box_size is then created as a cosmo_array with comoving=True, but that's acceptable because scale_factor=1 so it will just silently convert to physical if it ever needs to.

If we're not happy with that, then some further introspection will be needed to figure out if the snapshot is non-cosmological.

Copy link
Collaborator

@robjmcgibbon robjmcgibbon left a comment

Choose a reason for hiding this comment

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

Looks good to me, apart from a minor question about the test change

@@ -60,7 +60,9 @@ def test_soap_can_mask_spatial_and_non_spatial_actually_use(filename):
masses2 = data2.spherical_overdensity_200_mean.total_mass

# Manually mask
custom_mask = (masses2 >= lower) & (masses2 <= upper)
custom_mask = (
unyt.unyt_array(masses2.to_value(masses2.units), masses2.units) >= lower
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed, does masses2 not already support comparison?

Copy link
Member Author

@kyleaoman kyleaoman Dec 5, 2024

Choose a reason for hiding this comment

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

lower and upper are unyt_quantitys, not cosmo_arrays. This is correct given the type hints of constrain_mask used further up in the test, but correctly triggers a warning on comparison with masses2. Perhaps constrain_mask should be modified to expect cosmo_arrays. It would still work if given unyt_quantitys in that case but would raise warnings on receiving unyt_quantitys (which is what should happen in that case, I guess). If that happens then the change to custom_mask should be reverted (it will emit a warning in that case so shouldn't go unnoticed).

@kyleaoman kyleaoman merged commit 212acea into master Dec 5, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

boxsize in metadata should be cosmo_array, not unyt_array?
2 participants