Parameters and the OpenCosmoHeader

Every OpenCosmo files comes with a set of parameters that describe the dataset it was draw from and other relevant information. These parameters are parsed into an OpenCosmoHeader object which can be used throughout the code to verify properties of the dataset, or for reference.

Datasets and collections will allways make their header avaliable with the .header attribute. You can acccess the parameters in a given header with the .parameters attribute. The actual parameters available will vary depending on the type of data in the file.

class opencosmo.header.OpenCosmoHeader(file_pars, required_origin_parameters, optional_origin_parameters, dtype_parameters, unit_convention=UnitConvention.SCALEFREE)

A class to represent the header of an OpenCosmo file. The header contains information about the simulation the data is a part of, as well as other meatadata that are useful to the library in various contexts. Most files will have a single unique header, but it is possible to have multiple headers in a SimulationCollection.

Parameters:
  • file_pars (FileParameters)

  • required_origin_parameters (dict[str, BaseModel])

  • optional_origin_parameters (dict[str, BaseModel])

  • dtype_parameters (dict[str, BaseModel])

  • unit_convention (UnitConvention)

with_units(convention)
Parameters:

convention (UnitConvention | str)

property parameters

Return the parametrs stored in this header as key-value pairs. The values will be Pydantic models.

Any block of parameters that is returned from this method can also be accessed with standard dot notation. For example, HACC data contains a “simulation” block that contains the parameters that were used to run the original simulation. The following calls are equivalent:

header.simulation
header.parameters["simulation"]
Returns:

parameters – The parameter blocks associated with this header

Return type:

dict[str, pydantic.BaseModel]

with_parameter(key, value)

Update a dtype parameter with a new value. This in general should never be called by the user. Returns a copy.

Parameters:
  • key (str)

  • value (Any)

with_parameters(updates)
Parameters:

updates (dict[str, Any])

dump()
Return type:

Schema

property file: FileParameters

All files must at minimum have a “file” block in their header. This block contains basic information like the original source of the data and its data type.

Cosmology

Most OpenCosmo files will contain cosmology parameters, which describe the cosmology the simulation was run under. In general you will not interact with this parameter block directly. Instead, requiresting it will return an astropy.cosmology.Cosmology object. Dataset and collections will generally make this object available directly with the .cosmology attribute.

class opencosmo.dtypes.cosmology.CosmologyParameters(*, h, omega_m, omega_b, omega_l, n_eff_massless, n_eff_massive=0, sigma_8, w_0, w_a)

Responsible for validating cosmology parameters and handling differences in naming conventions between OpenCosmo and astropy.cosmology. Generally should not be used by the user directly

Parameters:
  • h (float)

  • omega_m (Annotated[float, Ge(ge=0)])

  • omega_b (Annotated[float, Ge(ge=0)])

  • omega_l (Annotated[float, Ge(ge=0)])

  • n_eff_massless (Annotated[float, Gt(gt=0)])

  • n_eff_massive (float)

  • sigma_8 (float)

  • w_0 (float)

  • w_a (float)

field h: float [Required]

Reduced Hubble constant

Constraints:
  • ge = 0.0

property H0: float

Hubble constant in km/s/Mpc

field Om0: float [Required] (alias 'omega_m')

Total matter density

Constraints:
  • ge = 0.0

field Ob0: float [Required] (alias 'omega_b')

Baryon density

Constraints:
  • ge = 0.0

field Ode0: float [Required] (alias 'omega_l')

Dark energy density

Constraints:
  • ge = 0.0

field Neff: float [Required] (alias 'n_eff_massless')

Effective number of neutrinos

Constraints:
  • gt = 0.0

field n_eff_massive: float = 0

Effective number of massive neutrinos

Constraints:
  • ge = 0.0

field sigma_8: float [Required]

RMS mass fluctuation at 8 Mpc/h

Constraints:
  • ge = 0.0

field w0: float [Required] (alias 'w_0')

Dark energy equation of state

field wa: float [Required] (alias 'w_a')

