betaFeedback

WorksPhysics and Astronomy

CosmoMap: Predicting Hot Gas Temperature and Density from Dark Matter with a Conditioned 3D U-Net

Abstract

Mock X-ray observations of hot gas in galaxy groups, clusters and the cosmic web require its temperature and density over large volumes and many cosmologies, for which hydrodynamical simulations are expensive. We present CosmoMap, a 3D U-Net FiLM-conditioned on cosmological and feedback parameters that predicts gas temperature TT and electron density nen_{\rm e} from dark matter density and velocity. On the CAMELS IllustrisTNG Latin hypercube, CosmoMap reaches R2=0.765R^2 = 0.765 for log⁡T\log T and 0.9340.934 for log⁡ne\log n_{\rm e} at z=0z=0, reducing the error of gradient-boosted trees by 22-23 per cent. Temperature is predicted best in the densest regions, mostly galaxy- and group-scale haloes (R2=0.88R^2 = 0.88), but the electron density of the brightest X-ray-emitting gas is biased low by 0.120.12 dex. One model outperforms the baselines at every redshift up to z=2z=2, and using inputs from gravity-only simulations costs little accuracy. The predictions reproduce scaling relations, surface brightness profile shapes and most of the cosmological information in the gas. They produce box-integrated luminosities with a median bias of −0.16-0.16 dex, sensitive at the 0.20.2 dex level to the inference scheme unless batch normalisation is used. Training for per-voxel uncertainties with a heteroscedastic likelihood costs accuracy and lowers luminosities by a further 0.10.1-0.30.3 dex; the composite-loss variant, CosmoMap-σσ, provides uncertainties that are calibrated at 68 per cent after rescaling by predicted emissivity, except for the density of the brightest gas. Compact structures are smoothed: mock X-ray lightcones recover 89 per cent of the brightest tenth of sources but 28 per cent of all sources.

Introduction

The hot gas in galaxy groups, clusters and the densest filaments is a sensitive probe of both cosmology and baryonic physics (Voit 2005; Allen et al. 2011; Kravtsov & Borgani 2012). At 10610^6–10810^8 K it radiates in X-rays mainly through thermal bremsstrahlung, with an emissivity scaling as ne2T1/2n_{\mathrm{e}}^2 T^{1/2} (Sarazin 1986; Rybicki & Lightman 1985). The first eROSITA all-sky survey catalogue already contains more than 12 000 groups and clusters from half of the sky (Bulbul et al. 2024), and the NewAthena mission (Cruise et al. 2025) will study fainter and more distant systems. Interpreting these surveys requires large numbers of mock observations to characterise selection effects and mass–observable relations, over the range of cosmologies and feedback models allowed by the data.

Hydrodynamical simulations such as IllustrisTNG (Springel et al. 2018; Pillepich et al. 2018; Nelson et al. 2019) and SIMBA (Davé et al. 2019) model the gas self-consistently, but are far more expensive than gravity-only N-body simulations. Machine learning offers a way to bridge the two (Dvorkin et al. 2022). Networks have been trained to predict galaxy properties (Kasmanoff et al. 2020; Zhang et al. 2019), neutr­al hydrogen (Wadekar et al. 2021) and thermal Sunyaev–Zel’dovich signals (Thiele et al. 2020) from dark matter, and several groups have “painted” hydrodynamical gas fields onto dark matter simulations using generative or Lagrangian models (Trost et al. 2019; Dai & Seljak 2021; Horowitz et al. 2022; Bernardini et al. 2022; Lee et al. 2025).

Closest to our goal, Cerardi et al. (2025) trained a Lagrangian deep learning emulator of the intracluster gas on CAMELS and used it to forward-model X-ray cluster counts for cosmological inference without explicit scaling relations, and Lee et al. (2026) inpaint the baryonic fields of CAMELS groups and clusters onto gravity-only haloes with a conditional generative model. The CAMELS project (Villaescusa-Navarro et al. 2021, 2022) makes it possible to train such mappings across a systematically varied space of cosmological and feedback parameters. For X-ray forward modelling, such a mapping must predict both fields that set the emission, respond to the cosmology and feedback model, be accurate in the dense regions that dominate the signal, and be shown to outperform simpler alternatives.

In this paper we present CosmoMap, a 3D U-Net (Ronneberger et al. 2015) conditioned on the six CAMELS parameters through feature-wise linear modulation (FiLM; Perez et al. 2018), which predicts gas temperature and electron density jointly from dark matter density and velocity. Relative to the approaches above, it combines joint three-dimensional prediction of the two fields that set the X-ray emission, explicit conditioning on all six cosmological and feedback parameters, and a benchmark against non-neural baselines and component ablations. We evaluate it under a single protocol, in which fields are normalised with fixed global statistics so that no property of a target field is used at test time, one simulation-level split is shared by every model, and training is repeated with several seeds. We test three things that matter for X-ray science:

(i) field accuracy against simple and strong baselines and through an ablation study, which retrains the model with one component changed at a time, as a function of environment, scale, redshift and simulation parameters;

(ii) preservation of physical structure and X-ray emission properties: dark matter–gas scaling relations, the detection and surface brightness profiles of bright emission structures, X-ray luminosities, cosmological information, and predictive uncertainties;

(iii) mock X-ray lightcones with survey-like selection, compared source by source with lightcones built from the true fields.

Two results shape the paper. Conditioning on the simulation parameters provides most of the network’s advantage over simpler models, especially in low-density gas. And training with a heteroscedastic likelihood loss, a common way to obtain per-voxel uncertainties, costs accuracy and biases X-ray luminosities in each of the three forms we test, though to different degrees. We therefore train the main CosmoMap model with a mean-squared-error loss and use a likelihood-trained variant, CosmoMap-σ\sigma, for uncertainty estimates.

The CAMELS volumes are 25 h−1h^{-1} Mpc across and contain few haloes above 1014 M⊙10^{14}\ M_{\odot}, so the densest regions we study are mostly galaxy- and group-scale haloes. We therefore present CosmoMap as a model for hot gas in haloes and the cosmic web; applying it to massive clusters requires training and testing on larger volumes (§ 7.2).

Data and preprocessing

CAMELS IllustrisTNG Latin hypercube

We use the IllustrisTNG Latin-hypercube set of CAMELS (Villaescusa-Navarro et al. 2021): 1000 simulations, each following 2563256^3 dark matter particles and 2563256^3 initial gas cells in a periodic box of side 25 h−1h^{-1} Mpc, with a different value of

p={Ωm, σ8, ASN1, AAGN1, ASN2, AAGN2},(1)p = \{\Omega_{\mathrm{m}},\ \sigma_8,\ A_{\mathrm{SN1}},\ A_{\mathrm{AGN1}},\ A_{\mathrm{SN2}},\ A_{\mathrm{AGN2}}\}, \tag*{(1)}

where ASN1A_{\mathrm{SN1}} and ASN2A_{\mathrm{SN2}} rescale the energy and wind speed of supernova feedback, and AAGN1A_{\mathrm{AGN1}} and AAGN2A_{\mathrm{AGN2}} the energy and burstiness of AGN feedback. The space-filling Latin-hypercube design matters here, because halo gas depends both on cosmology, through halo abundance and mass, and on feedback, through the gas thermodynamics. We chose TNG over SIMBA because its group and cluster gas has been compared extensively with X-ray observations and it includes a kinetic AGN feedback mode relevant to cluster cores. We use the 3D grids of the CAMELS Multifield Dataset (Villaescusa-Navarro et al. 2022) at 1283128^3 resolution (195 h−1195\ h^{-1} kpc voxels) and z∈{0,0.5,1,1.5,2}z \in\{0, 0.5, 1, 1.5, 2\}. The inputs are the dark matter mass density ρDM\rho_{\mathrm{DM}} and the magnitude of the dark matter velocity ∣vDM∣|\mathbf{v}_{\mathrm{DM}}|; the targets are the gas temperature TT and the electron number density nen_{\mathrm{e}}. In these grids TT is the mass-weighted temperature of the gas in each voxel, and nen_{\mathrm{e}} is the total number of electrons in the voxel divided by its comoving volume, in units of h2 cm−3h^2\ \mathrm{cm}^{-3} (Villaescusa-Navarro et al. 2022); both are therefore averages over 195 h−1h^{-1} kpc voxels.

Normalisation

The density and gas fields span four to seven orders of magnitude and are close to log-normal, so we work with x=log⁡10Xx = \log_{10} X, after applying small floors (10 K for temperature and 10−12 h2 cm−310^{-12}\ h^2\ \mathrm{cm}^{-3} for nen_{\mathrm{e}}) that guard against zeros and lie well below the values in the data. Each field is then standardised with a single mean and standard deviation, computed once from a subset of the training simulations at z=0z = 0 and frozen:

x′=x−μXσX,(2)x' = \frac{x-\mu_X}{\sigma_X}, \tag*{(2)}

where μX\mu_X and σX\sigma_X are the mean and standard deviation of xx for field XX. Because the same constants are used for every simulation and redshift, differences in amplitude between cosmologies and epochs are preserved, and predictions are converted to physical units with the same constants. No statistic of a target field is used at test time. The six parameters are standardised across the training set before conditioning.

Data splitting

We split the 1000 simulations once, with a fixed random seed, into 800 for training, 100 for validation and 100 for testing. All redshifts of a simulation belong to the same split, which prevents information leaking between splits through correlated snapshots. Every model and baseline uses this split, and field-level metrics are computed on the full 1283128^3 volumes of the 100 test simulations; analyses that use subsets are noted where they appear.

Model

FiLM-conditioned U-Net

CosmoMap is a 3D U-Net with three resolution levels of 64, 128 and 256 channels. Each level has a residual block of 333^3 convolutions with group normalisation (8 groups; [32]) and spatial dropout (p=0.1p = 0.1), and the bottleneck has two such convolutions. Encoder and decoder are joined by skip connections, and the network is fully convolutional. The same dark matter configuration produces different gas in different cosmologies and feedback models, so the network is conditioned on the parameters. The conditioning vector c\mathbf{c} holds the six standardised parameters and the redshift. A two-layer perceptron maps it to a 192-dimensional embedding, from which every convolution in every block computes a channel-wise scale and shift,

h→(1+γ(c))⊙h+β(c),(3)h \rightarrow(1+\gamma(\mathbf{c})) \odot h + \beta(\mathbf{c}), \tag*{(3)}

where hh is the feature map of the convolution, γ\gamma and β\beta are the scale and shift, with one value per channel, and ⊙\odot denotes channel-wise multiplication. The output head predicts a mean μ\mu for each of log⁡T\log T and log⁡ne\log n_{\mathrm{e}}, and, for the CosmoMap-σ\sigma variant, a log-variance ln⁡s2\ln s^2 for each, giving a Gaussian predictive distribution per voxel. Table 1 summarises the configuration and the distribution of the 1.11 ×107\times10^7 parameters. FiLM conditioning costs only 5 per cent of them. The network uses no attention layers: convolutions with a receptive field of several megaparsecs capture the local gravitational environment that sets the gas properties.

ConfigurationParameters by component
Input channels2 (log ρDM\rho_{\rm DM}, log ∣vDM∣\lvert v_{\rm DM}\rvert)Decoder5 671 104; 51.3%
Outputsμ\mu (and ln⁡s2\ln s^2) for TT, nen_{\rm e}Bottleneck3 540 480; 32.0%
Levels / channels3 / 64, 128, 256Encoder1 259 200; 11.4%
NormalisationGroupNorm, 8 groupsFiLM layers543 488; 4.9%
Conditioning7 inputs →\to 192-d embeddingConditioning MLP38 592; 0.3%
Training patch64364^3 voxels (12.5 h−1h^{-1} Mpc)Input stem3 648; <0.1%<0.1\%
Dropoutspatial, p=0.1p=0.1Output head260; <0.1%<0.1\%
Total11 056 772; 100%

Table 1. CosmoMap configuration and parameter distribution.

Loss functions

The main CosmoMap model is trained with the mean squared error of the predicted means, averaged over voxels and both fields. This is the standard loss for a point estimate and weights all voxels equally. To obtain per-voxel uncertainties as well, the standard approach is to have the network also predict a variance and train it with a heteroscedastic

Gaussian likelihood (Kendall & Gal 2017). The CosmoMap-σ\sigma variant does this with a composite loss that combines the heteroscedastic Gaussian negative log-likelihood with point-estimate terms and a variance penalty,

Lσ=0.408LNLL+0.150LMSE+0.134LMAE+0.207LHuber+0.01⟨s2⟩,(4)\mathcal{L}_{\sigma}=0.408\mathcal{L}_{\rm NLL}+0.150\mathcal{L}_{\rm MSE}+0.134\mathcal{L}_{\rm MAE} +0.207\mathcal{L}_{\rm Huber}+0.01\langle s^2\rangle, \tag*{(4)}
LNLL=12⟨(y−μ)2s2+ln⁡s2⟩(5)\mathcal{L}_{\rm NLL}=\frac{1}{2}\left\langle\frac{(y-\mu)^2}{s^2}+\ln s^2\right\rangle \tag*{(5)}

where yy is the standardised target, μ\mu and s2s^2 are the predicted mean and variance, angle brackets denote the average over voxels and both fields, and LMSE\mathcal{L}_{\rm MSE}, LMAE\mathcal{L}_{\rm MAE} and LHuber\mathcal{L}_{\rm Huber} are the mean squared, mean absolute and Huber errors of μ\mu. The weights are taken from a 67-trial search over the four weights, carried out in a different configuration with a different normalisation; they were not re-tuned here. Their precise values matter little here, because the ablation isolates the effect of the likelihood term directly (§ 6.2).

Training and inference

We train on random 64364^3 sub-volumes (12.5 h−1h^{-1} Mpc), cut with periodic wrapping and augmented with the 48 symmetries of the cube, which are exact symmetries of the data because the velocity input is a magnitude. We use AdamW (Loshchilov & Hutter 2019) with weight decay 10−510^{-5}, batch size 4, gradient-norm clipping at 1 and mixed precision. The learning rate warms up linearly to 2×10−42\times10^{-4} over the first epoch and then follows a cosine decay. Training runs for 30 epochs of 1000 steps, and we keep the checkpoint with the lowest loss on a fixed set of 320 validation sub-volumes (with one exception among the ablation variants, § 6.2). CosmoMap and CosmoMap-σ\sigma are close to convergence: in every seed the best checkpoint is at epoch 29 or 30, and the validation loss changes by less than 3 per cent over the last five epochs. The unconditioned and small networks select epochs 25 to 29, and their final validation losses are within 1 per cent of the best. One run takes about three hours on a single NVIDIA RTX 4070. CosmoMap, CosmoMap-σ\sigma, the unconditioned network and the small network (§ 4) are each trained at z=0z=0 with three random seeds; we report the mean and seed-to-seed standard deviation of their test metrics. Figures show the first seed, as do the analyses that need full predicted fields (scaling relations, structure detection and profiles, parameter recovery and parameter-space robustness). A second CosmoMap model is trained on all five redshifts.

To predict a full 1283128^3 box we tile it with periodic 64364^3 windows, the size of the training sub-volumes, and keep the central 32332^3 of each, so that every predicted voxel has at least 16 voxels (3.1 h−1h^{-1} Mpc) of context on each side. Matching the window to the training size keeps the group-normalisation statistics consistent with training. We adopt

this scheme for that reason rather than for its test performance; it does not minimise the luminosity bias, the median log⁡10\log_{10} ratio of predicted to true box-integrated X-ray luminosity (§ 4.4; Appendix § 10). Increasing the margin to 24 voxels changes no metric by more than 0.006, so the predictions have converged with respect to context; Appendix § 10 compares other inference schemes. Once trained, the model predicts a full 1283128^3 box in about 2 s on the RTX 4070. Because the cosmological and feedback parameters enter only through the conditioning vector, one trained model predicts the gas for any parameter combination within the training range: a new cosmology or feedback model changes only this input and requires no retraining. For CosmoMap-σ\sigma, the aleatoric variance is the network output and the epistemic variance is the spread of the predicted means over 8 forward passes with dropout active (Gal & Ghahramani 2016; Kendall & Gal 2017); their sum is the total predictive variance.

Validation framework

Baselines and ablations

We compare against three alternatives, all trained on the 800 training simulations:

Binned lookup: the training-set mean of the target in bins of log⁡ρDM\log\rho_{\rm DM} (width 0.1σ0.1\sigma), an estimate of the best one-to-one function of local dark matter density.

Gradient-boosted trees: a histogram gradient-boosted regressor (Pedregosa et al. 2011) for each target, on log⁡ρDM\log\rho_{\rm DM} smoothed at 0, 1, 2, 4 and 8 voxels, log⁡∣vDM∣\log\lvert v_{\rm DM}\rvert at 0 and 2 voxels, the six parameters and the redshift. It is trained on 2.4×1062.4\times10^6 voxels drawn from all training simulations, with early stopping, and is converged with respect to both training data and boosting iterations (Appendix § 9). It sees the local multi-scale environment and the parameters, but has no learned spatial features.

Unconditioned U-Net: CosmoMap trained and evaluated with the conditioning vector set to zero, so that the FiLM layers reduce to fixed learned affine maps; it therefore has the same number of parameters.

The ablation study further retrains CosmoMap with a smaller network (1.2×1061.2\times10^6 parameters, 20 base channels and 4 normalisation groups), with the point-estimate part of the composite loss only (MSE, MAE and Huber terms), and with three likelihood losses: the composite loss (CosmoMap-σ\sigma), the pure Gaussian negative log-likelihood LNLL\mathcal{L}_{\rm NLL}, and the β\beta-NLL loss of Seitzer et al. (2022) with β=0.5\beta=0.5, which weights each voxel’s likelihood term by s2βs^{2\beta} (with gradients stopped through the weight) so that poorly fitted voxels are down-weighted less.

Field accuracy

All metrics are computed on the 100 test boxes, which are used neither for training nor for model selection, and use log10_{10} of the physical fields, so errors are fractional. For each test box we compute R2R^2, the root-mean-square error (RMSE) and the mean bias. To test the core objective, improved prediction in dense regions, we rank the voxels of each box by ρDM\rho_{\mathrm{DM}} and compute the same metrics in six percentile ranges: deep voids (<P10< P_{10}), voids (P10P_{10}–P30P_{30}), sheets (P30P_{30}–P50P_{50}), filaments (P50P_{50}–P80P_{80}), halo outskirts (P80P_{80}–P95P_{95}) and halo cores (>P95> P_{95}). For scale dependence we compute the cross-correlation coefficient r(k)r(k) and transfer function Ppred/Ptrue\sqrt{P_{\mathrm{pred}}/P_{\mathrm{true}}} of the overdensity fields, where kk is the wavenumber, and PpredP_{\mathrm{pred}} and PtrueP_{\mathrm{true}} are the power spectra of the prediction and the truth.

Scaling relations

Gravitational binding of gas in dark matter haloes gives power-law relations ne∝ρDMαn_{\mathrm{e}} \propto\rho_{\mathrm{DM}}^{\alpha} and T∝ρDMβT \propto\rho_{\mathrm{DM}}^{\beta}. For each test box we fit α\alpha and β\beta by least squares in log space to 10410^4 random voxels, and separately to 10410^4 voxels from the densest five per cent, for the truth and for each model.

Bright emission structures, profiles and luminosities

We compute the bolometric free–free emissivity

ϵX=Ane2T1/2,A=1.42×10−27 erg s−1 cm3 K−1/2,(6)\epsilon_X = A n_{\mathrm{e}}^2 T^{1/2}, \qquad A = 1.42 \times10^{-27}\ {\rm erg\ s^{-1}\ cm^3\ K^{-1/2}}, \tag*{(6)}

with a Gaunt factor of unity and the ion term ∑iZi2ni\sum_i Z_i^2 n_i replaced by nen_{\mathrm{e}}.1 Because the fields are voxel averages, this is ⟨ne⟩2⟨T⟩1/2\langle n_{\mathrm{e}}\rangle^2\langle T\rangle^{1/2} rather than ⟨ne2T1/2⟩\langle n_{\mathrm{e}}^2T^{1/2}\rangle: it neglects sub-voxel clumping and is a resolution-dependent proxy for the X-ray emission of the simulated gas, not a prediction of its absolute luminosity. With nen_{\mathrm{e}} in h2 cm−3h^2\ {\rm cm}^{-3} the emissivity also carries a factor h4h^4. Truth and prediction are treated identically, and we only compare them with each other, so the constant, the h4h^4 factor and the clumping factor cancel in all ratios. We identify bright structures as 26-connected regions above a fixed emissivity threshold, the 99.9th percentile of the true emissivity in 30 validation boxes. A true structure counts as recovered if a predicted structure overlaps it, and a predicted structure counts as real if it overlaps a true one; because any overlap is a lenient criterion that favours smoothed predictions, we also report a strict version that requires at least half of the voxels of the structure being tested (the true structure for completeness, the predicted one for purity) to lie inside bright structures of the other field. Around the three brightest emission peaks of each test box we extract surface brightness profiles by projecting the emissivity of a 41341^3-voxel cube along one axis, and fit the β\beta-model

SX(r)=S0[1+(r/rc)2]−3β+1/2(7)S_X(r) = S_0 \left[1 + (r/r_c)^2\right]^{-3\beta+1/2} \tag*{(7)}

to the true and predicted profiles, where rr is the projected distance from the peak, S0S_0 the central surface brightness, rcr_c the core radius and β\beta the slope parameter of the profile. We also compare the box-integrated emissivity LL and the emission-weighted temperature.

Cosmological information

To test whether cosmological information survives the mapping, we compute 32 summary statistics of each box’s fields: the mean, standard deviation, skewness, kurtosis and 10th, 50th and 90th percentiles of log⁡T\log T, log⁡ne\log n_{\mathrm{e}} and log⁡ϵX\log\epsilon_X; power spectrum amplitudes of nen_{\mathrm{e}} and ϵX\epsilon_X at k=1k = 1, 2, 5 and 10 h Mpc−1h\ {\rm Mpc}^{-1}; and the number and filling factor of bright emission regions and the volume fraction above 10610^6 K. These statistics are intrinsic properties of the simulated 3D gas fields, not forward-modelled quantities such as X-ray fluxes: they test whether the predicted gas retains the parameter dependence of the simulated gas, not what an X-ray survey could constrain. A random forest with 500 trees regresses the six parameters, trained on the 100 validation boxes and tested on the 100 test boxes, so that no box used to train the networks is involved (the validation boxes were used only to select network checkpoints). With 100 training boxes for 32 features, the absolute R2R^2 values are limited by the size of the training set; the meaningful results are the comparisons between feature sources, which use identical forests. We compare four feature sources: the true gas fields (an upper bound for the predicted gas), the dark matter inputs alone (21 statistics: the same seven moments and percentiles of log⁡ρDM\log\rho_{\mathrm{DM}} and log⁡∣vDM∣\log|v_{\mathrm{DM}}|, power spectrum amplitudes of ρDM\rho_{\mathrm{DM}} at the same four scales, and the number, filling factor and mean size of regions above a fixed density threshold), the unconditioned U-Net predictions, and the CosmoMap predictions. CosmoMap is given the true parameters, so recovery from its predictions is partly circular; the unconditioned network is the fair test of whether the mapping preserves information present in the dark matter.

Uncertainty calibration and parameter-space robustness

For CosmoMap-σ\sigma we compare nominal and empirical coverage of central predictive intervals, then fit one multiplicative factor per field to the predicted standard deviations on the validation boxes and report test-set coverage before and after. To test robustness across parameter space, we compute the Mahalanobis distance dM=[(p−μ)TC−1(p−μ)]1/2d_M = [(\mathbf{p}-\boldsymbol{\mu})^{\mathrm{T}}\mathbf{C}^{-1}(\mathbf{p}-\boldsymbol{\mu})]^{1/2} of each test simulation from the training distribution, where μ\boldsymbol{\mu} and C\mathbf{C} are the mean and covariance matrix of the parameters of the training simulations, and correlate it with the test error. For draws from the prior, which is uniform in Ωm\Omega_{\mathrm{m}}, σ8\sigma_8 and the logarithms of the feedback parameters, the mean distance is dM≈2.4d_M \approx2.4 and 98 per cent of draws lie between 1.2 and 3.4, so this tests uniformity across the prior volume rather than extrapolation beyond it. The distance is computed with Ωm\Omega_{\mathrm{m}}, σ8\sigma_8 and the logarithms of the four feedback parameters, which span factors of 4 to 16.

X-ray lightcone generation

