An Observationally Driven Multifield Approach for Probing the
  Circum-Galactic Medium with Convolutional Neural Networks
The circum-galactic medium (CGM) can feasibly be mapped by multiwavelength
surveys covering broad swaths of the sky. With multiple large datasets becoming
available in the near future, we develop a likelihood-free Deep Learning
technique using convolutional neural networks (CNNs) to infer broad-scale
physical properties of a galaxy's CGM and its halo mass for the first time.
Using CAMELS (Cosmology and Astrophysics with MachinE Learning Simulations)
data, including IllustrisTNG, SIMBA, and Astrid models, we train CNNs on Soft
X-ray and 21-cm (HI) radio 2D maps to trace hot and cool gas, respectively,
around galaxies, groups, and clusters. Our CNNs offer the unique ability to
train and test on ''multifield'' datasets comprised of both HI and X-ray maps,
providing complementary information about physical CGM properties and improved
inferences. Applying eRASS:4 survey limits shows that X-ray is not powerful
enough to infer individual halos with masses $\log(M_{\rm{halo}}/M_{\odot}) <
12.5$. The multifield improves the inference for all halo masses. Generally,
the CNN trained and tested on Astrid (SIMBA) can most (least) accurately infer
CGM properties. Cross-simulation analysis -- training on one galaxy formation
model and testing on another -- highlights the challenges of developing CNNs
trained on a single model to marginalize over astrophysical uncertainties and
perform robust inferences on real data. The next crucial step in improving the
resulting inferences on physical CGM properties hinges on our ability to
interpret these deep-learning models.
Naomi Gluck, Benjamin D. Oppenheimer, Daisuke Nagai, Francisco Villaescusa-Navarro, Daniel Anglés-Alcázar
An Observationally Driven Multifield Approach for Probing the Circum-Galactic Medium with Convolutional Neural Networks

###### Abstract

The circum-galactic medium (CGM) can feasibly be mapped by multiwavelength surveys covering broad swaths of the sky. With multiple large datasets becoming available in the near future, we develop a likelihood-free Deep Learning technique using convolutional neural networks (CNNs) to infer broad-scale physical properties of a galaxy's CGM and its halo mass for the first time. Using CAMELS (Cosmology and Astrophysics with MachinE Learning Simulations) data, including IllustrisTNG, SIMBA, and Astrid models, we train CNNs on Soft X-ray and 21-cm (HI) radio 2D maps to trace hot and cool gas, respectively, around galaxies, groups, and clusters. Our CNNs offer the unique ability to train and test on "multifield" datasets comprised of both HI and X-ray maps, providing complementary information about physical CGM properties and improved inferences. Applying eRASS:4 survey limits shows that X-ray is not powerful enough to infer individual halos with masses \(\log(M_{\rm halo}/M_{\odot})<12.5\). The multifield improves the inference for all halo masses. Generally, the CNN trained and tested on Astrid (SIMBA) can most (least) accurately infer CGM properties. Cross-simulation analysis - training on one galaxy formation model and testing on another - highlights the challenges of developing CNNs trained on a single model to marginalize over astrophysical uncertainties and perform robust inferences on real data. The next crucial step in improving the resulting inferences on physical CGM properties hinges on our ability to interpret these deep-learning models.

keywords: galaxies: general, groups, clusters, intergalactic medium - X-ray: general - radio lines: general - software: simulations

## 1 Introduction

New telescopes are currently engaged in comprehensive surveys across large sky areas and reaching previously unobtainable depths, aiming to map the region beyond the galactic disk but within the galaxy's virial radius: the circum-galactic medium, or the CGM (Tumlinson et al., 2017). However, these telescopes have inherent limitations in detecting emissions from gaseous halos surrounding typical galaxies. Nevertheless, they offer an exceptional opportunity to characterize the broad properties of the CGM that extend beyond their original scientific scope. The CGM contains multiphase gas, partly accreted from the filaments of the cosmic web that is continuously being reshaped, used in star formation, and enriched by astrophysical feedback processes occurring within the galaxy (Keres et al., 2005; Oppenheimer et al., 2016; Christensen et al., 2016; Angles-Alcazar et al., 2017; Hafen et al., 2019).

A simple way to characterize the CGM is by temperature. The cool phase gas has a temperature of approximately \(T\sim 10^{4}\) K and has been the focus of UV absorption line measurements (e.g., Cooksey et al., 2010; Tumlinson et al., 2013; Werk et al., 2013; Johnson et al., 2015; Keeney et al., 2018). The hot phase of the CGM, with temperatures \(T>10^{6}\) K, is observable via X-ray facilities (e.g., Bregman et al., 2018; Bogdan et al., 2018; Mathur et al., 2023) and can contain the majority of a galaxy's baryonic content. Understanding both the cool and hot phases of the CGM may answer questions regarding where we may find baryons (Anderson and Bregman, 2011; Werk et al., 2014; Li et al., 2017; Oppenheimer et al., 2018), how galaxy quenching proceeds (Tumlinson et al., 2011; Somerville et al., 2015), and how the metal products of stellar nucleosynthesis are distributed (Peeples et al., 2014).

New, increasingly large datasets that chart the CGM across multiple wavelengths already exist. In particular, two contrasting wavelengths map diffuse gas across nearby galaxies: the X-ray and the 21-cm (neutral hydrogen, HI) radio. First, the _eROSITA1_ mission has conducted an all-sky X-ray survey, enabling the detection of diffuse emission from hot gas associated with groups and clusters and potentially massive galaxies (Predehl et al., 2021). Secondly, in the 21-cm
radio domain, the pursuit of detecting cool gas encompasses initiatives that serve as precursors to the forthcoming Square Kilometer Array (SKA) project. Notable among these are ASKAP (Johnston et al., 2007) and MeerKAT (Jonas and MeerKAT Team, 2016), both of which have already conducted comprehensive surveys of HI gas in galaxy and group environments through deep 21-cm pointings.

Cosmological simulations provide theoretical predictions of CGM maps, yet divergences arise due to varying hydrodynamic solvers and subgrid physics modules employed in galaxy formation simulations (Somerville et al., 2015; Tumlinson et al., 2017; Dave et al., 2020). As a result, we see very different predictions for the circumgalactic reservoirs surrounding galaxies. Distinctively, the publicly available simulations such as IllustrisTNG (Nelson et al., 2018; Pillepich et al., 2018), SIMBA (Dave et al., 2019), Astrid (Bird et al., 2022; Ni et al., 2022), among others (e.g., Schaye et al., 2015; Hopkins et al., 2018; Wetzel et al., 2023), are valuable resources for generating CGM predictions. CAMELS23(Cosmology and Astrophysics with MachinE Learning Simulations) is the first publicly available suite of simulations that includes thousands of parameter and model variations designed to train machine learning models (Villaescusa-Navarro et al., 2021, 2022). It contains four different simulations _sets_ covering distinct cosmological and astrophysical parameter distributions: LH Latin Hypercube, 1,000 simulations), 1P (1-Parameter variations, 61 simulations), CV (Cosmic Variance, 27 simulations), and EX (Extreme, 4 simulations). Of these, the CV set is uniquely significant as it fixes cosmology and astrophysics to replicate the observable properties of galaxies best, providing a fiducial model. We exclude the numerous CAMELS simulations that vary cosmology and astrophysical feedback to prevent unrealistic galaxy statistics. Thus, utilizing the diverse CAMELS CV sets, we explore three universe realizations that make distinguishing predictions for the CGM.

