JWST’s TEMPLATES for Star Formation: The First Resolved Gas-Phase Metallicity Maps of Dust-Obscured Star-Forming Galaxies at z ∼ 4

We present the ﬁrst spatially resolved maps of gas-phase metallicity for dust-obscured star-forming galaxies (DSFGs) at z ∼ 4, from the JWST TEMPLATES Early Release Science program, derived from NIRSpec integral ﬁeld unit spectroscopy of the H α and [N ii ] emission lines. Empirically derived literature optical line calibrations are used to determine that the sources are highly metal rich, with both appearing to display regions of supersolar metallicity, particularly in SPT2147-50. While we cannot rule out shocks or AGN in these regions, we suggest that the two systems have already undergone signiﬁcant enrichment as a result of their extremely high star-formation rates. Utilising ALMA rest-frame 380 µ m continuum and [C i ]( 3 P 2 – 3 P 1 ) line maps we compare metallicity and gas-to-dust ratio


INTRODUCTION
At so-called "cosmic noon" (z ∼ 2) and beyond, a significant fraction of the Universe's star formation occurs in dust-obscured star-forming galaxies (DSFGs; Casey et al. 2014;Swinbank et al. 2014;Dudzevičiūtė et al. 2020;Zavala et al. 2021).In such systems, the majority of the rest-frame optical and ultraviolet (UV) light associated with young stars is absorbed by dust and reprocessed into the far-infrared.
Multiwavelength analyses and molecular gas observations have revealed that DSFGs are massive, gas rich and highly star forming, with infrared luminosities L IR > 10 12 L ⊙ , implied star-formation rates (SFRs) of 100-1000 M ⊙ yr −1 (see e.g.Swinbank et al. 2014;Spilker et al. 2015;Aravena et al. 2016;Strandet et al. 2017;Dudzevičiūtė et al. 2020;Reuter et al. 2020;Birkin et al. 2021) and dense interstellar media (e.g.Spilker et al. 2014;Birkin et al. 2021;Rybak et al. 2022;Reuter et al. 2023).The observed properties of DSFGs (such as their high IR luminosities) and the fact that sources have been detected up to z ∼ 7 has made them challenging to reproduce in current models of galaxy formation and evolution (Davé et al. 2010;Lacey et al. 2016;McAlpine et al. 2019;Hayward et al. 2021;Bassini et al. 2022).Therefore, observations of DSFGs can provide strong constraints on such theories.
The interstellar medium (ISM) plays a critical role in the ongoing processes within DSFGs, such as star formation, supernovae and winds which add, remove, and redistribute metals.Therefore, measuring the gasphase metallicity and its variation across the galaxy is a powerful indicator of its past evolution (e.g.Maiolino & Mannucci 2019), for example through scaling relations such as the mass-metallicity relation (MZR; e.g.Tremonti et al. 2004) and fundamental metallicity relation (FMR; e.g.Mannucci et al. 2010;Curti et al. 2020).A simple and effective method for estimating metallicity is to measure the relative strengths of the [Nii] and Hα emission lines (e.g.Pettini & Pagel 2004;Marino et al. 2013;Dopita et al. 2016;Maiolino & Mannucci 2019), which suffer similar levels of dust extinction due to their * NASA Postdoctoral Fellow close proximity in wavelength.This method has limitations, such as being highly sensitive to the ionisation parameter and N/O abundance (Pérez-Montero & Contini 2009;Dopita et al. 2016;Pilyugin & Grebel 2016;Peng et al. 2021), but the brightness of these lines and their accessibility at high redshifts have made it a popular observable for metallicity (e.g.Steidel et al. 2014;Sanders et al. 2015;Gillman et al. 2022).
At high redshifts, strong gravitational lensing due to massive foreground structures allows us to observe galaxies at higher spatial resolution than would otherwise be possible.This technique is commonly used to study the DSFG population, with modest samples of lensed sources characterized by the Herschel, Planck, Atacama Cosmology Telescope (ACT), South Pole Telescope (SPT) (e.g Negrello et al. 2010;Vieira et al. 2013;Marsden et al. 2014;Bussmann et al. 2015;Harrington et al. 2016;Spilker et al. 2016;Everett et al. 2020;Kamieneski et al. 2023), and through the ALMA Cluster Lensing Survey (ALCS; e.g.Sun et al. 2022).Many sources have been detected up to z ∼ 7 (e.g.Marrone et al. 2018;Reuter et al. 2020;Endsley et al. 2023).
In this work, we present Director's Discretionary Early Release Science (DD-ERS) NIRSpec IFU observations of two SPT-selected gravitationally lensed DSFGs: SPT0418-17 at z = 4.2246 and SPT2147-50 at z = 3.7604 (Reuter et al. 2020), with which we demonstrate the significant advancements that JWST is already providing in our study of this population.The outline of this pa-per is as follows: in §2 we describe the observations carried out, our data reduction methods, and our analysis of the reduced data.In §3 we present the results and discuss their implications.In §4 we summarise our findings.Throughout this paper we adopt the cosmology measured by Planck Collaboration et al. (2020), i.e. flat with Ω m = 0.310 and H 0 = 67.7 km s −1 Mpc −1 , and a solar metallicity of 12 + log(O/H) = 8.69 (Asplund et al. 2021).Co-PI: J. Vieira).From TEMPLATES we utilize NIR-Spec IFU G395M/F290LP observations of two SPTselected DSFGs: SPT0418-47 and SPT2147-50.From spectral energy distribution (SED) fitting it is known that both galaxies are highly massive and highly starforming (Cathey et al. 2023, and see Table 1).
The JWST data used in this manuscript can be found in MAST: 10.17909/fdje-fq59.We reduce the data with the standard JWST pipeline (Version 1.10.2;Bushouse et al. 2023) using calibration reference data system (CRDS) context jwst 1089.pmap, with some modifications.Full details on the TEMPLATES data reduction will be provided in Rigby et al. (in prep.), but here we describe how our process differs from the standard pipeline.We modify the outlier detection stage of the pipeline as we found that in some cases the default stage can remove real signal.In our alternate sigma clipping method we first mask the galaxy and clip the background, and then perform the same process on layers of the galaxy of increasing signal-to-noise ratio (S/N).This layering was chosen to ensure that spaxels with weaker emission did not affect the clipping of spaxels with strong emission.We also applied a small offset (∼ 0.5 ′′ for both sources) to match the data to ALMA rest-frame 380 µm continuum data (see §2.2).These astrometric shifts were determined by comparing the coordinates of the central continuum source with HST/WFC3 F140W imaging (Ma et al. 2015).
As part of our analysis we also generate NIRSpec cubes with 0.5 ′′ resolution (as opposed to the original ∼ 0.1 ′′ resolution).This is done to ensure consistency with existing ALMA data (see §2.2), which we use to derive maps of the dust and gas emission.To generate the 0.5 ′′ resolution NIRSpec cubes we convolve the original (0.1 ′′ pixel scale) cubes with a circular Gaussian point spread function (PSF) of FWHM 0.49 ′′ .The target spatial resolution (0.5", and Gaussian by construction) is sufficiently poorer than the intrinsic JWST PSF (0.1") that the wings and spikes in the JWST PSF can be safely ignored.