The intended application of CosmoMap is rapid generation of synthetic X-ray sky maps. We test this with the multi-redshift model, building 1∘×1∘1^\circ\times1^\circ lightcones on 2562256^2 pixels from z=0.05z = 0.05 to z=2.25z = 2.25 for 10 test simulations, each using its own value of Ωm\Omega_{\mathrm{m}} in a flat Λ\LambdaCDM background. The line of sight is split into 25 h−1h^{-1} Mpc slabs at comoving distance χ(z)=∫0zc dz′/H(z′)\chi(z) = \int_0^z c\,\mathrm{d}z'/H(z'). Each slab uses the snapshot nearest in redshift (the z=2z = 2 snapshot for 2<z≤2.252 < z \leq2.25), with a random cube symmetry and periodic shift; truth and prediction use identical transformations. Each slab’s emissivity is projected along the line of sight and sampled at transverse comoving positions χθ\chi\theta, with bilinear interpolation and periodic replication. Beyond z≈0.55z \approx0.55 the field is wider than the box, so each slab is tiled two or three times across it and high-redshift structures recur within a map; this affects truth and prediction identically. The resulting surface brightness is

S=14π(1+z)4∑ϵX dlproper,(8)S = \frac{1}{4\pi(1+z)^4} \sum\epsilon_X\,\mathrm{d}l_{\mathrm{proper}}, \tag*{(8)}

where the sum runs over the voxels of the slab along the line of sight, zz is the redshift of the slab, dlproper\mathrm{d}l_{\mathrm{proper}} is the proper path length through one voxel, and the factor (1+z)−4(1+z)^{-4} is the cosmological dimming of surface brightness. We treat the gridded nen_e as a comoving density and convert it to physical density; this choice affects truth and prediction identically.

We then apply survey-like observational effects. The maps are convolved with a Gaussian point-spread function (PSF) of 30″ full width at half maximum, comparable to the angular resolution of the eROSITA survey, and converted to counts so that the median pixel of the true map has two source counts. A uniform background of 40 counts per pixel is added, and Poisson noise is drawn using the same random numbers for truth and prediction, so that differences reflect only the predicted fields. Sources are detected as connected regions more than 5σ5\sigma above a local, median-filtered background after smoothing with the PSF, and matched between maps within two PSF widths. Only relative fluxes are meaningful, because truth and prediction pass through the same pipeline and no instrument response, K-correction or absorption is applied. Once the boxes have been predicted, building one lightcone takes under a minute on a single CPU core.

Results

Field accuracy

CosmoMap is the best model on every metric in Table 2. It reduces the RMSE of the gradient-boosted trees by 23 and 22 per cent for temperature and electron density, and that of the unconditioned network by 17 per cent for both fields, while its seed-to-seed variation of R2R^2 and RMSE is below 0.5 per cent. All models predict electron density much better than temperature: on these scales gas largely follows the dark matter potential, whereas temperature depends on the history of shocks, cooling and feedback heating.

Modellog⁡T\log T R2R^2log⁡T\log T RMSE [dex]log⁡ne\log n_{\mathrm e} R2R^2log⁡ne\log n_{\mathrm e} RMSE [dex]log⁡ϵX\log\epsilon_X R2R^2σ(bias T)\sigma(\mathrm{bias}\ T) [dex]
Binned ρDM\rho_{\mathrm{DM}} lookup0.1730.6710.6520.3070.6310.210
Gradient-boosted trees0.6030.4700.8940.1820.8610.066
U-Net, no conditioning0.647±0.0080.647 \pm0.0080.438±0.0030.438 \pm0.0030.906±0.0010.906 \pm0.0010.172±0.0010.172 \pm0.0010.877±0.00030.877 \pm0.00030.142±0.0020.142 \pm0.002
CosmoMap-σ\sigma0.733±0.0040.733 \pm0.0040.385±0.0030.385 \pm0.0030.922±0.0010.922 \pm0.0010.156±0.0010.156 \pm0.0010.904±0.0020.904 \pm0.0020.048±0.0040.048 \pm0.004
CosmoMap0.765±0.0010.765 \pm0.0010.362±0.0010.362 \pm0.0010.934±0.00030.934 \pm0.00030.142±0.00030.142 \pm0.00030.917±0.00030.917 \pm0.00030.030±0.0030.030 \pm0.003

Table 2. Test-set accuracy at z=0z = 0 (100 simulations, full 1283128^3 volumes), in log⁡10\log_{10} physical units. Values are means over the 100 boxes; for the unconditioned U-Net, CosmoMap and CosmoMap-σ\sigma they are further averaged over three training seeds, with the seed-to-seed standard deviation given. The last column is the box-to-box standard deviation of the mean bias of log⁡T\log T, which measures how well each box’s overall temperature level is predicted.

The unconditioned U-Net improves on the trees, even though the trees see the parameters and the network does not, but most of CosmoMap’s advantage comes from combining learned 3D spatial features with knowledge of the cosmology and feedback model. Conditioning also sets the overall level of each box: the box-to-box scatter of the mean temperature bias falls from 0.14 dex without conditioning to 0.03 dex with it. Since the normalisation is global, this level has to be inferred from the inputs and parameters.

Figure 1 shows a slice through the test box with the median temperature R2R^2. Both CosmoMap and the trees recover the filaments and haloes, but CosmoMap reproduces the extent of the hot gas around haloes, heated by shocks and feedback, much better. It smooths the sharp outer edges of these regions, which is where its errors concentrate. The trees also systematically miss hot gas in regions that are cold on average, which CosmoMap largely places correctly.

A slab through the test box showing input fields, simulation truth, CosmoMap, boosted trees, and residuals

Figure 1. A 1.56 h−1h^{-1} Mpc-thick slab (averaged in log space) through the test box with the median temperature R2R^2, at z=0z = 0. Rows show temperature, electron density and emissivity; columns show the inputs, the simulation, CosmoMap, the gradient-boosted trees, and the residuals of CosmoMap and of the trees.

Ablation study

Table 3 isolates the contribution of each component by retraining the z=0z=0 model with one change at a time, under identical training and evaluation. Conditioning matters most: without FiLM, the temperature RMSE rises by 21 per cent and the box-to-box scatter of the luminosity rises from 0.24 to 0.39 dex (seed averages). Model size matters less for the bulk of the volume: a network with nine times fewer parameters loses only 0.016 in temperature R2R^2. It is clearly worse for the brightest gas, however: in every seed its electron density in the brightest one per cent of voxels (§ 6.6) has R2=0.34R^2=0.34 against 0.49, and its box luminosities are biased low by 0.41 dex on average, so capacity matters most where the X-ray emission is concentrated. Both reduced models also give box luminosities that depend on the training seed, from −0.22-0.22 to −0.48-0.48 dex without conditioning and from −0.24-0.24 to −0.51-0.51 dex for the small network, against −0.15-0.15 to −0.17-0.17 dex for CosmoMap. Their voxel-level accuracy is reproducible to 0.01 in R2R^2, but the level of the brightest gas is not.

ConfigurationParamslog⁡T\log T R2R^2log⁡T\log T RMSElog⁡ne\log n_{\mathrm e} R2R^2log⁡ne\log n_{\mathrm e} RMSElog⁡LpredLtrue\log\frac{L_{\mathrm{pred}}}{L_{\mathrm{true}}}
CosmoMap (MSE loss)11.1 M0.7650.3620.9340.142−0.16±0.01-0.16 \pm0.01
No FiLM conditioning11.1 M0.6470.4380.9060.172−0.37±0.14-0.37 \pm0.14
Small network1.2 M0.7490.3730.9240.154−0.41±0.15-0.41 \pm0.15
MSE + MAE + Huber loss11.1 M0.7590.3660.9350.142−0.19-0.19
Composite likelihood loss (CosmoMap-σ\sigma)11.1 M0.7330.3850.9220.156−0.46±0.04-0.46 \pm0.04
Pure Gaussian likelihood11.1 M0.7260.3900.9170.161−0.45-0.45
β\beta-NLL loss (β=0.5\beta= 0.5)11.1 M0.7580.3670.9310.146−0.33-0.33

Table 3. Ablation study at z=0z = 0: test-set accuracy and median log ratio of predicted to true box luminosity when one component is changed. CosmoMap, CosmoMap-σ\sigma and the networks without conditioning or with fewer parameters are averaged over three seeds, with the seed-to-seed standard deviation of the luminosity ratio given; the other variants use one seed. The β\beta-NLL row uses the weights of the last epoch (§ 6.2).