Footnote 2: CAMELS Project Website: [https://www.camel-simulations.org](https://www.camel-simulations.org)

Footnote 3: CAMELS Documentation available at [https://camels.readthedocs.io/en/latest/index.html](https://camels.readthedocs.io/en/latest/index.html)

In this study, we develop an image-based Convolutional Neural Network (CNN) to infer CGM properties from the CAMELS IllustrisTNG, SIMBA, and Astrid CV-set simulations. The definitions and ranges for all CGM properties are outlined in Table 1. Two significant and differently structured astrophysical feedback parameters that impact CGM properties, stellar and AGN feedback, remain predominantly unconstrained. The CV set does not explore the range of CAMELS feedback parameters like the other sets. However, we choose the CV set as a proof-of-concept and plan to include the much larger LH set that completely marginalizes over astrophysics (Villaescusa-Navarro et al., 2021) in the future. The CNN is trained and tested on diverse simulations, yielding valuable insights into the CGM properties. Additionally, we apply observational multiwavelength survey limits to the CNN for each field, guiding the design and approach of new instruments and novel surveys, maximizing their scientific returns on CGM properties, and significantly advancing our understanding of galaxy formation and large-scale structure.

This paper is outlined as follows. SS2 lays out the methods used to complete this work and includes subsections on specific simulation information (SS2.1), dataset generation (SS2.2), CNNs (SS2.3), and network outputs (SS2.4). We begin SS3 by presenting results using individual simulations to infer first the entire halo mass (SS3.1), then a global CGM property, the mass of the CGM over the mass of the halo, or \(f_{\rm cgm}\) (SS3.2), and the metallicity of the CGM (SS3.3) which exhibits large variation. We show results based on idealized soft X-ray and HI images and assess the impact of realistic observations with observational survey limits (SS3.4). We also perform _cross simulation inference_, where one trains a CNN on one galaxy formation model or simulation and tests on another to gauge its robustness (SS3.5). We discuss the interpretability of the cross-simulation inference analysis (SS4.1), the applicability and limitations of CNNs applied to the CGM (SS4.2), and a possible avenue for future work as an expansion of this analysis (SS4.3). Lastly, SS5 concludes.

## 2 Methods

In this section, we introduce the simulations (SS2.1) followed by how our halo-centric "map" datasets are generated and a description of the global properties we are training the network to infer (SS2.2). Then, SS2.3 describes the neural network applied to these datasets. Finally, we specify the network outputs, including statistical measures, to evaluate the performance of the CNN (SS2.4).

We define some vocabulary and common phrases within this work. _Fields_ refer to X-ray and 21-cm HI (hereafter HI), where using one field corresponds to either X-ray or HI; two fields, X-ray and HI, make up the multiplied. With our CNN architecture, the number of fields is equivalent to the number of channels. _Parameters_ and _hyperparameters_ define the inner workings of the CNN, where the latter must be optimized. This should not be confused with parameters in the context of astrophysical feedback. _Properties_ describe the attributes of the CGM that are inferred by the network: \(M_{\rm halo}\), \(f_{\rm cgm}\), \(\log(Z_{\rm cgm})\), \(M_{\rm cgm}\), \(f_{\rm cool}\), and \(\log(T_{\rm cgm})\). The _parameter space_ reflects the range of values for the CGM properties (between the 16\({}^{\rm th}\) and 84\({}^{\rm th}\) percentiles) that each simulation encapsulates.

### Simulations

We use the CV ("Cosmic Variance") set from three simulation suites, each of which uses a different hydrodynamic scheme: CAMELS-IllustrisTNG (referred to as IllustrisTNG) utilizing AREPO (Springel, 2010; Weinberger et al., 2020), CAMELS-SIMBA (referred to as SIMBA) utilizing GIZMO (Hopkins, 2015), and CAMELS-Astrid (referred to as Astrid) utilizing MP-Gadget (Springel, 2005). These simulations encompass 27 volumes spanning \((25h^{-1}{\rm Mpc})^{3}\) with fixed cosmological parameters (\(\Omega_{\rm M}=0.3\) and \(\sigma_{\rm B}=0.8\)) with varying random seeds for each volume's initial condition. The CAMELS astrophysical parameters for feedback are set to their fiducial values. We exclusively use the \(z=0\) snapshots for this work.

IllustrisTNG is an adaptation of the original simulation as described in Nelson et al. (2019) and Pillepich et al. (2018), using

\begin{table}
\begin{tabular}{l l l} \hline
**Property** & **Definition** & **Range** \\ \hline \(M_{\rm halo}\) & Logarithmic Halo mass in \(R_{200c}\) & \(11.5-14.3\) \\ \(f_{\rm cgm}\) & Mass ratio of CGM gas to total mass & \(0.0-0.23\) \\  & within \(R_{200c}\) & \(3.6-1.3\) \\ \hline \(Z_{\rm cgm}\) & Logarithmic CGM metallicity in 200 kpc & -\(3.6-1.3\) \\ \(M_{\rm cgm}\) & Logarithmic CGM mass in 200 kpc & \(8.0-12.5\) \\ \(f_{\rm cool}\) & Ratio of cool, low-ionized CGM gas & \(0.0-1.0\) \\  & within 200 kpc & \(3.9-7.6\) \\ \hline \end{tabular}
\end{table}
Table 1: Definitions and global value ranges of the CGM properties to be inferred and constrained by the network. These are the global value ranges, encompassing the individual ranges of IllustrisTNG, SIMBA, and Astrid. They remain consistent throughout any combination of simulations during training and testing. Properties are further distinguished by those radially defined by \(R_{200c}\) and those by 200 kpc.
the AREPO (Springel, 2010) magnetohydrodynamics code employing the N-body tree-particle-mesh approach for solving gravity and magnetohydrodynamics via moving-mesh methods. Like all simulation codes used here, IllustrisTNG has subgrid physics modules encompassing stellar processes (formation, evolution, and feedback) and black hole processes (seeding, accretion, and feedback). Black hole feedback uses a dual-mode approach that applies thermal feedback for high-Eddington accretion rates and kinetic feedback for low-Eddington rate accretion rates. The kinetic mode is directionally pushed and is more mechanically efficient than the thermal mode (Weinberger et al., 2017).

SIMBA, introduced in Dave et al. (2019) uses the hydrodynamics-based "Meshless Finite Mass" GIZMO code (Hopkins, 2015, 2017), with several unique subgrid prescriptions. It includes more physically motivated implementations of 1) AGN feedback and 2) black hole growth. SIMBA's improved subgrid physics model for AGN feedback is based on observations, utilizing kinetic energy outflows for both radiative and jet feedback modes operating at high and low Eddington ratios, respectively. Additionally, it applies observationally motivated X-ray feedback to quench massive galaxies. SIMBA's black hole growth model is phase-dependent. Cool gas accretion onto BHs is achieved through a torque-limited accretion model (Angles-Alcazar et al., 2017), and when accreting hot gas, SIMBA transitions to Bondi accretion.
### Dataset Generation

To create our halo-centric map datasets, we use \(\rm{yt}\)-based software (Turk et al., 2011) that allows for consistent and uniform analysis across different simulation codes. We generate maps of all halos within the CV set with masses of at least \(M_{\rm halo}=10^{11.5}\)\(\rm{M_{\odot}}\) along the three cardinal axes. There are approximately 5,000 halos for each simulation. The highest halo mass is \(10^{14.3}\)\(\rm{M_{\odot}}\), for a nearly 3 dex span in halo mass. Refer to Table 2 for additional details. We categorize all the halos within the simulations by halo mass, where Sub-L* halos are within the range \(11.5\leq\log(M_{\rm halo}/M_{\odot})\leq 12\), \(\rm{L^{*}}\) halos are within the range \(12\leq\log(M_{\rm halo}/M_{\odot})\leq 13\), and groups are within the range \(13\leq\log(M_{\rm halo}/M_{\odot})\leq 14.3\).

The relationship between \(\log(M_{\rm halo}/M_{\odot})\) and \(\log(M_{\rm cgm})\), \(\log(T_{\rm cgm})\), \(f_{\rm cgm}\), and \(\log(Z_{\rm cgm})\) for all simulations, the parameter space, is shown in Figure 1. The mean for each property is indicated with a solid line. Shaded regions represent the \(16^{\rm th}-84^{\rm th}\) percentiles, and dotted points indicate the "statistically low" region for halos with halo masses above \(\log(M_{\rm halo}/M_{\odot})>13.0\). In agreement with previous work (Oppenheimer et al., 2021; Delgado et al., 2023; Ni et al., 2023; Gebhardt et al., 2023), we illustrate how the properties of gas beyond the galactic disk can differ significantly between feedback implementations.

For \(\log(M_{\rm cgm})\) (top left), Astrid (blue) shows little scatter below \(\log(M_{\rm halo}/M_{\odot})>12.5\), IllustrisTNG (pink) shows similar but less extreme scatter, and SIMBA (purple) has consistent scatter throughout. In \(\log(T_{\rm cgm})\)(right), Astrid again has a low scatter throughout the entire \(M_{\rm halo}\) range. This scatter increases slightly for IllustrisTNG and again for SIMBA. Astrid has the most scatter for \(f_{\rm cgm}\) (bottom left), whereas IllustrisTNG and SIMBA display comparable scatter for lower masses, tapering off for higher masses. Finally, \(\log(Z_{\rm cgm})\) illustrates that all three simulations have significant and similar scatter. For \(M_{\rm cgm}\), \(\log(T_{\rm cgm})\), and \(f_{\rm cgm}\). Astrid has higher values for the entire \(M_{\rm halo}\) range, followed by IllustrisTNG and SIMBA. This is not the case in \(\log(Z_{\rm cgm})\), where there is significant overlap. The scatter on \(M_{\rm halo}\) was also computed with respect to the total flux per map, corresponding to the sum of all pixel values in X-ray and HI separately. When binned by \(M_{\rm halo}\), there are correlations only with IllustrisTNG and Astrid for X-ray (see Fig. A2). A more detailed discussion about the map trends and pixel counts is in Appendix A.

