sage_hdf5 module¶
This module defines the SageHdf5Data class. This class interfaces with the
Model class to read in binary data written by SAGE.
The value of sage_output_format is generally
sage_hdf5 if it is to be read with this class.
If you wish to ingest data from your own flavour of SAGE, please open a Github issue, I plan to add this documentation in future :)
Author: Jacob Seiler.
-
class
sage_analysis.sage_hdf5.SageHdf5Data(model: sage_analysis.model.Model, sage_file_to_read: str)¶ Bases:
sage_analysis.data_class.DataClassClass intended to inteface with the
Modelclass to ingest the data written by SAGE. It includes methods for reading the output galaxies, setting cosmology etc. It is specifically written for whensage_output_formatissage_hdf5.-
_check_model_compatibility(model: sage_analysis.model.Model, sage_dict: Optional[Dict[str, Any]]) → None¶ Ensures that the attributes in the
Modelinstance are compatible with the variables read from the SAGE parameter file (if read at all).Parameters: - model (
Modelinstance) – The model that this data class is associated with. - sage_dict (optional, dict[str, Any]) – A dictionary containing all of the fields read from the SAGE parameter file.
Warning
- UserWarning
- Raised if the user initialized
Modelwith a value ofnum_sage_output_filesthat is different to the value specified in the HDF5 file.
- model (
-
close_file(model)¶ Closes the open HDF5 file.
-
determine_num_gals(model: sage_analysis.model.Model, snapshot: int, *args)¶ Determines the number of galaxies in all cores for this model at the specified snapshot.
Parameters:
-
determine_volume_analyzed(model: sage_analysis.model.Model) → float¶ Determines the volume analyzed. This can be smaller than the total simulation box.
Parameters: model ( Modelinstance) – The model that this data class is associated with.Returns: volume – The numeric volume being processed during this run of the code in (Mpc/h)^3. Return type: float
-
read_gals(model: sage_analysis.model.Model, core_num: int, snapshot: int, pbar: Optional[tqdm.std.tqdm] = None, plot_galaxies: bool = False, debug: bool = False) → Any¶ Reads the galaxies of a single core at the specified
snapshot.Parameters: - model (
Modelclass) – TheModelwe’re reading data for. - core_num (Integer) – The core group we’re reading.
- pbar (
tqdmclass instance, optional) – Bar showing the progress of galaxy reading. IfNone, progress bar will not show. - plot_galaxies (Boolean, optional) – If set, plots and saves the 3D distribution of galaxies for this file.
- debug (Boolean, optional) – If set, prints out extra useful debug information.
Returns: gals – The galaxies for this file.
Return type: h5pygroupNotes
tqdmdoes not play nicely with printing to stdout. Hence we disable thetqdmprogress bar ifdebug=True.- model (
-
read_sage_params(sage_file_path: str) → Dict[str, Any]¶ Read the SAGE parameter file.
Parameters: sage_file_path (string) – Path to the SAGE parameter file. Returns: model_dict – Dictionary containing the parameter names and their values. Return type: dict [str, var]
-
update_snapshot_and_data_path(model: sage_analysis.model.Model, snapshot: int)¶ Updates the
snapshotattribute tosnapshot. As the HDF5 file contains all snapshot information, we do not need to update the path to the output data. However, ensure that the file itself is still open.
-
_abc_impl= <_abc_data object>¶
-