Internal structures¶
Simbelmynë uses internally several structures.
To each Simbelmynë structure corresponds a C-structure (defined in libSBMY/include/structures.h
) and a python class (found in pysbmy/*.py
). C and python reading/writing routines for HDF5 files are provided. The C reading/writing routines are defined in libSBMY/src/io.c
and the python equivalents in pysbmy/*.py
.
Field structure¶
This structure is used for cosmological fields of rank \(r\) (typically \(r=1\) for a scalar field and \(r=3\) for a vector field) defined on a 3D cartesian grid.
Content¶
The HDF5 file structure is:
/info/scalars/L0
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L1
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L2
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/corner0
(attribute, typedouble
): x-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/corner1
(attribute, typedouble
): y-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/corner2
(attribute, typedouble
): z-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/N0
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N1
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N2
(attribute, typeint
): number of volume elements of the mesh/info/scalars/rank
(attribute, typeint
): rank of the field (usually 1 or 3)/info/scalars/time
(attribute, typedouble
): time at which the field is represented/scalars/field
(dataset, type4-byte float little-endian
(<f4
), dimensions (N0
,N1
,N2
)): the field
Use in C¶
In Simbelmynë C files, a Field structure can be read, allocated, written and freed using respectively:
Field F = read_field("field.h5")
Field F = allocate_field(rank, N0, N1, N2, corner0, corner1, corner2, L0, L1, L2, Time);
Field F = allocate_scalar_field(N0, N1, N2, corner0, corner1, corner2, L0, L1, L2, Time);
write_field(F, "field.h5");
free_field(F);
Use in python¶
With python, a field structure can be read/written using:
from pysbmy.field import read_field
F=read_field("field.h5")
F.write("field.h5")
FourierGrid and PowerSpectrum structures¶
These structures are used for cosmological power spectra. The entire Fourier grid of the simulation box is stored. The PowerSpectrum structure is a super-structure of FourierGrid.
Content¶
The HDF5 file structure for a FourierGrid is:
/info/scalars/L0
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L1
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L2
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/N0
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N1
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N2
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N2_HC
(attribute, typeint
): number of modes in the half-complex Fourier space in the z-direction (\(\mathrm{N2\_HC}=(\mathrm{N2}+1)/2\);N2
should be a multiple of 2)/info/scalars/N_HC
(attribute, typeint
): number of modes in the half-complex Fourier space (\(\mathrm{N\_HC}=\mathrm{N0} \times \mathrm{N1} \times \mathrm{N2\_HC}\))/info/scalars/NUM_MODES
(attribute, typeint
): number of k modes/info/scalars/kmax
(attribute, typedouble
): maximum wavenumber/info/scalars/k_keys
(attribute, typeint
, dimensions (N0
,N1
,N2_HC
)): the keys to be used as a function of the Fourier mode (\(\mathrm{k\_keys}[i][j][k]=b\))/info/scalars/k_modes
(attribute, type4-byte float little-endian
(<f4
) dimensionNUM_MODES
): value of the wavenumber for this key (\(k[b]\))/info/scalars/k_nmodes
(attribute, typeint
, dimensionNUM_MODES
): number of modes for this key (\(N_k[b]\))
A PowerSpectrum structure contains additionally:
/scalars/powerspectrum
(dataset, type4-byte float little-endian
(<f4
) dimensionNUM_MODES
): value of the power spectrum for this key (\(P[b]\))
Use in C¶
In Simbelmynë C files, a FourierGrid structure can be read, written and freed using respectively:
FourierGrid G = read_FourierGrid("fouriergrid.h5")
write_FourierGrid(G, "fouriergrid.h5");
free_FourierGrid(G);
and similarly for a PowerSpectrum structure:
PowerSpectrum P = read_PowerSpectrum("powerspectrum.h5")
write_PowerSpectrum(P, "powerspectrum.h5");
free_PowerSpectrum(P);
Use in python¶
With python, a FourierGrid structure can be read/written using:
from pysbmy.fft import read_FourierGrid
G=read_FourierGrid("fouriergrid.h5")
G.write("fouriergrid.h5")
and a PowerSpectrum structure using:
from pysbmy.power import read_powerspectrum
P=read_powerspectrum("powerspectrum.h5")
P.write("powerspectrum.h5")
SurveyGeometry and GalaxySelectionWindow structures¶
These structures are used for survey geometry and selection windows.
Content¶
For both SurveyGeometry and GalaxySelectionWindow structures, HDF5 files contain:
/info/scalars/L0
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L1
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/L2
(attribute, typedouble
): size of the box in Mpc/h/info/scalars/corner0
(attribute, typedouble
): x-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/corner1
(attribute, typedouble
): y-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/corner2
(attribute, typedouble
): z-position in Mpc/h of the corner of the box with respect to the observer (which is at (0,0,0))./info/scalars/N0
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N1
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N2
(attribute, typeint
): number of volume elements of the mesh/info/scalars/N_COSMOPAR
(attribute, typeint
): number of cosmological parameters stored/info/scalars/cosmo
(attribute, typedouble
, dimensionN_COSMOPAR
): cosmological parameters stored in the default order of Simbelmynë (seepysbmy/cosmology.py
)
SurveyGeometry structures contain additionally:
/info/scalars/bright_cut
(attribute, typedouble
, dimensionN_CAT
): lower value of the cuts in magnitude in each subcatalog/info/scalars/faint_cut
(attribute, typedouble
, dimensionN_CAT
): upper value of the cuts in magnitude in each subcatalog/info/scalars/rmin
(attribute, typedouble
, dimensionN_CAT
): minimum comoving distance of objects in each subcatalog/info/scalars/rmax
(attribute, typedouble
, dimensionN_CAT
): maximum comoving distance of objects in each subcatalog/info/scalars/zmin
(attribute, typedouble
, dimensionN_CAT
): minimum redshift of objects in each subcatalog/info/scalars/zmax
(attribute, typedouble
, dimensionN_CAT
): maximum redshift of objects in each subcatalog/info/scalars/N_BIAS
(attribute, typeint
): number of bias parameters/info/scalars/galaxy_bias_mean
(attribute, typedouble
, dimensions (N_CAT
,N_BIAS
)): mean values of bias parameters in each subcatalog/info/scalars/galaxy_bias_std
(attribute, typedouble
, dimensions (N_CAT
,N_BIAS
)): standard deviations of bias parameters in each subcatalog/info/scalars/galaxy_nmean_mean
(attribute, typedouble
, dimensionN_CAT
): mean value of the expected number of galaxies in each subcatalog/info/scalars/galaxy_nmean_std
(attribute, typedouble
, dimensionN_CAT
): standard deviation of the expected number of galaxies in each subcatalog/info/scalars/N_CAT
(attribute, typeint
): number of subcatalogs/scalars/galaxy_sel_window_{ICAT
} (dataset, type4-byte float little-endian
(<f4
), dimensions (N0
,N1
,N2
)) for \(0 \leq \mathrm{ICAT} < \mathrm{N\_CAT}\): the 3D galaxy selection window for each subcatalog
GalaxySelectionWindow structures contain additionally:
/info/scalars/bright_cut
(attribute, typedouble
): lower value of the cuts in magnitude in each subcatalog/info/scalars/faint_cut
(attribute, typedouble
): upper value of the cuts in magnitude in each subcatalog/info/scalars/rmin
(attribute, typedouble
): minimum comoving distance of objects in each subcatalog/info/scalars/rmax
(attribute, typedouble
): maximum comoving distance of objects in each subcatalog/info/scalars/zmin
(attribute, typedouble
): minimum redshift of objects in each subcatalog/info/scalars/zmax
(attribute, typedouble
): maximum redshift of objects in each subcatalog/info/scalars/N_BIAS
(attribute, typeint
): number of bias parameters/info/scalars/galaxy_bias_mean
(attribute, typedouble
, dimensionN_BIAS
): mean values of bias parameters in each subcatalog/info/scalars/galaxy_bias_std
(attribute, typedouble
, dimensionN_BIAS
): standard deviations of bias parameters in each subcatalog/info/scalars/galaxy_nmean_mean
(attribute, typedouble
): mean value of the expected number of galaxies in each subcatalog/info/scalars/galaxy_nmean_std
(attribute, typedouble
): standard deviation of the expected number of galaxies in each subcatalog/scalars/galaxy_sel_window_{ICAT
} ifICAT
is defined, or/scalars/field
(dataset, type4-byte float little-endian
(<f4
), dimensions (N0
,N1
,N2
)): the 3D galaxy selection window
Use in C¶
C routines to read and free SurveyGeometry and GalaxySelectionWindow structures are available and can be used as follows:
SurveyGeometry SG = read_survey_geometry_header("survey_geometry.h5");
free_survey_geometry_header(SG);
GalaxySelectionWindow GSW = read_galaxy_selection_window("galaxy_sel_window.h5", ICAT);
free_galaxy_selection_window(GSW);
read_galaxy_selection_window
will only work if ICAT
is set in the file to be read.
Use in python¶
With python, a SurveyGeometry structure can be read/written using:
from pysbmy.survey_geometry import read_survey_geometry
SG=read_survey_geometry("survey_geometry.h5");
SG.write("survey_geometry.h5");
and a GalaxySelectionWindow structure using:
from pysbmy.survey_geometry import read_galaxy_sel_window
GSW=read_galaxy_sel_window("galaxy_sel_window.h5")
GSW.write("galaxy_sel_window.h5")