From the snapshot data obtained from the X-ray and HI maps, we provide an equation describing the calculation of each CGM property (\(M_{\rm halo}\), \(f_{\rm cgm}\), \(Z_{\rm cgm}\), \(M_{\rm cgm}\), \(f_{\rm cool}\), and \(T_{\rm cgm}\)):

\[\begin{split} M_{\rm halo}=&\sum m_{\rm DM}(r\,< \,R_{200\rm c})\\ &+\sum m_{\rm gas}(r\,<\,R_{200\rm c})+\sum m_{\rm star}(r\,<\,R_{200 \rm c})\\ \end{split} \tag{1}\]

\[f_{\rm cgm}=\frac{\sum m_{\rm cgm}(r\,<\,R_{200\rm c})}{M_{\rm halo}} \tag{2}\]

\[Z_{\rm cgm}=\sum\left(z_{\rm cgm}\times\,m_{\rm cgm}\right)\,(r\,<200\,\,{\rm kpc}) \tag{3}\]

\[M_{\rm cgm}=\sum m_{\rm cgm}(r\,<\,200\rm kpc) \tag{4}\]

\[f_{\rm cool}=\frac{\sum m_{\rm cool}(r\,<\,200\,\,{\rm kpc})}{\sum m_{\rm cgm }(r\,<\,200\,\,{\rm kpc})} \tag{5}\]

\[T_{\rm cgm}=\sum\left(z_{\rm cgm}\times\,m_{\rm cgm}\right)\,(r\,<\,200\,\,{ \rm kpc}) \tag{6}\]

where \(m\) is the mass of dark matter (DM), gas, or stellar (star) particles enclosed within \(r<200\) kpc. The subscript "cgm" refers to any gas that is not star-forming. \(z_{\rm cgm}\) is the particle gas metallicity. \(m_{\rm cool}\) is CGM gas with \(T<10^{6}\) K. \(t_{\rm cgm}\) is the particle gas temperature. For the definitions and numerical ranges of the above CGM properties, see Table 1.

We generate one channel for each field (HI or X-ray), adding them together in the multifield case (HI+X-ray). Each map utilizes values obtained through mock observation, as described below. For X-ray, we map X-ray surface brightness emission in the soft band between 0.5 and 2.0 keV. HI, or "Radio" refers to the 21-cm emission-based measurement that returns column density maps, which is a data reduction output of 21-cm mapping techniques. Each map is 128x128 pixels, spanning \(512\times 512\) kpc\({}^{2}\) with a 4 kpc resolution. The depth spans \(\pm 1000\) kpc from the center of the halo. Two types of maps are generated for each field: those with no observational limits, called idealized maps, and maps with observed limits imposed. We first explain the generation of idealized maps. X-ray maps are created using the pyXSIM package (ZulHone & Hallman, 2016). While pyXSIM can generate lists of individual photons, we use it in a non-stochastic manner to map the X-ray emission across the kernel of the fluid element. Therefore, our X-ray maps are idealized in their ability to map arbitrarily low emission levels. Radio-based HI column density maps are created using the Trident package (Hummels et al., 2017) where the Haardt & Madau (2012) ionization background is assumed with the self-shielding criterion of Rahmati et al. (2013) applied.

Figure 2: Each column illustrates maps for IllustrisTNG, SIMBA, and Astrid, respectively. Each row corresponds to maps for idealized X-rays, X-rays with observational limits, idealized HI, and HI with observational limits. These maps display the same halo across the CV set of the three simulations.
Figure 2 depicts maps of the same massive halo in the three simulations: IllustrisTNG, SIMBA, and Astrid, from left to right, respectively. The four rows illustrate 1) idealized X-ray, 2) observationally limited X-ray, 3) idealized HI, and 4) observationally limited HI. For X-ray with observational limits, we set the surface brightness limit to \(2.0\times 10^{-13}\) erg s\({}^{-1}\) cm\({}^{-2}\) arcmin\({}^{-2}\) corresponding to the observing depth of the _eROSITA_ eRASS:4 all-sky survey (Predehl et al., 2021). For HI with observational limits, we set the column density limit to \(N_{\rm HI}=10^{19.0}\) cm\({}^{-2}\), which is approximately the limit expected for the 21-cm HI MHONGOOSE Survey at a 15" beam size similar to the _eROSITA_ survey (de Blok et al., 2016). The observational limits are implemented by setting a lower limit floor corresponding to the detectability of the telescope. Accessing the same halo across the three simulations is possible since the CV set shares the same initial conditions between the different simulation suites. The X-ray maps tracing gas primarily above \(T>10^{6}\) K are brightest for Astrid and dimmrest for SIMBA, a trend also seen when the observational limits are imposed. The HI maps, probing \(T\sim 10^{4}\) K gas, are less centrally concentrated than the X-ray and often trace gas associated with satellites.

We expand upon the first column in Fig. 2 in Fig. A1, formatted similarly, for a range of halo masses within IllustrisTNG from \(\log(M_{\rm halo}/M_{\odot})=13.83\) (leftmost) to \(\log(M_{\rm halo}/M_{\odot})=11.68\) (rightmost). X-ray emission, which traces gas with a temperature above \(10^{6}\) K, indicates a strong correlation with halo mass. Features seen here include wind-blown bubbles (Predehl et al., 2020), satellite galaxies creating bow shocks (Kang et al., 2007; Bykov et al., 2008; Zinger et al., 2018; Li et al., 2022), and emissions associated with galaxies themselves. HI does not have this same correlation with halo mass, strengthening our choice in creating the HI+X-ray multifield.

### Convolutional Neural Network

The advantage of employing CNNs lies in their capacity to simultaneously learn multiple features from various channels or fields (X-ray and HI). Fields can be used either independently or together for training, validating, and testing without modifications to the network architecture and only minor changes in the scripts wherever necessary. This work adopts likelihood-free inference methods, suitable for cases where determining a likelihood function for large and complex datasets is computationally demanding or is not attainable. Our CNN architecture is based on the architecture used with the CAMELS Multifield Dataset (CMD) in Villaescusa-Navarro et al. (2021), inferring two cosmological and four astrophysical feedback parameters. Aside from now inferring six CGM _properties_, the remaining modifications stem from replacing the LH set (Villaescusa-Navarro et al., 2022) with the CV set. We must be capable of accommodating the unevenly distributed discrete-valued data in the form of "halo-centric" points, which can be seen in a property like halo mass. This is compared to the LH-based CMD dataset, made to infer the evenly distributed cosmological and astrophysical feedback parameters by design.

Our CNN makes two main adjustments: 1) the kernel size is changed from 4 to 2 to accommodate a smaller initial network input, and 2) the padding mode is altered from "circular" to "zeros." The padding mode is crucial in guiding the network when the image dimensions decrease, as it no longer perfectly fits the original frame. Changing to "zeros" means filling the reduced areas with zeros to maintain the network's functionality. The CNN architecture is outlined in greater detail in Appendix C in Table C1 for the main body of the CNN and Table C2 for additional functions utilized after the main body layers.

The CNN also includes hyperparameters: 1) the _maximum learning rate_ (also referred to as step size), which defines how the application of weights changes during training, 2) the _weight decay_ as a regularization tool to prevent over-fitting by reducing the model complexity, 3) the _dropout value_ (for fully connected layers) as random neuron disabling to prevent over-fitting, and 4) the _number of channels_ in the CNNs (set to an integer larger than one). To optimize these hyperparameters, we employ Optuna (Akiba et al., 2019)4, a tool that efficiently explores the parameter space and identifies the values attributed to returning the lowest validation loss, thereby achieving the best performance.

