From 4207dfc6ee51920be6f6774686105e35e5efdedc Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Fri, 25 Oct 2024 11:29:18 +0100 Subject: [PATCH] Format --- velociraptor/catalogue/soap_catalogue.py | 9 +- velociraptor/catalogue/translator.py | 130 +++++------------------ 2 files changed, 31 insertions(+), 108 deletions(-) diff --git a/velociraptor/catalogue/soap_catalogue.py b/velociraptor/catalogue/soap_catalogue.py index 941a56b..a2e9692 100644 --- a/velociraptor/catalogue/soap_catalogue.py +++ b/velociraptor/catalogue/soap_catalogue.py @@ -141,7 +141,9 @@ def _register_metadata(self, handle: h5py.File): """ metadata = handle[self.name].attrs factor = ( - metadata["Conversion factor to physical CGS (including cosmological corrections)"][0] + metadata[ + "Conversion factor to physical CGS (including cosmological corrections)" + ][0] * unyt.A ** metadata["U_I exponent"][0] * unyt.cm ** metadata["U_L exponent"][0] * unyt.g ** metadata["U_M exponent"][0] @@ -374,7 +376,7 @@ def _register_elements(self, handle: h5py.File): """ h5group = handle[self.name] if self.name != "" else handle["/"] for (key, h5obj) in h5group.items(): - if key == 'Cells': + if key == "Cells": continue if isinstance(h5obj, h5py.Group): el = CatalogueGroup(self.file_name, f"{self.name}/{key}", handle) @@ -542,8 +544,7 @@ def _register_quantities(self): # get the box size and length unit from the SWIFT header and unit metadata boxsize = handle["SWIFT/Header"].attrs["BoxSize"][0] boxsize_unit = ( - handle["Units"].attrs["Unit length in cgs (U_L)"][0] - * unyt.cm + handle["Units"].attrs["Unit length in cgs (U_L)"][0] * unyt.cm ).in_base("galactic") boxsize *= boxsize_unit physical_boxsize = self.a * boxsize diff --git a/velociraptor/catalogue/translator.py b/velociraptor/catalogue/translator.py index 3f0f07e..6c1be0c 100644 --- a/velociraptor/catalogue/translator.py +++ b/velociraptor/catalogue/translator.py @@ -852,10 +852,7 @@ def VR_to_SOAP(particle_property_name: str) -> str: "spherical_overdensities.r_2500_rhocrit": ("so.2500_crit.soradius", -1), "spherical_overdensities.r_500_rhocrit": ("so.500_crit.soradius", -1), "structure_type.structuretype": ("inputhalos.iscentral", -1), - "black_hole_masses.max": ( - "boundsubhalo.mostmassiveblackholemass", - -1, - ), + "black_hole_masses.max": ("boundsubhalo.mostmassiveblackholemass", -1), "temperature.t_gas": ("boundsubhalo.gastemperature", -1), "temperature.t_gas_hight_incl": ( "boundsubhalo.gastemperaturewithoutcoolgas", @@ -875,89 +872,29 @@ def VR_to_SOAP(particle_property_name: str) -> str: "positions.zcmbp": ("inputhalos.halocentre", 2), "positions.zcminpot": ("inputhalos.halocentre", 2), "metallicity.zmet_gas": ("boundsubhalo.gasmassfractioninmetals", -1), - "metallicity.zmet_star": ( - "boundsubhalo.stellarmassfractioninmetals", - -1, - ), + "metallicity.zmet_star": ("boundsubhalo.stellarmassfractioninmetals", -1), "number.bh": ("boundsubhalo.numberofblackholeparticles", -1), "number.gas": ("boundsubhalo.numberofgasparticles", -1), "number.star": ("boundsubhalo.numberofstarparticles", -1), - "veldisp.veldisp_xx_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 0, - ), - "veldisp.veldisp_xx_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 0, - ), - "veldisp.veldisp_xy_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 3, - ), - "veldisp.veldisp_xy_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 3, - ), - "veldisp.veldisp_xz_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 4, - ), - "veldisp.veldisp_xz_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 4, - ), - "veldisp.veldisp_yx_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 3, - ), - "veldisp.veldisp_yx_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 3, - ), - "veldisp.veldisp_yy_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 1, - ), - "veldisp.veldisp_yy_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 1, - ), - "veldisp.veldisp_yz_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 5, - ), - "veldisp.veldisp_yz_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 5, - ), - "veldisp.veldisp_zx_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 4, - ), - "veldisp.veldisp_zx_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 4, - ), - "veldisp.veldisp_zy_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 5, - ), - "veldisp.veldisp_zy_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 5, - ), - "veldisp.veldisp_zz_gas": ( - "boundsubhalo.gasvelocitydispersionmatrix", - 2, - ), - "veldisp.veldisp_zz_star": ( - "boundsubhalo.stellarvelocitydispersionmatrix", - 2, - ), - "stellar_age.tage_star": ( - "boundsubhalo.massweightedmeanstellarage", - -1, - ), + "veldisp.veldisp_xx_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 0), + "veldisp.veldisp_xx_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 0), + "veldisp.veldisp_xy_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 3), + "veldisp.veldisp_xy_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 3), + "veldisp.veldisp_xz_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 4), + "veldisp.veldisp_xz_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 4), + "veldisp.veldisp_yx_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 3), + "veldisp.veldisp_yx_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 3), + "veldisp.veldisp_yy_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 1), + "veldisp.veldisp_yy_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 1), + "veldisp.veldisp_yz_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 5), + "veldisp.veldisp_yz_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 5), + "veldisp.veldisp_zx_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 4), + "veldisp.veldisp_zx_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 4), + "veldisp.veldisp_zy_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 5), + "veldisp.veldisp_zy_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 5), + "veldisp.veldisp_zz_gas": ("boundsubhalo.gasvelocitydispersionmatrix", 2), + "veldisp.veldisp_zz_star": ("boundsubhalo.stellarvelocitydispersionmatrix", 2), + "stellar_age.tage_star": ("boundsubhalo.massweightedmeanstellarage", -1), "snia_rates.snia_rates_30_kpc": ("exclusivesphere.30kpc.totalsniarate", -1), "snia_rates.snia_rates_50_kpc": ("exclusivesphere.50kpc.totalsniarate", -1), "snia_rates.snia_rates_100_kpc": ("exclusivesphere.100kpc.totalsniarate", -1), @@ -1225,26 +1162,14 @@ def VR_to_SOAP(particle_property_name: str) -> str: "boundsubhalo.medianstellarbirthdensity", -1, ), - "stellar_birth_densities.min": ( - "boundsubhalo.minimumstellarbirthdensity", - -1, - ), - "stellar_birth_densities.max": ( - "boundsubhalo.maximumstellarbirthdensity", - -1, - ), + "stellar_birth_densities.min": ("boundsubhalo.minimumstellarbirthdensity", -1), + "stellar_birth_densities.max": ("boundsubhalo.maximumstellarbirthdensity", -1), "stellar_birth_pressures.median": ( "boundsubhalo.medianstellarbirthpressure", -1, ), - "stellar_birth_pressures.min": ( - "boundsubhalo.minimumstellarbirthpressure", - -1, - ), - "stellar_birth_pressures.max": ( - "boundsubhalo.maximumstellarbirthpressure", - -1, - ), + "stellar_birth_pressures.min": ("boundsubhalo.minimumstellarbirthpressure", -1), + "stellar_birth_pressures.max": ("boundsubhalo.maximumstellarbirthpressure", -1), "stellar_birth_temperatures.median": ( "boundsubhalo.medianstellarbirthtemperature", -1, @@ -1561,10 +1486,7 @@ def VR_to_SOAP(particle_property_name: str) -> str: "exclusivesphere.100kpc.linearmassweightedironfromsniaoverhydrogenofstars", -1, ), - "searchradius.search_radius": ( - "boundsubhalo.encloseradius", - -1, - ), + "searchradius.search_radius": ("boundsubhalo.encloseradius", -1), } try: