0% found this document useful (0 votes)
5 views14 pages

Pymgal: A Python Package For Generating Optical Mock Observations From Hydrodynamical Simulations

PyMGal is a Python package designed to generate optical mock observations of galaxies from hydrodynamical simulations by utilizing spectral energy distributions (SEDs) based on stellar population models. It allows users to customize various parameters, including models, filters, and output units, facilitating direct comparisons between simulated and observed data. The software aims to enhance the understanding of galaxy evolution and observational effects through efficient and flexible synthetic observations.

Uploaded by

andersonsoza01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views14 pages

Pymgal: A Python Package For Generating Optical Mock Observations From Hydrodynamical Simulations

PyMGal is a Python package designed to generate optical mock observations of galaxies from hydrodynamical simulations by utilizing spectral energy distributions (SEDs) based on stellar population models. It allows users to customize various parameters, including models, filters, and output units, facilitating direct comparisons between simulated and observed data. The software aims to enhance the understanding of galaxy evolution and observational effects through efficient and flexible synthetic observations.

Uploaded by

andersonsoza01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

RASTI 000, 1–13 (2025) Preprint 2 July 2025 Compiled using rasti LATEX style file v3.

PyMGal: A Python Package for Generating Optical Mock Observations


from Hydrodynamical Simulations
Patrick Janulewicz 1,2,3,4★ , Weiguang Cui 5,6,7 †
1 Department of Physics, McGill University, Montreal H3A 2T8, Canada
2 Trottier Space Institute, McGill University, Montreal H3A 2A7, Canada
3 Ciela Institute, Montreal H2V 0B3, Canada
4 Mila - Quebec Artificial Intelligence Institute, Montreal H2S 3H1, Canada
5 Departamento de Física Teórica, Módulo 15, Facultad de Ciencias, Universidad Autónoma de Madrid, 28049 Madrid, Spain
6 Centro de Investigación Avanzada en Física Fundamental (CIAFF), Facultad de Ciencias, Universidad Autónoma de Madrid, 28049 Madrid, Spain
arXiv:2507.00123v1 [astro-ph.GA] 30 Jun 2025

7 Institute for Astronomy, University of Edinburgh, Royal Observatory, Blackford Hill, Edinburgh EH9 3HJ, UK

Accepted XXX. Received YYY; in original form ZZZ

ABSTRACT

We introduce PyMGal, a Python package for generating optical mock observations of galaxies from hydrodynamical simula-
tions. PyMGal reads the properties of stellar particles from these simulations and generates spectral energy distributions (SEDs)
based on a variety of stellar population models that can be customised to fit the user’s choice of applications. Given these SEDs,
the program can calculate the brightness of particles in different output units for hundreds of unique filters. These quantities can
then be projected to a 2D plane mimicking a telescope observation. The software is compatible with different snapshot formats
and allows a flexible selection of models, filters, output units, axes of projection, angular resolutions, fields of view, and more.
It also supports additional features including dust attenuation, particle smoothing, and the option to output spectral data cubes
and maps of mass, age, and metallicity. These synthetic observations can be used to directly compare the simulated objects to
reality in order to model galaxy evolution, study different theoretical models, and investigate different observational effects. This
package allows the user to perform fast and consistent comparisons between simulation and observation, leading to a better and
more precise understanding of what we see in our Universe.
Key words: cosmological simulations – galaxy evolution – mock observations

1 INTRODUCTION mation, such as position and velocity, is saved in discrete time steps.
These steps, commonly referred to as snapshots, contain the relevant
Hydrodynamical simulations provide key insights to enhance our un-
data describing the simulated universe at that point in time. As such,
derstanding of the Universe. By solving the equations of gravity and
the matter distribution and dynamical information of the simulation
hydrodynamics within a discretised box, they are used to trace the
can be mapped out through the sample particles. Different simulation
distribution of matter and the properties of astrophysical objects from
codes may have different formatting for the snapshot data, with each
early times to the modern era. These simulations have evolved sig-
one potentially requiring unique handling when being read.
nificantly since they were first introduced, with many different codes
and formats available. These include GADGET (Springel et al. 2001) Modern hydrodynamical simulation projects, such as Illustris (Vo-
and its subsequent versions and variants, such as GIZMO (Hop- gelsberger et al. 2014), EAGLE (Schaye et al. 2015), IllustrisTNG
kins 2015), Arepo (Springel 2010), and GADGET-4 (Springel et al. (Nelson et al. 2019), SIMBA (Davé et al. 2019) and many others,
2021). Besides the GADGET family, many other numerical simula- also provide the baryonic information through the gas and star par-
tion programs, such as RAMSES (Teyssier 2002), SWIFT (Schaller ticles. Due to the computational demand of these simulations, these
et al. 2016), ENZO (Bryan et al. 2014), and Pkdgrav3 (Potter et al. particles represent populations of astronomical objects rather than
2017), offer different features, including baryonic physics and hy- being individually resolved. Each stellar particle in a simulation, for
drodynamics solvers, or are designed with different scientific goals instance, represents a group of coeval stars known as a simple stellar
in mind. These simulations generally track the matter in the uni- population (SSP). While the information provided for stellar parti-
verse, such as dark matter and baryons, through different particles. cles includes physical quantities such as position, mass, age, and
As these codes follow the evolution of a system, this particle infor- metallicity, it generally does not contain the brightness of a given
particle, which is directly measured by the observer. This creates a
barrier between simulation and observation. To overcome this prob-
★ E-mail: [email protected] lem, one often needs to infer the spectrum based on the different
† E-mail: [email protected] physical properties of the stellar particles. The light emitted from

© 2025 Janulewicz & Cui


2 Janulewicz & Cui
these particles at different wavelengths is described by the spectral lated and positions provided, the information can be combined in
energy distribution (SED). Stellar population synthesis (SPS), which order to visualise the inside of the simulation box.
provides a framework for modelling the SEDs of stellar populations In this paper, we present PyMGal, a Python program to gener-
based on their physical characteristics, can then be leveraged to infer ate mock observations of hydrodynamical simulations in the optical
the observable properties of these simulated stellar particles. Mod- regime. PyMGal performs forward modelling by leveraging SPS to
elling stellar populations, however, is a challenging task, as many convert the physical properties of simulated stellar particles into ob-
unknowns exist within the field. Different design choices must be servable quantities, enabling direct comparison between simulations
made to handle these unknowns, including the initial mass function and real astronomical observations. These projections can be made
(IMF), the star formation history (SFH), and the treatment of stellar in various output units along any arbitrary axis, with over one hun-
evolution models. dred filters included in the package. It is compatible with simulation
Many different solutions have been proposed to visualise the con- formats such as GADGET, GIZMO, AREPO, and more, and it can
tents of these simulations, typically by using existing SPS libraries to also be extended to other formats if needed.
infer SEDs, incorporating relevant physical processes, and project- One of the key strengths of PyMGal is its ability to incorporate
ing the resulting data. The most complete approaches, which include any choice of stellar population model, regardless of its original li-
radiative transfer processes, such as powderday (Narayanan et al. brary, underlying assumptions, or parameter choices. This ensures
2021) and GRASIL-3D (Domínguez-Tenreiro et al. 2014), are very that users are not restricted to any predefined set but can instead
time-consuming. Therefore, other packages, such as FORECAST implement the most suitable framework for their research, thus fa-
(Fortuni et al. 2023) and Synthesizer (Lovell et al. 2024) have cilitating comparisons across different models and enabling tailored
been developed. These packages provide a link that allows consistent selection based on specific scientific goals. Another advantage is the
comparisons between simulation and observation. In this work, we flexibility in the data products that it can output. In addition to sup-
present a fast and flexible approach for creating these synthetic obser- porting a wide range of output units for optical maps, the package
vations that facilitates comparison between different SPS models and allows users to generate maps of mass, age, and metallicity that align
addresses the many uncertainties associated with modelling stellar with these optical observations. It also features the ability to gener-
populations. ate spectral data cubes for these projections, allowing for the detailed
A simple solution to perform these comparisons is proposed by study of the object’s intrinsic spectrum along different viewing an-
EzGal (Mancone & Gonzalez 2012), which provides tools to cal- gles. Moreover, PyMGal is optimised for speed and efficiency. It has
culate magnitudes and other observables across a range of stellar a lightweight design that allows for fast processing of large datasets
population models from various works. Included among these is the without compromising the flexibility and range of outputs.
model set introduced in Bruzual & Charlot (2003; hereafter BC03), The paper is organised as follows. In Section 2, we describe the
which is one of the most widely used model sets in the literature. approach taken to model stellar populations and generate SEDs for
Another is the set from Maraston (2005; hereafter M05), which thor- simulated particles. In Section 3, we explain the methods used to
oughly treats thermally pulsating asymptotic giant branch (TP-AGB) calculate magnitudes in a photometric band given a filter response
stars due to their importance in the infrared emission of young stellar curve. In Section 4, we describe the techniques used to generate pro-
populations. EzGal also features a subsequent version of the BC03 jections given these particles and their computed magnitudes. We
models described in works such as Bruzual (2007; hereafter CB07), also describe optional modifiable parameters in this section such as
which updates the BC03 models to treat these TP-AGB stars. The smoothing, the addition of spectra, mass, age, and metallicity maps,
𝛼-enhanced BaSTI models by Percival et al. (2009; hereafter P09) and more. In Section 5, we demonstrate the reliability of PyMGal’s
and the customisable FSPS models from Conroy et al. (2009; here- outputs by comparing to an established benchmark. Finally, in Sec-
after C09) and Conroy & Gunn (2010b) are included as well. Finally, tion 6, we conclude and discuss the applications of this software to
the PEGASE.2 set from Fioc & Rocca-Volmerange (1999; hereafter modern problems.
P2), was also added to this list after publication. In addition to the
sets mentioned above, EzGal also supports custom models, enabling
users to tailor them to specific scientific needs while ensuring adapt-
ability to future advancements in the field. These models can be used 2 MODELLING STELLAR POPULATIONS
in combination with an initial mass function such as Salpeter (1955),
2.1 Reading data and generating SEDs
Kroupa (2001), or Chabrier (2003) to model SEDs of different stel-
lar populations. EzGal also provides a framework for constructing The first data product required by the software is the SPS library.
composite stellar population (CSP) models from these SSP models, Though the appearance of this distribution is dependent upon the
which may involve more sophisticated star formation histories. Ez- choice of model, all share a common structure. Each one can be
Gal is often used in observation to fit the SED of a galaxy to derive represented by a two-dimensional array containing ages on one axis
its physical quantities, such as mass, metallicity and SFH. and wavelengths or frequencies on the other. The value at any given
However, from the simulator’s point of view, the problem is differ- age-wavelength or age-frequency pair will describe the energy output
ent. The physical quantities for cosmological simulations are already of the object being studied. However, these SEDs vary as a function
known, but one would wish to see what the simulated galaxies look of metallicity as well. To address this, the metallicity range can be di-
like through different telescopes. Therefore, SPS can be leveraged vided into discrete levels, with each level being assigned its own file
to model SEDs for simulated stellar particles given some assumed containing a two-dimensional SED array. Particles within the simu-
model by using EzGal reversely. By combining this with the flexible lation, on the other hand, may have a more continuous range of such
approach described above, we are able to predict SEDs in cosmolog- values. To resolve this, the SEDs will be interpolated, allowing the
ical simulations for any arbitrary choice of stellar population model. software to assign SEDs to particles given their age and metallicity.
Using these SEDs and some assumed filter response curves, we can We illustrate this process in Figure 1.
calculate the magnitudes of simulated stellar particles as would be PyMGal can then begin to assign SEDs to particles within the
seen through different photometric bands. With magnitudes calcu- simulation. To do this, data must be read from the snapshot file,