ALMA
To supplement the data from JWST/NIRSpec, we utilize ALMA data covering the rest-frame 380 µm continuum emission and the [Ci]( 3 P 2 -3 P 1 ) line emission, which will be used in §3.3 as proxies for dust mass and gas mass, respectively.For SPT0418-47 we utilize Band 4 data from program 2021.1.00252.S (PI: J. Vieira), which we image using natural weighting and taper to a spatial resolution of 0.5 ′′ , creating continuum images and CO(7-6)/[Ci](2-1) cubes.For SPT2147-50 we utilize Band 5 data from program 2018.1.01060.S (PI: J. Vieira) which is processed in the same way, except the imaging was performed using Briggs weighting with a robust parameter of 0.45.This enabled us to achieve the same resolution as the SPT0418-47 data.To achieve our goal of determining how the metallicity varies across our two targets, we model the Hα and [Nii] complex as a triple-Gaussian profile, on a pixel-by-pixel basis, tying the wavelengths of the emission and coupling their linewidths, with the Hα/[Nii] flux ratio left as a free parameter.The flux ratio of [Nii]λ6584/[Nii]λ6548 is fixed at 2.8 (Osterbrock & Ferland 2006), and we also include a constant continuum component.We attempt to model the emission lines in each pixel, and if we measure a S/N of at least 8 across the Hα+[Nii] complex the pixel is included in the flux maps.Otherwise, the pixel is ignored, and not used in our subsequent analysis.The threshold of S/N = 8 was chosen through trial and error, to minimize pixels where the apparent Hα emission is largely due to noise while ensuring that the derived flux maps contain enough pixels to study the resolved properties.To boost the S/N we bin each spaxel with its eight neighbouring spaxels.Finally, we visually inspect the resultant Hα flux maps along with the fits to each spaxel, and mask by hand any spaxels where the emission does not appear to be coming from the target galaxy.This includes masking emission from a newly detected companion galaxy (Peng et al. 2022;Cathey et al. 2023, and see §3.1), which we elect not to study in detail in this work.

