Recent advances in machine learning algorithms have unlocked new insights in observational astronomy by allowing astronomers to probe new frontiers. In this article we present a methodology to disentangle the intrinsic Xray spectrum of galaxy clusters from the instrumental response function. Employing stateoftheart modeling software and data mining techniques of the Chandra data archive we construct a set of 100000 mock Chandra spectra. We train a recurrent inference machine RIM to take in the instrumental response and mock observation and output the intrinsic Xray spectrum. The RIM can recover the mock intrinsic spectrum below the 1sigma error threshold moreover the RIM reconstruction of the mock observations are indistinguishable from the observations themselves. To further test the algorithm we deconvolve extracted spectra from the central regions of the galaxy group NGC 1550 known to have a rich Xray spectrum and the massive galaxy clusters Abell 1795. Despite the RIM reconstructions consistently remaining below the 1sigma noise level the recovered intrinsic spectra did not align with modeled expectations. This discrepancy is likely attributable to the RIMs method of implicitly encoding prior information within the neural network. This approach holds promise for unlocking new possibilities in accurate spectral reconstructions and advancing our understanding of complex Xray cosmic phenomena.
['Astrophysics - Astrophysics of Galaxies']
Deconvolving Xray Galaxy Cluster Spectra Using a Recurrent Inference Machine
{'Deconvolving X-ray Galaxy Cluster Spectra Using a Recurrent Inference Machine': "Carter Lee Rhea , 1, 2, 3 Julie Hlavacek-Larrondo , 1 Alexandre Adam , 1, 4 Ralph Kraft , 5 ' Akos Bogd'an , 5 Laurence Perreault-Levasseur , 6, 4, 7 and Marine Prunier 1, 2, 8  \n1 D'epartement de Physique, Universit'e de Montr'eal, Succ. Centre-Ville, Montr'eal, Qu'ebec, H3C 3J7, Canada  \n2 Centre de recherche en astrophysique du Qu'ebec (CRAQ)  \n3 Iuvo-ai, Montr'eal, Qu'ebec, Canada  \n4 Mila - Quebec Artificial Intelligence Institute, Montreal, Qu'ebec, Canada  \n5 Center for Astrophysics | Harvard & Smithsonian, 60 Garden Street, Cambridge, MA 02138, USA 6 D'epartement de Physique, Universit'e de Montr'eal, Succ. Centre-Ville, Montr'eal, Qu'ebec, H3C 3J7, Canada 7 Center for Computational Astrophysics, Flatiron Institute, New York, USA  \n8 Max-Planck-Institut fur Astronomie, Konigstuhl 17, D-69117 Heidelberg, Germany", 'ABSTRACT': "Recent advances in machine learning algorithms have unlocked new insights in observational astronomy by allowing astronomers to probe new frontiers. In this article, we present a methodology to disentangle the intrinsic X-ray spectrum of galaxy clusters from the instrumental response function. Employing state-of-the-art modeling software and data mining techniques of the Chandra data archive, we construct a set of 100,000 mock Chandra spectra. We train a recurrent inference machine (RIM) to take in the instrumental response and mock observation and output the intrinsic X-ray spectrum. The RIM can recover the mock intrinsic spectrum below the 1σ error threshold; moreover, the RIM reconstruction of the mock observations are indistinguishable from the observations themselves. To further test the algorithm, we deconvolve extracted spectra from the central regions of the galaxy group NGC 1550, known to have a rich X-ray spectrum, and the massive galaxy clusters Abell 1795. Despite the RIM reconstructions consistently remaining below the 1σ noise level, the recovered intrinsic spectra did not align with modeled expectations. This discrepancy is likely attributable to the RIM's method of implicitly encoding prior information within the neural network. This approach holds promise for unlocking new possibilities in accurate spectral reconstructions and advancing our understanding of complex X-ray cosmic phenomena.", '1. INTRODUCTION': "Galaxy clusters harbor large reservoirs of hot gas ( ∼ 10 7 -10 8 K), called the IntraCluster Medium (ICM), which account for the majority of baryonic matter in the cluster (e.g., Fabian & Allen 2003). This gas consists primarily of ionized hydrogen and helium but also contains numerous heavier elements (e.g., Mushotzky 1984; Mohr et al. 1999; Loewenstein 2003). Emission mechanisms such as thermal bremsstrahlung, boundfree atomic transitions, and the collisional excitation of hydrogen are responsible for the X-ray continuum (e.g., Markevitch & Vikhlinin 1997; Ettori & Fabian 1998; Sarazin et al. 1999; Markevitch et al. 1998). The Xray spectra of galaxy clusters also exhibit strong emis-  \nCorresponding author: Carter Rhea  \ncarterrhea@astro.umontreal  \nsion lines from heavier atoms (e.g., Fabian 2012; Sarazin et al. 1999). In the soft X-ray regime (0 . 5 -2 keV), several of these emission lines are present such as several Iron species (Fe XIX, Fe XVII, and Fe XVIII), Oxygen species (O VII), Nitrogen species (N VII), and Silicon species (Si XIII and Si XIV). The rest-wavelengths of these lines are contained in the atomic database for collisional plasma tailored to high-energy X-ray astrophysics, AtomDB (Foster et al. 2012; this is primarily Chandra calibration data), and the calibration database, CalDB (Graessle et al. 2006). The underlying temperature of the ICM and the relative abundances of these metals have a substantial effect on the resulting X-ray spectrum (e.g., Fabian & Allen 2003; Markevitch & Vikhlinin 1997; Mushotzky 1984); this enables the study of galaxy clusters through fitting plasma physics models to observed X-ray spectra.  \nThe ICM was first observed over five decades ago; the first targets were the brightest and most nearby galaxy clusters: Perseus, M87, and Coma (Bradt et al. 1967; Gursky et al. 1971; Gursky 1973). Since these first targets, X-ray observatories such as Uhuru (Sarazin 1986), EXOSAT (Giacconi et al. 1979), the EINSTEIN Observatory (Forman et al. 1978), XMM-Newton (Jansen et al. 2001; Wilman & Fabian 1999), and the Chandra X-ray Observatory ( CXO ) have revolutionized our understanding of the ICM (Forman et al. 2002a; Forman et al. 2002b; Vikhlinin et al. 2002; Mazzotta et al. 2001).  \nIn particular, the CXO , with an unprecedented spectral and spatial resolution has changed the field of X-ray astronomy (Weisskopf et al. 2000; Weisskopf 2005; Weisskopf 2010). This observatory uses a charge-coupled device to capture high-energy photons between approximately 0 . 3 -10 keV. Not only does it collect the spatial information of the incident photons, but it also registers their energy on the device. Consequently, we can construct a spectrum for each pixel on the CCD.  \nDue to its exquisite spatial resolution (0 . 492 arcsec per pixel), the CXO produces highly detailed, spatially resolved images of its targets. Precise spectroscopic measurements have allowed astronomers to map out temperature profiles and, in some cases, spatially resolved temperature maps (e.g., Bourdin et al. 2004; Pratt et al. 2007; Adam et al. 2017; Alden et al. 2019). These maps, in conjunction with metallicity maps, allow for studying the energetic history of the ICM by tracing gradients in the thermodynamic parameters. Moreover, these observations, used in synergy with other observations at different wavelengths, have shed light on the role of the central supermassive black hole in regulating the ICM (Fabian et al. 2009; Rafferty et al. 2006; Ruszkowski et al. 2019).  \nTo extract these parameters, we fit theoretical models of the underlying astrophysics to the observed spectrum, considering any instrumental effects. One longstanding challenge in X-ray astronomy is that the observed X-ray spectrum, S ( E ' ), is the result of a convolution between the source's intrinsic spectrum, F ( E ), and the instrumental response, R ( E ' , E ) as shown in the equation:  \nS ( E ' ) = ∫ ∞ 0 R ( E ' , E ) F ( E ) dE, (1)  \nwhere E ' denotes the discrete photon energies captured by the detector and E is the measured energy. Despite the simplicity of equation 1, a direct deconvolution of the instrumental response function and model spectrum poses several issues (see Rhea et al. 2021a for an indepth discussion). Primarily, the instrumental response varies greatly as a function of position, and the detec-  \nr energy space is limited and finite by design. Since the sampling of the detector space E ' is discrete, we can rewrite equation 1 as a matrix equation (Kaastra & Bleeker 2016):  \nS i = ∑ j R ij F j . (2)  \nWe have replaced the instrumental response function with its matrix counterpart, R ij . The first index, i , indicates the detector channel in E ' -space, while the second index, j , denotes the emitted photon energy in E -space. In this formulation, S i represents the observed photon count rate in units of counts s -1 for a given detector energy bin. F j is the model (also denoted as true) spectrum flux in units of counts m -2 s -1 in emitted energy bin j . We note that this discretization of equation 1 explicitly linearizes the equation. The ramifications of this choice are discussed in section 4.3.  \nAs demonstrated in Rhea et al. (2021a), standard numerical methods, including different regularization methods, fail to deconvolve the true spectrum from the response matrix given the observed spectrum. Consequently, we began exploring a promising method known as the Recurrent Inference Machine (RIM) for deconvolution. This approach has shown remarkable success in deconvolving 2D radio images (Morningstar et al. 2018; Morningstar et al. 2019), separating gravitational lens sources from their foreground counterparts (Adam et al. 2022b), and reconstructing MRI images (Lønning et al. 2019).  \nIn Rhea et al. (2023), we initially demonstrated the potential of this method for deconvolving X-ray spectra. Although astronomers have been able to fit the observed spectrum through a technique known as forward modeling, by which the theoretical model is convolved with the instrumental response and subsequently fitted, there are several benefits to having access to the intrinsic spectrum. Once deconvolved, these spectra can be fit directly, circumventing the need for forward modeling. Moreover, they can be used as inputs for machine learning algorithms such as a convolutional neural network to extract point estimates of the underlying thermodynamic parameters. This methodology can also study the line-by-line calibration of the CXO by extracting the intrinsic spectrum of a non-changing calibration target where the intrinsic spectrum is not expected to evolve.  \nTherefore, we develop a new algorithm in this paper that can successfully disentangle the intrinsic Xray spectrum from the instrumental response function. Throughout this paper, we limit the case to the X-ray spectra of galaxy clusters but stress that the method we develop could be applied to all fields of X-ray astronomy. In § 2, we present the RIM and convolutional  \nneural network used throughout this paper and the synthetic and natural X-ray observations used. We then discuss the results of using our RIM to deconvolve X-ray spectra in § 3. We compare fits using the deconvolved spectra with traditional methods, explore the reasoning behind the deconvolution, and explore failure modes in § 4. Finally, we conclude our paper in § 5. We assume a Hubble constant of H 0 =69.6, an energy density of matter, Ω M =0.286, an energy density of the vacuum, Ω vac =0.714, and a flat curvature.", '2. METHODS AND OBSERVATIONS': 'This paper aims to show that RIMs can successfully deconvolve the X-ray spectrum from the Chandra instrumental response function. Below, we outline in detail the machine and how it was trained.', '2.1. Recurrent Inference Machine': 'The RIM is an extension of a recurrent neural network (RNN) in which the RNN is used to provide updates to the solution mimicking a standard Newton-Raphson update; they have been used to solve 2D inverse problems (e.g., Putzky & Welling 2017; Morningstar et al. 2018; Morningstar et al. 2019). We adopt this architecture to solve our one-dimensional inverse problem described in equation 2.  \nFigure 1. Schematic view of the RIM. Nodes in dark gray are treated as inputs to the RIM. Note that we separate the hidden layers before applying the RIM and combine them after applying the RIM. The teal box represents the RIM itself.  \n<!-- image -->  \nIn general, the RIM solves the generalized linear problem  \ny = A x + n (3)  \nby solving for x , the solution vector, recursively where y is the measurement vector, A is some operation which  \nmanipulates the solution vector, and n is the noise vector.  \nAt each step, the RIM uses the previous solution, x ( t ) , and the gradient of the log-likelihood function, ∇ log p ( y | x ( t ) ), to solve for an update to the solution ∆ x ( t ) . The solution is updated at each step as  \nx ( t +1) = x ( t ) +∆ x ( t ) . (4)  \nThe update of the solution can be viewed through the lense of a maximum a prosteriori (MAP) framework where  \nˆ x MAP = argmax x [ log p ( y | x ) + log p ( x ) ] (5)  \nFor this paper, we drop the prior term, log p ( x ), following Morningstar et al. (2018).  \nMore specifically, we can express the iterative solution, x at time step t +1 as  \nx ( t ) = x ( t ) + g θ ( x ( t ) , ∇ x log p ( y | x ) , h ( t ) ) h ( t +1) = g θ ( x ( t ) , ∇ x log p ( y | x ) , h ( t ) ) (6)  \nwhere g θ is the neural network and θ represents the weights of the network, p ( y | x ) is the likelihood, and h is the hidden vector used in the neural network.  \nFigure 1 shows the standard architecture of a RIM (e.g., Morningstar et al. 2018; Morningstar et al. 2019); the teal box represents the RIM itself. The methodology is as follows:  \n- 1. Initialize the hidden vectors, h 1 and h 2 , the initial solution, x ( t =0) , and all weights of the gated recurrent units (GRUs) and convolutional layers of the RIM.\n- 2. Calculate the gradient of the likelihood function ∇ log p ( y | x ( t ) ).\n- 3. Pass the solution at the current time step, x ( t ) , the current value of the gradient of the likelihood function, ∇ log p ( y | x ( t ) ), and the state vectors, h 1 and h 2 to the RIM.\n- 4. Forward pass through the neural network.\n- 5. Update the current value of the solution, x ( t +1) with the output of the RIM, ∆ x , and the solution at the previous step, x ( t ) , following equation 4.\n- 6. Repeat steps 2-5 a predefined number of times.  \nWe note that the constituent layers of the RIM, the convolutional layers and GRUs function as normal and  \nare updated through standard back-propagation following the Adam optimization scale (Kingma & Ba 2017). Following Morningstar et al. (2019), we initialize x ( t =0) = 0 and each state vector, h ( t )=0 1 and h ( t =0) 2 , as the zero vector. We defined the likelihood as  \nlog p ( y | x ( t ) ) = -1 2 ( y -A x ( t ) ) T C -1 ( y -A x ( t ) ) (7)  \nwhere C ∈ A m × m is the covariance of the additive Gaussian noise of a particular observation. A Gaussian likelihood is ubiquitous in machine learning applications since the target distribution is often expected to be Gaussian.  \nTherefore, the gradient is written as  \n∇ x ( t ) log p ( y | x ( t ) ) = ( y -A x ( t ) ) T C -1 A (8)  \nBy explicitly defining the physical model, we stress that our network is less of a black box since the physics of the problem is encoded in the likelihood. This allows us to incorporate the specific physics of the problem (i.e., the response matrix) in the updates. Furthermore, we apply an arcsinh transformation function on the gradient of the likelihood function before passing it to the RIM to avoid exploding gradients. We use a mean squared loss backpropagated through time function:  \nL = 1 T T ∑ t =1 M ∑ i =1 (ˆ x ( t ) i -x i ) 2 (9)  \nwhere ˆ x ( t ) i is the current best reconstruction at time t and M is the total number of spectral channels in the spectrum. Using this loss function, the RIM solution is considered at each time step.  \nIn the case of the inverse problem investigated in this paper, we compute the loss function by comparing the result of our RIM with the actual spectrum. Thus, the RIM only sees the observed spectrum and the response matrix. The layers of the RIM are the following:  \n- 1. Convolutional Layer 1: 64 filters with a tanh activation function, stride equal 1, and padding equal 1\n- 2. GRU 1: 800 nodes with sigmoid activation function\n- 3. Convolutional Layer 2: 128 filters with a tanh activation function, stride equal 1, and padding equal 1\n- 4. GRU 2: 800 nodes with sigmoid activation function\n- 5. Convolutional Layer 3: 128 filters with a linear activation function, stride equal 1, and padding equal 1  \nThe convolutional filters all have a kernel size of 3. We ran hyper-parameter tuning on the number of nodes in each GRU, filters and kernel size for each convolutional layer, and the batch size. We determined that eight convolutional filters and three kernel sizes were optimal.', '2.2. Synthetic X-ray Data': 'To train the RIM to deconvolve the intrinsic spectrum from the response matrix, we need groups of response matrices, true intrinsic spectra (referred to as ground truth ) and the corresponding convolved observed spectra. Since we cannot access ground truth spectra for real observations, we rely on synthetic spectra to train our algorithm. We create the synthetic spectra using the analysis software SOXS 1 , which was created to generate high spectral resolution mock spectra for the Lynx observatory (e.g., Gaskin & Swartz 2019). To create the synthetic spectra, we first generate 100,000 mock spectra of the ICM using the APEC model - a standard thermodynamic model that uses a combination of collisional ionization equilibrium (CIE) physics and nonequilibrium ionization (NEI) physics to model the emission of the ICM (Smith et al. 2001). CIE and NEI spectra are generated using AtomDB. We also trained the model on 200,000 mock spectra and found no difference in the reconstructions. To generate the spectra, users are required to input the temperature of the gas, the metal abundance in solar units, the redshift of the gas, z , and the normalization of the model defined as  \nN = 10 -14 ∫ n e n p 4 π (1 + z ) 2 D 2 A dV (10)  \nwhere n e and n p are the densities of the electrons and protons, respectively, D A is the angular diameter distance to the gas, and V is the volume of the gas. We randomly select the gas temperature from a uniform distribution between 0.4 and 8 keV. This range is chosen because it coincides with the majority of gas temperatures in nearby clusters as revealed by Chandra (e.g., Cavagnolo et al. 2009). The metallicity of the gas is randomly sampled from a uniform distribution between 0.2 Z ⊙ and 1.2 Z ⊙ . Similarly, these values are standard in nearby galaxy clusters. We restrict the redshift to only nearby galaxy clusters below z = 0 . 02 for this proof-ofconcept. We set the normalization by randomly selecting a value from a uniform distribution between 0.1 and  \n10; we discuss the impact of this choice on the application to real spectra in section 3.2. We apply additional foreground absorption using the tbabs model (Wilms et al. 2000). We allow the column density, N H to vary between 0.001 × 10 20 cm -2 and 1 × 10 20 cm -2 . The SNR was uniformly sampled between 5 and 100. These SNR values run the gambit of typical observations (e.g., Cavagnolo et al. 2009) We provide the code to create the synthetic spectra in appendix A.1.  \nA crucial free parameter governing synthetic data creation is the instrumental response. We limit our analysis to the ACIS instruments. Since the response matrix varies as a function of time and position on the chip, it is essential to sample the space of possible response matrices adequately. To do this, we mined the Chandra archive of observations of well-studied galaxy clusters designated as such in Mushotzky (1984). We created 1000 response matrices by randomly sampling 10 arcsec regions from the chip where the cluster center was located.  \nWe create our training data on the fly using the forward model  \nS = R ⊗ F + N (11)  \nwhere N is a randomly sampled Gaussian distributon representing the noise. The sigma of the noisy distribution is randomly sampled, assuming a minimum and maximum signal to noise; we take the minimal value to be 10 and the maximum SNR to be 150. Below a SNR of 10, the observed X-ray data is dominated by the noise. By building our training data, we can explore a vast parameter space describing the intrinsic emission model, response matrices, and noise configurations. We show an example of mock ground truth spectrum, response matrix, and convolved observed spectrum in Figure 2.', '2.3. Chandra X-ray Observations': 'In this work, we apply our trained RIM to actual observations to validate its use. We select NGC 1550 as our first test since it is a galaxy group that has a rich X-ray spectrum with a well-constrained temperature ( kT = 1 . 37 ± 0 . 01 keV) and metallicity ( Z ≈ 0 . 27 Z ⊙ ; Sun et al. 2009; Kolokythas et al. 2020) at R 500 . NGC 1550 is at a redshift z = 0.0124 (Sun et al. 2009). The CXO has observed this target twice with the ACIS-I instrument.  \nAs our second test, we select the galaxy cluster Abell 1795. Contrary to NGC 1550, Abell 1795 has a considerably hotter ICM (kT ≈ 6 keV; Ehlert et al. 2015); due to this higher temperature, the intrinsic X-ray spectrum is expected to have fewer emission lines than NGC 1550; therefore, this cluster is a good juxtaposition. Abell 1795 is located at a redshift of z = 0.062476 (Oegerle &  \nHill 2001). In Table 1, we detail these observations. The data were downloaded directly from the data archive, chaser . All data were treated using CIAO (v.14.5.1) .  \nThese objects were chosen since they represent two distinct points of the temperature scale in galaxy clusters and, thus, are represented by different spectral profiles. For NGC 1550, we use the two available observations to demonstrate how the deconvolution results change as a function of the observation. For Abell 1795, we select one random observation to highlight how the network responds to a different intrinsic spectrum. For each observation, the convolved observed spectrum is passed to the trained RIM, which, in turn, returns the deconvolved, intrinsic spectrum of the observation, referred to as the RIM Solution.  \nAfter downloading the data, we reduce and clean the level 1 event files using an in-house reduction pipeline located at https://github.com/XtraAstronomy/AstronomyTools.  \nThe pipeline first uses a CCD containing only background emission to construct a background light curves. We use the CIAO tool lc sigma clip to identify periods during the observation where the background differed from the 3σ level. These times were removed from the observations. We then destreak the event file and remove any bad pixels. The final processing is completed using acis process events with the vfaint option set to true since we are interested in the diffuse extended emission in the galaxy cluster. This entire process results in a level 2 event file for each ObsID. We extract the spectra within a radius of R 500 2 for the galaxy cluster using specextract , which creates the spectrum file and the two response files. These files are combined into a single response matrix using rmfimg with the argument product=true . We also extract a background spectrum from a region on the same CCD chip with no ICM emission.We subtract this background spectrum, S bkg , from the source spectrum, S src , using the following equation:  \nS src -S bkg ∗ exp src ∗ bks src exp bkg ∗ bks bkg  \nwhere exp src and exp bkg are the exposure times of the source and background spectra, respectively, while bks src and bks bkg are the source and background backscales.', '3. RESULTS': "<!-- image -->  \n<!-- image -->  \nFigure 2. Schematic of the convolution applied by the ACIS instrument on Chandra . This graphic demonstrates the response matrix's profound effect on the observed spectrum. The true intrinsic spectrum, the ground truth spectrum, is a typical emission spectrum from the ICM modeled using the apec model with a temperature of 2.0 keV and a metallicity of 0.3 Z ⊙ . The response matrix was taken from a randomly chosen ObsID (2707); the matrix displayed is the log of the response matrix. The convolved observed spectrum was created following the methodology outlined in § 2.2.  \n<!-- image -->  \nTable 1. Chandra ObsIDs used to test the RIM. We select two objects representing two extreme temperature scales in galaxy clusters, with NGC 1550 being a low temperature group and Abell 1795 being a massive hot galaxy cluster.", '3.1. Synthetic X-ray Data': "We run the RIM described in § 2.1 on 50,000 synthetic data created following the methodology outlined in § 2.2. We assign 90% The RIM was trained for 10 timesteps. We remind the reader that the network's output is the deconvolved spectrum (also denoted as the RIM Solution) for each time step. We applied a batch size of 64 and trained the network for 500 epochs. We tested different batch sizes and timesteps but found no effect on the final results.  \nIn Figure 3, we show the true intrinsic spectrum, i.e. the ground truth, vs. the RIM solution (top left), the convolved observed spectrum vs. the RIM reconstruction (top right), the error in the RIM solution as compared to the ground truth (bottom left), and the error in the RIM reconstruction as compared to the convolved observed spectrum (bottom right) for a randomly selected test spectrum. The RIM solution is the direct output of the RIM, while the RIM reconstruction is the result of passing the RIM solution through the forward model (equation 1). The left-hand plot demonstrates that the RIM solution agrees with the literature model under 1σ . The most significant errors occur in the region between 0.5 and 1.0 keV where the strong sulfur, silicon, and lithium emission lines are present (e.g., Markevitch & Vikhlinin 1997; Mushotzky 1984; Sarazin et al. 1999). While the errors remain below the 1σ level, we note that the RIM misses small-scale features while glob-  \nly reconstructing the spectrum; this has been noted for previous use cases of the RIM (e.g., Adam et al. 2022a). The right-hand plot demonstrates that the RIM reconstruction is indistinguishable from the mock observation to a 1σ level except for the same region between 0.5 and 1.0 keV. This indicates that the RIM is learning the noiseless intrinsic spectrum to an accuracy below 1σ except in this region.  \nSince this region is physically essential, we attempted several changes to the hyper-parameters of the RIM, including a dynamic learning rate scheduler and training for more extended periods. However, none of these changes improved the results of the RIM in this critical section. We explore the ramifications of this in section 4.2.", '3.2. Chandra X-ray Observations': "We use both the extracted spectra and their associate response matrices to deconvolve the R 500 spectra created in section 2.3 for NGC 1550 and Abell 1795.  \nTo normalize the data for NGC 1550, the spectra are multiplied by the observation's exposure times, 9,650 seconds and 9,990 seconds, respectively, for ObsID 3186 and ObsID 3187. In doing so, we ensure that the data fed to the network resembles the magnitude of the synthetic data. The noise level of the observation is estimated as the standard deviation of the intensity over the entire bandpass. In Figure 5, we show the results of  \n<!-- image -->  \nFigure 3. The RIM applied to synthetic X-ray spectra. In this figure, we show the results of the RIM deconvolution process on a randomly selected spectrum from the test set. We compare the ground truth in the upper left panel versus the RIM solution. In the upper right panel, we compare the convolved observed spectrum with the RIM reconstruction created by passing the RIM solution through the forward model. The bottom left panel shows the error between the ground truth and the RIM solution in units of σ . In the right bottom panel, we show the error between the convolved observed spectrum and the RIM reconstruction in units of σ .  \n<!-- image -->  \nthe RIM deconvolution for ObsID 3186 (top) and ObsID 3187 (bottom). In the left panel, we show the direct result of the RIM deconvolution (red), i.e. the RIM solution. In the center panel, we display the observed spectrum (black) and the RIM reconstruction (blue). We show the normalized residuals between the observed spectrum and the RIM reconstruction in the right panels. These results demonstrate that the RIM reconstruction matches the observed spectra below the 1σ level except for in the busiest area of the spectrum around 1 keV. We explore the limitations of this reconstruction in § 4.2.  \nIn Figure 6, we show the results of the spectral deconvolution of ObsID 5289 (Abell 1795). Here, we used an exposure time of 14,950 seconds to normalize the data. Since Abell 1795 has a high temperature, the complex of strong emission lines around 1.0 keV is not as prominent as with NGC 1550. Figure 6 demonstrates similarly that the RIM reconstruction matches the observed spectrum below the 1σ level in all spectrum regions.", '4.1. Reasoning Behind Deconvolution': "Although the community has been working with the convolved X-ray spectra for the last several decades, deconvolution of X-ray spectra promises many benefits. Using deconvolved spectra, it will be possible to directly stack X-ray observations of the same target to improve the signal-to-noise. In doing so, we will no longer need to rely on simultaneous fitting of multiple observations, which is costly.  \nMoreover, the deconvolved spectra can be passed to machine learning algorithms capable of extracting the  \nunderlying model parameters (i.e. the temperature and metallicity) without worrying about the response matrices. The benefit of this methodology has been shown extensively in the literature (e.g., Fabbro et al. 2018; Rhea et al. 2020; Rhea et al. 2021b).  \nX-ray time variability has been the focus of many studies (e.x. Mushotzky et al. 1993; Giannios et al. 2004; van der Klis 2006); these studies tend to focus on either photometric measurements, or, in the case when they are studying the spectra, model fits to convolved spectra. Our proposed methodology to deconvolve X-ray spectra could be used to study the variability of X-ray sources in time. Typically, changes to the spectrum due to time variability are nearly indistinguishable due to the convolution. However, if we have access to the deconvolved spectrum, the evolution of the spectrum will be clear without the use of additional modeling.  \nThe RIM offers new possibilities for verifying the consistency of the CXO calibration over time. Indeed, contamination layers on Chandra's optical blocking filters cause the instrumental response of its detectors to evolve, leading to changes in the spectra of stable astrophysical sources observed across different cycles. These sources, which should have consistent spectra over time, are used as calibration sources to update the response matrix models, which are then used for data processing and spectral analysis. If the RMF calibration is accurate, the RIM-deconvolved spectra of these non-changing calibration targets across different cycles should be identical. If not, the RIM can be used to adjust the RMF by deconvolving recent spectra and comparing them to a reference spectrum from the initial cycle, which is assumed to be accurately calibrated. The  \nFigure 4. Montage of 16 randomly selected mock observed spectra (black) and the RIM reconstructions (blue) for a variety of temperatures and metalicities. Included in each subfigure is the reduced chi squared value. The temperature increases from top to bottom and the metalicity increases from left to right.  \n<!-- image -->  \nFigure 5. Results of the RIM on the galaxy group NGC 1550. In the left panels, we show the RIM solution (i.e. the result of the deconvolution process) for ObsID 3186 and 3187, top and bottom, respectively (red). The middle panel shows the observed spectrum after background subtraction (black) and the RIM reconstruction (blue). The RIM reconstruction results from passing the RIM solution through the forward model developed in equation 2. The right panel shows the residual between the observed spectrum and the RIM reconstruction normalized to the noise level of the observation.  \n<!-- image -->  \nFigure 6. Results of the RIM on the massive galaxy cluster Abell 1795. In the left panels, we show the RIM solution (i.e. the result of the deconvolution process) for ObsID 5289 (red). The middle panel shows the observed spectrum after background subtraction (black) and the RIM reconstruction (blue). The RIM reconstruction results from passing the RIM solution through the forward model developed in equation 2. The right panel shows the residual between the observed spectrum and the RIM reconstruction normalized to the noise level of the observation.  \n<!-- image -->  \ncoefficients of the response matrix are iteratively modified until the deconvolved spectra match the reference, minimizing the residual and resulting in a recalibrated matrix.", '4.2. Limitations of the Model': 'In Section 3.1, we demonstrated that the RIM reconstructions match the synthetic ground truth spectra well below the noise level. However, we do not have access to the ground truth for the real data. Therefore, we instead compare the RIM solution of the spectrum predicted from the best-fit model in the literature.  \nHere is the corrected version while keeping all LaTeX commands and symbols intact:  \nMore specifically, in the case of NGC 1550, we use the best-fit model estimated in Kolokythas et al. (2020) and refer to this as kolokythas2020 from now on. Here, the authors fitted the convolved observed spectrum and estimated that the ICM can be modeled by an absorbed APEC model, where the metallicity is set to 0.27 Z ⊙ and the temperature is set 1.38 keV. The only parameter we modify is the normalization parameter to match the deconvolved spectra, i.e., the RIM solution. In Figure 7, we show the comparison between the model predicted from kolokythas2020 (dashed line) and the RIM solution from ObsID 3186 and ObsID 3187 (solid line). We stress that since we are deconvolving a real observation, there is no ground truth to compare the results to, but rather a fit that implicitly carries all the assumptions that go into the standard fitting procedure.  \nFirst, Figure 7 shows that, while the deconvolution of ObsID 3186 and ObsID 3187 return similar intrinsic spectra, there are discrepencies between the two deconvolutions. Galaxy clusters change on the timescales of tens of millions of years, therefore it is unexpected for the intrinsic spectrum to change. We consider the driving force between the differences in deconvolution to be the considerable singularity of the response matrices which differ from one observation to the other even though the RIM has converged and shows excellent results on realistic synthetic data. This result highlights the intrinsic difficulties in deconvolving the X-ray spectrum from the response matrix.  \nMore importantly, the deconvolved spectra do not match the expected model spectrum using the Kolokythas2020 model. The Kolokythas2020 model differs from the RIM solution in three main ways: the intensity of the powerlaw is slightly diminished, the intensity of the iron features around 0.8 - 1.2 keV are subdued, and the peak of the emission line around 2.2 keV is lower. This result can be interpreted as either the RIM solution, although relatively stable over different obser-  \nFigure 7. In this figure we compare the RIM solution for both ObIDs (ObsID 3186 and ObsID 3187 in red) and the model taken from literature values (green) for NGC 1550. The later was obtained by estimating the thermodynamic properties of the cluster from the convolved observed spectrum in Kolokythas2020 and then creating a mock spectrum using in SOXS .  \n<!-- image -->  \nvations, is incorrectly capturing the intrinsic emission due to the inherent complexities of the inversion process, or the Kolokythas2020 model does not accurately represent the intrinsic emission. It is impossible to distinguish between the two scenarios without knowing the true result, which would require a higher resolution observation.  \nFigure 8 shows the equivalent RIM solution for ObsID 5289 and the expected model spectrum of Abell 1795. We calculate the expected model spectrum by assuming a temperature of kT ≈ 5 keV and a metallicity of Z ≈ 0 . 5 Z ⊙ ; these values were approximated from Ettori et al. (2002) and Walker et al. (2014); we therefore refer to this as the Walker2014 model from now on. The galactic absorption was set to 1.2 × 10 20 cm -2 following measurements by Kalberla et al. (2005). While the RIM solution more closely matches the literature model, there are still discrepencies between the two in the location and amplitude of the emission lines.  \nDespite these challenges with actual X-ray observations, the RIM performs remarkably well on synthetic data, consistently achieving highly accurate reconstructions that closely match the ground truth. This demonstrates the robustness of the method in controlled scenarios. However, further investigation is required to address the complexities of applying the RIM to actual observed data, which may involve refining the model and accounting for observational uncertainties. We discuss  \nFigure 8. Same as in Fig. 7, but for Abell 1795. In this figure we compare the RIM solution for ObsID 5289 (red) and the model taken from literature values (green) taken from Walker2014.  \n<!-- image -->  \nthis further in the next section. Additionally, our results suggest that the thermodynamic parameters estimated from the convolved observed spectra may not fully capture the intrinsic properties of the cluster, potentially requiring a more nuanced approach.', '4.3. Future Improvements': "Given the inherent challenges of solving highly illposed inverse problems, here we investigate more stateof-the-art approaches that could improve the accuracy of the RIM in future applications.  \nAdam et al. (2022b) applied the RIM to strongly gravitationally lensed systems, developing a method to simultaneously reconstruct undistorted images of the background source and the lens mass density distribution as pixelated maps. While successful, the authors showed that fine-tuning the RIM's objective function was necessary to improve reconstructions when fine structure was present in the data. Although this approach did not entirely eliminate the issue, it significantly improved the results. This methodology could potentially be adapted to X-ray spectra; however, since our current reconstructions are already at the noise level of the observations, this technique may have limited impact in our specific case.  \nThe root of the problem lies in the way the RIM implicitly encodes the prior inside the neural network trained using the maximum likelihood estimate. Therefore, the RIM will produce blurred reconstructions because it returns an average spectrum corresponding to an observation.  \nRecent advances in diffusion models have shown marked improvement over other techniques such as the RIM (e.g., Adam et al. 2022a; Dia et al. 2023; Adam et al. 2023). Diffusion-based techniques achieve better results by accurately encoding the priors using scorebased models that implicitly do not require the prior to be learned.  \nTherefore, a future paper will use diffusion models to recover the intrinsic spectrum. Furthermore, since diffusion models are anchored in Bayesian statistics, this will also give us uncertainties on the reconstructions, which is crucial for comparing the deconvolution results with contemporary models bound by literature results.  \nAnother potential improvement arises from our assumption when transitioning from equation 1 to equation 2, where we linearized each term in the integral equation. The linearization of equation 1 implictly assumes that the response matrix behaves in a linear manner from one bin in energy space to another. This is potentially true for high resolution spectra such as those obtained with the X-Ray Imaging and Spectroscopy Mission (XRISM), but it is likely not the case for Chandra ACIS-I or ACIS-S observations. If this is the case, then additional terms need to be added to equation 2 that capture the nonlinear nature of the initial spectral equation for the two equations to be truly equivalent.  \nTherefore, in the case of new and upcoming high spectral resolution missions such as XRISM, new Athena, or LEM, we expect the linearization condition to hold since it requires a small bin size in energy space (Kaastra & Bleeker 2016). The RIM provides an accurate and efficient way in obtaining the actual intrinsic spectra of X-ray sources for these observatories.  \nFurthermore, high spectral resolution missions will, by design, produce high resolution spectra where the response matrix does not cause strong degenerecies in the physical parameter space employing mixing emission lines. In future works, we will explore additional terms in the linearization of equation 1 and apply the RIM to future observatories.  \nAnother potential challenge in recovering the intrinsic spectrum of real observations is that the ICM has a variety of temperatures but is rather fully characterized by a distribution of temperatures. While this poses a problem for the RIM which outputs a single expected spectrum, the diffusion-based model can capture this distribution in the posterior it will provide.", '5. CONCLUSIONS': "In this paper, we explored using a machine learning algorithm, the RIM, to deconvolve the intrinsic X-ray spectrum of an emitting source from the instrumental  \nresponse function observed using data from the Chandra X-ray Observatory.  \nWe demonstrate that the RIM effectively reconstructs the global features in modeled ICM spectra below a 1sigma noise level. Moreover, the RIMreconstructed spectra match the realistic synthetic observations closely.  \nFurthermore, we apply our trained RIM to actual observations of the NGC 1550 and Abell 1795 galaxy clusters. The RIM, again, achieves a reconstruction error under 1σ . While these results represent a significant improvement over previous attempts to deconvolve X-ray spectra from the instrumental response, they highlight the method's inability to reconstruct local changes in the reconstructed spectra. In the case of using the deconvolved spectra for science, the local features are crucial since they encode physical information about the emitting gas such as the underlying temperature or metallicity.  \nHowever, this assumes that the expected models are correct, which implicitly asserts that the literature values of thermodynamic parameters are accurate. While not unreasonable, these results present a different intrinsic spectrum of Abell 1795 and NGC 1550; this underscores the need to validate that the RIM results are physically consistent.  \nFuture works will use carefully constructed priors to augment the RIM and score-based models for deconvolving X-ray spectra.", '6. SOFTWARE AND THIRD PARTY DATA REPOSITORY CITATIONS': 'Facilities: CXO  \nSoftware:  \nastropy', 'A. CHANDRA OBSERVATIONS FOR RESPONSE MATRICES': 'In this section, we enumerate the Chandra observations used to construct the response matrix catalog.  \nA.1. SOXS Data Creation Commands  \nThis section provides the code used to create the sythetic spectra.  \n```\nfrom soxs import ApecGenerator , RedistributionMatrixFile rmf = RedistributionMatrixFile("region1.rmf") # THIS IS ONLY USED TO GET THE RANGE AND SPACING emin = rmf.elo[0] emax = rmf.ehi[-1] nbins = rmf.n\\_e binscale = "linear" agen = ApecGenerator(emin, emax, nbins, binscale=binscale) num\\_spec = 100000 true\\_ys = [] for i in tqdm(range(num\\_spec)): # Randomly select xspec parameters redshift = random.uniform(0.0, 0.8) # redshift temp = random.uniform(0.4, 8.0) # temperature in keV abundance = random.uniform(0.2, 1.2) # Metallicity abundance in Z\\_solar kT = (temp, "keV") norm = random.uniform(0.1, 1) spec = agen.get\\_spectrum(kT, abundance , redshift , norm) n\\_H = random.uniform(0.001, 0.01) # Foreground Galactic Absorption spec.apply\\_foreground\\_absorption(n\\_H, model="tbabs") true\\_ys.append(spec.flux)\n```', 'REFERENCES': '```\nAdam, A., Coogan, A., Malkin, N., et al. 2022a, E1, doi: 10.48550/arXiv.2211.03812\n```  \nAdam, A., Perreault-Levasseur, L., & Hezaveh, Y. 2022b, Pixelated Reconstruction of Gravitational Lenses using Recurrent Inference Machines, arXiv,  \ndoi: 10.48550/arXiv.2207.01073'}