RASTI 000, 1–13 (2025)


PyMGal 3
𝜆 Category IMF Z/Z ⊙ No. Z No. ages

Z Chabrier
BC03 0.005 - 2.5 6 221
Salpeter
A Kroupa
M05 0.05 - 3.5 5 68
Salpeter
P(A𝑖 , M𝑖 , Z𝑖 ) SED
Chabrier
CB07 0.005 - 2.5 6 221
Salpeter
Chabrier
C09 Salpeter 0.01 - 1.5 22 189
Kroupa
P09 Kroupa 0.005 - 2.5 10 56
P2 Salpeter 0.005 - 5 7 69
Model
Table 1. EzGal-formatted SPS libraries that are also supported by PyMGal.
Figure 1. Visualisation of how SEDs can be inferred given the mass, age, The first column indicates the work from which the model was obtained, the
and metallicity of a particle. Each square represents a 2D array indexed by second column specifies the available initial mass functions, and the third
wavelength 𝜆 and age A. The particle P with metallicity Z𝑖 is assigned to the column indicates the range of metallicities covered by the library. The fourth
closest metallicity value. The shape of the SED is then inferred given its age and fifth columns indicate the number of metallicities and ages, respectively,
A𝑖 , and it is later scaled by its mass M𝑖 . featured by the library.

which provides the coordinates and physical properties of particles. any arbitrary set of parameters. The user may define such a custom
The program can read the data given a centre and radius representing a file and add it in the relevant directory.
region of the box. A volume is then computed given this information, This file, or set of files, will then be read by the program and used
and all stellar particles within it are then handled by the software. Any in interpolation. A list of EzGal models also supported by PyMGal
particles falling outside the specified region will not be considered. can be found in Table 1. Users may also add additional models to
This can be modified by the user to encompass any arbitrary region, match their research goals.
including the entire simulation box. The age and metallicities of the The effect of nebular emission may play an important role in
particles are of particular interest for the task of assigning SEDs, broadband imaging data. Users wishing to incorporate this effect are
and the resulting SEDs are scaled based on the mass of the particle. encouraged to use SPS models designed to replicate the impact of
To perform this scaling, the SED is first divided by the normalised nebular emission. For instance, software such as FSPS and works
mass provided in the model file and then multiplied by the mass of such as Gutkin et al. (2016) provide a framework for modelling
the simulated stellar particle. This ensures proper treatment of the emission lines in stellar SEDs. PyMGal allows users to input such
mass loss due to evolution. PyMGal also reads the cosmology of the models, ensuring that these effects are taken into account in the
simulation, which is required to calculate different values including simulated observations.
age, redshift, and distance. Given this information, particle SEDs can
be inferred, and the program can move on to the next step.
When using the software, the user should ensure that the selected 2.3 Dust models
SPS library encompasses the full range of metallicities present in
The effect of dust attenuation can optionally be included. Though
the simulation to maintain consistency in the assigned SEDs. If the
some SPS software provides the option to apply dust attenuation
metallicity range of the models is insufficient, values outside this
immediately upon calculating the SEDs, this may not always be the
range will be mapped to the nearest boundary and may not capture
case. We therefore provide two simple models.
the true nature of the particles. In such cases, an SPS library with
A typical example of dust attenuation is described by Charlot &
extended metallicity values may be used to better match the properties
Fall (2000). The impact of dust as a function of wavelength Γ(𝜆) can
of the simulated stellar particles.
be described mathematically using Equation 1.

2.2 Model selection −𝑛


Γ(𝜆) = 𝑒 − 𝜏 (𝑡 ) (𝜆/5500Å) (1)
PyMGal must be provided with a model on which it bases its SEDs.
In the above expression, we have 𝜏(𝑡) = 1.0 for 𝑡 ≤ 𝑡 break and
The software supports different formats for these model files.
𝜏(𝑡) = 0.5 for 𝑡 > 𝑡 break and a power law index 𝑛 that is typically
To begin, the software is compatible with all EzGal SSP and CSP
assigned a value of 0.7. Moreover, 𝑡 break is a cutoff time that differ-
models, which are distributed in EzGal’s .model format and are
entiates younger stars from older ones, often assigned a value of 107
readily convertible to the more standard Flexible Image Transport
years. For stars younger than the cutoff time, contributions from both
System .fits format. It comes pre-installed with many of these
the birth cloud and the interstellar medium are considered, while stars
files, though more can be added if needed. The SSP model files are
older than this time model only contributions from the interstellar
defined by the model type, the IMF, and the metallicity. Model types
medium.
include BC03, M05, CB07, P09, C09, and P2, while choices of IMF
Another common example is the dust function from Calzetti et al.
include Salpeter, Kroupa, and Chabrier. Each model file will contain
(2000), the effect of which is described in Equation 2, where 𝑘 ′ (𝜆)
the SED’s evolution at various ages for a given metallicity. PyMGal
is the starburst reddening curve and 𝐸 𝑠 (𝐵 − 𝑉) is the colour excess
is also compatible with the binary .ised format in which the BC03
of the stellar continuum.
and CB07 models are distributed. Finally, to maximise flexibility,
PyMGal can also read files in the ASCII .txt format. In theory,

these options allow the user to implement any arbitrary model with Γ(𝜆) = 10 −0.4𝐸𝑠 (𝐵−𝑉 ) 𝑘 (𝜆) (2)

RASTI 000, 1–13 (2025)


4 Janulewicz & Cui
While PyMGal provides built-in support for these two functions,
others may also be added. Users may define and implement a custom
𝜅 𝑒 ≈ 0.2(1 + 𝑋) (4)
dust function that suits the specific needs of their research applica-
25 −3.5
tions in the program. 𝜅 𝐾 ≈ 4 × 10 𝑍 (1 + 𝑋) 𝜌𝑇 (5)
 