RESULTS AND DISCUSSION
Fig. 1 shows the 1-D spectra extracted from the two DSFGs in pixels where Hα and [Nii] are detected, and Fig. 2 shows the same spectra, but this time zoomed into the Hα, [Nii] and [Sii] lines.We show both the integrated spectra, and a sample spaxel (binned with neighbouring spaxels) for each galaxy.The [Sii] doublet is shown with a double-Gaussian fit in the integrated spectra as it is clearly detected, but the S/N is insufficient to detect it in individual pixels.Therefore we do not model [Sii] in our resolved fitting.The triple Gaussian fit models the Hα and [Nii] lines well in both cases.The resultant maps of Hα and [Nii]   respectively.We detect continuum emission across the observed wavelength range in both sources, a combination of stellar continuum from the background DSFGs and light from the bright foreground lenses blurred into the background emission by the JWST PSF.We model the continuum using a running median with a window size large enough so as to avoid removing any flux from the emission lines (∼ 10000 km s −1 ).Both DSFGs display strong Hα and [Nii]λ6584 emission, along with the [Sii]λ6717,31 and [Siii]λ9071,9533 doublets.Additionally, in the lower-redshift SPT2147-50 we detect Hei and Paγ emission, with tentative evidence for Paδ.

Line ratios and metallicities
To derive metallicities for the two DSFGs we first convert the [Nii]λ6584/Hα ratio from the line fits to an oxygen abundance 12 + log(O/H) using the calibration for N2 ≡ log 10 ([Nii]/Hα) as derived by Marino et 2016) (hereafter D16), the latter of which also uses the [Sii] doublet.We selected the M13 calibration as it is considered more reliable at high redshifts and in better agreement with other calibrations than PP04 (e.g.Poetrodjojo et al. 2021), and simpler to extrapolate to higher metallicities than C20, who used a fourth-order polynomial fit which is not well constrained in the high-metallicity regime.As an alternative measurement we briefly discuss results using the D16 calibration, but as the S/N of our [Sii] detections is low we are unable to use this line on a spatially resolved basis.Therefore for consistency we primarily use the M13 calibration.We note here that while we later study the global mass-metallicity relation and fundamental metal- licity relation, our main concern in this work is the spatial variation of the metallicity with other properties rather than their absolute values.
As the [Nii]/Hα ratio is very high (> 0.8) in several regions of both sources, we cannot rule out active galactic nuclei (AGN) as being responsible for this emission.In SPT2147-50 this is supported by very broad line FWHMs (∼ 800 km s −1 ) which correspond with regions of high [Nii]/Hα.This could be evidence for AGNdriven winds in this system.No previous work on these two sources has suggested that either are AGN hosts (e.g.Bothwell et al. 2017;De Breuck et al. 2019).The same is true for other DSFGs from the same parent sample (Ma et al. 2016;Apostolovski et al. 2019).Therefore, this is a surprising result, particularly for SPT2147-50 which shows the highest [Nii]/Hα ratios.
Galaxies are commonly classified as AGN dominated or otherwise using the Baldwin, Phillips and Terlevich (BPT; Baldwin et al. 1981) diagram (e.g.Kewley et al. 2006).However, the other BPT diagnostics [Oiii] and Hβ (neither of which fall within the coverage of our data) are needed to confirm this.Even with these additional diagnostics, the boundary between star-forming galaxies and AGN in the BPT diagram is uncertain at z ∼ 2, let alone at z ∼ 4 where the two DSFGs reside (Kewley et al. 2013).We therefore also derive metallicities masking out individual pixels with [Nii]/Hα > 0.5, which we choose to provide a conservative lower limit on the integrated metallicity.
Adopting a conservative cutoff of [Nii]/Hα > 0.5 (which masks ∼ 43 % and ∼ 70 % of the pixels in SPT0418-47 and SPT2147-50 respectively) these values change to Z = 0.7 ± 0.3 Z ⊙ for SPT0418-47 and Z = 0.7 ± 0.3 Z ⊙ for SPT2147-50.Interestingly, applying this correction does not significantly change the global metallicity values; both are still a significant fraction of the solar value, and consistent with solar abundances in all cases.
The detections of [Sii]λ6717,31 are significant enough in the integrated spectra of both galaxies (see Fig. 2) to provide an independent estimate of the metallicity.Additionally, [Sii]  negligible.We therefore also apply the D16 calibration for Hα, [Nii] and [Sii] to estimate 12 + log(O/H).Interestingly, this calibration gives significantly higher values of metallicity: Z = 1.8 ± 0.7 Z ⊙ for SPT0418-47 and Z = 2.7 ± 1.0 Z ⊙ for SPT2147-50 (decreasing to 1.5 ± 0.6 Z ⊙ and 1.7 ± 0.7 Z ⊙ respectively when applying our AGN masking).The D16 calibration has been claimed to have a reduced dependence on the ionisation parameter when compared to N2, and therefore this is further evidence that the two DSFGs are highly enriched with metals, possibly even to solar or super-solar levels.
We note here that the two [Siii] lines that we detect here can also be used to trace the ionization parameter and metallicity.There remains uncertainty over the reliability of NIRSpec flux calibrations as a function of wavelength, and so we prefer to only use ratios between emission lines that are close in wavelength.Additionally, we would require the application of extinction corrections to our data, given the large wavelength difference between [Siii] and the other lines.As we do not have measurements of the Hβ flux, and therefore the Balmer decrement, our extinction corrections would be highly uncertain.Therefore we have elected not to use the [Siii] lines in our analysis.
As a side note, a companion source to SPT0418-47 (SPT0418-47B) has been detected by Peng et al. (2022) and Cathey et al. (2023).While we are not focused on the nature of this source here, we note that we measure a metallicity of ∼ 0.6-0.7 Z ⊙ (applying the M13 calibration), which we find to be consistent with Peng et al. (2022).Therefore the smaller merging companion to SPT0418-47 is a slightly less metal-rich system.
A potential source of uncertainty in our metallicity estimates may arise from diffuse ionized gas (DIG), as the resolution of our observations is much greater than the scale of individual Hii regions.Vale Asari et al. (2019) investigated this effect for star-forming galaxies in the MaNGA survey and found the diffuse component to have a ∼ 0.1 dex contribution to metallicity estimates derived using the [Nii]/Hα index, at the high-metallicity end.They also found the DIG to have a more prominent effect on the mass-metallicity relation at the high stellar mass end, where our sources (particularly SPT2147-50) lie.Similar findings were also made by Poetrodjojo et al. (2019).A correction for this potential effect is beyond the scope of this work, however.
In general, due to the systematic uncertainties in different calibrations and the fact that these are derived for galaxies at much lower redshifts than the two SPT DSFGs, it is highly challenging to confidently constrain their global metallicities.However, even while being conservative over the possibility of AGN emission in the two DSFGs, we can confidently say that both are enriched to near-solar levels, likely as a result of their very high SFRs.