Footnote 4: [https://github.com/pfnet/optuna/](https://github.com/pfnet/optuna/)

We divide the full dataset into a training set (60%), validation set (20%), and testing set (20%). Only the training set contains the same halo along three different axis projections (setting the network parameter split=3). In contrast, the latter sets include neither the axis projections of any halo nor the original image of the halos assigned to the training set. The split is performed during each new training instance for a new combination of fields and simulations. We set the same random seed across all network operations, such that we aim to drastically reduce the probability of overlap between training, validation, and testing sets. Without the same random seed, the dataset will not be split the same way each time, and one halo could appear in two or more sets, causing inaccurate results. This process is necessary to ensure that the network does not perform additional "learning" in one phase.

### Network Outputs

Here, the "moment" network (Jeffrey and Wandelt, 2020) takes advantage of only outputting the mean, \(\mu\), and variance, \(\sigma\), of each property for increased efficiency, instead of a full posterior range. The minimum and maximum values used for calculating the network error for the six CGM properties are kept the same throughout this work, regardless of which simulation is used for training. Doing so ensures that the results are comparable in the cross-simulation analysis or training on one simulation and testing on another.

We additionally include four metrics to determine the accuracy and precision of the CNN's outputs for each CGM property: the root mean squared error (RMSE), the coefficient of determination (\(R^{2}\)), the mean relative error (\(\epsilon\)), and the reduced chi-squared (\(\chi^{2}\)). In the formulae below, we use the subscript \(i\) to correspond with the index value of the properties [1-6], the marginal posterior mean, \(\mu_{i}\), and standard deviation, \(\sigma_{i}\). Four different statistical measurements are used to make such conclusions, and TRUE\({}_{\rm i}\) is used to denote the true value of any given CGM property with respect to the simulation-based maps.

**Root mean squared error, RMSE**:

\[\text{RMSE}_{\rm i}=\sqrt{\langle(\text{TRUE}_{\rm i}-\mu_{\rm i})^{2}\rangle} \tag{7}\]

where smaller RMSE values can be interpreted as increased model accuracy in units that can be related to the measured property.

**Coefficient of determination, \(R^{2}\)**:

\[R_{i}^{2}=1-\frac{\Sigma_{i}(\text{TRUE}_{\rm i}-\mu_{\rm i})^{2}}{\Sigma_{i }(\text{TRUE}_{\rm i}-\overline{\text{TRUE}}_{\rm i})^{2}} \tag{8}\]

representing the scale-free version of the RMSE, where the closer \(R^{2}\) is to one, the more accurate the model.
**Mean relative error, \(\epsilon\)**:

\[\epsilon_{i}=\left<\frac{\sigma_{i}}{\mu_{i}}\right> \tag{9}\]

where smaller \(\epsilon_{i}\) values can be interpreted as increased model precision. This is also the type of error predicted by CNN.

**Reduced chi-squared, \(\chi^{2}\)**:

\[\chi_{i}^{2}=\frac{1}{N}\sum_{i=1}^{N}\left(\frac{\rm TRUE_{i}-\mu_{i}}{\epsilon_ {i}}\right)^{2} \tag{10}\]

where this quantifies how "trustworthy" the posterior standard deviation is, such that values close to one indicate a properly quantified error. Values greater than one indicate that the errors are underestimated, and those smaller than one are overestimated. We do not expect deviations far from one when analyzing inferences from CNNs trained and tested on the same simulation. However, values much greater than one are expected if network training and testing occur on different simulations. The variation in parameter spaces between simulations can be seen in Fig. 1.

It is also important to note that the values reported in subsequent figures correspond to the subset of the data that has been plotted, not the entire set unless otherwise noted. To achieve such a reduced set, we randomly select a fraction of data points that vary with halo mass - for example, approximately \((1/30)^{\rm th}\) of \(\log(M_{\rm halo}/M_{\odot})=11.5\) halos, but all halos above \(\log(M_{\rm halo}/M_{\odot})=13.0\) are plotted.

## 3 Results

We present our main results in this section. First, we discuss training and testing on one idealized field at a time for the same simulation (single-simulation analysis), focusing on three inferred properties: 1) halo mass in \(R_{200c}\) (\(M_{\rm halo}\) in SS3.1), 2) the mass ratio of CGM gas to the total mass inside \(R_{200c}\) (\(f_{\rm cgm}\) in SS3.2), and 3) the metallicity of the CGM inside 200 kpc (\(\log(Z_{\rm cgm})\) in SS3.3). We do not display the case of a multiplied here, as the results do not indicate significant improvement. Following this, we show the results for the observationally limited case (for properties \(M_{\rm halo}\) and \(M_{\rm cgm}\)), strengthening the motivation for using a multifield (SS3.4). We also organize the network errors (RMSE) by mass bin (see Table 2) and by simulation (training and testing on the same simulation) for the multifield case with observational limits (SS3.4.1). Finally, we provide the results of a cross-simulation analysis encompassing all three simulations, with and without observational limits for comparison (SS3.5).

We utilize Truth-Inference scatter plots to display the inferences on the CGM properties. Each plot consists of multiple panels distinguished by field, simulation, or both. Panels visualize the true value, \(\rm TRUE_{i}\), on the x-axis and the inferred posterior mean, \(\mu_{i}\), on the y-axis, with error bars corresponding to the posterior standard deviation, \(\sigma_{i}\). Four statistics (for the subset of data that is plotted and _not_ the entire dataset) are also provided for each panel: the root-mean-square-error (RMSE, Equation 7), coefficient of determination (\(R^{2}\), Equation 8) values, mean relative error (\(\epsilon\), Equation 9), and reduced \(\chi^{2}\) values (Equation 10). Definitions and equations for each are in SS2.4. The black diagonal line also represents a "perfect inference" one-to-one line between the true and inferred values.

### Inferred Halo Mass

Halo mass emerges as a readily interpretable property, directly deducible from the network, owing to its clear expectations: "true" high-mass halos should yield correspondingly high "inferred" halo masses, regardless of the simulation used for training and testing. Figure 3 illustrates the Inference-Truth plots for \(M_{\rm halo}\) across all three simulations for a subset of the data. We define halo mass in Equation 1 as the sum of dark matter, gas, and stars within \(r<R_{200c}\).

The top row corresponds to the results using idealized X-ray maps to infer \(M_{\rm halo}\), and similarly for the bottom row using HI maps. Columns are ordered by the simulation used for training and testing: IllustrisTNG (left), SIMBA (middle), and Astrid (right). The points are colored by halo mass throughout. We examine the CNN with input X-ray maps first. In the first panel, we train and test on IllustrisTNG and obtain inferences that indicate a relatively well-constrained monotonic relationship. Some points remain further away from the "truth" values set by the black diagonal line in the low-mass end, suggesting that X-ray may not be the best probe for these low-mass halos. The next panel visualizes the training and testing results on SIMBA, with a slight improvement in the higher mass range and an overall relatively well-constrained, monotonic trend with a few outliers that stray far from the black line. This is exactly what is expected and is the same across simulations and fields. There are a few more outliers than IllustrisTNG and slightly larger error bars across the entire mass range. Finally, the third panel demonstrates that the CNN trained on and tested with Astrid has excellent inference power, as indicated by smaller error bars throughout the mass range.

We can now look at the results obtained using HI input maps. In the first panel, with training and testing on IllustrisTNG, we obtain a clear and well-constrained monotonic relationship with relatively little scatter. There is a slight improvement in the error predictions when using HI instead of X-ray, as indicated by the change in the \(\chi^{2}\) value from 0.918 with X-ray to 0.938 with HI. Visually, we can see the improvement in the lower mass range, as there is less scatter. The middle panel shows training and testing on SIMBA, where the inference made is significantly worse than it is with X-ray throughout the entire parameter space, especially intermediate to low masses with increased scatter and larger error bars. The last panel shows training and testing on Astrid. Training and testing the CNN on Astrid with HI input maps yields the best inference of the three galaxy formation models, indicated by the highest \(R^{2}\) and lowest \(\epsilon\). However, the inference made with HI is outperformed by that made with X-ray in the intermediate to high mass range.

Quantitatively, Astrid provides the most accurate and precise inference for both fields following the RMSE and \(\epsilon\) values, respectively. It also has the highest \(R^{2}\) score, indicating a CNN trained and tested on Astrid can best explain the variability in the data. SIMBA has the lowest \(R^{2}\) value overall with HI input maps, making it the least accurate in this case. Investigating the \(\chi^{2}\) values, CNNs training and testing on 1) IllustrisTNG consistently overestimate the error (\(\chi^{2}<1\)), 2) SIMBA consistently underestimates the error (\(\chi^{2}>1\)), and 3) Astrid overestimate the X-ray error but underestimate the HI error.

### Inferred CGM Gas Fraction

Figure 4 shows the Truth-Inference plots for \(f_{\rm cgm}\) in the same format as Fig. 3, with the color bar still indicating \(M_{\rm halo}\). We see that \(f_{\rm cgm}\) does not have a monotonic trend, seen explicitly in Fig. 1. Higher masses tend to be more constrained, illustrated by less deviation from the black line and smaller errors than the lower mass halos. However, this is likely due to having fewer higher mass halos for the network to learn from. We define \(f_{\rm cgm}\) in Equation 2, as the sum of
non-star-forming gas within a radius of \(r<200\) kpc divided by halo mass.