The loss function has a large effect. Training with the composite likelihood loss (CosmoMap-σ\sigma) lowers the temperature R2R^2 from 0.765 to 0.733 and biases box-integrated luminosities low by 0.46 dex, against 0.16 dex for the mean-squared-error loss. Both models are trained with three seeds, and both differences are seven to eight times their combined seed-to-seed standard deviation. Keeping the point-estimate terms but removing the likelihood term recovers most of the accuracy and removes most of the luminosity bias (one seed). Because the composite loss mixes the likelihood with other terms, with weights tuned in a different configuration, we also train with a pure Gaussian likelihood and with β\beta-NLL (one seed each). The pure likelihood is the least accurate of the loss variants (R2=0.726R^2=0.726 and 0.917) and gives the same luminosity bias as the composite loss (−0.45-0.45 dex). For β\beta-NLL the validation loss is not a reliable guide to accuracy: in three training runs with the same seed, which differ because training on a GPU is not bit-reproducible, it is lowest at epoch 10, 13 or 15, while the validation RMSE of both fields falls by a further 2–5 per cent by the last epoch. For this variant we therefore evaluate the weights of the last epoch. β\beta-NLL then recovers about 80 per cent of the temperature accuracy lost by the pure likelihood (R2=0.758R^2=0.758 in both runs that we evaluated at the last epoch) and removes part of the luminosity bias (leaving −0.33-0.33 and −0.25-0.25 dex). The checkpoints with the lowest validation loss are less accurate (R2=0.740R^2=0.740–0.749), and their luminosity bias ranges from −0.22-0.22 to −0.50-0.50 dex, so the luminosity bias of this variant is not well determined. The cost of learning per-voxel variances is therefore not an artefact of the composite loss, although β\beta-NLL reduces it. This is consistent with a known failure mode of heteroscedastic regression ((Seitzer et al. 2022)): the likelihood lets the network assign large variance to voxels it fits poorly, which down-weights them in training. The accuracy cost is spread over all environments, with temperature R2R^2 lower by 0.05 in deep voids and 0.03 in the densest regime. Because the X-ray luminosity is dominated by the densest gas, however, the under-prediction there likely produces the large luminosity bias. The likelihood-trained model remains useful for its per-voxel uncertainties (§ 6.8).

Performance in high-density regions

The core objective of this work is accurate prediction in the densest environments. We label the densest five per cent of voxels “halo cores”; in 25 h−1h^{-1} Mpc boxes these are mostly the central regions of galaxy- and group-scale haloes, with few true clusters. Figure 2 shows that temperature accuracy improves systematically with density: for CosmoMap (averaged over seeds), R2R^2 rises from 0.62 in deep voids to 0.88 in halo cores, and the RMSE falls from 0.38 to 0.24 dex, so the gain is not merely an effect of the larger dynamic range in dense regions. In cores, gas is expected to be heated mainly by gravitational collapse and accretion shocks, which the dark matter traces. At low densities, temperature depends on photoheating, adiabatic cooling and the reach of feedback-driven outflows, which local dark matter constrains less.

Figure 2. R2R^2 of temperature (left) and electron density (right) within six ranges of dark matter density at z=0z = 0. Error bars show the scatter over the 100 test boxes. The binned lookup, not shown, has negative R2R^2 in every regime except for electron density in cores (0.35).

Conditioning shows the same physics from the other side. In cores the learned models are within about 0.1 in R2R^2 of each other (0.88, 0.84 and 0.78 for CosmoMap, the unconditioned network and the trees), while in voids and sheets CosmoMap reaches R2≈0.63R^2 \approx0.63 against 0.39 for the unconditioned network and 0.38 for the trees. A natural interpretation is that this is where the gas temperature depends most on how far and how strongly feedback has heated it, and only the conditioned model knows the feedback parameters. Electron density follows a similar pattern.

CosmoMap’s mean biases are at most 0.02 dex in every regime, becoming slowly more negative towards the densest regions, while the unconditioned network over-predicts electron density by 0.01–0.03 dex, most in voids, likely reflecting the ambiguity in the feedback strength of a given simulation (Figure C1 in Appendix § 11).

Figure C1. Figure C1. Mean bias (prediction minus truth) of temperature (left) and electron density (right) within six ranges of dark matter density at z=0z = 0. Error bars show the scatter over the 100 test boxes.

In Fourier space (Figure C2 in Appendix § 11), CosmoMap’s electron density and emissivity cross-correlate with the truth at r(k)>0.9r(k) > 0.9 down to scales of about 1 h−1 Mpc1\,h^{-1}\,\mathrm{Mpc} (k≈7k \approx7–8 h Mpc−18\,h\,\mathrm{Mpc}^{-1}), and the density amplitude is recovered to within 7 per cent up to k≈5 h Mpc−1k \approx5\,h\,\mathrm{Mpc}^{-1}; the trees decorrelate beyond k≈2k \approx2–3 h Mpc−13\,h\,\mathrm{Mpc}^{-1}. Temperature decorrelates on larger scales (r>0.9r > 0.9 only to k≈1 h Mpc−1k \approx1\,h\,\mathrm{Mpc}^{-1}), with excess power at k≈1k \approx1–2 h Mpc−12\,h\,\mathrm{Mpc}^{-1} and a deficit on small scales, consistent with the smoothed edges of the hot regions.

Figure C2. Cross-correlation coefficient r(k)r(k) (top) and transfer function Ppred/Ptrue\sqrt{P_{\mathrm{pred}}/P_{\mathrm{true}}} (bottom) for temperature, electron density and emissivity at z=0z = 0, averaged over test boxes.

Redshift evolution

Table 4 compares the multi-redshift model with baselines trained on the same five redshifts. To limit the cost of computing features for all snapshots, these baselines use 160 of the training simulations, which at z=0z = 0 lowers the tree R2R^2 by about 0.02 for temperature and 0.006 for density relative to Table 2. All models predict both fields with smaller RMSE at higher redshift, where structures are less evolved and feedback has had less time to act. CosmoMap is the best model at every redshift: its temperature RMSE is 24–29 per cent below that of the trees, with the largest gain at z=2z = 2, and its density RMSE 22–23 per cent below. At z=0z = 0 the multi-redshift model is almost as accurate as the z=0z = 0 model (R2=0.760R^2 = 0.760 against 0.765 for temperature), even though the same training budget is spread over five redshifts.

zz\multicolumn{3}{c}{log TT: R2R^2 (RMSE [dex])}\multicolumn{3}{c}{log nen_{\mathrm e}: R2R^2 (RMSE [dex])}
BinnedTreesCosmoMapBinnedTreesCosmoMap
0.00.158 (0.674)0.581 (0.482)0.760 (0.366)0.645 (0.306)0.888 (0.187)0.931 (0.146)
0.50.249 (0.558)0.594 (0.412)0.777 (0.306)0.657 (0.269)0.915 (0.149)0.949 (0.115)
1.00.309 (0.449)0.617 (0.336)0.794 (0.247)0.659 (0.240)0.938 (0.117)0.963 (0.090)
1.50.341 (0.365)0.650 (0.271)0.815 (0.197)0.656 (0.221)0.954 (0.094)0.972 (0.073)
2.00.364 (0.285)0.700 (0.204)0.849 (0.144)0.647 (0.203)0.967 (0.073)0.980 (0.057)

Table 4. Test-set accuracy of the multi-redshift CosmoMap model and the baselines trained on the same redshifts.

Scaling relations

The predicted fields reproduce the dark matter–gas scaling relations. Over all voxels, the true slopes are α=0.955±0.029\alpha= 0.955 \pm0.029 and β=0.642±0.075\beta= 0.642 \pm0.075 (mean and box-to-box scatter), and CosmoMap and the trees give 0.948 and 0.631, and 0.952 and 0.640; slopes fitted to random voxels are dominated by voids and sheets, so this test barely discriminates between models. In the densest five per cent of voxels the slopes flatten to α=0.796\alpha= 0.796 and β=0.552\beta= 0.552; CosmoMap gives 0.783 and 0.547, with half the per-box error in α\alpha of the trees (0.019 against 0.038), and tracks the variation of the slopes between boxes.

These are voxel-level relations that mix gas in haloes, filaments and voids, not the halo scaling relations used in cluster cosmology, and their dependence on the feedback parameters need not follow physical expectations for haloes; we use them only to compare predicted and true fields from the same simulations, and their agreement does not imply that individual haloes are recovered accurately (§ 6.6).

X-ray emissivity, bright structures and profiles

