API Reference
This page provides detailed information about the galaxyGenius API.
Core Classes
Configuration
- class galaxyGenius.config.Configuration(surveys: str | list[str] | None = None)[source]
Bases:
objectThe Configuration class handles all configuration settings for galaxyGenius, including:
Main configuration settings
Survey-specific configurations
Configuration validation and management
- add_survey(surveys: str | list[str] | None = None)[source]
Add surveys. Call
get_config()to get the updated configs.
- remove_survey(surveys: str | list[str] | None = None)[source]
Remove surveys. Call
get_config()to get the updated configs.
- save_config(conf: dict | None = None)[source]
Manually save the current configuration to the specified TOML files.
Parameters: conf (dict, optional): A dictionary containing configuration values.
PreProcess
- class galaxyGenius.preprocess.PreProcess(config: dict)[source]
Bases:
objectThe PreProcess class handles the preparation of data for SKIRT simulation:
Reading and processing subhalo data
Preparing particle data
Creating SKIRT input files
Managing simulation parameters
- get_subhalos() dict[source]
Retrieve subhalos from TNG snapshot or from requests.
- Returns:
A dictionary containing subhaloIDs, SFRs.
- Return type:
- subhalo(subhaloID: int)[source]
Specify one subhalo to be processed
- Parameters:
subhaloID (
int) – subhaloID of the subhalo to be processed
- get_default_params()[source]
Returns default parameters and their units for stars and gas (if includeDust is True).
- Parameters:
None
- Returns:
returns – Returns a tuple, where the first element is a dictionary of star parameters and their units, and the second element is a dictionary of gas parameters and their units (if includeDust is True). If includeDust is False, then the tuple contains only the star parameters and their units. The format of the dictionaries is {parameter: unit}.
- Return type:
- includeParams(starParams: list | dict | None = None, gasParams: list | dict | None = None, **kwargs)[source]
Adds parameters to the list of parameters to include in the data.
- Parameters:
starParams (list or dict, optional) – List of parameters to include for stars. If a list is given, it should contain the parameter names as strings. If a dict is given, it should be in the format {parameter: unit}. In this case, the unit is not used to deduce the unit of the parameter but is directly used.
gasParams (list or dict, optional) – List of parameters to include for gas particles. If a list is given, it should contain the parameter names as strings. If a dict is given, it should be in the format {parameter: unit}. In this case, the unit is not used to deduce the unit of the parameter but is directly used.
**kwargs – Additional keyword arguments are not used.
- Returns:
This function does not return anything.
- Return type:
None
- inputSubhaloParticleFile(subhaloParticleFile: str, subhaloInfo: dict, centerPosition: list | Quantity | None = None)[source]
Input subhalo particle file in h5 format.
- Parameters:
subhaloParticleFile (str) – path to the subhalo particle file in h5 format.
subhaloInfo (dict) – dictionary containing information about the subhalo, required: SubhaloID, stellarMass, halfStellarMassRadius.
centerPosition (Union[list, u.Quantity, None], optional) – center position of the galaxy. If None, the particles are assumed to be in center coordinates.
- createFile(paramNames, partType, saveFilename, function)[source]
Create a file containing the parameters of particles of a given type.
DataGeneration
- class galaxyGenius.generation.DataGeneration(config: dict)[source]
Bases:
objectThe DataGeneration class manages the SKIRT radiative transfer simulation process:
Running SKIRT simulations
Managing input/output files
Handling data cube generation
PostProcess
Utility Functions
Utility functions for various operations including:
Data conversion and manipulation
File handling
Mathematical operations
Visualization helpers
- class galaxyGenius.utils.Units(cosmology=None, snapRedshift=None, reinitialize=False)[source]
Bases:
object- explain()[source]
Default unit conventions are used by TNG simulation:
distance: ckpc / h
density: (10**10 * Msun) / (ckpc / h)^3
mass: 10**10 * Msun
sfr: Msun / yr
velocity: km * sqrt(a) / s
potential: (km / s)^2 / a
temperature: K
energy: (km / s)^2
comoving quantities can be converted to physical ones by multiplying for the appropriate power of the scale factor a. For instance, to convert a length in physical units it is sufficient to multiply it by a, volumes need a factor a^3, densities a^-3 and so on.
When using other simulations, the unit convention can be re-defined.
- galaxyGenius.utils.setup_logging(log_file='galaxygenius.log', log_level=20, force_reconfigure=False)[source]
Set up logging configuration that can be used across multiple modules
- Parameters:
log_file (default:
'galaxygenius.log') – Path to the log filelog_level (default:
20) – Logging level (default: logging.INFO)force_reconfigure (default:
False) – If True, forces reconfiguration even if handlers exist. Use this after moving log files to update file handlers.
- galaxyGenius.utils.u2temp(u_energy: float | Quantity, x_e: float) float[source]
u_energy: InternelEnergy x_e: ElectronAbundance
return: T: temperatrure in K
- Return type:
- galaxyGenius.utils.convert_to_rgb(bandpassImage: ndarray | list, idx: list = [2, 3, 5]) ndarray[source]
Convert the bandpass image to RGB image
- galaxyGenius.utils.split(string: str, castType: type | None = None) list[source]
Split the string into a list
- galaxyGenius.utils.get_wavelength_scale(filename: str) float[source]
Get the wavelength scale of the filter
- Parameters:
filename (
str) – filename of the filter- Returns:
wavelength scale of the filter
- Return type:
wavelength_scale
- galaxyGenius.utils.calc_pivot(dataDir: str, survey: str, filter: str) float[source]
Calculate the pivot wavelength of the filter
- galaxyGenius.utils.extend(values: int | float | list | Quantity, nums: int) list[source]
Extend the values to list with size consistent with nums