In addition to the above models, PyMGal may also be used to cal- 𝑍
culate the effect of dust along the line of sight. Rather than employing 𝜅 𝐻 − ≈ 2.5 × 10 −31 𝜌 1/2𝑇 9 (6)
0.02
computationally expensive radiative transfer mechanisms, we adopt  𝛾
𝜆
a fast approach by modelling dust based on the gas particles along 𝜅 𝑑 ≈ 𝜅0 (7)
each stellar particle’s line of sight. This method is designed to en- 𝜆0
sure computational efficiency while providing a fast yet adaptable Given these preferences, one opacity value is computed for each
treatment of line-of-sight dust attenuation. gas particle between the associated stellar particle and the observer,
If this option is selected, the software will read the properties and and an average opacity is determined. The total mass of these gas par-
positions of gas particles once they are projected using the process ticles 𝑚 𝑔 , as well as the pixel area 𝐴, are also computed. With these
described in Section 4.1. For each projection, both stellar and gas values, the optical depth for a stellar particle can then be estimated
particles are binned to a 2D histogram, and the bin assignments are and used to dim the brightness of the stellar particles to provide a
stored by the program. The software identifies gas particles that share more realistic rendition of the synthetic observation.
the same histogram bin and are positioned between a given stellar
particle and the observer, ignoring those located behind it.
With the relevant gas particles identified, PyMGal then computes 3 FILTERS AND MAGNITUDES
the effect they will have on their associated stellar particle. This effect
−𝜏 3.1 Calculating magnitudes
will dim the∫ brightness of a particle by a factor of 𝑒 for an optical
depth 𝜏 = 𝜅𝜌𝑑𝑠, where 𝜅 is the opacity, 𝜌 is the density along the With the SEDs computed and the optional dust attenuation function
line of sight, and 𝑠 is the path from the particle to the observer. The applied, the next step is to calculate magnitudes. The software uses
exact treatment of this optical depth will then depend on the user’s the approach from EzGal, which calculates magnitudes in the ob-
choice of assumptions. In the simplifying assumption of constant server’s frame as a function of redshift 𝑧 and formation redshift 𝑧 𝑓 .
opacity and density along the path, the optical depth may be written The age of a galaxy can then be denoted 𝑡 (𝑧, 𝑧 𝑓 ) = 𝑇𝑈 (𝑧) − 𝑇𝑈 (𝑧 𝑓 )
𝑚
𝜏 = 𝜅 𝐴𝑔 , where 𝑚 𝑔 is the total gas mass along the line of sight where 𝑇𝑈 (𝑧) is the age of the universe as a function of redshift given
within a pixel of area 𝐴. The effect of dust in this case can be written the cosmology of the simulation, and the redshifted SED at this age
in the form of Equation 3 assuming a wavelength-dependent opacity. can then be written 𝐹𝜈 [𝜈(1 + 𝑧), 𝑡 (𝑧, 𝑧 𝑓 )]. The magnitude can then
be defined as the projection of the redshifted SED through a filter
response curve 𝑅(𝜈), compared to a zero magnitude AB source. This
𝑚𝑔 calculation is illustrated in Equation 8. In this equation, the SED has
Γ(𝜆) = 𝑒 −𝜅 (𝜆) 𝐴 (3) units of erg s-1 cm-2 Hz -1 for an object at a distance of 10 pc.

𝑀AB [𝑧, 𝑡 (𝑧, 𝑧 𝑓 )] = (8)


The user’s preferred treatment for the opacity will help determine " ∫ ∞ −1 #
the value of the optical depth. This opacity may be specified by 𝜈 (𝑧 + 1)𝐹𝜈 [𝜈(1 + 𝑧), 𝑡 (𝑧, 𝑧 𝑓 )] 𝑅(𝜈)𝑑𝜈
the user or inferred from the properties of the gas particles. When − 2.5 log −∞ ∫∞ − 48.60
−∞
𝜈 −1 𝑅(𝜈)𝑑𝜈
inferring this value based on gas properties, there exist several differ-
ent sources of opacity that may dominate in different environments. The rest-frame magnitude uses the same approach, but calculates
For instance, in highly ionised gas, electron scattering is a dom- the magnitude as 𝑀AB [0, 𝑡 (𝑧, 𝑧 𝑓 )].
inant opacity source, which we denote 𝜅 𝑒 . Free-free, bound-free, PyMGal supports conversions to other units and magnitude sys-
and bound-bound electron transitions become important in regimes tems. It can convert to Vega or solar magnitude, as well as different
where the material is partially ionised, and their contributions can be units of flux, flux density, and luminosity. More details on output
approximated using Kramers opacity 𝜅 𝐾 . Moreover, in solar atmo- units and conversions can be found in Section 3.3.
spheres, opacity due to the negative hydrogen ion 𝜅 𝐻 − dominates. We provide a comparison of the magnitudes produced from differ-
Finally, opacity from dust 𝜅 𝑑 also has an important impact in regions ent stellar population models by calculating the luminosity evolution
such as the interstellar medium where dust grains are abundant. The of a 1 𝑀 ⊙ stellar particle. To ensure consistent comparison, we as-
user may choose to consider contributions from one or several of sume a solar metallicity with a Salpeter IMF and calculate dust-free
these sources. Mathematical descriptions of these opacity sources magnitudes in the SDSS r-band (Gunn et al. 1998). We select and
in units of cm2 g-1 are shown in Equations 4 to 7. The first three compare all models that feature this IMF as an option, which include
sources are defined for a gas of density 𝜌, temperature 𝑇, hydrogen BC03, M05, CB07, C09, and P2. We then use Equation 8 to compute
mass fraction 𝑋, and metallicity 𝑍 (Hansen & Kawaler 1994). For magnitudes at each age given the SEDs from the model files and the
the dust opacity, we provide a flexible power law scaling given an SDSS r-band filter response curve. We convert these magnitudes to
exponent 𝛾 and a reference opacity 𝜅0 at a reference wavelength 𝜆0 . a luminosity and present the results in Figure 2. For the purpose of
A typical exponent for the interstellar medium is given by 𝛾 ≈ 1.7 this demonstration, we calculate magnitudes in the observer’s frame
with 𝜅0 = 0.01 cm2 g-1 based on dust mass at 𝜆 = 250 𝜇m (Draine assuming a cosmology of Ω𝑚 = 0.307, ΩΛ = 0.693, ℎ = 0.678.
2006; Hildebrand 1983), though the user may modify these to best
match the conditions of the simulation. As PyMGal continues to
3.2 Set of filters
be developed, we expect to expand upon the treatment of opacities
and extend its capabilities to even broader ranges of astrophysical PyMGal requires a filter in order to calculate magnitudes. The pro-
conditions. gram contains many filters across different systems, instruments,

RASTI 000, 1–13 (2025)


PyMGal 5

Class Subclass Units


Luminosity L erg s-1
L⊙ L⊙
Flux/Flux Density F erg s-1 cm-2
F𝜈 erg s-1 cm-2 Hz-1
F𝜆 erg s-1 cm-2 Å-1
Jy Jansky
Magnitude AB -
Vega -
Solar -

Table 2. Available output units. Note that magnitudes in any system can be
set to either absolute or apparent.

