Skip to content

Commit e370182

Browse files
authored
Merge pull request #73 from SWIFTSIM/add_registration_element_masses_in_stars
Register element masses in stars
2 parents b168a6b + 8ae60f9 commit e370182

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

velociraptor/catalogue/registration.py

+40
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,45 @@ def registration_spherical_overdensities(
14431443
return unit, full_name, snake_case
14441444
else:
14451445
raise RegistrationDoesNotMatchError
1446+
1447+
1448+
def registration_element_masses_in_stars(
1449+
field_path: str, unit_system: VelociraptorUnits
1450+
) -> (unyt.Unit, str, str):
1451+
"""
1452+
Registers element masses contained in stars
1453+
"""
1454+
1455+
unit = unit_system.mass
1456+
1457+
# Capture aperture size
1458+
match_string = "Aperture_([a-zA-Z]*)Masses_aperture_total_star_([0-9]*)_kpc"
1459+
regex = cached_regex(match_string)
1460+
match = regex.match(field_path)
1461+
1462+
if match:
1463+
element = match.group(1)
1464+
aperture_size = match.group(2)
1465+
1466+
try:
1467+
field = {
1468+
"Oxygen": "Total Oxygen mass in stars",
1469+
"Magnesium": "Total Magnesium mass in stars",
1470+
"Iron": "Total Iron mass in stars",
1471+
}[element]
1472+
except KeyError:
1473+
raise RegistrationDoesNotMatchError
1474+
1475+
full_name = f"{field} computed in apertures of size ({aperture_size} kpc)"
1476+
1477+
snake_case = f"{element.lower()}_mass_{aperture_size}_kpc"
1478+
1479+
return unit, full_name, snake_case
1480+
else:
1481+
raise RegistrationDoesNotMatchError
1482+
1483+
return
1484+
14461485

14471486
# TODO
14481487
# lambda_B
@@ -1503,6 +1542,7 @@ def registration_spherical_overdensities(
15031542
"cold_dense_gas_properties",
15041543
"log_element_ratios_times_masses",
15051544
"lin_element_ratios_times_masses",
1545+
"element_masses_in_stars",
15061546
"fail_all",
15071547
]
15081548
}

0 commit comments

Comments
 (0)