Mass-metallicity relation and the fundamental metallicity relation
In general, galaxies appear to display a correlation between gas-phase metallicity and stellar mass, the socalled Mass-Metallicity Relation (MZR; e.g.Tremonti et al. 2004).In addition, a "three-dimensional" relation between stellar mass, metallicity and SFR has been suggested and named the Fundamental Metallicity Relation (FMR; Mannucci et al. 2010).In the FMR, low-mass galaxies with higher SFRs typically contain a lower proportion of metals, and in high-mass galaxies the metallicity saturates and becomes independent of SFR (as in the mass-metallicity relation).Mannucci et al. (2010) found this relation to hold constant with low scatter up to z ∼ 2.5 (also see e.g.Lara-López et al. 2010;Troncoso et al. 2014;Curti et al. 2020), attributing the result to the dominance and consistency of smooth secular processes at low to intermediate redshifts, with this equilibrium being reached at least as early as z ∼ 2.5.
At higher redshifts the picture is less clear.Mannucci et al. (2010) showed that galaxies at z ∼ 2.5 are offset from the FMR, specifically around 0.6 dex towards lower metallicities, which may imply that smooth secular processes are less prominent in higher redshift sources.To test this for the two z ∼ 4 DSFGs, in Fig. 5 we show the derived oxygen abundances 12 + log(O/H) using the C20 calibration versus stellar masses derived from SED fitting with cigale (Cathey et al. 2023, Phadke et al. in prep.).The open points indicate the oxygen abundances derived from masking emission in pixels with [Nii]/Hα > 0.5, and are shifted horizontally for visual clarity.
For comparison with other similarly selected sources, we also include in Fig. 5 z ∼ 2 DSFGs with [Nii]/Hα measurements from the K-band Multi-Object Spectrograph (KMOS; Birkin 2022), along with z ∼ 1.3-2.6 galaxies from the KMOS 3D survey (Wisnioski et al. 2015), the latter of which is generally comprised of galaxies with lower SFRs than those studied in this work.The two DSFGs presented in this work are consistent with the majority of the comparison sources, albeit generally on the more metal-rich end.
From C20 we show the mass-metallicity relation for local galaxies, along with the FMR for the SFRs of the two galaxies (see Table 1), including the scatter in both cases.Both galaxies are consistent with the local massmetallicity relation within the uncertainties -they are high-mass galaxies, at which point the metallicity is expected to saturate at around 12 + log(O/H) ∼ 8.7-8.8.According to the FMR they are both marginally more metal rich than expected, although generally consistent within the large uncertainties, especially when we account for potential AGN emission.Mannucci et al. (2010) claim that the relatively small scatter in the FMR up to z ∼ 2.5 implies constant relative significance of star formation, infall and outflows of gas.The two galaxies presented in this paper appear to have metallicities consistent with the FMR and could therefore fit into this picture.However, SPT0418-47 seems to be interacting with a companion (Peng et al. 2022;Cathey et al. 2023), which may be expected to drive it away from the FMR.Studies using both observations and simulations have shown that in the early stages of a merger the gas is diluted, thus lowering the metallicity.Subsequently, the metallicity is increased as the merger proceeds, when the star-formation rate is enhanced (e.g.Rupke et al. 2008;Montuori et al. 2010;Rupke et al. 2010).It is therefore interesting that SPT0418-47 remains consistent with the FMR.We choose not to overinterpret this result given the large uncertainties on the oxygen abundances.
We note that we use the relations from C20 as Marino et al. (2013) do not derive either the FMR or the MZR from their calibration.However, we note that we would expect both to move down if these relations were available for the M13 calibration, and if anything this would place the two DSFGs ∼ 0.2 dex further above the FMR than we see in Fig. 5.This would put both sources firmly above the FMR.
An important consideration to make is whether or not the line calibrations we assume are applicable at z ∼ 4.There are few T e method-based metallicity measurements calibrated to Hα and [Nii] at this epoch (although some work has been done with Hβ and [Oiii]; e.g.Curti et al. 2023;Trump et al. 2023), hence our reliance on local calibrations, and it is possible DSFGs exhibit different relative abundances than nearby galaxies.For instance, a top-heavy initial mass function, as has been suggested as necessary to reconcile DSFG number counts with theory (e.g.Baugh et al. 2005), and therefore a large number of high-mass stars, would lead to a change in the relative abundance of nitrogen, oxygen and hydrogen.A lack of observational data limits our ability to draw the correct conclusion, however some work on this topic has already been done with NIRSpec.For example, for z = 2.18 galaxies Sanders et al. (2023) have found evidence that the local C20 N2 calibration for metallicity is biased ∼ 0.5 dex high when compared to direct measurements from auroral lines.This bias may be as significant, or potentially even worse, at z ∼ 4.
A further consideration is that if SPT2147-50 does in fact host an AGN that is contributing significantly to the infrared emission, then this could result in a larger estimate of the SFR from SED fitting than the true value.This would in turn mean that the expected metallicity from the FMR is actually lower than it should be.Additionally, the SFRs used in the C20 scaling relations are derived from the Hα luminosities, scaled to a total SFR.Given the high levels of dust extinction in the two galaxies (see Table 1), we do not derive Hα-based SFRs in this work, as the corrections are likely to be significant and uncertain.We instead use total SFRs derived from cigale SED fitting, which uses the parameterization from Boquien et al. (2019), with the star-formation histories modelled as an exponential decay (τ burst = 1 Gyr) including an additional burst component using the stellar population model from Bruzual & Charlot (2003).