(UVIS) as well as infrared (IR) (e.g. Holtzman et al. 1995; Sirianni


et al. 2005; Thompson 1994; Cheng & WFC3 Team 1999). This
list also encompasses: the Near Infrared Camera (NIRCam) from
the James Webb Space Telescope (JWST; Gardner et al. 2006); the
Figure 2. The luminosity evolution of a 1 𝑀 ⊙ stellar particle across various
models, all assuming a Salpeter IMF and solar metallicity. The models exhibit
Infrared Array Camera (IRAC; Fazio et al. 2004) and Multiband
minor variations but remain in reasonable agreement. Imaging Photometer for Spitzer (MIPS; Rieke et al. 2004) from the
Spitzer Space Telescope; the Infrared Spectrometer And Array Cam-
era (ISAAC; Moorwood et al. 1999) and Focal Reducer and low dis-
persion Spectrograph (FORS; Appenzeller & Rupprecht 1992) from
and surveys. The transmission through the filter is defined by a re-
the Very Large Telescope (VLT); the Photoconductor Array Camera
sponse curve 𝑅(𝜈) or 𝑅(𝜆), where 𝜈 and 𝜆 are the frequency and
and Spectrometer (PACS; Poglitsch et al. 2010) and the Spectral and
wavelength, respectively. This response curve is read and is used to
Photometric Imaging Receiver (SPIRE; Griffin et al. 2010) from the
calculate brightness as described by Equation 8.
Herschel Space Observatory; and the Canada-France-Hawaii 12K
Many of these curves are obtained from the Flexible Stellar Popu-
camera (CFH12K; Cuillandre et al. 2000) and MegaCam (Boulade
lation Synthesis (FSPS) software by Conroy & Gunn (2010a). These
et al. 2003) from the Canada-France-Hawaii Telescope (CFHT).
include the Johnson-Cousins system described in Bessell (1990), the
In addition to those provided by FSPS, we also add filters from
Bessell filters from Bessell & Brett (1988), and the Strömgren filters
the Chinese Space Station Telescope (CSST; Zhan 2018), and bands
from Bessell (2011). It also includes the Steidel set from Steidel et al.
from the Beijing-Arizona Sky Survey (BASS) and the Mayall z-
(2003), the Buser filter taken from Bruzual & Charlot (2003), and
band Legacy Survey (MzLS), which are used in the Dark Energy
the idealised bandpass system.
Spectroscopic Instrument (DESI; Dey et al. 2019) survey.
Filters from various telescopes and surveys are also included. This
The full set of filters can be found in Table A1, with an updated
includes the Two Micron All-Sky Survey (2MASS; Skrutskie et al.
version being maintained at the documentation website. In addition
2006), the Sloan Digital Sky Survey (SDSS; York et al. 2000), the
to the currently existing set, custom filters may also be added by the
Galaxy Evolution Explorer (GALEX; Martin et al. 2005), the Dark
user.
Energy Camera (DECam) from the Dark Energy Survey (DES; The
Dark Energy Survey Collaboration 2005), the Wide Field Camera
(WFCAM) from the United Kingdom Infrared Telescope (UKIRT; 3.3 Output units
Lawrence et al. 2007), the Wide-field Infrared Survey Explorer
(WISE; Wright et al. 2010), the Swift Ultraviolet and Optical Tele- PyMGal provides the option to convert between various output units
scope (UVOT; Roming et al. 2005), the Submillimetre Common-User to facilitate the comparison with observed data. We divide this into
Bolometer Array (SCUBA; Holland et al. 1999) from the James Clerk three main classes: luminosity, flux or flux density, and magnitude.
Maxwell Telescope (JCMT), and the Infrared Astronomical Satellite A summary of available units can be found in Table 2.
(IRAS; Neugebauer et al. 1984). It also contains the National Optical The first option is luminosity. This may be useful if the user wishes
Astronomy Observatory’s (NOAO) Extremely Wide Field Infrared to study the intrinsic energy output of the object, with no dependence
Imager (NEWFIRM; Autry et al. 2003), the Visible and Infrared on the distance at which the projection is held. This can provide a
Survey Telescope for Astronomy (VISTA; Sutherland et al. 2015) direct measurement of the total energy output of stars within the sim-
and its VISTA Infrared Camera (VIRCAM), the Suprime-Cam from ulation. Available units in this category are erg s-1 or solar luminosity
the Subaru Telescope (Miyazaki et al. 2002), the Panoramic Survey L⊙ .
Telescope and Rapid Response System 1 (Pan-STARRS1; Chambers The second category is flux and spectral flux density. We denote
et al. 2016), the Vera C. Rubin Observatory’s Large Synoptic Survey the flux by the symbol 𝐹. Since flux is the luminosity per unit area,
it is related to luminosity given 𝐹 = 4 𝜋𝑑𝐿 and is expressed in units
Telescope (LSST; Ivezić et al. 2019), as well as the Euclid (Laureijs 2

et al. 2011) and Roman (Eifler et al. 2021) space telescopes. of erg s-1 cm-2 .
Some of these telescopes or surveys contain multiple instruments. An alternative to flux is the spectral flux density, which can mea-
The Hubble Space Telescope (HST) is an example of this, as it sure either the flux per unit wavelength of the flux per unit frequency.
features the Wide Field and Planetary Camera 2 (WFPC2), the Ad- We denote the former 𝐹𝜆 and the latter 𝐹𝜈 . Another common unit
vanced Camera for Surveys (ACS), the Near Infrared Camera and for flux density is the jansky, typically denoted Jy. The jansky is
Multi-Object Spectrometer (NICMOS), and the Wide Field Camera equivalent to 𝐹𝜈 within a multiplicative factor of 10-23 . 𝐹𝜈 and 𝐹𝜆
3 (WFC3), which contains channels for ultraviolet and visible light at a given wavelength are related by 𝐹𝜆 = 𝜆𝑐2 𝐹𝜈 .

RASTI 000, 1–13 (2025)


6 Janulewicz & Cui
Z model, we select a dust-free BC03 model with a Chabrier IMF, and
we set the default filter to be the SDSS r-band. We set the smoothing
Simulation Model Filter
length to be the distance to a particle’s 100th nearest neighbour and
choose flux in erg s-1 cm-2 to be the default output units. We produce
256x256 pixel images representing a physical side length of 1.5 Mpc.

Compute particle SEDs

4.1 Projecting along an axis


Once the brightness of particles in the appropriate units is known,
Calculate magnitudes mock observations can be generated by projecting the three-
dimensional region to two dimensions. To do this, an axis of projec-
tion must be specified. The principal axes 𝑥, 𝑦, and 𝑧 are intuitive
choices that may be selected. Additionally, PyMGal supports ar-
Project results bitrary projection directions, allowing for the simulation data to be
observed through any possible angle.
With an axis specified, the positions of particles are projected to
Figure 3. A flowchart demonstrating the way PyMGal processes its input.
This example shows the process for models containing multiple metallicities two dimensions. Mock observations are produced by binning these
(denoted Z) with magnitudes being calculated over several filters. However, particle brightness values to a 2D histogram. There are three param-
the program can also be run with a single model file and a single filter. eters that will affect the way in which simulated particles will be
binned. The first of these is the number of bins in the histogram,
which is equivalent to the number of pixels in the output image. The
The final category is the magnitude system. These magnitude sys- other two are the angular resolution and the distance at which the
tems are logarithmically scaled and defined by some choice of refer- object is held. Further details on the pixel size and the angular reso-
ence brightness. The brightness of an object is then compared with lution of the image can be found in Section 4.2, while details on the
that of the reference and can either be apparent or absolute. distance of the observation can be found in Section 4.6.
The absolute magnitude is defined as the brightness that an object Each particle is then assigned to a bin in the histogram given its
would have if it were placed 10 pc away from the observer. By doing coordinates from the simulation file. The brightness of the particle is
so, it eliminates the effect of distance when calculating magnitudes. then added to the histogram bin, and this process is repeated for all
For apparent magnitude, the distance of the object does affect its particles.
value. The apparent magnitude can be obtained by calculating the We provide a first example of these projections in Figure 4. We
absolute magnitude and adding a distance term as shown in Equation demonstrate a projection of the simulated data along the three prin-
9. cipal axes and use filter response curves from multiple different
projects and instruments. To show the brightness of the simulated
 
𝑑 galaxy cluster across multiple wavelengths, we select filters ranging
𝑚 apparent = 𝑚 absolute + 5 log (9) from ultraviolet to infrared. This decreasing frequency trend can be
10 pc
seen from left to right in the figure’s columns. Furthermore, to display
We include three common magnitude systems. The default is AB the ability of the software to mimic different surveys, each frequency
magnitude, which uses a reference point of 3631 Jy that is indepen- uses a filter from a different system, survey, or instrument. From left
dent of filter choice. The Vega magnitude system is also supported. In to right, we show the u-band from LSST, the g-band from SDSS,
this system, the zero point is equal to the brightness of the star Vega the V-band from the Johnson system, the VIS band from Euclid, the
in the given filter. The third is the solar magnitude system, which F110W band from HST’s Wide Field Camera 3, and the F200W band
uses the magnitude of the Sun in a given filter to serve as a reference. from JWST’s Near Infrared Camera.
Once the magnitudes have been calculated, the final step is to
project the particles to two dimensions. Though we discuss the pro-
jection process in greater detail in Section 4, we close this section by 4.2 Dimensions and angular resolution
summarising the way in which data products are read and handled
by the program. A flowchart demonstrating these processes can be The user may select a custom angular resolution and pixel dimension
seen in Figure 3. for the output image. The angular resolution, represented by a pixel
scale, defines the smallest angular separation between two objects
that can be distinguished in the resulting mock observation. A finer
angular resolution results in a finer grid of pixels when binning
4 PROJECTIONS
the particles to a 2D histogram. The angular resolution may be set
In this section, we will perform a variety of different tests to demon- to match that of the instrument they wish to mimic. If an angular
strate the capabilities and features of this software. To avoid unnec- resolution is not specified, it will be automatically calculated to
essary repetition of the parameters of these tests, we define a default encompass all particles within the selected region.
configuration. For the simulation data, we use a simulated galaxy Another parameter is the number of pixels in the image. For a fixed
cluster from The Three Hundred project (Cui et al. 2018). We angular resolution, increasing the number of pixels will increase the
select the most massive cluster from the first resimulation region field of view of the observation. As a result, the total angular size
of the GIZMO-SIMBA run (Cui et al. 2022). We select the 118th of the image depends on both the pixel scale and the number of
snapshot, which corresponds to a redshift of 𝑧 ≈ 0.25. We set the pixels. In addition to this, the distance of the simulated region to
centre of these projections to be the cluster’s halo centre as defined the frame of observation described in Section 4.6 will also affect the
by the Amiga Halo Finder (Knollmann & Knebe 2009). As a default physical appearance of the mock observation. It is therefore possible