Emissivity is predicted well voxel by voxel (R2=0.917R^2 = 0.917 in log space), but voxel-level scores are dominated by the far more numerous low-density voxels and say little about clusters, so we test the bright structures directly. Projected emissivity maps correlate with the truth at r=0.976r = 0.976 (box-to-box standard deviation 0.007). Of the 17,416 bright structures in the true test boxes, CosmoMap recovers 76 per cent, the unconditioned network 76 per cent and the trees 23 per cent, and 84, 80 and 68 per cent of their predicted structures are real (pooled over boxes). With the strict criterion, completeness falls to 66, 65 and 13 per cent and purity to 82, 74 and 59 per cent, so CosmoMap is as complete as the unconditioned network, far more complete than the trees, and its structures are more often real than those of either alternative. The luminosity of the recovered structures is low by a median of 0.21 dex for CosmoMap, 0.20 dex for the unconditioned network and 0.76 dex for the trees. The reason is visible in the brightest one per cent of voxels: there temperature is accurate (R2=0.84R^2 = 0.84, bias −0.04-0.04 dex), but electron density is biased low by 0.12 dex (R2=0.49R^2 = 0.49). The emission-weighted temperature of each box, a proxy for the spectroscopic temperature, has a median offset within 0.03 dex for every seed, compared with 0.52 dex too low for the trees.

Figure 3 compares surface brightness profiles around the three brightest peaks of each test box (295 profiles, because some boxes have fewer than three peaks above the emissivity threshold). The predicted profiles have the right shape: fitted β\beta-model slopes have medians of 0.603 (truth) and 0.611 (CosmoMap) and correlate at r=0.80r = 0.80 from structure to structure. The predicted profiles lie below the truth at all radii. The deficit is 0.19 dex in the central bin and 0.13 dex at 0.4 h−1 Mpch^{-1}\,\mathrm{Mpc}, and then grows outwards to 0.24 dex at 3–4 h−1 Mpch^{-1}\,\mathrm{Mpc}; beyond 1 h−1 Mpch^{-1}\,\mathrm{Mpc} 84–89 per cent of the profiles lie below the truth. Outside the central bin, the outskirts are therefore under-predicted more than the inner regions, consistent with the under-predicted extent of the hot gas around haloes (Figure 1). The core radius is not measurable at this resolution: for 88 per cent of the true profiles the fit prefers rcr_{\mathrm c} smaller than one voxel, so the fitted β\beta effectively measures the slope of the outer profile. Figure 4 shows three individual structures. The emission morphology, including substructure and neighbouring haloes, is reproduced, and the residual maps show the main failure mode: hot regions whose extent is under-predicted.

Figure 3. Median surface brightness profiles around the three brightest emission peaks of each test box (295 profiles, z=0z = 0), normalised to the central truth value (top), and the median log ratio of predicted to true profile (bottom; the shaded band is the 16–84 per cent range for CosmoMap).

Projected emissivity around the three brightest structures in one test box at $z = 0$: truth, CosmoMap and residual (left), and surface brightness profiles with $\beta$-model fits (right)

Figure 4. Projected emissivity around the three brightest structures in one test box at z=0z = 0: truth, CosmoMap and residual (left), and surface brightness profiles with β\beta-model fits (right). The maps are 8.0 h−1h^{-1} Mpc across and integrated over the same depth.

Box-integrated luminosities have a median log⁡10(Lpred/Ltrue)\log_{10}(L_{\mathrm{pred}}/L_{\mathrm{true}}) of −0.16-0.16 (seed average; −0.15-0.15, −0.17-0.17 and −0.17-0.17 for the three seeds), with a box-to-box scatter of 0.24 dex (Figure 5). For comparison, the trees give −0.89-0.89 dex with 0.42 dex scatter, the unconditioned network −0.37-0.37 dex (seed average; −0.22-0.22 to −0.48-0.48 dex) with 0.39 dex, and CosmoMap-σ\sigma −0.46-0.46 dex with 0.33 dex. For CosmoMap-σ\sigma, part of the bias can be removed after training. If each voxel’s predictive distribution of log⁡10ϵX\log_{10}\epsilon_X is Gaussian with variance s2=4s22+s22/4s^2 = 4s_2^2 + s_2^2/4, the expected emissivity is 10μexp⁡[12(ln⁡10)2s2]10^\mu\exp[\frac{1}{2}(\ln10)^2s^2]; for the first seed this correction brings the median to −0.04-0.04 dex with the raw variances and to −0.20-0.20 dex with the validation-calibrated variances (§ 6.8), without reducing the scatter. These luminosity biases are not robust

Figure 5. Ratio of predicted to true box-integrated emissivity for the 100 test boxes at z=0z = 0 (first seed of each network).

at the 0.2 dex level: across inference schemes the median bias of CosmoMap ranges from −0.15-0.15 to +0.04+0.04 dex (first seed), while voxel-level metrics barely change (§ 7.2 and Appendix § 10).

Cosmological parameter recovery

Figure 6 shows how well the six parameters can be recovered from summary statistics. From the true gas fields, Ωm\Omega_{\mathrm m} and σ8\sigma_8 are recovered with R2=0.94R^2 = 0.94 and 0.79, and of the feedback parameters only the supernova energy ASN1A_{\mathrm{SN1}} (R2=0.55R^2 = 0.55). The dark matter inputs alone give 0.96 and 0.83 for the cosmological parameters, showing that most of this information is already present in the dark matter. Predictions of the unconditioned network preserve most of it (R2=0.85R^2 = 0.85 and 0.74) but, as expected, contain no information on feedback. Predictions of CosmoMap give 0.90 and 0.71 for the cosmological parameters and 0.52 for ASN1A_{\mathrm{SN1}}, close to the true gas for ASN1A_{\mathrm{SN1}}. As a ratio, Ωm\Omega_{\mathrm m} recovered from the CosmoMap predictions is Ωm,pred/Ωm,true=1.01±0.11\Omega_{\mathrm{m,pred}}/\Omega_{\mathrm{m,true}} = 1.01 \pm0.11 (median and half the 16–84 per cent range over the test boxes), against 1.01±0.091.01 \pm0.09 from the true gas and 1.01±0.151.01 \pm0.15 from the unconditioned network; for σ8\sigma_8 the values are 1.02±0.081.02 \pm0.08, 1.01±0.071.01 \pm0.07 and 1.01±0.081.01 \pm0.08. Because CosmoMap is given the parameters, its recovery of ASN1A_{\mathrm{SN1}} shows that the network imprints feedback on the gas with a realistic signature, not that the information was recovered from the dark matter. None of the remaining feedback parameters is recoverable from either true or predicted fields at this resolution.

The median relative error of the recovered Ωm\Omega_{\mathrm m} and σ8\sigma_8 is 4–11 per cent whichever fields the summary statistics are computed from (true gas, dark matter, unconditioned network or CosmoMap; Figure 4 in Appendix § 11 shows three of these), and their mean biases are at most 3 per cent of the parameter range. These constraints are still several times looser than the few-per-cent precision targeted by cluster cosmology surveys. The other feedback parameters reach training R2R^2 of 0.6–0.8 but test R2R^2 near zero, so their apparent signal is over-fitting.

Uncertainty quantification

Per-voxel uncertainties come from CosmoMap-σ\sigma and are dominated by the aleatoric part: Monte Carlo dropout contributes only 3 and 4 per cent of the variance for temperature and density (first seed), although it is known to underestimate epistemic uncertainty.

We assess the uncertainties through their coverage: the fraction of test voxels whose true value lies inside the central predictive interval of a given nominal probability, for example the ±1σ\pm1\sigma interval for 68 per cent. Well-calibrated uncertainties give a coverage equal to the nominal probability, so the curves in Figure 7 would lie on the diagonal. The raw 68 per cent intervals are too wide, containing 84 and 78 per cent of temperature and density voxels (seed average), while the raw 95 per cent intervals contain 97 and 96 per cent. One scale factor per field, fitted on the validation boxes, brings the 68 per cent coverage to 0.67–0.69, but the 95 per cent coverage then falls to 0.89 and 0.92, because the errors have heavier tails than a Gaussian. Given the accuracy cost of the likelihood loss, a practical approach is to use CosmoMap for the fields and CosmoMap-σ\sigma for their uncertainties. Scored against the residuals of CosmoMap trained with the same seed, the CosmoMap-σ\sigma uncertainties rank the errors as well as they rank their own (Spearman correlation with the absolute residual 0.77–0.79 for temperature and 0.62 for density) and, with the scale factor refitted, reach the same coverage.

Figure 7. Empirical coverage of central predictive intervals of CosmoMap-σ\sigma against nominal level for the 100 test boxes at z=0z = 0 (every 64th voxel, first seed), with the raw uncertainties and after rescaling by one factor per field fitted on the 100 validation boxes.