The CNN performs poorly with IllustrisTNG on idealized X-ray maps, resulting in scattered points with large error bars. The network underestimates the error bars, as indicated by a \(\chi^{2}\) value greater than one. The next panel shows the results with SIMBA, for which there is better agreement and less scatter toward the higher and intermediate halo masses. However, for the low-mass halos, there is no distinctive trend, though the network can predict the values well overall but with somewhat large error bars (also underestimated). SIMBA also has slightly lower \(f_{\rm{cgm}}\) values than IllustrisTNG (c.f., Fig. 1). Finally, a CNN with Astrid provides an excellent inference for \(f_{\rm{cgm}}\) and accurately estimates the network error. The values are systematically larger, matching Fig. 1.

Similarly, we display HI in the bottom row, with overall trends matching those seen with X-ray. However, HI offers tighter constraints at lower mass halos (higher \(f_{\rm{cgm}}\) values). This indicates that HI is a slightly better probe for \(f_{\rm{cgm}}\) than X-ray. Interestingly, SIMBA now overestimates the network error (\(\chi^{2}\) value less than one), while IllustrisTNG and Astrid underestimate the errors. Overall, \(f_{\rm{cgm}}\) performs worse than \(M_{\rm{halo}}\), but the CNN is learning to infer this property using a single idealized field.

It does not appear that the quality of inference by the CNN depends on where the range of \(f_{\rm{cgm}}\) lies with respect to the entire value space spanned by all three simulations - IllustrisTNG returns the worst performance but has intermediate \(f_{\rm{cgm}}\) values, with an underestimate of the error. Astrid yields the most accurate and precise inferences for X-ray and HI fields, with lower scatter and error values in predicting \(M_{\rm{halo}}\) compared to IllustrisTNG and SIMBA. While SIMBA generally performs worse, it exhibits relatively good results in this case, especially with HI.

### Inferred Metallicity