RASTI 000, 1–13 (2025)


PyMGal 7

Figure 4. A sample image of a galaxy cluster along different axes and different filters. The three rows show projections along the three principal axes, while the
columns indicate different filters from different surveys and instruments. From left to right, the pivot wavelength of the filter becomes larger. Note that the field
of view and angular resolution are fixed and identical across all images.

that the area covered by the output image does not correspond to the particle density, this method preserves local features in dense regions
exact user-specified region defined in Section 2.1. If the field of view while mitigating noise or artifacts in sparse regions.
is smaller than this region, the mock observation will only cover a For mass, age, and metallicity maps, it may not make physical sense
subset of it. If the field of view is larger, pixels in regions without to spread the particles as though they are light, as these properties do
particles are set to zero. not travel in the same way as light. In this case, there exists another
parameter. The maximum size of kernels for these quantities can be
limited by the gravitational softening length. This softening length
4.3 Smoothing is then converted to a pixel value during projection. This pixel value
is set to be the maximum standard deviation for the Gaussian kernel
PyMGal performs Gaussian smoothing on particles using the 𝑘-
used to spread mass, age, and metallicity. Further details on these
nearest neighbours (kNN) approach. For each stellar particle, the
quantities are presented in Section 4.4.
distance to its 𝑘 th nearest neighbour in the simulation box is calcu-
The user may also apply smoothing by specifying an array rep-
lated and converted to a pixel value. This distance is then used as one
resenting the point spread function (PSF) that may be customised
standard deviation of a 2D Gaussian distribution, which is then mul-
to match the characteristics of the instrument being simulated. This
tiplied by the value of the pixel. Because the integral of the normal
PSF will then be used to convolve the image and spread the intensity
distribution is equal to one, this ensures that the total quantity within
of each pixel. By incorporating an appropriate PSF, users can more
the pixel, such as luminosity, flux, mass, or other, is conserved. The
precisely simulate how the instrument interacts with light, allowing
user may define the value of 𝑘, which will affect how smooth the par-
for a more faithful reproduction of how the observed object would
ticles become. The user may also opt to forgo smoothing altogether.
appear in actual observations.
In this case, the particles are binned into 2D projections and are left
as individual pixel values.
This smoothing method aims to ensure that the light emitted by
each particle behaves in a manner more consistent with physical ex-
4.4 Mapping mass, age, and metallicity
pectations. Rather than being confined to a single point, light is spread
over some area, with its intensity decreasing as it travels further away In addition to projections of luminosity, magnitudes, or flux through a
from its source. This also helps remove sharp discontinuities between given filter, PyMGal also provides the option to output maps of mass,
adjacent pixels resulting from binning particles into a discrete pixel age, and metallicity. This is an optional output that is calculated after
space. Moreover, by using adaptive smoothing scales based on local the positions of the particles have been calculated in a 2D projection.

RASTI 000, 1–13 (2025)


8 Janulewicz & Cui

Figure 6. A visualisation of a spectral data cube created by PyMGal. A


sample of the full spectral range is shown, with each slice representing the
galaxy cluster at a specific wavelength. From left to right, the slices represent
wavelengths of approximately 300, 450, 650, 900, 1500, 3000, and 5000
nanometres. Note that this is the intrinsic spectrum and does not represent an
observation through a particular filter.

These maps can also be smoothed using the techniques described


in Section 4.3. For mass maps, the mass pixels are replaced by
Gaussian kernels and are smoothed similar to light. For age maps,
the product of the age and the mass 𝐴𝑖 𝑚 𝑖 is computed and is then
replaced by a Gaussian kernel. It is then divided by the Gaussian
Figure 5. A sample projection of luminosity, mass, age, and metallicity. The kernel of 𝑚 𝑖 , which has the same size as its numerator. An analogous
first row shows the luminosity in units of 𝐿 ⊙ , while the second row shows process is used for metallicity maps. The smoothing of these maps
the mass in 𝑀⊙ . The third and fourth rows show the age in Gy and the may also be limited by a gravitational softening length as described
metallicity, respectively. The left column shows an image without smoothing, in Section 4.3. An example of these maps and their smoothing is
and the right column contains the same image smoothed with a length equal to shown in Figure 5.
the distance between a particle and its 100th nearest neighbour. Restrictions
on the smoothing length are not applied to the mass, age, and metallicity
maps.
4.5 Generating spectra
In other words, each unique projection has a corresponding map for Another feature supported by PyMGal is the ability to output a
mass, age, and metallicity. data cube containing the intrinsic spectrum of the object being ob-
To calculate the mass inside a pixel, the masses of all particles served. The resulting data product is a series of two-dimensional
within the pixel are added together. In the case of age and metal- slices stacked along a third spectral dimension. This allows the user
licity maps, values are mass-weighted. Within a pixel, the age or to view the object along the entire wavelength range covered by
metallicity of a particle is multiplied by its mass. All of these values the SEDs of the stellar particles within the simulation. For a given
are then summed together and then divided by the total mass. These wavelength, PyMGal reads the brightness of each particle at that
relationships can be described mathematically using Equations 10, wavelength based on its SED and generates a mock observation by
11, and 12, where 𝑚, 𝐴, and 𝑍 represent mass, age, and metallicity binning the particles in the same manner as shown in Section 4.1.
respectively, and 𝑁 is the number of particles assigned to a pixel. This process is then repeated for each wavelength. A visualisation of
this feature is shown in Figure 6.
𝑁
∑︁ The spacing between wavelengths is defined by the spectral res-
𝑚 px = 𝑚𝑖 (10) olution. The maximum possible spectral resolution is that of the
𝑖=1 SEDs of the stellar particles, though this resolution may be modified.
Í𝑁 For instance, the spectral resolution may be decreased to match the
𝑖=1 𝐴𝑖 𝑚 𝑖
𝐴px = Í𝑁 (11) user’s research goals or reduce the memory footprint. Doing so will
𝑖=1 𝑚 𝑖 increase the wavelength difference between neighbouring observa-
Í𝑁 tions and will therefore reduce the number of wavelengths in the
𝑖=1 𝑍 𝑖 𝑚 𝑖
𝑍px = Í𝑁 (12) resulting output. The user may also specify a list of wavelengths, in
𝑖=1 𝑚 𝑖 which case only those specified will be selected for the output.

RASTI 000, 1–13 (2025)


PyMGal 9

Figure 8. A demonstration of different noise levels added to the image. From


left to right, a limiting AB magnitude of 27, 26, and 25 is selected with a
constant signal-to-noise ratio of 5 within a circular aperture of radius 0.25
arcseconds.

as described in Section 4.6, with no restriction placed on thickness.


In the bottom row, we restrict the thickness to 100 kpc. While the
Figure 7. A demonstration of selecting different redshift values and thickness two settings produce similar images, we find that some galaxies are
cuts for observation. The cluster is shown at different distances for each omitted when the thickness is limited.
column, with 𝑧 = 0.25 on the left, 𝑧 = 0.50 in the centre, and 𝑧 = 1.00 on
the right. In the top row, the entire thickness of the region is selected, while
in the bottom row, a cut of 100 kpc is taken in the projection direction.
4.8 Adding noise
4.6 Observed redshift Noise may also be added to the observations to add realism and make
The observed redshift is a parameter that can be modified to move them align more closely with real observations. PyMGal features the
the object nearer or farther away from the observational frame. Spec- option to add adjustable levels of Gaussian noise that can be tailored
ifying this distance will modify the apparent distance of the mock to match the observational scenario being modelled. This level can
observations, spectra, and maps of mass, age, and metallicity. This be modified on a continuous scale and is defined as a limiting AB
feature may be used for a variety of exercises, such as rescaling for magnitude at a chosen signal-to-noise ratio (SNR) within a chosen
apparent brightness and angular size. circular aperture.
It is important to note that placing objects at distances that differ To model this, PyMGal begins by converting the limiting AB
from their simulation redshift should be treated purely as an obser- magnitude into the user’s selected output units. It then scales this
vational exercise. This feature does not affect the physical properties flux value based on the SNR and the area of the aperture. We can
or evolutionary traits of the simulation and should not be used in an define this mathematically as follows, where we take 𝑚 𝑙𝑖𝑚 to be the
attempt to realistically simulate an object at higher or lower redshift limiting AB magnitude, 𝑔 to be a function that maps this magnitude
than that of the simulation snapshot. The user is advised to keep the to the appropriate output units, SNR to be the signal-to-noise ratio,
same redshift as the simulation when producing mock observations and 𝑟 ap to be the radius of the aperture converted into a pixel value.
that attempt to replicate real systems.
We demonstrate this effect in the columns of Figure 7. We show 𝑔(𝑚 𝑙𝑖𝑚 )
a projection of the same simulation region in units of flux for three 𝜎(𝑚 𝑙𝑖𝑚 , SNR, 𝑟 ap ) = √ (13)
SNR 𝜋𝑟 ap
different redshift values. The rows of this figure display different
choices of thicknesses along the axis of projection, which is described This value is then used as the standard deviation for a Gaussian
in Section 4.7. distribution used to combine the image with noise. Should the se-
lected output unit be a magnitude, where smaller values correspond
to higher brightness, the values are first converted into flux, combined
4.7 Thickness
with noise, and then converted back to magnitude.
The user can optionally select to project only a slice of the data We demonstrate this effect in Figure 8, where three gradually
along the axis of projection. By default, all particles in the specified increasing noise levels are presented from left to right. We select a
field of view are shown in the resulting maps. However, a cut can constant signal-to-noise ratio of 5 and a constant aperture radius of
be made along the depth axis to limit its thickness. If a thickness is 0.25 arcseconds. In each case, we amplify the noise level by one AB
specified, only particles falling within the projection centre plus or magnitude.
minus the depth will be displayed in the output image. Any particle Users requiring more detailed noise characteristics are encour-
falling beyond this range will not be shown. This feature can be used aged to obtain noise images directly from the instrument and filter
for different research purposes, such as to help focus on a specific being modelled. To more accurately replicate observational condi-
region or omit foreground and background objects. tions, mock images may be embedded into noise frames in order to
This effect is illustrated in the rows of Figure 7. In the top row, incorporate elements such as foreground objects and instrumental
we project the entire simulated region for different redshift values artifacts.