These coverages are dominated by voids and sheets. In the brightest one per cent of emission voxels the globally rescaled 68 per cent intervals contain only 55 and 57 per cent of temperature and density voxels (first seed), and the predicted standard deviation barely ranks the errors (Spearman correlation 0.17–0.18). Rescaling instead with one factor per field in five bins of predicted emissivity, which needs no truth at test time, gives a 68 per cent coverage of 0.69 over all voxels and, in the brightest one per cent, 0.70 for temperature and 0.62 for electron density. The density uncertainties of the brightest gas therefore remain somewhat too narrow, and such an environment-dependent rescaling should be applied before the uncertainties are propagated into mock X-ray maps.

Figure 6. Test R2R^2 of a random forest predicting the six CAMELS parameters from summary statistics of each field source, trained on validation boxes and tested on test boxes at z=0z = 0. Error bars show the scatter over five forest seeds. Recovery from CosmoMap predictions (hatched) is partly circular, because the network is conditioned on the true parameters.

Robustness across parameter space

The test simulations lie at Mahalanobis distances between 1.4 and 3.5 from the centre of the training distribution, and the test error is uncorrelated with this distance (r=0.02r = 0.02 and 0.01 for temperature and density), so performance does not degrade towards the edges of the prior volume. It does depend on the individual parameters (Figure C3 in Appendix § 11): errors grow with Ωm\Omega_{\mathrm{m}} and σ8\sigma_8 (correlation coefficients 0.43–0.60), which produce more collapsed, shock-heated structure, and fall with the supernova energy ASN1A_{\mathrm{SN1}} (−0.58 for temperature), whose stronger winds smooth the gas. Because the errors are in log⁡10\log_{10}, it is the fractional error that grows with Ωm\Omega_{\mathrm{m}} and σ8\sigma_8. The other feedback parameters have weaker effects (∣r∣≤0.30|r| \le0.30).

Figure C3. Per-box RMSE of CosmoMap at z=0z = 0 against the six CAMELS parameters, with Pearson correlation coefficients (against the logarithm for the four feedback parameters).

Gravity-only inputs

In an application, the input dark matter would come from a gravity-only simulation rather than from the hydrodynamical run, whose dark matter responds to the baryons. To test this, we replace both inputs of each test box by those of the matched CAMELS NN-body run, which shares its initial conditions and parameters. The density is converted from mass per voxel to density and rescaled by (Ωm−Ωb)/Ωm(\Omega_{\mathrm{m}} - \Omega_{\mathrm{b}})/\Omega_{\mathrm{m}} (with Ωb=0.049\Omega_{\mathrm{b}} = 0.049) to the dark matter share. The gridded NN-body data provide only the density, so we grid the velocities from the z=0z = 0 NN-body snapshots: each particle’s speed is deposited with its mass using the fourth-order (piecewise cubic spline) kernel of the Multifield Dataset, and the mass-weighted mean speed is taken in each voxel. Applied to the dark matter of a hydrodynamical run, this procedure reproduces the published velocity grid of a test box (log correlation 0.998 over all voxels, median deviation 0.7 per cent). Without retraining, the temperature and electron density R2R^2 change from 0.764 and 0.934 to 0.760 and 0.930 (first seed), and the median box luminosity from −0.15 to −0.22 dex. Replacing only the density gives nearly the same result (0.758, 0.930 and −0.24 dex), so the velocity input is barely affected by the baryons. Baryonic effects on the dark matter therefore change the voxel-level predictions very little, although they have a measurable effect on the brightest structures.

Mock X-ray lightcones

Figure 8 compares a lightcone built from the true fields with one built from CosmoMap’s predictions. Averaged over 100 lightcones, the PSF-convolved maps correlate at r=0.95r = 0.95 in log surface brightness, the large-scale pattern of emission is reproduced, and the total flux is low by 0.30 dex. Source detection is harder: at the same detection threshold, the predicted maps contain 357 sources against 1016 in the true maps. Pooled over the lightcones, 28 per cent of the true sources are recovered (281 of 1016), and 80 per cent of the predicted sources (287 of 357) correspond to true ones, although this purity ranges from 40 to 95 per cent between lightcones; one in five predicted sources is therefore a false positive. Completeness rises steeply with flux: CosmoMap recovers 46 per cent of the true sources brighter than the median, 62 per cent of the brightest quarter and 89 per cent of the brightest tenth (102 sources, with fluxes above about 11 times the median), and 94 per cent of the brightest tenth of its own detections are real. Matched sources are fainter by a median of 0.84 dex. The model misses mainly the fainter emission peaks that are detectable in the true maps, consistent with its smoothing of compact structures. In its current form CosmoMap is therefore well suited to the diffuse and large-scale X-ray signal, but source counts require a model that reproduces compact peaks more faithfully. The detected sources here are emission peaks from simulated groups and clusters, not a realistic X-ray source population.

Discussion

Accuracy versus uncertainty

The ablation exposes a trade-off: a heteroscedastic likelihood gives useful per-voxel uncertainties but, by down-weighting poorly fitted voxels, under-fits the densest gas and biases luminosities, and β\beta-NLL (Seitzer et al. 2022), designed to reduce this down-weighting, recovers most of the accuracy and removes part of the luminosity bias. All three likelihood variants over-cover before rescaling (raw 68 per cent coverage 0.82–0.87 for temperature and 0.77–0.81 for electron density, first seed) and reach 0.68–0.70 after one rescaling. Training the variance head after freezing a mean-trained network could provide uncertainties without the accuracy cost; the pairing test of § 6.8 suggests that this would work.

Limitations

Compact structures. CosmoMap smooths the sharpest structures, so the electron density of the brightest gas is under-predicted by about 0.12 dex and nearly three quarters of the sources detected in the true lightcones are missed. This smoothing is expected from the squared-error loss, which is minimised by the average of all gas configurations consistent with the dark matter and so blurs peaks whose position and amplitude the input does not fix. Reproducing them probably requires a model that draws samples of the gas field instead of predicting its mean, such as a diffusion model or a generative adversarial network.

Inputs from the hydrodynamical run. The network is trained on dark matter fields from the same simulations as the targets, which include the back-reaction of baryons on the dark matter. With the density and velocity of matched gravity-only runs as input, the accuracy drops only slightly (§ 6.10), but box luminosities fall by a further 0.07 dex. Training on gravity-only inputs would remove this mismatch.

Normalisation statistics. Group normalisation computes its statistics over the input volume, so the predictions depend on the size of the inference window, which is why we use windows of the training size. With full 1283128^3 boxes instead, the voxel-level R2R^2 of CosmoMap changes by at most 0.005, but its median box luminosity shifts from −0.15 to +0.03 dex (first seed), and the unconditioned network, which must infer the overall gas level from the input statistics, loses 0.05 in density R2R^2. Normalisation with statistics fixed after training removes this sensitivity. Retrained with batch normalisation (Ioffe & Szegedy 2015) and otherwise unchanged (first seed), CosmoMap reaches R2=0.761R^2 = 0.761 and 0.935 with a median box luminosity of −0.18 dex for every inference scheme we tested, including the full box (Table B1), and the box-to-box scatter of the luminosity falls from 0.25 to 0.17 dex. Its accuracy matches that of the group-normalised model, so it can replace it where the inference window must vary; we keep the group-normalised model as the reference because all other experiments use it.

ModelWindow (core, margin)R2log⁡TR^2 \log TR2log⁡neR^2 \log n_emedian log⁡LpredLtrue\log\frac{L_{\mathrm{pred}}}{L_{\mathrm{true}}}
CosmoMap64364^3 (32, 16)0.7640.934−0.15-0.15
CosmoMap96396^3 (32, 32)0.7630.934−0.03-0.03
CosmoMap1283128^3 (64, 32)0.7620.934+0.04+0.04
CosmoMapfull box0.7600.933+0.03+0.03
U-Net, no conditioning64364^3 (32, 16)0.6460.906−0.22-0.22
U-Net, no conditioning96396^3 (32, 32)0.6570.902−0.07-0.07
U-Net, no conditioningfull box0.6600.853−0.01-0.01
CosmoMap-σ\sigma64364^3 (32, 16)0.7350.923−0.45-0.45
CosmoMap-σ\sigma96396^3 (32, 32)0.7370.923−0.34-0.34
CosmoMap-σ\sigma1283128^3 (64, 32)0.7370.923−0.31-0.31
CosmoMap-σ\sigmafull box0.7360.923−0.36-0.36
Small network64364^3 (32, 16)0.7500.924−0.49-0.49
Small network96396^3 (32, 32)0.7470.924−0.38-0.38
Small network1283128^3 (64, 32)0.7450.924−0.35-0.35
Small networkfull box0.7360.921−0.37-0.37
CosmoMap, batch norm.every scheme above0.7610.935−0.18-0.18