Figure 5 shows the Truth-Inference plots for metallicity, plotted as the logarithm of the absolute value of \(Z\) (note, \(\log(Z_{\odot})=1.87\), Asplund et al. (2009) on this scale. Metallicity presents an interesting challenge to our CNN as there are often \(\sim 1\) dex of scatter in \(Z\) at the same halo mass with no obvious trend (see Fig. 1). When training and testing on IllustrisTNG (top left), we see that higher-mass halos are slightly better constrained than low-mass halos, which are more scattered and have larger (and overall underestimated) error bars. We define the metallicity of the CGM in Equation 3 as the sum of the gas particle metallicity times the mass of non-star-forming gas within a radius of \(r<200\)kpc.

Training and testing on SIMBA results in significant scatter across the entire mass range, with larger and underestimated error bars. \(L^{*}\) and group halos have higher metallicity values overall than in the previous panel. The last panel shows training and testing with Astrid, returning the best overall inference on \(\log(Z_{\rm{cgm}})\) across the

Figure 3: The Truth–Inference plots for \(M_{\rm{halo}}\) when training and testing on the same simulation using idealized single-field data. IllustrisTNG, SIMBA, and Astrid are shown from left to right, and X-ray and HI are shown on the top and bottom rows, respectively. The data is at \(z=0.0\). We plot a mass-dependent fractional sample of halos from the testing set.
entire mass range. Even though the error is underestimated, Astrid has much higher accuracy and precision based on RMSE, \(R^{2}\), and \(\epsilon\) values. We argue this is quite an impressive demonstration of our CNN's ability to predict a value with significant scatter at a single halo mass.

The bottom row illustrates this same inference but now using HI, where we see similar trends as with X-ray, though slightly more constrained in the case of IllustrisTNG and SIMBA and slightly less constrained in the case of the low mass end of Astrid. The same upward shift for \(L^{*}\) and group halos is seen with SIMBA, alluding to SIMBA's strong astrophysical feedback prescriptions that impact higher mass halos. This is also seen by the changes in lower (higher) \(\chi^{2}\) values for IllustrisTNG and SIMBA (Astrid). We conclude that neither X-ray nor HI is powerful enough on its own to infer \(\log(Z_{\rm cgm})\). Surprisingly, the entire metallicity of the CGM can be well inferred using HI, especially in the case of Astrid, despite it being a small fraction of overall hydrogen, which itself is a primordial element.

### Observational Limits and Multifield Constraints

Simulations must consider the limitations of current and future observational multiwavelength surveys, such that a one-to-one correlation between them and the developing models can exist. The specific limits used in this work come from the eROSITA eRASS:4 X-ray luminosity of \(2\times 10^{-13}\) erg s\({}^{-1}\) cm\({}^{-2}\) arcmin\({}^{-2}\), and the typical radio telescope column density for measurements of HI as \(10^{19}\) cm\({}^{-2}\). Again, we include RMSE values, \(R^{2}\), \(\epsilon\), and \(\chi^{2}\), which are especially important to distinguish between single and multifield inferences.

The top row of Figure 6 displays the Truth-Inference plots, highlighting the power of using multiple fields to infer \(M_{\rm halo}\) by training and testing a CNN with the IllustrisTNG observationally limited datasets. Utilizing X-ray (top left), it is clear that we cannot make an inference toward lower halo masses (Sub-L*). This is expected, given the _eROSITA_-inspired limits, which show X-ray emission strongly correlating with halo mass, following Fig. 11. The inability to make a clear inference in this mass regime despite providing the CNN with the most information (nearly 3500 separate Sub-L* halos, see Table 2) reiterates the weaknesses of X-ray. The X-ray inference improves in the L* range, but is still highly scattered. Chadayamuri et al. (2022) targeted L* galaxies by stacking _eROSITA_ halos and found a weak signal, which appears to be supported by the assessment here. Groups provide a much better inference for \(M_{\rm halo}\) given that these objects should be easily detectable via _eROSITA_. In the middle panel, we explore HI with observational limits to infer \(M_{\rm halo}\). Interestingly, HI does a far better job for sub-L* halos, as these are robustly detected in the 21-cm mapping (see Fig. 11). The inference worsens for L* halos and much of the Group range. Thus far, HI shows improvements via a lower RMSE value, an \(R^{2}\) value closer to 1, and a lower \(\epsilon\) value. It also indicates that the network predicts a greater error underestimation due to a higher \(\chi^{2}\) value.

As neither X-ray nor HI is robust enough to infer \(M_{\rm halo}\) alone properly, we now train and test the network on the combined HI+X

Figure 4: The Truth–Inference plots for \(f_{\rm cgm}\), with idealized X-ray (top) and idealized HI (bottom), where the color bar still represents halo mass. Astrid performs the best with the tightest constraints and smallest errors, while IllustrisTNG performs the worst, likely due to the sharp rise of \(f_{\rm cgm}\) at low mass.
ray "multifield". The multifield approach is specifically used when one field alone may not be enough to constrain a property fully or only constrain a property within a certain range of values. The secondary or tertiary fields would then be able to fill in some gaps or tighten the constraints within the inference. Additionally, with the ability to adjust the network based on current observations, we form computational counterparts to future surveys to aid their construction. We achieve stronger constraints throughout the entire mass range, even with observational limits from both X-ray and HI. X-ray probes the L* and Group mass range well, while HI probes the sub-L* mass well, alleviating the previously unresolved noise of the left panel. We see quantitative improvement in the multifield approach in lower values for RMSE, \(R^{2}\), and \(\epsilon\), which comes at the price of increased underestimation of errors seen with a slight increase in \(\chi^{2}\) value.

The bottom row of Fig. 6 provides similar results and trends for \(M_{\rm cgm}\) (defined in Equation 4) via Illustris TNG with X-ray, HI, and the multifield using observational limits. X-ray here is also not powerful enough as a probe to infer this property, especially in the low halo mass region. We then look at HI, where there is a better overall inference in the low halo mass region. However, HI produces more scatter towards the high halo masses than with X-ray. The last panel displays results from the HI+X-ray multifield, which is an overall improvement compared to either field alone. The constraints are tighter overall, and the scatter is reduced, as seen in the RMSE values, \(R^{2}\), \(\epsilon\), and \(\chi^{2}\). Additional Truth-Inference multifield plots with observational limits for the remaining CGM properties can be found in Appendix B.

#### 3.4.1 Visualizing the CNN Error

To quantify the CNN error across all six CGM properties (\(M_{\rm halo}\), \(f_{\rm cgm}\), log(\(Z_{\rm cgm}\)), \(M_{\rm cgm}\), \(f_{\rm cool}\), and log(\(T_{\rm cgm}\))), we plot the error on each property binned by halo mass. In the left panel of Figure 7, we plot the error (neural network error, or mean relative error) for each property when considering the observational limits on HI, X-ray, and the multifield HI+X-ray for a CNN that is trained and tested on Illustris TNG. Panels are separated by halo mass, where we use the full dataset instead of the subset in the Truth-Inference plots.

We outline the general trends of this figure and point out interesting features. In the Sub-L* panel, X-ray maps alone provide the highest error, followed by the multifield, and then HI with the lowest error, to be expected. Note that there is an infinitesimal difference between the multifield and using HI alone. In the second panel (L*), the margin of error between X-ray and HI is decreasing, meaning that X-ray is becoming increasingly more important in the intermediate halo mass range. The multifield is also strictly improving upon using HI alone. With Groups, the multifield offers a greater improvement over either field alone, except for log(\(M_{\rm cgm}\)) where X-ray has a slightly lower error.

Focusing on \(f_{\rm cgm}\), the errors are generally smaller than those from \(M_{\rm halo}\), but this may reflect the quantity range that is inferred as \(f_{\rm cgm}\)

Figure 5: The Truth–Inference plots for metallicity, with idealized X-ray (top) and idealized HI (bottom), where the color bar still represents halo mass. Astrid performs the best, while SIMBA performs the worst, as it has the most varied Z values across the mass range, while Astrid has the most confined values.
is mainly between \(0.0-0.16\) while \(M_{\rm halo}\) varies between \(11.5-14.3\). Meanwhile, \(\log(Z_{\rm cgm})\) has similar error levels between HI and X-ray, with a small improvement for the multifield for sub-L* and L*. The errors in \(\log(Z_{\rm cgm})\) vary between \(0.16-0.24\), so measuring metallicity at this level of accuracy is promising, but distinguishing high values of metallicity from low ones is disappointing for IllustrisTNG (see Fig. 14).

The last three sets of properties, \(\log(M_{\rm cgm})\), \(f_{\rm cool}\), and \(\log(T)\), have not been illustrated previously as Truth-Inference plots. They depict similar trends and show general multifield improvement. HI infers sub-L* the best, while X-ray infers Groups the best. The multifield is most important for L* halos, and across all six properties, there is a significant improvement in the inference. Other halo categories usually do not result in as much improvement; in some cases, the multifield performs slightly worse. We note that inference of \(f_{\rm cool}\) for groups is a significant improvement, from 0.102 (X-ray) and 0.125 (HI) to 0.084 (multifield), which reflects that the CNN integrates both observations of cool gas (HI) and hot gas (X-ray) in this fraction.

The right panel of Fig. 15 outlines the errors in IllustrisTNG, SIMBA, and Astrid for the multifield HI+X-ray with observational limits for all six properties. Halo mass again separates the three panels. Generally, a CNN trained and tested on SIMBA has the highest error over the entire mass range, while a CNN trained and tested on Astrid returns a better inference. \(f_{\rm cgm}\) breaks this trend, as it is significantly worse for L* mass halos when using IllustrisTNG, which is directly due to the drastic inflection point seen in Fig. 1. Additionally, Astrid can infer \(\log(Z_{\rm cgm})\) remarkably well for L* mass halos, compared to the high error when using IllustrisTNG. This can be seen in Fig. 14 where IllustrisTNG has much more scatter across the entire mass range, while Astrid shows little scatter.

### Cross Simulation Inference

Until now, each Truth-Inference plot has been created by training and testing on the same simulation. In this section, we provide the results obtained when training on one simulation or galaxy formation model and testing on another to prove the degree of robustness across any particular simulation. We do this both for an X-ray with observational limits and the multifield with observational limits.

In Figure 16, we demonstrate the cross-simulation inference between IllustrisTNG, SIMBA, and Astrid, using X-ray with observational limits only on the \(M_{\rm halo}\) property. The plots on the diagonal

Figure 14: Truth–Inference figures for X-ray (left), HI (middle), and HI+X-ray (right) for IllustrisTNG with observational limits imposed on \(M_{\rm halo}\) (_top row_) and \(M_{\rm cgm}\) (_bottom row_) using IllustrisTNG. X-ray provides a poor inference, especially for lower mass galaxies, as there are very few, sometimes no emission lines detected if they are too faint. On the other hand, the inference produced from HI results in more uniform errors throughout the mass range, as HI is detected around both low and high-mass halos. Combined with their observational limits, the inference is enhanced with tighter constraints at all mass scales.
correspond to training and testing on IllustrisTNG, SIMBA, and Astrid from upper left to lower right (repeated from the upper panels of Fig. 3).

The top row refers to CNNs trained on IllustrisTNG, where each panel from left to right has been tested on IllustrisTNG, SIMBA, and Astrid, respectively. When tested on SIMBA, most points are close to the black line but with significantly more scatter. When tested on Astrid, we can only recover good constraints for the high halo mass range. There is much more scatter in the low mass range, as a majority of them are overestimated, except for a few outliers, most likely resulting from the inability of X-ray to probe the low halo mass range.

When training on SIMBA but then testing on IllustrisTNG, there is still quite a bit of scatter in the low-mass halos, and the high-mass halos are now overestimated. This matches the expectations from brightness differences between IllustrisTNG (brighter) and SIMBA (dimmer). When testing on Astrid, all points are shifted up and overestimate halo mass.

Finally, training on Astrid and testing on IllustrisTNG cannot recover any of the results. There is a lot of scatter for the low halo mass range with large error bars, with points that do not follow the expected trends in IllustrisTNG for intermediate and high masses. Astrid underestimates the majority of the halo masses. When testing on SIMBA, the results cannot be recovered either, as most points underestimate halo mass. Even though training and testing on Astrid seem to provide the best constraints on halo mass with X-ray observational limits, it is the least robust simulation out of the three, as measured by its ability to be applied to other simulations as a training set. In contrast, other models trained on the Astrid LH set (Ni et al., 2023; de Santi et al., 2023) are the most robust, as the parameter variations produce the widest variation in galaxy properties, in turn making ML models more robust to changes in baryonic physics. IllustrisTNG is the most robust in this case, as it returns the results of the other two simulations with the least amount of scatter.

One oddity in the statistical measurements produced comes from training on either IllustrisTNG or SIMBA and testing on Astrid, which results in a negative \(R^{2}\) value, indicating a significant mismatch in the models. Another unusual statistic is in the extremely high \(\chi^{2}\) values from three cases: 1) training on IllustrisTNG and testing on Astrid, 2) training on SIMBA and testing on Astrid, and 3) training on Astrid and testing on either IllustrisTNG or SIMBA. Each reiterates the lack of robust results that can be achieved with Astrid.

Figure 9 illustrates the cross-simulation results on \(M_{\rm halo}\) with observational limits on the multifield HI+X-ray for IllustrisTNG, SIMBA, and Astrid. The top left panel shows this multifield, trained on and tested with IllustrisTNG, where overall, \(M_{\rm halo}\) can somewhat be constrained throughout the entire parameter space. The second panel on the diagonal corresponds to the same multifield but is now trained on and tested with SIMBA. The constraints here are weaker throughout the entire parameter space as there is more overall scatter, though the trend is the same as expected. The last panel on the diagonal shows the network trained on and tested with Astrid, where we can obtain the tightest constraints overall, especially in the higher halo mass range. The few outliers towards the mid (L*) to low (Sub-L*) mass range with larger error bars may need further investigation.

The top row shows training with IllustrisTNG and testing on IllustrisTNG, SIMBA, and Astrid, respectively. When training on IllustrisTNG and testing on SIMBA, we expect that for a given mass halo in IllustrisTNG, that same halo will look dimmer and, therefore, less massive in SIMBA. This is seen here, as most halos are below the black line. When the network is now tested on Astrid, a similar but opposite expectation is met. With the knowledge that for a given halo mass in IllustrisTNG, that same halo will look brighter and, therefore, more massive in Astrid, this trend also makes sense as we

Figure 7: _Left:_ Average RMSE values split by halo category for training and testing on IllustrisTNG, with fields X-ray, HI, and the multifield HI+X-ray with observational limits, for all six properties. These bars are representative of the _full_ dataset. We provide a dashed vertical line to distinguish between properties that are radially bound by \(R_{200c}\) and those by 200 kpc. _Right:_ Average RMSE values split by simulation (training and testing on IllustrisTNG, SIMBA, or Astrid), with HI+X-ray and observational limits, for all six properties. These bars are representative of the _full_ dataset. Neither panel is entirely comparable to the Truth–Inference plots, as these categorize errors by halo mass and are for the full dataset.
see a large majority of the points shifted above the black line. We can conclude that with observational limits on the multifield, training on IllustrisTNG can return the trends in SIMBA and Astrid, but there is an offset in recovered \(M_{\rm halo}\) explainable by the shift in observables.