RASTI 000, 1–13 (2025)


10 Janulewicz & Cui

Figure 9. A comparison of PyMGal’s outputs in the first row using the radiative transfer package powderday in the second row as a benchmark. The third
row displays the luminosity distribution in pixel counts for both packages. From left to right, we display the most massive halo across 𝑧 ≈ 0.25 snapshots from
the EAGLE, IllustrisTNG, The Three Hundred, and SIMBA hydrodynamical simulations, ordered by increasing stellar mass within a 50 kpc radius of the
halo centre. The stellar mass within this region is indicated in the bottom-left corner of each subplot in the second row, while a 250 kpc ruler is included in the
top-left corner of each subplot in the first row for size reference.

5 VALIDATION mass within 50 kpc of the halo centre as an estimate of the central
galaxy’s stellar mass. In increasing order of stellar mass, we find
In this section, we demonstrate the fidelity of PyMGal’s outputs by values of 4.13 × 1011 M ⊙ for EAGLE, 1.01 × 1012 M ⊙ for Illus-
comparing them with an established benchmark. We use powderday trisTNG, 1.38 × 1012 M ⊙ for The Three Hundred, and 4.31 × 1012
as this benchmark, which features a full radiative transfer pipeline M ⊙ for SIMBA. We then produce images with physical side lengths
with customisable stellar population modelling via FSPS. We per- of 500 kpc for EAGLE, 750 kpc for IllustrisTNG, and 1.5 Mpc for
form this comparison across four different simulations of varying box both The Three Hundred and SIMBA. We project along the z-axis
sizes and resolutions. More specifically, we choose volumes from the in the SDSS r-band and generate 256x256 pixel images. To match
EAGLE, SIMBA, IllustrisTNG, and The Three Hundred simula- powderday’s stellar population models, we construct a custom SSP
tions at redshifts of approximately 𝑧 ≈ 0.25 to maintain consistency model using FSPS having 30 metallicities ranging from 𝑍 = 0.0001
with the previous section. to 𝑍 = 0.05 that are equally separated on a logarithmic scale. We do
For EAGLE, we select the 25th snapshot from the RefL0050N0752 not treat effects from nebular emission or black holes, and we select
run, which has a box size of 50 Mpc and 2×7523 particles (i.e. the a Chabrier IMF in each case. We generate powderday observations
same number of dark matter and baryonic components). For SIMBA, using a dust-to-metals ratio of 0.3, and we generate correspond-
we take the 137th snapshot of the flagship run (m100n1024), which ing PyMGal observations using a Charlot & Fall dust function and a
has a size of 100 ℎ-1 Mpc and 2×10243 particles. For IllustrisTNG, constant-opacity line-of-sight attenuation model matched to the level
we select the 80th snapshot from the intermediate resolution run of of powderday. We do not add smoothing, thickness cuts, or noise.
TNG300 (TNG300-2), which has a size of approximately 300 Mpc The results can be seen in Figure 9.
and 2×12503 particles. Finally, for The Three Hundred, we select
the same snapshot used throughout Section 4.1, which shows a resim- We find that the outputs from PyMGal are consistent with those
ulation region within a 1 ℎ-1 Gpc box containing 38403 dark matter from the radiative transfer package and show only minor variations.
particles. All above box sizes are reported as comoving distances. This can be seen visually by comparing images from PyMGal in
We then run both PyMGal and powderday on the most massive the first row of Figure 9 with images from powderday in the sec-
halo within each simulation snapshot. We compute the total stellar ond row. The luminosity distributions in the third row also exhibit

RASTI 000, 1–13 (2025)


PyMGal 11
close agreement between the two packages, with both yielding simi- ACKNOWLEDGEMENTS
lar luminosity values. While the validation performed in this section
We acknowledge access to the theoretically modelled galaxy cluster
assesses the core functionality of the package, users interested in
data via The Three Hundred1 collaboration. The simulations used
a more detailed assessment of PyMGal’s outputs are encouraged
in this paper have been performed in the MareNostrum Supercom-
to perform additional tests tailored to their scientific uses. These
puter at the Barcelona Supercomputing Center, thanks to CPU time
include comparisons at different wavelengths, notably those more
granted by the Red Española de Supercomputación. As part of The
affected by dust, statistical analyses of fluxes and colour indices on
Three Hundred project, this work has received financial support from
large samples of sources, and comparisons against observed datasets.
the European Union’s Horizon 2020 Research and Innovation pro-
Nonetheless, these results demonstrate that PyMGal can reliably
gramme under the Marie Skłodowska-Curie grant agreement number
reproduce synthetic observations while offering significant compu-
734374, the LACEGAL project.
tational efficiency compared to full radiative transfer methods.
PJ acknowledges support from the Centre de recherche en astro-
physique du Québec, un regroupement stratégique du FRQNT. He
also acknowledges the support of the Natural Sciences and Engi-
neering Research Council of Canada (NSERC), [funding reference
number RGPIN-2020-04606]. WC is supported by the Atracción
de Talento Contract no. 2020-T1/TIC-19882 granted by the Comu-
nidad de Madrid in Spain, and the Agencia Estatal de Investigación
6 CONCLUSIONS (AEI) for the Consolidación Investigadora Grant CNS2024-154838.
He also thanks the Ministerio de Ciencia e Innovación (Spain) for
PyMGal provides a quick and flexible way of generating mock ob-
financial support under Project grant PID2021-122603NB-C21 and
servations from cosmological simulations. The functionality of the
HORIZON EUROPE Marie Sklodowska-Curie Actions for support-
software can be broadly split into three parts: the modelling of stellar
ing the LACEGAL-III project with grant number 101086388. This
populations, the calculation of magnitudes given a filter, and the pro-
work is supported by the China Manned Space Program with grant
jection of the particles to a 2D plane. Each of these parts is detailed
no. CMS-CSST-2025-A04.
in a section of this paper.
The first part, highlighted in Section 2, involves modelling stellar
populations and leveraging this to generate SEDs. The software infers
the SEDs of stellar particles in simulation snapshot files given an DATA AVAILABILITY
SPS library that can be tailored to fit the user’s research goals. While
different libraries can be selected, they share a similar structure. Each PyMGal is registered with the Python Package Index at https:
file consists of a 2D array with ages on one axis and wavelengths //pypi.org/project/pymgal/, which contains the relevant in-
or frequencies on the other. The libraries account for the metallicity formation, documentation, and links. The documentation can also be
dependence of these SEDs by dividing the metallicity range into directly accessed at https://pymgal.readthedocs.io.
discrete quantities and having one file for each value. PyMGal then This paper uses data from the EAGLE, SIMBA, IllustrisTNG, and
reads the physical properties of simulated particles and assigns SEDs The Three Hundred hydrodynamical simulations. All relevant data
based on the selected library. The package supports all SPS libraries products used in this work are either publicly available or may be
included in EzGal and allows the user to implement customised shared upon request to the respective collaboration.
libraries as well.
The second part, shown in Section 3, describes the way PyMGal
calculates magnitudes given the SEDs and a filter response curve. REFERENCES
The magnitudes computed for different SPS models will vary model
by model, but display reasonable agreement when compared. These Appenzeller, I. & Rupprecht, G., 1992. FORS - the focal reducer for the
filters can be selected from a wide range of surveys, systems, and VLT., The Messenger, 67, 18–21.
Autry, R. G., Probst, R. G., Starr, B. M. et al., 2003. NEWFIRM: the
instruments. The package supports several different output units in-
widefield IR imager for NOAO 4-m telescopes, in Instrument Design
cluding luminosity, flux, spectral flux density, and magnitude. and Performance for Optical/Infrared Ground-based Telescopes, vol.
Once these magnitudes have been computed, mock observations 4841 of Society of Photo-Optical Instrumentation Engineers (SPIE)
can be created by projecting the data to two dimensions as described Conference Series, pp. 525–539.
in Section 4. This can be done by mapping the physical positions of Bessell, M. S., 1990. UBVRI passbands., PASP, 102, 1181–1199.
the particles to a pixel position in a 2D image. PyMGal supports Bessell, M. S., 2011. Photonic Passbands and Zero Points for the Strömgren
different projection features, including the choice of projection axis, uvby System, PASP, 123(910), 1442.
image dimensions, angular resolution, and particle smoothing. It also Bessell, M. S. & Brett, J. M., 1988. JHKLM Photometry: Standard Systems,
has the ability to create mass, age, and metallicity maps, as well as Passbands, and Intrinsic Colors, PASP, 100, 1134.
Boulade, O., Charlot, X., Abbon, P. et al., 2003. MegaCam: the new Canada-
spectral data cubes for a given mock observation. Finally, the user
France-Hawaii Telescope wide-field imaging camera, in Instrument De-
may also customise the apparent distance of the observation, the
sign and Performance for Optical/Infrared Ground-based Telescopes,
thickness in the projection region, and the level of noise. vol. 4841 of Society of Photo-Optical Instrumentation Engineers
In summary, PyMGal is a versatile tool that bridges cosmological (SPIE) Conference Series, pp. 72–81.
simulations with observational data, allowing researchers to create Bruzual, A. G., 2007. On TP-AGB stars and the mass of galaxies, in Stellar
optical mock observations of galaxies from hydrodynamical simu- Populations as Building Blocks of Galaxies, vol. 241 of IAU Symposium,
lations based on the stellar population model that best suits their pp. 125–132.
needs. It is adaptable to different simulation formats, output units,
SPS models, filter response curves, and more, making it a practical
resource for various astrophysical research applications. 1 https://www.the300-project.org