metallicities and the gas-to-dust ratio
The impressive sensitivity and resolution of JWST has allowed us to spatially resolve the [Nii]/Hα flux ratio (see Figs. 3 and 4).We wish to compare these with the distribution of dust and gas in the two galaxies in order to determine how they are related.We therefore compare the [Nii]/Hα maps from NIRSpec with existing ALMA imaging of the rest-frame 380 µm continuum and [Ci] line emission, which provide estimates of the dust and ISM masses.
Figs. 3 and 4 show ALMA rest-frame 380 µm continuum maps and [Ci] emission line maps of the two DS-FGs, the latter of which are derived by summing the flux within twice the FWHM of the line.We also show the ratio of the [Ci] to 380 µm maps, which we use as a proxy for the gas-to-dust ratio (δ GDR ).Visually, these three maps are broadly consistent in terms of regions of high [Nii]/Hα coinciding with regions of high flux in the ALMA maps.This is most clear in SPT2147-50, which displays two bright regions in the 380 µm maps that are also present in the NIRSpec data.
To quantify the relation between the metallicity, gas, and dust, we convert the ALMA maps to dust and gas mass surface density Σ dust and Σ gas and plot both versus [Nii]/Hα on a pixel-by-pixel basis, as shown in Fig. 6.To convert the ALMA rest-frame 380 µm continuum maps to dust mass maps we apply Eq. ( 1) of Dunne et al. (2003), assuming a dust mass opacity coefficient at 125 µm of 2.64 m 2 kg −1 , a dust temperature T dust of 40 K, and extrapolating to 380 µm with dust emissivity index β = 2.0.
This approach ignores any potential variations in T dust and β.However, Spilker et al. (2023) recently analysed rest-frame 120 µm and 160 µm data from SPT0418-47 and found no evidence of significant variations in dust temperature across the source.If indeed we are seeing AGN emission in SPT2147-50 then we may expect these regions to display higher dust temperatures, but we flag regions of the parameter space in Fig. 6 where this is likely to be the case and avoid overinterpreting these regions.There has yet to be significant study of variations in the dust emissivity across individual galaxies, and indeed we cannot rule this out in our sources.
To convert the [Ci] emission line maps to molecular gas mass maps we use Eq. ( 6) of Bothwell et al. (2017), except in our case we use the Einstein A 21 = 2.68 × 10 −7 s −1 coefficient (Papadopoulos & Greve 2004) and excitation factor Q 21 = 0.22 (Dunne et al. 2022) for the [Ci](2-1) transition instead of the [Ci](1-0) values.Following Papadopoulos & Greve (2004) and Bothwell et al. (2017) we adopt a [Ci]/H 2 abundance ratio of X [CI] = 3 × 10 −5 .This is a com-0.25 0.50 0.75 1.00 [NII]/Hα   On the top axes we show the corresponding oxygen abundances according to the calibration of Marino et al. (2013).On the right axes we show the corresponding dust mass surface density Σ dust , gas mass surface density Σgas, and gas-to-dust ratio δGDR, using the conversions described in §3.3.We plot a binned median (gray line) with 1-σ scatter (gray region), and color-code points by Hα FWHM.We also indicate the solar metallicity (Asplund et al. 2021) and shade the region where [Nii]/Hα > 0.8, the latter of which is likely to be contaminated to some extent by AGN emission.Notably, in this region Hα emission is broadest when compared to the rest of the source.
In both sources the gas-to-dust ratio appears to decline with increasing metallicity, although this trend is more prominent in SPT2147-50.In the bottom panels we also show models from Rémy-Ruyer et al. (2014) and Aniano et al. (2020), which are discussed further in §3.3.monly adopted value in the literature, but we note that this value cannot be measured for high-z galaxies and is therefore based on measurements from local galaxies.It is therefore subject to considerable uncertainty.Indeed, through a comparison with dust-based gas masses, Bothwell et al. (2017) suggested that a higher value of X [CI] = 7 × 10 −5 could also be reasonable.Given that we are primarily concerned with the variation of δ GDR with metallicity, rather than its absolute value, this assumption should not significantly affect our conclusions.
In Fig. 6 we plot three quantities as a function of [Nii]/Hα, a proxy for metallicity.These are S 380µm , S [CI] and S [CI] /S 380µm , which we use as proxies for dust mass surface density, gas mass surface density, and gas-todust ratio respectively.The points are color-coded by Hα FWHM.Given the various caveats and assumptions which come with these proxies, we choose to plot both the observed and converted quantities.Our interpretation will mostly focus on the variation of these properties rather than their absolute values.Additionally, all corresponding panels are shown on the same scale (of absolute values) to enable a direct comparison between the two galaxies.We also indicate the solar metallicity and shade the region where [Nii]/Hα > 0.8 which the BPT diagram suggests is likely to result from AGN emission.
Firstly, we note that in both galaxies, there appears to be a positive correlation between dust/gas mass surface density and metallicity.This indicates that regions containing more gas and dust are also more metal rich.This trend is stronger in SPT2147-50, in which we see that the most metal-rich regions also display the broadest Hα emission.Given that these points fall within the shaded region, it is likely that the most "metal-rich" regions of SPT2147-50 are in fact regions of AGN emission.This is a striking conclusion given that no clear AGN have previously been identified in any SPT-selected DSFG, including some objects more extreme than those targeted here (e.g.Ma et al. 2016;Apostolovski et al. 2019).It is theorized that DSFGs proceed to evolve through a quasi-stellar object (QSO) phase (Blain et al. 2002;Swinbank et al. 2006;Hopkins et al. 2008), and therefore we may be observing the beginnings of this evolution in SPT2147-50.NIRSpec follow up should be proposed for other sources in the SPT DSFG sample, in order to identify any further AGN candidates.
Turning to the bottom panels, we see that the gas-todust ratio appears to decline with increasing metallicity, a result that has been observed in local galaxies (e.g.Leroy et al. 2011;Rémy-Ruyer et al. 2014;Aniano et al. 2020).In the bottom panels of Fig. 6 we plot two models to compare with our data.We show the model fit by Rémy-Ruyer et al. (2014) to 126 local galaxies spanning ∼ 2 dex in metallicity, derived from strong-line calibrations.Next we include a simple model from Aniano et al. (2020) in which the gas-to-dust ratio is estimated assuming that essentially all heavy elements are in dust grains, with solar relative abundances.This results in a linear relation between metallicity and δ GDR .Both models appear to match the results from both galaxies within the uncertainties.Even if we ignore the absolute values, the trend of decreasing δ GDR with metallicity is generally well described by both models.We tentatively conclude that the gas-to-dust ratio and its variation with metallicity in these two DSFGs is consistent with findings from local galaxies, which is not necessarily unexpected but has not yet been shown for DSFGs as distant as the two we present in this paper.

