sage_binary module¶
This module defines the SageBinaryData 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_binary 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_binary.SageBinaryData(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_binary.-
_check_for_file(model: sage_analysis.model.Model, file_num: int) → Optional[str]¶ Checks to see if a file for the given file number exists. Importantly, we check assuming that the path given in the SAGE parameter file is relative and absolute.
Parameters: file_num (int) – The file number that we’re checking for files. Returns: If a file exists, the name of that file. Otherwise, if the file does not exist (using either relative or absolute paths), then None.Return type: fname or None
-
_get_galaxy_struct()¶ Sets the
numpystructured array for holding the galaxy data.
-
close_file(model: sage_analysis.model.Model)¶ An empty method to ensure consistency with the HDF5 data class. This is empty because snapshots are saved over different files by default in the binary format.
-
determine_num_gals(model: sage_analysis.model.Model, *args)¶ Determines the number of galaxies in all files for this
Model.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, file_num: int, snapshot: int, pbar: Optional[tqdm.std.tqdm] = None, plot_galaxies: bool = False, debug: bool = False)¶ Reads the galaxies of a model file at snapshot specified by
snapshot.Parameters: - model (
Modelclass) – TheModelwe’re reading data for. - file_num (int) – Suffix number of the file we’re reading.
- pbar (
tqdmclass instance, optional) – Bar showing the progress of galaxy reading. IfNone, progress bar will not show. - plot_galaxies (bool, optional) – If set, plots and saves the 3D distribution of galaxies for this file.
- debug (bool, optional) – If set, prints out extra useful debug information.
Returns: gals – The galaxies for this file.
Return type: numpystructured array with format given by :py:method:`~_get_galaxy_struct`Notes
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, use_absolute_path: bool = False)¶ Updates the
_sage_data_pathto point to a new redshift file. Uses the redshift arrayredshifts.Parameters: - snapshot (int) – Snapshot we’re updating
_sage_data_pathto point to. - use_absolute_path (bool) – If specified, will use the absolute path to the SAGE output data. Otherwise, will use the path that is relative to the SAGE parameter file. This is hand because the SAGE parameter file can contain either relative or absolute paths.
- snapshot (int) – Snapshot we’re updating
-
_abc_impl= <_abc_data object>¶
-