RASTI 000, 1–13 (2025)


12 Janulewicz & Cui
Bruzual, G. & Charlot, S., 2003. Stellar population synthesis at the resolution Holland, W. S., Robson, E. I., Gear, W. K. et al., 1999. SCUBA: a common-
of 2003, MNRAS, 344(4), 1000–1028. user submillimetre camera operating on the James Clerk Maxwell Tele-
Bryan, G. L., Norman, M. L., O’Shea, B. W. et al., 2014. ENZO: An Adaptive scope, MNRAS, 303(4), 659–672.
Mesh Refinement Code for Astrophysics, ApJS, 211(2), 19. Holtzman, J. A., Burrows, C. J., Casertano, S. et al., 1995. The Photometric
Calzetti, D., Armus, L., Bohlin, R. C. et al., 2000. The Dust Content and Performance and Calibration of WFPC2, PASP, 107, 1065.
Opacity of Actively Star-forming Galaxies, ApJ, 533(2), 682–695. Hopkins, P. F., 2015. A new class of accurate, mesh-free hydrodynamic
Chabrier, G., 2003. Galactic Stellar and Substellar Initial Mass Function, simulation methods, Monthly Notices of the Royal Astronomical Society,
PASP, 115(809), 763–795. 450(1), 53–110.
Chambers, K. C., Magnier, E. A., Metcalfe, N. et al., 2016. The Pan-STARRS1 Ivezić, Ž., Kahn, S. M., Tyson, J. A. et al., 2019. LSST: From Science Drivers
Surveys, arXiv e-prints, p. arXiv:1612.05560. to Reference Design and Anticipated Data Products, ApJ, 873(2), 111.
Charlot, S. & Fall, S. M., 2000. A Simple Model for the Absorption of Knollmann, S. R. & Knebe, A., 2009. Ahf: Amiga’s halo finder, The Astro-
Starlight by Dust in Galaxies, ApJ, 539(2), 718–731. physical Journal Supplement Series, 182(2), 608–624.
Cheng, E. S. & WFC3 Team, 1999. The Wide-Field Camera 3 For The Hubble Kroupa, P., 2001. On the variation of the initial mass function, MNRAS,
Space Telescope, in American Astronomical Society Meeting Abstracts, 322(2), 231–246.
vol. 195 of American Astronomical Society Meeting Abstracts, p. Laureijs, R., Amiaux, J., Arduini, S. et al., 2011. Euclid Definition Study
85.06. Report, arXiv e-prints, p. arXiv:1110.3193.
Conroy, C. & Gunn, J. E., 2010a. FSPS: Flexible Stellar Population Synthesis, Lawrence, A., Warren, S. J., Almaini, O. et al., 2007. The UKIRT Infrared
Astrophysics Source Code Library, record ascl:1010.043. Deep Sky Survey (UKIDSS), MNRAS, 379(4), 1599–1617.
Conroy, C. & Gunn, J. E., 2010b. The Propagation of Uncertainties in Stellar Lovell, C. C., Starkenburg, T., Ho, M. et al., 2024. Learning the Universe:
Population Synthesis Modeling. III. Model Calibration, Comparison, and Cosmological and Astrophysical Parameter Inference with Galaxy Lu-
Evaluation, ApJ, 712(2), 833–857. minosity Functions and Colours, arXiv e-prints, p. arXiv:2411.13960.
Conroy, C., Gunn, J. E. & White, M., 2009. The Propagation of Uncertainties Mancone, C. L. & Gonzalez, A. H., 2012. EzGal: A Flexible Interface for
in Stellar Population Synthesis Modeling. I. The Relevance of Uncertain Stellar Population Synthesis Models, PASP, 124(916), 606.
Aspects of Stellar Evolution and the Initial Mass Function to the Derived Maraston, C., 2005. Evolutionary population synthesis: models, analysis
Physical Properties of Galaxies, ApJ, 699(1), 486–506. of the ingredients and application to high-z galaxies, MNRAS, 362(3),
Cui, W., Knebe, A., Yepes, G. et al., 2018. The Three Hundred project: a large 799–825.
catalogue of theoretically modelled galaxy clusters for cosmological and Martin, D. C., Fanson, J., Schiminovich, D. et al., 2005. The Galaxy Evolution
astrophysical applications, MNRAS, 480(3), 2898–2915. Explorer: A Space Ultraviolet Survey Mission, ApJ, 619(1), L1–L6.
Cui, W., Dave, R., Knebe, A. et al., 2022. THE THREE HUNDRED project: Miyazaki, S., Komiyama, Y., Sekiguchi, M. et al., 2002. Subaru Prime Focus
The GIZMO-SIMBA run, MNRAS, 514(1), 977–996. Camera – Suprime-Cam, PASJ, 54, 833–853.
Cuillandre, J.-C., Luppino, G. A., Starr, B. M. et al., 2000. Performance of Moorwood, A., Cuby, J. G., Ballester, P. et al., 1999. ISAAC at the VLT., The
the CFH12K: a 12K by 8K CCD mosaic camera for the CFHT prime Messenger, 95, 1–5.
focus, in Optical and IR Telescope Instrumentation and Detectors, vol. Narayanan, D., Turk, M. J., Robitaille, T. et al., 2021. POWDERDAY: Dust
4008 of Society of Photo-Optical Instrumentation Engineers (SPIE) Radiative Transfer for Galaxy Simulations, ApJS, 252(1), 12.
Conference Series, pp. 1010–1021. Nelson, D., Springel, V., Pillepich, A. et al., 2019. The IllustrisTNG simula-
Davé, R., Anglés-Alcázar, D., Narayanan, D. et al., 2019. SIMBA: Cosmolog- tions: public data release, Computational Astrophysics and Cosmology,
ical simulations with black hole growth and feedback, MNRAS, 486(2), 6(1), 2.
2827–2849. Neugebauer, G., Habing, H. J., van Duinen, R. et al., 1984. The Infrared
Dey, A., Schlegel, D. J., Lang, D. et al., 2019. Overview of the DESI Legacy Astronomical Satellite (IRAS) mission., ApJ, 278, L1–L6.
Imaging Surveys, AJ, 157(5), 168. Percival, S. M., Salaris, M., Cassisi, S. et al., 2009. A Large Stellar Evolution
Domínguez-Tenreiro, R., Obreja, A., Granato, G. L. et al., 2014. GRASIL- Database for Population Synthesis Studies. IV. Integrated Properties and
3D: an implementation of dust effects in the SEDs of simulated galaxies, Spectra, ApJ, 690(1), 427–439.
MNRAS, 439(4), 3868–3889. Poglitsch, A., Waelkens, C., Geis, N. et al., 2010. The Photodetector Array
Draine, B. T., 2006. On the Submillimeter Opacity of Protoplanetary Disks, Camera and Spectrometer (PACS) on the Herschel Space Observatory,
ApJ, 636(2), 1114–1120. A&A, 518, L2.
Eifler, T., Miyatake, H., Krause, E. et al., 2021. Cosmology with the Roman Potter, D., Stadel, J. & Teyssier, R., 2017. PKDGRAV3: beyond trillion
Space Telescope - multiprobe strategies, MNRAS, 507(2), 1746–1761. particle cosmological simulations for the next era of galaxy surveys,
Fazio, G. G., Hora, J. L., Allen, L. E. et al., 2004. The Infrared Array Camera Computational Astrophysics and Cosmology, 4(1), 2.
(IRAC) for the Spitzer Space Telescope, ApJS, 154(1), 10–17. Rieke, G. H., Young, E. T., Engelbracht, C. W. et al., 2004. The Multiband
Fioc, M. & Rocca-Volmerange, B., 1999. PEGASE.2, a metallicity-consistent Imaging Photometer for Spitzer (MIPS), ApJS, 154(1), 25–29.
spectral evolution model of galaxies: the documentation and the code, Roming, P. W. A., Kennedy, T. E., Mason, K. O. et al., 2005. The Swift
arXiv e-prints, pp. astro–ph/9912179. Ultra-Violet/Optical Telescope, Space Sci. Rev., 120(3-4), 95–142.
Fortuni, F., Merlin, E., Fontana, A. et al., 2023. FORECAST: A flexible Salpeter, E. E., 1955. The Luminosity Function and Stellar Evolution., ApJ,
software to forward model cosmological hydrodynamical simulations 121, 161.
mimicking real observations, A&A, 677, A102. Schaller, M., Gonnet, P., Chalk, A. B. G. et al., 2016. SWIFT: Using
Gardner, J. P., Mather, J. C., Clampin, M. et al., 2006. The James Webb Task-Based Parallelism, Fully Asynchronous Communication, and Graph
Space Telescope, Space Sci. Rev., 123(4), 485–606. Partition-Based Domain Decomposition for Strong Scaling on more than
Griffin, M. J., Abergel, A., Abreu, A. et al., 2010. The Herschel-SPIRE 100,000 Cores, in Proceedings of the Platform for Advanced Scientific
instrument and its in-flight performance, A&A, 518, L3. Computing Conference, p. 2.
Gunn, J. E., Carr, M., Rockosi, C. et al., 1998. The Sloan Digital Sky Survey Schaye, J., Crain, R. A., Bower, R. G. et al., 2015. The EAGLE project:
Photometric Camera, AJ, 116(6), 3040–3081. simulating the evolution and assembly of galaxies and their environments,
Gutkin, J., Charlot, S. & Bruzual, G., 2016. Modelling the nebular emission MNRAS, 446(1), 521–554.
from primeval to present-day star-forming galaxies, MNRAS, 462(2), Sirianni, M., Jee, M. J., Benítez, N. et al., 2005. The Photometric Performance
1757–1774. and Calibration of the Hubble Space Telescope Advanced Camera for
Hansen, C. J. & Kawaler, S. D., 1994. Stellar Interiors. Physical Principles, Surveys, PASP, 117(836), 1049–1112.
Structure, and Evolution.. Skrutskie, M. F., Cutri, R. M., Stiening, R. et al., 2006. The Two Micron All
Hildebrand, R. H., 1983. The determination of cloud masses and dust char- Sky Survey (2MASS), AJ, 131(2), 1163–1183.
acteristics from submillimetre thermal emission., QJRAS, 24, 267–282. Springel, V., 2010. E pur si muove: Galilean-invariant cosmological hydro-