CONCLUSIONS
We have presented two of the first spatially resolved metallicity maps of dust-obscured star-forming galaxies at z ∼ 4, utilizing IFU observations with JWST/NIRSpec.Both sources are detected in Hα and [Nii] at very high S/N, enabling us to perform resolved spectroscopy on these lensed systems.We find both SPT0418-47 and SPT2147-50 to be enriched to near-solar metallicity (conservatively ∼ 0.7 Z ⊙ ), with evidence for AGN-like [Nii]/Hα ratios and broad Hα emission.The derived oxygen abundances are consistent with the fundamental metallicity relation for both galaxies.Through a direct comparison with ALMA restframe 380 µm continuum and [Ci] line maps at matched resolution, which we use as proxies for dust and gas mass, we find that the gas-to-dust ratio is negatively correlated with the metallicity, a result that is consistent with literature studies of local galaxies.At least qualitatively, it appears that these early-universe dusty galaxies bear some resemblance to expectations from z ∼ 0 galaxies, even on highly resolved spatial scales.
In the absence of [Oiii] and Hβ coverage we interpret these results with caution, as the possibility remains that regions of high [Nii]/Hα are actually the result of AGN emission.Furthermore, detailed lens modelling analysis and source plane reconstruction of these data have not yet been carried out; this will be explored in future work.Regardless, this work presents the first resolved metallicity maps in DSFGs at z ∼ 4, and the data quality shows the potential of JWST to further our understanding of the processes that shape the ISM in high-redshift DSFGs.
observations are drawn from the DD-ERS programme TEMPLATES: Targeting Extremely Magnified Panchromatic Lensed Arcs and Their Extended Star formation (Program 1355; PI: J. Rigby;

Figure 1 .
Figure 1.One-dimensional JWST/NIRSpec rest-frame spectra of SPT0418-47 and SPT2147-50, displaying strong detections of the Hα and [Nii] emission lines, in addition to the [Siii] doublet.Both spectra are extracted only from spaxels where Hα+[Nii] is detected with S/N > 8. SPT2147-50 displays detections of the He I line and Pa γ lines, and marginal evidence for Pa δ emission.Neither of the sources are detected in [Oi].

Figure 2 .
Figure2.Zoom-in 1-D spectra from SPT0418-47 (top) and SPT2147-50 (bottom).All flux densities are in units of erg cm −2 s −1 µm −1 .The left panels show the integrated spectra, and the right panels show a sample typical 3x3 binned spaxel, as used in the spatially resolved fitting.The emission lines are well modelled by Gaussians.We note that the integrated spectra are fit here with[Sii]  as shown in the plot, but for the binned spaxels we only fit Hα and the [Nii] doublet, as[Sii]  is typically too faint to be significantly detected in individual binned spaxels.
Figure 3. Top row: Resolved Hα, [Nii], and [Nii]/Hα maps of SPT0418-47 from JWST/NIRSpec (left to right).The [Nii]/Hα map is used as a proxy for metallicity.Bottom row: ALMA rest-frame 380 µm continuum and [Ci] line maps, along with the resultant [Ci]/380 µm map (left to right).The [Ci]/380 µm map is used as a proxy for the gas-to-dust ratio.The grey circles show the approximate point spread function of the data in each panel, and the horizontal bars in the top right of each panel indicate the scale of 1 ′′ (∼ 0.7 kpc at z = 4).

Figure 4 .
Figure 4. Same maps as presented in Fig. 3, this time for SPT2147-50.This source displays two regions of very intense [Nii] emission which clearly match with regions of strong rest-frame 380 µm and [Ci] emission.Given that [Nii]/Hα > 1 in these regions, we are likely detecting emission from an AGN.

Figure 6 .
Figure 6.Spaxel-by-spaxel (0.1 ′′ , ∼ 0.7 kpc) variation of 380 µm flux (top), [Ci] line flux (middle) and [Ci]/380 µm flux ratio (bottom) as a function of [Nii]/Hα line ratio for the two SPT DSFGs.On the top axes we show the corresponding oxygen abundances according to the calibration ofMarino et al. (2013).On the right axes we show the corresponding dust mass surface density Σ dust , gas mass surface density Σgas, and gas-to-dust ratio δGDR, using the conversions described in §3.3.We plot a binned median (gray line) with 1-σ scatter (gray region), and color-code points by Hα FWHM.We also indicate the solar metallicity(Asplund et al. 2021) and shade the region where [Nii]/Hα > 0.8, the latter of which is likely to be contaminated to some extent by AGN emission.Notably, in this region Hα emission is broadest when compared to the rest of the source.In both sources the gas-to-dust ratio appears to decline with increasing metallicity, although this trend is more prominent in SPT2147-50.In the bottom panels we also show models fromRémy-Ruyer et al. (2014) andAniano et al. (2020), which are discussed further in §3.3.
TAH is supported by an appointment to the NASA Postdoctoral Program (NPP) at NASA Goddard Space Flight Center, administered by Oak Ridge Associated Universities under contract with NASA.The SPT is supported by the NSF through grant OPP-1852617.J.D.V. and K.P. acknowledge support from the US NSF under grants AST-1715213 and AST-1716127.J.D.V. acknowledges support from an A. P. Sloan Foundation Fellowship.JSS is supported by NASA Hubble Fellowship grant #HF2-51446 awarded by the Space Telescope Science Institute, which is operated by the Association of Universities for Research in Astronomy, Inc., for NASA, under contract NAS5-26555.D.N. acknowledges support from the US NSF under grant 1715206 and Space Telescope Science Institute under grant AR-15043.0001M.A. acknowledges support from FONDECYT grant 1211951, ANID+PCI+INSTITUTO MAX PLANCK DE AS-TRONOMIA MPG 190030, ANID+PCI+REDES 190194 and ANID BASAL project FB210003.JWST is operated by the Space Telescope Science Institute under the management of the Association of Universities for Research in Astronomy, Inc., under NASA contract no.NAS 5-03127.The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.This paper makes use of the following ALMA data: ADS/JAO.ALMA#2018.1.01060.S and ADS/JAO.ALMA#2021.1.00252.S. ALMA is a partnership of ESO (representing its member states), NSF (USA) and NINS (Japan), together with NRC (Canada), MOST and ASIAA (Taiwan), and KASI (Republic of Korea), in cooperation with the Republic of Chile.The Joint ALMA Observatory is operated by ESO, AUI/NRAO and NAOJ.