velociraptor.catalogue.derived module¶
Objects required to register derived quantities. Enables the extension of the catalogue object.
-
class
velociraptor.catalogue.derived.DerivedQuantities(registration_file_path: Union[List[str], str], catalogue)[source]¶ Bases:
objectDerived quantities class. Contains methods to open (a) python source file(s) that create(s) derived quantities as follows:
The source file will have access to:
- numpy (imported as np)
- unyt (imported as unyt)
You should write your derived quantities as follows:
self.derived_quantitiy_name = catalogue.type.field_name * 0.5 self.derived_quantitiy_name_two = ( catalogue.type.field_name / catalogue.type.field_name_two )
For example, to register the specific star formation rate in apertures:
for aperture_size in [5, 10, 30, 50, 100]: stellar_mass = catalogue.get_quantity( f"apertures.mass_star_{aperture_size}_kpc" ) star_formation_rate = catalogue.get_quantity( f"apertures.sfr_gas_{aperture_size}_kpc" ) ssfr = star_formation_rate / stellar_mass # Don't forget to set the name or your plot will be un-labeled! ssfr.name = f"Specific SFR ({aperture_size} kpc)" setattr( self, f"specific_sfr_gas_{aperture_size}_kpc", ssfr )
The path to this file(s) should be passed to the __init__ method of this class. Note that you should only register quantities that you do in fact intend to use, as these are not lazily loaded in the same way as the properties that are built into catalogues. For example, in the above registration both the star formation rate and stellar mass are loaded from the VELOCIraptor catalogue file, a behaviour which may not be ideal if the catalogue is very large.