velociraptor.catalogue.soap_catalogue module¶
-
class
velociraptor.catalogue.soap_catalogue.SWIFTUnitsMockup(units: Dict[KT, VT])[source]¶ Bases:
objectTakes a dict with internal swift units and generates a unyt system compatible with swiftsimio.
-
mass¶ unit for mass used
Type: float
-
length¶ unit for length used
Type: float
-
time¶ unit for time used
Type: float
-
current¶ unit for current used
Type: float
-
temperature¶ unit for temperature used
Type: float
-
-
class
velociraptor.catalogue.soap_catalogue.CatalogueElement(file_name: pathlib.Path, name: str)[source]¶ Bases:
objectAbstract class for catalogue elements. These map to specific objects in the SOAP output file.
The SOAP output file is a tree structure with HDF5 groups that contain either more HDF5 groups or HDF5 datasets. Each group/dataset has a name that corresponds to its path in the SOAP file.
-
class
velociraptor.catalogue.soap_catalogue.CatalogueDataset(file_name: pathlib.Path, name: str, handle: h5py._hl.files.File)[source]¶ Bases:
velociraptor.catalogue.soap_catalogue.CatalogueElementRepresentation of a SOAP dataset.
A dataset has unit metadata and values that are only read if the dataset is actually used.
-
set_value(value: unyt.array.unyt_array, group: velociraptor.catalogue.soap_catalogue.CatalogueGroup)[source]¶ Setter for the dataset values.
Parameters: - value (-) – unyt.unyt_array New values for the dataset.
- group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object).
-
del_value(group: velociraptor.catalogue.soap_catalogue.CatalogueGroup)[source]¶ Deleter for the dataset values.
Parameters: group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object).
-
get_value(group: velociraptor.catalogue.soap_catalogue.CatalogueGroup) → unyt.array.unyt_array[source]¶ Getter for the dataset values. Performs lazy reading: if the value has not been read before, it is read from the SOAP catalogue file. Otherwise, a buffered value is used.
Parameters: group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object). Returns the dataset values as a unyt.unyt_array.
-
-
class
velociraptor.catalogue.soap_catalogue.CatalogueDerivedDataset(file_name: pathlib.Path, name: str, terms: List[velociraptor.catalogue.soap_catalogue.CatalogueDataset])[source]¶ Bases:
velociraptor.catalogue.soap_catalogue.CatalogueElement,abc.ABCRepresentation of a derived SOAP dataset.
A derived dataset is a dataset that can be trivially derived from another (set of) dataset(s). It is similar to a dataset registered using a registration function, but still supports lazy evaluation. Its main purpose is to guarantee full compatibility between the SOAP and VR catalogues in the pipeline.
-
set_value(value: unyt.array.unyt_array, group: velociraptor.catalogue.soap_catalogue.CatalogueGroup)[source]¶ Setter for the dataset values.
Parameters: - value (-) – unyt.unyt_array New values for the dataset.
- group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object).
-
del_value(group: velociraptor.catalogue.soap_catalogue.CatalogueDataset)[source]¶ Deleter for the dataset values.
Parameters: group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object).
-
get_value(group: velociraptor.catalogue.soap_catalogue.CatalogueDataset) → unyt.array.unyt_array[source]¶ Getter for the dataset values. Performs lazy evaluation: if the value has not been computed before, all the datasets that are required to compute it are obtained (and might be lazily read at this point), and the child class specific computation method is called. Otherwise, a buffered value is returned.
Parameters: group (-) – CatalogueGroup Group this dataset belongs to. Only provided for property() compatibility (since we want the dataset to be a property of the CatalogueGroup object). Returns the dataset values as a unyt.unyt_array.
-
-
class
velociraptor.catalogue.soap_catalogue.VelocityDispersion(file_name: pathlib.Path, name: str, terms: List[velociraptor.catalogue.soap_catalogue.CatalogueDataset])[source]¶ Bases:
velociraptor.catalogue.soap_catalogue.CatalogueDerivedDatasetCatalogueDerivedDataset that computes the 1D velocity dispersion from the full 3D velocity dispersion matrix.
-
compute_value(velocity_dispersion_matrix: unyt.array.unyt_array) → unyt.array.unyt_array[source]¶ Calculate the 1D velocity dispersion from the velocity dispersion matrix.
The velocity dispersion matrix in SOAP consists of the 6 non-trivial elements of
V_{ij} = Sigma_p (v_{p,i} - <v>_i)**2 * (v_{p,j} - <v>_j)**2,where v_p is the particle velocity and <v> is a reference velocity.
- Since this is a symmetric matrix, SOAP only outputs (in this order)
- V_XX, V_YY, V_ZZ, V_XY, V_XZ, V_YZ
- The 1D velocity dispersion output by VR is
- sqrt(V_XX + V_YY + V_ZZ)
Parameters: velocity_dispersion_matrix (-) – unyt.unyt_array SOAP velocity dispersion matrix. Returns the 1D velocity dispersion as a unyt.unyt_array.
-
-
class
velociraptor.catalogue.soap_catalogue.CatalogueGroup(file_name: pathlib.Path, name: str, handle: h5py._hl.files.File)[source]¶ Bases:
velociraptor.catalogue.soap_catalogue.CatalogueElementRepresentation of an HDF5 group in the SOAP catalogue.
A CatalogueGroup contains other groups or datasets. Datasets are exposed as new attributes for the CatalogueGroup object, so that things like
so.v200_crit.totalmass- map directly to the CatalogueDataset::get_value() function that retrieves
- SOAP_catalogue[“SO/200_crit/TotalMass”][:]
Note that attribute names cannot start with a number, so we use the convention that numeric group names are preceded by a ‘v’ (for value).
-
velociraptor.catalogue.soap_catalogue.dynamically_register_properties(group: velociraptor.catalogue.soap_catalogue.CatalogueGroup)[source]¶ Trick an object into thinking it is of a different class that has additional properties, based on the properties contained in the group.properties dictionary.
- Concrete example: suppose ‘group’ enters this method as
group.elements = [CatalogueDataset<a>, CatalogueDataset<b>] group.properties= {“a_name”: (CatalogueDataset<a>, CatalogueDataset<a>.value),
“b_name”: (CatalogueDataset<a>, CatalogueDataset<a>.value)},- where we have used
- CatalogueDataset<x>.value
- as a shorthand for
- property(CatalogueDataset<x>.get_value,
- CatalogueDataset<x>.set_value, CatalogueDataset<x>.del_value)
- After this method acts on ‘group’, it will look like this:
- group.a_name = CatalogueDataset<a>.get_value group.b_name = CatalogueDataset<b>.get_value
-
class
velociraptor.catalogue.soap_catalogue.SOAPCatalogue(file_name: pathlib.Path)[source]¶ Bases:
velociraptor.catalogue.catalogue.CatalogueCatalogue specialisation for a SOAP catalogue.
-
print_fields()[source]¶ Debugging function used to output the fields that were actually accessed sicne the catalogue was opened.
-
get_SOAP_quantity(quantity_name: str) → unyt.array.unyt_array[source]¶ Get the quantity with the given name from the catalogue.
Quantities should be addressed using their full path in the catalogue file, with the convention that the name is fully written in small caps and that ‘/’ is replaced with ‘.’. Since attribute names cannot start with a digit, we additionally add a ‘v’ in between ‘.’ and any digit.
Parameters: quantity_name (-) – str Full path to the quantity in the SOAP catalogue. Returns the corresponding quantity as a unyt.unyt_array.
-
get_quantity(quantity_name: str) → unyt.array.unyt_array[source]¶ Get the quantity with the given name from the catalogue.
This version uses a fallback mechanism to deal with quantities that are addressed using the wrong name, i.e. quantities for which the old VR catalogue name is used. We first try to use the parent class get_quantity() version that assumes all datasets are simply exposed as attributes. If this fail, we use the SOAP catalogue version above. If that fails too, we try to find a SOAP equivalent for the given quantity name in the VR_to_SOAP translator function. If that fails to, we bail out with a NotImplementedError.
Parameters: quantity_name (-) – str Full path to the quantity in the SOAP catalogue. Returns the corresponding quantity as a unyt.unyt_array.
-