The middle row shows training with SIMBA and testing on IllustrisTNG, SIMBA, and Astrid, respectively. When the network trains on IllustrisTNG, it can recover the inference and achieve good constraints. The same halo in SIMBA will seem brighter in IllustrisTNG, so the shift in most points upward above the black line is, therefore, as expected. When testing on Astrid, we still recover the inference and achieve good constraints, but we see the same shift as we saw when training on IllustrisTNG and testing on Astrid. This also aligns with the expectations, as halos in Astrid will seem much brighter than those in SIMBA. We can conclude that with observational limits on the multifield, SIMBA is also robust enough to recover the inference and constraints for \(M_{\rm halo}\).

The bottom row shows training with Astrid and testing on IllustrisTNG, SIMBA, and Astrid, respectively. When the network tests

Figure 8: Cross-simulation results for IllustrisTNG, SIMBA, and Astrid on X-ray for \(M_{\rm halo}\), with observational limits. The x-axis of each panel corresponds to the true values of \(M_{\rm halo}\), and the y-axis corresponds to the inference values of \(M_{\rm halo}\), as before. The y-axis labels indicate that the panels on the top row were trained on IllustrisTNG, the middle row on SIMBA, and the bottom row by Astrid. The columns are labeled such that the panels in the first column were tested on IllustrisTNG, the second column’s panels on SIMBA, and the third on Astrid. The diagonal panels are the result of training and testing on the same simulation. Training and testing on Astrid provide the tightest constraints and the best inference. These points are a fraction of the full dataset.
on IllustrisTNG, we can recover the general trend with slightly less strong constraints. We can recover the general trend with slightly less strong constraints when the network tests on SIMBA. Halos in Astrid will be brighter than the same halos in IllustrisTNG and SIMBA, so with the majority of the points below the black line when testing on IllustrisTNG and SIMBA. We can conclude that a CNN trained on Astrid cannot recover the inference and constraints for \(M_{\rm halo}\). We see the same statistical nuances as in the previous figure: negative \(R^{2}\) values and large \(\chi^{2}\) values in the same configurations.

By adding observational constraints for both HI and X-ray, the simulations gain a further level of similarity, which enhances their constraining power in the cross-simulation analysis. Figure 10 shows the results from using the multifield (HI+X-ray) approach with observational limits on \(M_{\rm cgm}\), with observational limits. The layout of the plot is analogous to that of Fig. 9. Training on IllustrisTNG (top row) over-predicts the results for intermediate and low mass halos when testing on SIMBA and under-predicts the same results when testing on Astrid. This aligns with the expectations in the bottom left panel of Figure 1, outlining the relationship between halo mass and \(M_{\rm cgm}\). Training on SIMBA (middle row) under-predicts intermediate and low mass halos results when testing on IllustrisTNG and Astrid. Note that there is much more scatter when testing on

Figure 9: Cross-simulation results to infer \(M_{\rm halo}\) using the multifield with observational limits for IllustrisTNG, SIMBA, and Astrid. The layout is the same as in Fig. 8. Even with the observational limits of HI and X-ray, training and testing on Astrid have the best overall inference for \(M_{\rm halo}\).
IllustrisTNG, especially for objects with low \(M_{\rm cgm}\) values. Training on Astrid (bottom row) does reasonably well when testing on IllustrisTNG with some scatter in the intermediate and low mass halos. However, it over-predicts these intermediate and low mass halos when testing on SIMBA. Although able to return similar trends, cross-simulation training and testing display offsets related to different CGMs across the simulations. However, it is enlightening to see that the cross-simulation inference improves when more bands are included, which indicates broad properties like \(M_{\rm halo}\) and \(M_{\rm cgm}\) are more robustly characterized by observing in multiple bands.

## 4 Discussions

In this section, we discuss the interpretation of cross-simulation analysis (SS4.1), the applications and limitations of CNNs when applied to the CGM (SS4.2), and an intriguing direction for future work (SS4.3).

### Cross-Simulation Interpretability

In the previous sections, we explored the robustness of simulations by examining cross-simulation inference with and without observational limits. Fig. 9 presents cross-simulation inferences for the multifield H+X-ray with observational limits on \(M_{\rm halo}\). Upon initial

Figure 10: Cross-simulation results to infer \(M_{\rm cgm}\) using the multifield with observational limits for IllustrisTNG, SIMBA, and Astrid. The layout is the same as in Figure 8.
inspection, training, and testing on Astrid offer the tightest constraints across the entire mass bin. In general, a test simulation will overpredict (underpredict) properties when trained on a simulation with CGM observables that are dimmer (brighter). Among the three simulations, a CNN trained on IllustrisTNG is the most robust, as it accurately captures the differences between halo mass measurements when training on SIMBA and Astrid. However, more work must be done to show that a CNN trained on IllustrisTNG will produce the most robust predictions when applied to real observational data. A novel aspect to further explore is training and testing on multiple simulations, varying the feedback parameters such that the CNN would marginalize over the uncertainties in baryonic physics.

The effort to train and test on different simulations mimics training on a simulation and predicting real observational data. Although it is disappointing to see such deviations in the results of cross-simulation analysis, we know that some simulations outperform others. Using observational limits that resemble the ranges of detection of current instruments as a simulation constraint, we can begin directly comparing simulations and observations. From the results of Oppenheimer et al. (2021), we know that IllustrisTNG reproduces X-ray properties of group-mass halos better than SIMBA (c.f. Fig. 9). Astrid may probably have a high \(f_{\rm gas}\); however, no mock X-ray observations have yet been conducted for this simulation. Ultimately, no simulation is a perfect representation of the real universe, and it is thus crucial to develop CNNs that can marginalize over uncertainties in subgrid physics.

Robustness quantification, or how well a network trained on one simulation can infer a given quantity when tested on another simulation within any set of simulations and machine learning algorithm, including the CAMELS suites, is crucial for furthering their development (Villaescusa-Navarro et al., 2021; Villanueva-Domingo and Villaescusa-Navarro, 2022; Echeverri et al., 2023; de Santi et al., 2023). Lack of robustness can be due to either 1) differences between simulations, 2) networks learning from numerical effects or artifacts, or 3) lack of overlapping between simulations in the high-dimensional parameter space. These reasons are not surprising due to the use of the CV set within CAMELS, and there could be slight variations in feedback that are unaccounted for. Using the LH set instead would improve the results obtained in this work. Additionally, precision (smaller error bars) without accuracy (recovering the "true" values) is meaningless. So, although Astrid generally has the smallest error bars, this alone shows strong biases when tested on other models. Future work can be done to address the inability to obtain robust constraints while performing cross-simulation analysis. One avenue is through domain adaptation (Ganin et al., 2015), which allows for a smoother transition between training and testing on different simulations such that we obtain robust results.

### Applicability and Limitations of CNNs Applied to the CGM

We have applied a CNN following the structural format used by Villaescusa-Navarro et al. (2022) and modifying it to infer underlying _properties_ of the CGM of individual halos with fixed cosmology and astrophysics within the CAMELS CV set. The former CNN infers six independent parameters (two cosmological and four astrophysical feedback) _by the design of the LH simulation set_. Our trained CGM CNN learns to predict properties with high co-dependencies (e.g., \(\log(M_{\rm halo})\) and \(\log(T_{\rm cgm})\)) and related quantities (\(f_{\rm cgm}\) and \(M_{\rm cgm}\)). In the latter case, there are two different ways to quantify CGM mass in two distinct apertures- \(M_{\rm cgm}\) is the CGM mass inside 200 kpc, and \(f_{\rm cgm}\) is CGM mass over total mass inside \(R_{200c}\).

We attempted to infer one property at a time instead of all six and found only a marginal improvement. The CNN implemented in this work, categorized as a moment network (Jeffrey and Wandelt, 2020), has the flexibility of inferring multiple properties simultaneously, but requires a rigorous hyperparameter search as detailed in SS2.3.

