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: object

The Configuration class handles all configuration settings for galaxyGenius, including:

  • Main configuration settings

  • Survey-specific configurations

  • Configuration validation and management

__init__(surveys: str | list[str] | None = None)[source]

Initialize a Configuration object for GalaxyGenius.

Parameters:

surveys (str, list[str], or None, optional) – Survey names to process. Can be a single survey name as a string, a list of survey names, or None. If None, an empty list will be used. Default is None.

init()[source]

Initialize configuration. Only use by init.py

add_survey(surveys: str | list[str] | None = None)[source]

Add surveys. Call get_config() to get the updated configs.

Parameters:

surveys (str or list[str] or None) – Survey names to add. If None, no surveys will be added.

remove_survey(surveys: str | list[str] | None = None)[source]

Remove surveys. Call get_config() to get the updated configs.

Parameters:

surveys (str or list[str] or None) – Survey names to remove. If None, no surveys will be removed.

save_config(conf: dict | None = None)[source]

Save the current configuration to files.

The configuration is saved to config.toml for the main settings, and separate config_{survey}.toml files for each survey’s specific settings.

Parameters:

conf (dict or None, optional) – Dictionary containing configuration updates to apply before saving. If None, saves the current configuration without modifications.

get_config()[source]

Update and return the current configuration.

Returns:

The updated configuration dictionary.

Return type:

dict

check_config() int[source]

Check the configuration for any inconsistencies and issues.

Returns:

The number of issues found in the configuration.

Return type:

int

PreProcess

class galaxyGenius.preprocess.PreProcess(config: dict)[source]

Bases: object

The 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

__init__(config: dict)[source]

Initialize a PreProcess object for preparing simulation data for SKIRT.

The PreProcess class handles tasks like loading and converting particle data, calculating derived quantities, and preparing input files for SKIRT simulations.

Parameters:

config (dict) – Configuration dictionary containing simulation parameters and settings.

get_subhalos() dict[source]

Get subhalos

Returns:

dictionary containing number of subhalos, subhaloIDs, subhaloSFRs

Return type:

subhalos

subhalo(subhaloID: int)[source]

Specify one subhalo to be processed

Parameters:

subhaloID (int) – subhaloID of the subhalo to be processed

prepare(arguments: dict | None = None)[source]

Prepare the data and ski file for simulation

Parameters:

arguments (Optional[dict], default: None) – dictionary containing modifications for configurations to be used for the simulation

inputs(data: dict)[source]

Input the data to create the ski file, used for simulations that are not TNG

Parameters:

data (dict) – dictionary containing data to be used for the simulation

DataGeneration

class galaxyGenius.generation.DataGeneration(config: dict)[source]

Bases: object

The DataGeneration class manages the SKIRT radiative transfer simulation process:

  • Running SKIRT simulations

  • Managing input/output files

  • Handling data cube generation

__init__(config: dict)[source]

Initialize a DataGeneration object for running SKIRT simulations and managing outputs.

Parameters:

config (dict) – Configuration dictionary containing simulation parameters and settings.

runSKIRT(skirtPath: str | None = None)[source]

Run SKIRT radiative transfer simulation.

This method executes the SKIRT radiative transfer simulation using the configured parameters. It checks required files, runs SKIRT, saves the output data cube, and cleans up temporary files.

Parameters:

skirtPath (str, optional) – Path to SKIRT executable. If None, assumes ‘skirt’ is in PATH.

Returns:

0 if successful, exits with error otherwise.

Return type:

int

PostProcess

class galaxyGenius.postprocess.PostProcess(subhaloID: int)[source]

Bases: object

The PostProcess class handles the post-processing of simulation results:

  • Processing data cubes

  • Generating bandpass images

  • Creating SEDs

  • Visualizing results

__init__(subhaloID: int)[source]

Initialize a PostProcess object for post-processing SKIRT simulation outputs.

The PostProcess class handles tasks like PSF convolution, filter application, and image processing of SKIRT datacubes to create synthetic observations that match specific surveys.

Parameters:

subhaloID (int) – ID of the subhalo/galaxy to process

runPostprocess(showImages: bool = False)[source]

This method performs the post-processing of the mock observations for the specified subhalo.

Parameters:

showImages (bool, optional) – If True, displays the generated images, and can only work in Jupyter environment.

Utility Functions

Utility functions for various operations including:

  • Data conversion and manipulation

  • File handling

  • Mathematical operations

  • Visualization helpers

galaxyGenius.utils.u2temp(u_energy: float, x_e: float) float[source]

Convert internal energy to temperature

Parameters:
  • u_energy (float) – InternelEnergy

  • x_e (float) – ElectronAbundance

Returns:

temperatrure in K

Return type:

T

galaxyGenius.utils.convert_to_rgb(bandpassImage: ndarray | list, idx: list = [2, 3, 5]) ndarray[source]

Convert the bandpass image to RGB image

Parameters:
  • bandpassImage (Union[ndarray, list]) – bandpass image

  • idx (list, default: [2, 3, 5]) – index of the bandpass image used to create the RGB image

Returns:

RGB image

Return type:

rgb

galaxyGenius.utils.split(string: str, castType: type | None = None) list[source]

Split the string into a list

Parameters:
  • string (str) – string to be split

  • castType (Optional[type], default: None) – type of the elements in the list

Returns:

list of the split string

Return type:

splits

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

Parameters:
  • dataDir (str) – directory of the data

  • survey (str) – survey name

  • filter (str) – filter name

Returns:

pivot wavelength of the filter

Return type:

pivot

galaxyGenius.utils.copyfile(src: str, tar: str)[source]

Copy a file from source to target location if target doesn’t exist

Parameters:
  • src (str) – source file path

  • tar (str) – target file path

galaxyGenius.utils.extend(values: int | float | list, nums: int) list[source]

Extend the values to list with size consistent with nums

Parameters:
  • values (Union[int, float, list]) – values to be extended

  • nums (int) – number of values to be extended

Returns:

extended values

Return type:

values

galaxyGenius.utils.custom_serialier(obj)[source]

Custom serializer for json dump

Parameters:

obj – object to be serialized

Returns:

serialized object

Return type:

obj