Dark energy equation of state evolution

Simulation Parameters

Data that was originally produced by HACC will contain the parameters that were used to initialize the simulation. Datasets and collections will generally make these paramters available with the .simulation attribute.

class opencosmo.dtypes.hacc.HaccSimulationParameters(*, box_size, z_ini, z_end, n_gravity=None, n_steps, pm_grid, offset_gravity_ini=None)
Parameters:
  • box_size (float)

  • z_ini (float)

  • z_end (float)

  • n_gravity (int | None)

  • n_steps (int)

  • pm_grid (int)

  • offset_gravity_ini (float | None)

field box_size: float [Required]

Size of the simulation box (Mpc/h)

Constraints:
  • ge = 0

field z_ini: float [Required]

Initial redshift of the simulation

Constraints:
  • ge = 0.01

field z_end: float [Required]

Final redshift of the simulation

Constraints:
  • ge = 0.0

field n_gravity: int | None = None

Number of gravity-only particles (per dimension). In hydrodynamic simulations, this parameter will not be set.

Constraints:
  • ge = 2

field n_steps: int [Required]

Number of time steps

Constraints:
  • ge = 1

field pm_grid: int [Required]

Number of grid points (per dimension)

Constraints:
  • ge = 2

field offset_gravity_ini: float | None = None

Lagrangian offset for gravity-only particles

property step_zs: list[float]

Get the redshift of the steps in this simulation. Outputs such that redshift[step_number] returns the redshift for that step. Keep in mind that steps go from high z -> low z.

class opencosmo.dtypes.hacc.HaccHydroSimulationParameters(*, box_size, z_ini, z_end, n_gravity=None, n_steps, pm_grid, offset_gravity_ini=None, n_bar, n_dm, offset_bar_ini, offset_dm_ini, subgrid_agn_kinetic_eps, subgrid_agn_kinetic_jet_vel, subgrid_agn_nperh, subgrid_agn_seed_mass, subgrid_wind_egy_w, subgrid_wind_kappa_w)
Parameters:
  • box_size (Annotated[float, Ge(ge=0)])

  • z_ini (Annotated[float, Ge(ge=0.01)])

  • z_end (Annotated[float, Ge(ge=0)])

  • n_gravity (Annotated[int | None, Ge(ge=2)])

  • n_steps (Annotated[int, Ge(ge=1)])

  • pm_grid (Annotated[int, Ge(ge=2)])

  • offset_gravity_ini (float | None)

  • n_bar (int)

  • n_dm (Annotated[int, Ge(ge=2)])

  • offset_bar_ini (float)

  • offset_dm_ini (float)

  • subgrid_agn_kinetic_eps (float)

  • subgrid_agn_kinetic_jet_vel (float)

  • subgrid_agn_nperh (float)

  • subgrid_agn_seed_mass (float)

  • subgrid_wind_egy_w (float)

  • subgrid_wind_kappa_w (float)

field n_gas: int [Required] (alias 'n_bar')

Number of gas particles (per dimension)

field n_dm: int [Required]

Number of dark matter particles (per dimension)

Constraints:
  • ge = 2

field offset_gas_ini: float [Required] (alias 'offset_bar_ini')

Lagrangian offset for gas particles

field offset_dm_ini: float [Required]

Lagrangian offset for dark matter particles

field agn_kinetic_eps: float [Required] (alias 'subgrid_agn_kinetic_eps')

AGN feedback efficiency

field agn_kinetic_jet_vel: float [Required] (alias 'subgrid_agn_kinetic_jet_vel')

AGN feedback velocity

field agn_nperh: float [Required] (alias 'subgrid_agn_nperh')

AGN sphere of influence

field agn_seed_mass: float [Required] (alias 'subgrid_agn_seed_mass')

AGN seed mass (Msun / h)

field wind_egy_w: float [Required] (alias 'subgrid_wind_egy_w')

Wind mass loading factor

field wind_kappa_w: float [Required] (alias 'subgrid_wind_kappa_w')

Wind velocity