A concern that often appears with any simulation-based approach is the possibility of biases seeing into the result, generally due to incomplete modeling of physical processes. We aim to alleviate this concern first by using the CV set within the CAMELS simulations, where the values of cosmological and astrophysical feedback parameters are fixed to their fiducial values. The LH set, which was not used in this work (but could easily be integrated as part of future efforts), increases the chances of successful cross-simulation analysis as the astrophysical dependencies are completely marginalized over. From this standpoint, the CV set is not best suited to produce robust cross-simulation analysis. Utilizing the CV set, we gain valuable insights into the distinctions among the simulations and their effects on the results of CGM properties in this study. In addition to using the LH set, we can explore training and testing on more than one simulation or performing a similar analysis on the broader parameter space of TNG-SB28 (Ni et al., 2023).

We apply CNNs to the CGM datasets to 1) determine the degree to which physical properties of the CGM can be inferred given a combination of fields and simulations and 2) examine different observing strategies to determine how combining different wavebands can infer underlying CGM properties.

We demonstrate the feasibility of applying a CNN to observational datasets and return values and errors for CGM properties, including \(M_{\rm halo}\) and \(M_{\rm cgm}\). Additionally, the inference of \(M_{\rm halo}\) is more robustly determined when another field, along with its associated observational limits, is added. However, training on one simulation and testing on another uphold the notion that predictions can produce significantly divergent results compared to the true values, as seen in Figs. 8 and 9. As mentioned in SS4.1, although IllustrisTNG, SIMBA, and Astrid have been tuned to reproduce galaxies' and some gas properties, they make varied predictions for gaseous halos. In future efforts to improve this work, the LH set would replace the CV set, under the expectations of improvement as all astrophysics is marginalized over. Should this not be the case, domain adaptation is the longer-term solution to help bridge the many gaps between different subgrid physics models. Another interesting future direction would include training and testing on combinations of simulations, though this is ideally performed with the LH set.

### Future Work

In expanding the scope of this work to additional wavelengths in the future, we also aim to advance our understanding of where the CNN extracts important information from within a given map. We can use the information gained from this type of analysis, which has not been applied to CGM data before this work, to inform future observational surveys on how best to achieve the greatest scientific returns given wavelength, survey depth, and other specifications. Additionally, this type of analysis will be necessary to determine machine learning verification and validation. To achieve this, we hypothesize that moving towards higher resolution simulations, including IllustrisTNG-100 and EAGLE, among others, will have a more significant impact across a wide range of scales, especially in the case of observational limits.
## 5 Conclusions

In this study, we use convolutional neural networks (CNNs) trained and tested on CAMELS simulations based on the IllustrisTNG, SIMBA, and Astrid galaxy formation models to infer six broad-scale properties of the circum-galactic medium (CGM). We focus on halo mass, CGM mass, metallicity, temperature, and cool gas fraction. We simulate two observational fields, X-ray and 21-cm HI radio, that can represent the broad temperature range of the CGM. We test our CNN on datasets with and without (idealized) observational limits. Our key findings include:

1. When training and testing the CNN on the same simulation: 1. Comparing all the CGM properties the CNN is trained to infer, it performs the best overall on \(M_{\rm halo}\) and \(M_{\rm cgm}\), both with and without observational limits. For IllustrisTNG with observational limits, the RMSE values returned for \(M_{\rm halo}\) are \(\sim 0.14\) dex, and \(M_{\rm cgm}\) are \(\sim 0.11\) dex when combining X-ray and HI data. 2. The "multifield" CNN trained simultaneously on X-ray and HI data with observational limits allows for the best inference across the entire mass range using the same inputs without the discontinuities seen when trained only on one field. Obtaining interpretable inferences on halo mass for the continuous range of \(11.5\leq\log(M_{\rm halo}/M_{\odot})\leq 14.5\) requires a multifield, even though various combinations may be better over smaller mass bins than others. Sub-\(L^{*}\) halos (\(M_{\rm halo}=10^{11.5-12}\) M\({}_{\odot}\)) are only marginally better inferred with HI than the multifield. Moving to \(L^{*}\) halos (\(M_{\rm halo}=10^{12-13}\) M\({}_{\odot}\)) and the more massive groups (\(M_{\rm halo}>10^{13}\) M\({}_{\odot}\)), there is a drastic improvement when using the multifield over both X-ray and HI alone. Our exploration demonstrates that CNN-fed multiple observational fields with detectable signals can continuously improve the inference of CGM properties over a large mass range given the same input maps. 3. The performance of CNNs tends to improve when training on simulations that produce less scatter in CGM properties at fixed halo mass, with Astrid generally providing more accurate results compared to CNNs trained on TNG or SIMBA (and tested on the same model). Generally, \(Z_{\rm cgm}\) has worse performance, especially for SIMBA and IllustrisTNG. However, the CNN trained on Astrid displays superior performance for metallicity despite significant scatter at a given halo mass. Generally, the narrower the dispersion of properties, the better the CNN performs. 4. When adding observational limits to the multifield CNN, the inference accuracy declines, but still returns RMSE values indicating success. Recovering total mass from observations appears to be feasible with our CNN. HI mapping is especially critical for recovering CGM properties of sub-L* and L* galaxies.
2. For CNN cross-simulation analysis (training on one simulation and testing on another): 1. When applying cross-simulation analysis by training on one simulation and testing on another, the inferred values generally correlate with the true physical properties. Still, they are frequently offset, indicating strong biases and overall poor statistical performance. 2. Interestingly, the cross-simulation analysis reveals that using the HI+X-ray multifield with observational limits improves the halo mass inference compared to that from X-ray maps alone. In the process of adding constraints in this case, the difference between the individual simulation parameter spaces becomes smaller and acts as tighter boundary conditions for the network. Our results have broader implications for applying deep learning algorithms to the CGM than those outlined here. First, performing a cross-simulation analysis and determining that the CNN is robust opens the possibility of replacing one of the simulations with real data to infer the actual physical properties of observed systems. Second, adding more wavelengths is easily implemented within image-based neural networks. To continue making connections to both current and future multiwavelength surveys, we can expand the number of fields used in this architecture beyond X-ray and HI, including image-based CGM probes like the Dragonfly Telescope that can map the CGM in optical ions, like H\(\alpha\) and NII (Lokhort et al., 2022), and UV emission from ground or space-based probes (Johnson et al., 2014, 2018; Burchett et al., 2018; Peroux and Howk, 2020). Most importantly, this method would allow simulation differences to be marginalized over while still obtaining correlations and constraints. We can overcome the current challenges of cross-simulation analysis by training our CNN on multiple CAMELS simulations and parameter variations existing and in production (including expanding to EAGLE (Schaye et al., 2015), RAMSES (Teyssier, 2010), Enzo (Bryan et al., 2014), and Magneticum5) while integrating additional wavebands. It is crucial to identify the primary source of information for the CNN to increase the quantity of simulations and wavelengths used as inputs. Future work incorporates performing saliency analysis with integrated gradients to determine the most important pixels in a given map. It allows for more targeted and efficient adjustments to improve inferences. This can reveal what underlying physical properties are universally recoverable and robustly predictable in observations. The CGM demarcates a region of space defined by nebulous boundaries, which poses a unique challenge to traditional analysis techniques like Principal Component Analysis (PCA). Moreover, there are no established methods for characteristically analyzing the CGM. The phrase "characteristically analyzing" implies categorizing entities distinctly. For instance, traditional analysis can be used with galaxies to classify them into various categories based on their unique evolutionary traits, as evidenced by Lotz et al. (2004). However, the CGM refers to the area surrounding the galactic disk until the accretion shock radius, where neither boundary is precisely defined as they cannot be directly observed. Applying the same traditional analysis approach to a CGM dataset would require a rigid pipeline, making it difficult to incorporate new simulations or wavelengths without extensive reconfiguration. Deep learning offers a more flexible and versatile approach as a solution.

Footnote 5: [http://www.magneticum.org/](http://www.magneticum.org/)

## Acknowledgements

We thank Shy Genel and Matthew Ho for valuable feedback and suggestions for the paper. The CAMELS simulations were performed on the supercomputing facilities of the Flatiron Institute, which is supported by the Simons Foundation. This work is supported by the NSF grant AST 2206055 and the Yale Center for Research Computing facilities and staff. The work of FVN is supported by the Simons Foundation. The CAMELS project is supported by the Simons Foundation and the NSF grant AST 2108078. DAA acknowledges support by NSF grants AST-2009687 and AST-2108944, CXO grant TM2-23006X, Simons Foundation Award CCA-1018464, and Cottrell Scholar Award CS-CSA-2023-028 by the Research Corporation for Science Advancement.
## Data Availability

CAMELS data is publicly available at [https://camels.readthedocs.io/en/latest/](https://camels.readthedocs.io/en/latest/). Original data are available from the authors upon request by emailing naomi.gluck@yale.edu.
