Skip to content

Commit ed861d7

Browse files
authored
Merge pull request #51 from SWIFTSIM/cold_gas
Add registration function for HI and H_2 masses in apertures.
2 parents 06052ec + 4492de2 commit ed861d7

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

velociraptor/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.13.2"
1+
__version__ = "0.14.0"

velociraptor/catalogue/registration.py

+44-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,12 @@ def registration_number(
842842

843843
if field_path[:2] == "n_":
844844
unit = unyt.dimensionless
845-
switch = {"bh": "Black Hole", "gas": "Gas", "star": "Star", "interloper": "Interloper"}
845+
switch = {
846+
"bh": "Black Hole",
847+
"gas": "Gas",
848+
"star": "Star",
849+
"interloper": "Interloper",
850+
}
846851
snake_case = field_path[2:]
847852
full_name = f"Number of {switch.get(snake_case, 'Unknown')} Particles"
848853

@@ -857,6 +862,43 @@ def registration_number(
857862
return unit, full_name, snake_case
858863

859864

865+
def registration_gas_species_masses(
866+
field_path: str, unit_system: VelociraptorUnits
867+
) -> (unyt.Unit, str, str):
868+
"""
869+
Registers the HI masses in apertures.
870+
"""
871+
872+
unit = unit_system.mass
873+
874+
# Capture aperture size
875+
match_string = (
876+
"Aperture_([a-zA-Z]*)_index_0_aperture_total_gas_([0-9]*)_kpc"
877+
)
878+
regex = cached_regex(match_string)
879+
880+
match = regex.match(field_path)
881+
882+
if match:
883+
long_species = match.group(1)
884+
aperture_size = match.group(2)
885+
886+
try:
887+
short_species = {
888+
"AtomicHydrogenMasses": "HI",
889+
"MolecularHydrogenMasses": "H2",
890+
}[long_species]
891+
except KeyError:
892+
raise RegistrationDoesNotMatchError
893+
894+
full_name = f"{short_species} gas mass ({aperture_size} kpc)"
895+
snake_case = f"{short_species}_mass_{aperture_size}_kpc"
896+
897+
return unit, full_name, snake_case
898+
else:
899+
raise RegistrationDoesNotMatchError
900+
901+
860902
def registration_hydrogen_phase_fractions(
861903
field_path: str, unit_system: VelociraptorUnits
862904
) -> (unyt.Unit, str, str):
@@ -1124,6 +1166,7 @@ def registration_spherical_overdensities(
11241166
"stellar_birth_densities",
11251167
"snii_thermal_feedback_densities",
11261168
"species_fractions",
1169+
"gas_species_masses",
11271170
"fail_all",
11281171
]
11291172
}

0 commit comments

Comments
 (0)