RASTI 000, 1–13 (2025)


PyMGal 13
dynamical simulations on a moving mesh, MNRAS, 401(2), 791–851.
Springel, V., Yoshida, N. & White, S. D. M., 2001. GADGET: a code for
collisionless and gasdynamical cosmological simulations, New Astron.,
6(2), 79–117.
Springel, V., Pakmor, R., Zier, O. et al., 2021. Simulating cosmic structure
formation with the GADGET-4 code, MNRAS, 506(2), 2871–2949.
Steidel, C. C., Adelberger, K. L., Shapley, A. E. et al., 2003. Lyman Break
Galaxies at Redshift z ~3: Survey Description and Full Data Set, ApJ,
592(2), 728–754.
Sutherland, W., Emerson, J., Dalton, G. et al., 2015. The Visible and Infrared
Survey Telescope for Astronomy (VISTA): Design, technical overview,
and performance, A&A, 575, A25.
Teyssier, R., 2002. Cosmological hydrodynamics with adaptive mesh refine-
ment. A new high resolution code called RAMSES, A&A, 385, 337–364.
The Dark Energy Survey Collaboration, 2005. The Dark Energy Survey,
arXiv e-prints, pp. astro–ph/0510346.
Thompson, R. I., 1994. Near infrared camera and multiobject spectrometer
(NICMOS): the near infrared space mission on HST, in Space Optics
1994: Earth Observation and Astronomy, vol. 2209 of Society of Photo-
Optical Instrumentation Engineers (SPIE) Conference Series, pp.
319–330.
Vogelsberger, M., Genel, S., Springel, V. et al., 2014. Introducing the Illustris
Project: simulating the coevolution of dark and visible matter in the
Universe, MNRAS, 444(2), 1518–1547.
Wright, E. L., Eisenhardt, P. R. M., Mainzer, A. K. et al., 2010. The Wide-
field Infrared Survey Explorer (WISE): Mission Description and Initial
On-orbit Performance, AJ, 140(6), 1868–1881.
York, D. G., Adelman, J., Anderson, Jr., J. E. et al., 2000. The Sloan Digital
Sky Survey: Technical Summary, AJ, 120(3), 1579–1587.
Zhan, H., 2018. An Overview of the Chinese Space Station Optical Survey,
in 42nd COSPAR Scientific Assembly, vol. 42, pp. E1.16–4–18.

APPENDIX A: TABLE OF AVAILABLE FILTERS


We include a table of all filters included in the package upon down-
load. An up-to-date version of this list can be found on the documen-
tation website. The user may also add custom filters if the desired
one is not present.

This paper has been typeset from a TEX/LATEX file prepared by the author.

RASTI 000, 1–13 (2025)


14 Janulewicz & Cui

Group Specification Filters

Johnson-Cousins U, V, B, R, I

Buser B2

Bessell L, L’, M

Strömgren u, v, b, y

Steidel U𝑛 , G, R𝑠 , I

Idealised bandpass 1500Å, 2300Å, 2800Å


2MASS J, H, K𝑠

SDSS u, g, r, i, z

GALEX FUV, NUV

DES DECam g, r, i, z, Y

UKIRT WFCAM Z, Y, J, H, K

WISE W1, W2, W3, W4

Swift UVOT W2, M2, W1

JCMT SCUBA 450WB, 850WB

IRAS 12𝜇m, 25𝜇m, 60𝜇m, 100𝜇m

NOAO NEWFIRM J1, J2, J3, H1, H2, K

VISTA VIRCAM Y, J, H, K

Subaru Suprime-Cam B, g, V, r, i, z

Pan-STARRS1 g, r, i, z, y

LSST u, g, r, i, z, y

Euclid VIS, Y, J, H

Roman F062, F087, F106, F129, F158, F184

HST WFPC2 F255W, F300W, F336W, F439W, F450W, F555W, F606W, F814W, F850LP
ACS F435W, F475W, F555W, F606W, F625W, F775W, F814W, F850LP
F218W, F225W, F275W, F336W, F390W, F438W, F475W, F555W,
WFC3 UVIS
F606W, F775W, F814W, F850LP
WFC3 IR F098M, F105M, F110M, F125M, F140M, F160M
NICMOS F110W, F160W

JWST NIRCam F070W, F090W, F115W, F150W, F200W, F277W, F356W, F444W

Spitzer IRAC 3.6𝜇m, 4.5𝜇m, 5.8𝜇m, 8.0𝜇m


MIPS 24𝜇m, 70𝜇m, 160𝜇m

VLT ISAAC K𝑠
FORS V, R

CFHT CFH12K B, R, I
MegaCam u, g, r, i, z

Herschel PACS 70𝜇m, 100𝜇m, 160𝜇m


SPIRE 250𝜇m, 350𝜇m, 500𝜇m

DESI BASS g, r
MzLS z

CSST NUV, u, g, r, i, z, y

Table A1. Available filters. An updated version is maintained at the documentation website https://pymgal.readthedocs.io.

RASTI 000, 1–13 (2025)

You might also like