Table B1. Table B1. Test-set accuracy at z=0z = 0 for different inference schemes (first seed). Windows tile the 1283128^3 box periodically; only the central core of each window is kept. The full-box scheme predicts the whole box in one pass with periodic padding. The scheme used throughout the paper is marked in bold.

Resolution and volume. At 195 h−1 kpc195\ h^{-1}\ \mathrm{kpc} per voxel, the cores of haloes are not resolved (the flattest core radii are below one voxel), and features such as cool cores and AGN cavities are absent. A 25 h−1 Mpc25\ h^{-1}\ \mathrm{Mpc} box contains few haloes above 1014 M⊙10^{14}\ M_\odot, so the halo-core regime is dominated by galaxy- and group-scale haloes, and the results should be extended to cluster masses with larger volumes before being applied to clusters. The most direct test would apply CosmoMap at fiducial parameters to TNG100 or TNG300 (Pillepich et al. 2018; Nelson et al. 2019) degraded to the same voxel size, although their different mass resolution would first need to be accounted for. The CAMELS grids at 2563256^3 and 5123512^3 would reduce the voxel size by factors of two and four.

Emissivity and lightcone model. We use bolometric bremsstrahlung computed from voxel-averaged density and mass-weighted temperature, which neglects sub-voxel clumping, so absolute luminosities would be underestimated even with perfect predictions. In the soft band where eROSITA is most sensitive, line emission is a large fraction of the flux from gas below a few keV, so a realistic model needs a band-limited cooling function and the metallicity field. The lightcones use relative fluxes, a Gaussian PSF and a uniform background, without an instrument response or K-corrections.

Input information. Only the magnitude of the dark matter velocity is available. The velocity divergence and shear, which trace accretion shocks directly, would probably improve temperature prediction most.

Comparison with alternative approaches

Semi-analytic models and scaling-relation-based painting can populate haloes with integrated gas properties at negligible cost, but they do not provide the spatially resolved, morphologically diverse gas distribution needed for realistic mock images, and they ignore gas outside haloes. Our binned and tree baselines represent the simplest local versions of such mappings, and they fall well short of a 3D network, particularly at small scales and in hot gas around haloes. Generative and Lagrangian painting methods (Tröster et al. 2019; Dai & Seljak 2021; Horowitz et al. 2022; Bernardini et al. 2022, 2025; Cerardi et al. 2025; Lee et al. 2026) can produce sharper fields and realistic small-scale scatter, which would address the smoothing of compact structures we find, at the cost of more complex training and no direct per-voxel uncertainty. CosmoMap complements these methods with joint 3D prediction of temperature and density, explicit parameter conditioning and a benchmarked evaluation.

A $1^\circ \times 1^\circ$ mock X-ray lightcone and cumulative source counts

Figure 8. A 1∘×1∘1^\circ\times1^\circ mock X-ray lightcone (0.05<z<2.250.05 < z < 2.25) built from the true fields (left) and from the multi-redshift CosmoMap predictions (centre), after convolution with a 30′′ PSF; circles mark detected sources. This is the first of the 10 lightcones; it has 93 true and 60 predicted sources, against 1016 and 357 over all ten. Right: cumulative source counts above the local background, per square degree, over 10 lightcones.

Outlook

Using CosmoMap for eROSITA-like survey modelling requires training on gravity-only inputs and on larger, higher-resolution volumes that cover the cluster mass range; converting the emissivity to counts with a band-limited cooling function that includes line emission, K-corrections, absorption and the instrument response; reproducing compact structures more faithfully; and tiled inference that keeps the normalisation statistics consistent with training. With these in place, a model that predicts a 1283128^3 box in about 2 s on a consumer GPU would allow selection functions and detection rates to be explored as functions of cosmology and feedback, which is impractical with hydrodynamical simulations alone. Predicting metallicity and pressure, and testing transfer between simulation suites with different feedback models, are further natural extensions.

ity. In summary, Ωm\Omega_{\rm m} recovered from CosmoMap’s predicted gas has Ωm,pred/Ωm,true=1.01±0.11\Omega_{\rm m,pred}/\Omega_{\rm m,true} = 1.01 \pm0.11, close to the 1.01±0.091.01 \pm0.09 obtained from the simulated gas (a partly circular test, because the network is given the parameters), and mock X-ray lightcones built from its predictions recover 89 per cent of the brightest tenth of sources, with 94 per cent of the brightest predicted sources real. The main remaining weakness is the smoothing of compact structures, which reduces the number of sources detected in mock X-ray lightcones by a factor of about three, mostly at the faint end.

Acknowledgements

We thank the CAMELS collaboration for making their simulations publicly available.

Data availability

The CAMELS simulations used in this work are publicly available at https://camels.readthedocs.io. The code used to produce the results in this paper is available at https://github.com/amanbh1/CosmoMap. The trained models and derived data products will be shared on reasonable request to the authors.

Conclusions

We have presented CosmoMap, a FiLM-conditioned 3D U-Net that predicts gas temperature and electron density from dark matter density and velocity across the CAMELS IllustrisTNG parameter space. With no target statistics used at test time, it reaches R2=0.765R^2 = 0.765 for temperature and 0.934 for electron density at z=0z = 0, reduces the error of gradient-boosted trees by 22–23 per cent, outperforms them at every redshift up to z=2z = 2, and loses little accuracy when its inputs are taken from matched gravity-only simulations. Conditioning on the simulation parameters accounts for most of the gain over simpler models, especially in low-density gas, and of the models trained with a squared-error loss, only the full conditioned network gives box luminosities that are reproducible between training seeds. Temperature is predicted best in halo cores (R2=0.88R^2 = 0.88), but the electron density of the brightest gas is biased low by 0.12 dex. The predictions preserve the scaling relations, the shapes of surface brightness profiles, box-integrated luminosities to a median of −0.16 dex (sensitive at the 0.2 dex level to the inference scheme unless batch normalisation is used) and most of the cosmological information in the gas. Training with a heteroscedastic likelihood gives per-voxel uncertainties at the cost of accuracy and a larger luminosity bias, and the uncertainties need rescaling as a function of predicted emissiv-

Baseline details

The gradient-boosted trees use up to 2000 boosting iterations with early stopping on a held-out 10 per cent of the training voxels, which stopped training after 727 and 579 iterations for temperature and density. Training on 160 instead of all 800 training simulations lowers their R2R^2 at z=0z = 0 by only 0.024 for temperature and 0.008 for density, and a run capped at 400 iterations gives the same accuracy to within 0.001, so we do not expect a substantially stronger tree baseline from more data or iterations.

Sensitivity to the inference scheme

Table B1 compares inference schemes for the first seed of CosmoMap, CosmoMap-σ\sigma, the small network and the unconditioned network. Voxel-level accuracy is insensitive to the scheme, but box-integrated luminosities and the unconditioned network depend on the window size through the group-normalisation statistics (§ 7.2). At a fixed window size, increasing the margin has a smaller effect, and for 64364^3 windows a margin of 16 voxels is converged. The luminosity gap between CosmoMap and CosmoMap-σ\sigma is 0.30–0.39 dex for every scheme, and the small network is biased low by at least 0.35 dex for every scheme, so the conclusions of the ablation (§ 6.2) do not depend on the inference scheme. The batch-normalised retraining of CosmoMap gives the same accuracy and luminosity, to within 0.001, for every scheme.

Additional figures

Figure C1 shows the systematic biases by density regime, Figure C2 the scale dependence of the predictions, Figure C3 the errors against the simulation parameters, and Figure C4 the recovered parameters for individual test boxes.

Figure C4. Recovered against true Ωm\Omega_{\mathrm{m}}, σ8\sigma_8 and ASN1A_{\mathrm{SN1}} for the 100 test boxes, from summary statistics of the true gas fields, the unconditioned U-Net and CosmoMap.

This paper has been typeset from a TeX/LaTeX file prepared by the author.

References

  1. [32]Wu Y., He K., 2018, in Computer Vision – ECCV 2018. Springer, pp 3–19 (arXiv:1803.08494), doi:10.1007/978-3-030-01261-8_1

Paper details

vlnc:W_45y6rpsr
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents