<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>JWST Early Release Science Program TEMPLATES: Targeting Extremely Magnified Panchromatic Lensed Arcs and Their Extended Star Formation</title></titleStmt>
			<publicationStmt>
				<publisher>ApJ</publisher>
				<date>12/27/2024</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10626778</idno>
					<idno type="doi">10.3847/1538-4357/ad7501</idno>
					<title level='j'>The Astrophysical Journal</title>
<idno>0004-637X</idno>
<biblScope unit="volume">978</biblScope>
<biblScope unit="issue">1</biblScope>					

					<author>Jane R Rigby</author><author>Joaquin D Vieira</author><author>Kedar A Phadke</author><author>Taylor A Hutchison</author><author>Brian Welch</author><author>Jared Cathey</author><author>Justin S Spilker</author><author>Anthony H Gonzalez</author><author>Prasanna Adhikari</author><author>M Aravena</author><author>Matthew B Bayliss</author><author>Jack E Birkin</author><author>Emmy Bursk</author><author>Scott C Chapman</author><author>Håkon Dahle</author><author>Lauren A Elicker</author><author>Travis C Fischer</author><author>Michael K Florian</author><author>Michael D Gladders</author><author>Christopher C Hayward</author><author>Rose Hewald</author><author>Lily A Kettler</author><author>Gourav Khullar</author><author>Seonwoo Kim</author><author>David R Law</author><author>Guillaume Mahler</author><author>Sangeeta Malhotra</author><author>Eric J Murphy</author><author>Desika Narayanan</author><author>Grace M Olivier</author><author>James E Rhoads</author><author>Keren Sharon</author><author>Manuel Solimano</author><author>Athish Thiruvengadam</author><author>David Vizgan</author><author>Nikolas Younker</author><author>TEMPLATES_collaboration</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[<title>Abstract</title> <p>This paper gives an overview of Targeting Extremely Magnified Panchromatic Lensed Arcs and Their Extended Star formation (TEMPLATES), a JWST Early Release Science program that targeted four extremely bright, gravitationally lensed galaxies, two extremely dusty and two with low attenuation, as templates for galaxy evolution studies with JWST. TEMPLATES obtains a common set of spectral diagnostics for these 1.3 ≤<italic>z</italic>≤ 4.2 galaxies, in particular H<italic>α</italic>, Paschen<italic>α</italic>, and the rest-frame optical and near-infrared continua. In addition, two of the four targets have JWST coverage of [O<sc>iii</sc>] 5007 Å and H<italic>β</italic>; the other two targets have JWST coverage of polycyclic aromatic hydrocarbon 3.3<italic>μ</italic>m and complementary Atacama Large Millimeter/submillimeter Array data covering the [C<sc>ii</sc>] 158<italic>μ</italic>m emission line. The science goals of TEMPLATES are to demonstrate attenuation-robust diagnostics of star formation, map the distribution of star formation, compare the young and old stellar populations, and measure the physical conditions of star formation and their spatial variation across the galaxies. In addition, TEMPLATES has the technical goal to establish best practices for the integral field units within the NIRSpec and MIRI instruments, both in terms of observing strategy and in terms of data reduction. The paper describes TEMPLATES’s observing program, scientific and technical goals, data reduction methods, and deliverables, including high-level data products and data reduction cookbooks.</p>]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Introduction</head><p>This is the overview paper for Targeting Extremely Magnified Panchromatic Lensed Arcs and Their Extended Star formation (TEMPLATES), a 54 hr JWST observing program that was part of the Director's Discretionary Early Release Science (ERS) initiative, with program ID (PID) 1355. TEMPLATES pairs the exquisite spatial resolution and multiplexed spectroscopic capabilities of JWST with the natural telescopes that are strong gravitational lenses. The science goals of TEMPLATES are to spatially resolve the star formation in four gravitationally lensed galaxies, and to characterize the physical conditions of star formation across a broad range of dust obscuration. The program website is accessible online,<ref type="foot">foot_0</ref> as well as its GitHub repository. <ref type="foot">32</ref>The ERS initiative is a set of 13 JWST observing programs, totaling &#8764;450 hr of Director's Discretionary Time, that were selected in 2017 through competitive peer review. In addition to the usual selection criteria of scientific merit, ERS programs were also solicited to serve the scientific user community: to obtain representative data sets early in the mission lifetime, to support community preparation of Cycle 2 and 3 proposals, to engage a broad cross section of the astronomical community, and to help users become familiar with JWST data and JWST's scientific capabilities. To support these community service goals, the ERS programs were preferentially scheduled early in the first year of JWST science operations.</p><p>TEMPLATES accomplishes the ERS goals by conducting compelling extragalactic science, by generating data cubes and derived data products with high signal-to-noise ratio (SNR) and high dynamic range, and by exercising four science instrument modes and a wide variety of setups within those modes: four NIRSpec integral field spectroscopy (IFS) grating/filter setups, six NIRCam imaging filters, seven MIRI imaging filters, and two of the three MIRI Medium Resolution Spectrograph (MRS) grating settings. TEMPLATES' key deliverables include science-ready data products and high-level science products, lens models, and Python notebooks that document how we reduced the data, by using a combination of the jwst pipeline, third party tools, and our own custom steps. Our goal in releasing these notebooks is to enable the user community to efficiently process their own data sets, particularly in the spectroscopic modes MIRI/MRS and NIRSpec/IFS, since these are widely used modes of JWST with broad scientific applicability, where the data reduction has been particularly difficult.</p><p>This paper is organized as follows. Section 2 summarizes the scientific context and the philosophy that informed the TEMPLATES program. Section 3 summarizes the science goals, and Section 4 the technical goals. Section 5 describes the target selection and design of the observations. Section 6 describes at length how we reduced the data, including issues encountered and mitigated. Section 7 takes a step back and explores the lessons learned from this early JWST observing program, which should influence the design, execution, and data processing of subsequent programs. Section 8 describes the deliverables that TEMPLATES is releasing, most notably high-level science-ready data products, and Jupyter Python notebooks that document exactly how we reduced the data. Section 9 closes the paper.</p><p>All calculations assume the Planck P. <ref type="bibr">Collaboration et al. (2020)</ref> cosmology unless otherwise indicated.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Scientific and Technical Context</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1.">Galaxies Across the Full Range of Dustiness</head><p>The optical and infrared backgrounds have roughly equal power at wavelengths above and below 3.5 &#956;m (M. G. <ref type="bibr">Hauser 1992)</ref>, which strongly implies that both unobscured and obscured star formation were important over cosmic history. Spectacular examples of the obscured mode include submillimeter galaxies (SMGs), which include the most luminous, dustiest galaxies known (see the review by C. M. <ref type="bibr">Casey et al. 2014a.)</ref> By contrast, UV-bright galaxies selected by dropout techniques such as the Lyman break galaxies (LBGs) have low obscuration, and are far more common than SMGs, with much lower star formation rates (SFRs; see the review by A. E. <ref type="bibr">Shapley 2011.)</ref> Selection of UV-bright galaxies from deep surveys from the Hubble Space Telescope (HST) has revealed the star formation history of the Universe (P. Madau &amp; M. Dickinson 2014), a major accomplishment of modern astrophysics. However, these studies with HST relied on rest-frame UV continuum emission to trace star formation-a diagnostic that is extremely susceptible to attenuation by dust. Indeed, the most prodigiously star-forming galaxies, which have been found through large-area millimeter and submillimeter surveys like those performed by Herschel, Planck, and the South Pole Telescope (SPT; J. D. <ref type="bibr">Vieira et al. 2010</ref><ref type="bibr">Vieira et al. , 2013;;</ref><ref type="bibr">M. Negrello et al. 2010;</ref><ref type="bibr">J. L. Wardlow et al. 2013;</ref><ref type="bibr">K. C. Harrington et al. 2016;</ref><ref type="bibr">W. B. Everett et al. 2020</ref>) disappear entirely from HST surveys due to dust attenuation (e.g., F. <ref type="bibr">Walter et al. 2012;</ref><ref type="bibr">C.-C. Chen et al. 2015;</ref><ref type="bibr">J. Ma et al. 2015)</ref>.</p><p>Though both high-attenuation and low-attenuation galaxies are important to the cosmic history of star formation (J. A. <ref type="bibr">Zavala et al. 2021</ref>, especially their Figure <ref type="figure">7</ref>), the scientists who study each group have historically had almost no data in common, and therefore rarely attend the same conferences.</p><p>We were therefore motivated to study both highly obscured and unobscured galaxies with a common set of diagnostics. JWST is the first observatory that bridges the divide between low-attenuation and high-attenuation galaxies, because it can obtain a common set of spectral diagnostics across the full range of dust attenuation. Thanks to its tremendous sensitivity <ref type="bibr">(J. Rigby et al. 2023)</ref>, JWST can obtain the polycyclic aromatic hydrocarbon (PAH) dust features in lensed galaxies even when the obscuration is very low. Such dust diagnostics were extremely difficult for Spitzer to obtain spectroscopically in the distant Universe (J. R. <ref type="bibr">Rigby et al. 2008;</ref><ref type="bibr">K. Men&#233;ndez-Delmestre et al. 2009</ref>). Likewise, JWST can obtain rest-frame optical spectral diagnostics for z &gt; 3 galaxies even when the obscuration is very high; such restframe optical spectra simply did not exist for highly obscured galaxies before JWST.</p><p>Further, JWST can obtain the emission line Paschen &#945; at &#955; = 1.8751 &#956;m (hereafter Pa&#945;) for galaxies with little regard for attenuation. Pa&#945; is the gold standard diagnostic of SFR in the nearby Universe (A. <ref type="bibr">Alonso-Herrero et al. 2006</ref>), as it is extremely robust to attenuation and, as a hydrogen recombination line, it directly measures the recombination rate, and thus (in equilibrium) the ionization rate. While Pa&#945; is the best SFR diagnostic available, it may not be perfect; it is possible that Pa&#945; may be optically thick in the most obscured galaxies (J. M. <ref type="bibr">Simpson et al. 2017;</ref><ref type="bibr">S. Jin et al. 2022)</ref>. While it was extremely difficult for Spitzer to measure Pa&#945; for galaxies in the distant Universe (C. <ref type="bibr">Papovich et al. 2009;</ref><ref type="bibr">W. Rujopakarn et al. 2012)</ref>, with JWST these measurements were expected to be routine.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2.">The Advantage of Gravitational Lensing</head><p>The physical scales corresponding to the diffraction limit of current telescopes do not permit the study of the internal processes of distant galaxies. Gravitational lensing offers a way to push past this physical limit, to discern important structures such as star-forming regions and star clusters. Accordingly, numerous programs with HST and now JWST have targeted strongly lensed galaxies.</p><p>Some worked examples illustrate this point. The diffraction limit of HST, 0 034 at &#955; = 0.4 &#956;m, corresponds to a physical scale of 300 pc at z = 1.5 and 240 pc at z = 4. These are the same physical scales achieved by JWST at 1.1 &#956;m, the wavelength at which the telescope becomes diffraction limited (C.-P. <ref type="bibr">Lajoie et al. 2023;</ref><ref type="bibr">J. Rigby et al. 2023;</ref><ref type="bibr">M. W. McElwain et al. 2023)</ref>. Such unlensed spatial resolution can discern largescale properties such as bulges and disks, but will blur out all but the largest star-forming regions and stellar clusters.</p><p>For the examples above, in cases of isotropic lensing magnification, the physical resolution scales as the square root of the strong lensing magnification factor ( m ~), a magnification of &#956; = 25 enables spatial resolution of &#8776;60 and 50 pc at z = 1.5 and z = 4, respectively; in cases of high shear where most of the magnification is in one dimension, the spatial resolution will be even smaller. Thus, gravitational lensing provides the only way to access the internal physical scales that are important for galaxy evolution, like the scales of star clusters, over most of cosmic time.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3.">Specific JWST Context</head><p>JWST&#700;s incredible sensitivity <ref type="bibr">(J. Rigby et al. 2023</ref>) has revealed galaxies out to very high redshift (E. Curtis-Lake et al. <ref type="formula">2023</ref>), and captured their rest-frame optical and rest-frame UV spectral diagnostics (e.g., A. J. <ref type="bibr">Bunker et al. 2023;</ref><ref type="bibr">F. D'Eugenio et al. 2024;</ref><ref type="bibr">J. Matthee et al. 2023;</ref><ref type="bibr">M. Tang et al. 2023;</ref><ref type="bibr">S. Fujimoto et al. 2023</ref>.) Though JWST's striking images have captured the public's imagination (K. M. <ref type="bibr">Pontoppidan et al. 2022)</ref>, three-quarters of the general observing time in the first 2 years has gone to spectroscopy (70% in Cycle 1 33 and 77% in Cycle 2 34 ), and 77% in Cycle 3. 35 All four of JWST's science instruments have spectroscopic capabilities. Spectroscopic programs to harvest the deep fields are measuring the SFRs, physical conditions, and gas kinematics of galaxies across cosmic time.</p><p>Given their ability to push past the diffraction limit, studies of gravitationally lensed galaxies have proven popular for JWST, with 19 approved programs in the first 2 years of science. Given our team's interests in studying galaxy evolution using gravitationally lensed galaxies, we proposed for ERS the program TEMPLATES, a spectroscopy-focused program to study four lensed galaxies that span a large parameter space of attenuation, redshift, and SFR. Available imaging before the JWST launch for the four targeted sources is shown in Figure <ref type="figure">1</ref>. Figure <ref type="figure">2</ref> shows the proposed depths along with the spectral energy distributions (SEDs) for all our sources. TEMPLATES not only pioneered lensed galaxy science with JWST, the program also demonstrated highly effective methods of taking and reducing data from JWST, especially IFS from the NIRSpec and MIRI science instruments.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.4.">Early Spectroscopic Results with JWST</head><p>Most of the initial papers examining JWST spectroscopy of galaxies used the NIRSpec multi-object spectroscopy (MOS) mode (e.g., A. C. <ref type="bibr">Carnall et al. 2023;</ref><ref type="bibr">A. J. Bunker et al. 2023;</ref><ref type="bibr">E. Curtis-Lake et al. 2023;</ref><ref type="bibr">R. L. Larson et al. 2023)</ref>, rather than Figure <ref type="figure">1</ref>. The TEMPLATES sample. The HST filters used were F390W, F775W, and F110W for SGAS1723+34; F606W, F814W, and F110W for SGAS1226+21; and F140W for the two SMGs. The ALMA band is the rest-frame 160 &#956;m continuum. A 3&#8243; scale bar is shown to illustrate the approximate size of the NIRSpec integral field unit (IFU) field of view (FOV). The TEMPLATES galaxies are all highly magnified, with sizes that fit in the FOVs of the JWST IFUs. The sources are all aligned with north up and east left.</p><p>33 <ref type="url">https://www.stsci.edu/files/live/sites/www/files/home/jwst/science- planning/user-committees/jwst-users-committee/_documents/jstuc-0421- jwst-cycle1-review-package.pdf</ref> 34 <ref type="url">https://www.stsci.edu/files/live/sites/www/files/home/jwst/science- planning/user-committees/jwst-users-committee/_documents/jwst-cycle2- peer-review-results.pdf</ref> 35 <ref type="url">https://www.stsci.edu/files/live/sites/www/files/home/jwst/science- planning/user-committees/jwst-users-committee/_documents/jstuc-0324- cycle3-review-chen.pdf</ref> the NIRSpec IFS mode or the MIRI spectroscopic modes (MRS and LRS). A notable exception was the ERS program Q3D (PI: D. Wylezalek), which analyzed NIRSpec/IFS spectra (D. <ref type="bibr">Wylezalek et al. 2022;</ref><ref type="bibr">A. Vayner et al. 2024;</ref><ref type="bibr">S. Veilleux et al. 2023)</ref>. In retrospect this trend makes sense: while MOS is the most complex operational mode on board JWST, MOS data are simpler to reduce than data from the IFS modes. For NIRSpec MOS spectroscopy in the default configuration, the spectra of spatially adjacent microshutters are subtracted from the targeted microshutter, a process that removes much of the detector's pattern noise. This detector noise is significant for NIRSpec, and the NIRSpec IFS mode has no comparable way to remove it; instead the noise must be corrected at the exposure level. We believe this detector noise issue has been a main impediment to publishing science results from NIRSpec IFS mode to date; we describe this residual noise and its mitigation in Section 6.4.</p><p>For the MIRI MRS mode, cosmic-ray showers have been the largest barrier to early publication; we discuss those issues and their mitigation in Section 6.5.</p><p>Mindful of these trends, in this paper we spend considerable effort documenting our data reduction methods for IFS for both NIRSpec and MIRI. We hope that the community can apply our methods to efficiently obtain high-quality science-ready data from similar JWST observing programs.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Science Goals</head><p>TEMPLATES was built around four science goals:</p><p>1. Demonstrate attenuation-robust SFR diagnostics for distant galaxies. 2. Map the distribution of star formation in distant galaxies. 3. Compare the young and old stellar populations. 4. Measure the physical conditions of star formation, and their spatial variation.</p><p>We now discuss each of these science goals in turn.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.">Demonstrate Attenuation-robust Star Formation Rate Diagnostics for Distant Galaxies</head><p>What is the relation between obscured and unobscured star formation? How does one reconcile discrepancies between SFRs measured in the UV and the far-infrared? Does the light of different star formation indicators even come from the same locations in galaxies? Studies of nearby galaxies like GOALS (L. <ref type="bibr">Armus et al. 2009</ref>) and SINGS (R. C. <ref type="bibr">Kennicutt et al. 2003)</ref> have measured all the major SFR diagnostics: UV continuum, far-infrared continuum, H&#945;, Pa&#945;, and PAHs. Diagnostics calibrated to these local samples may not we well suited to the redshifted Universe, because we know that galaxies have experienced tremendous evolution in size, SFR surface density, star formation efficiency, and gas supply. Unfortunately, highredshift galaxy samples typically have an SFR measured either from the rest-frame UV continuum or from the rest-frame farinfrared continuum; rarely do the samples, observables, or indeed research communities intersect. For instance, vigorously star-forming (SFR &gt; 100 M e yr -1 ) galaxies are always accompanied by large amounts of dust attenuation. The inferred SFRs in such galaxies from H&#945; and far-infrared can be discrepant by an order of magnitude (e.g., T. <ref type="bibr">Takata et al. 2006</ref>; C. M. <ref type="bibr">Casey et al. 2017)</ref> or even 2 orders of magnitude (C. C. <ref type="bibr">Hayward et al. 2018)</ref>.</p><p>For LBGs (i.e., those with significant escaping UV emission) it is notoriously difficult to measure dust properties and farinfrared luminosities (e.g., <ref type="bibr">Watson et al. 2015;</ref><ref type="bibr">Knudsen et al. 2017;</ref><ref type="bibr">N. Laporte et al. 2017)</ref>. A primary goal of TEMPLATES is to empirically calibrate the SFR estimators in a sample of distant galaxies spanning a broad range of SFR, attenuation, and stellar mass, and to do so on resolved scales corresponding to the individual star-forming regions within said galaxies. These calibrations will be used by the JWST user community to inform observations, survey strategies, and interpretation of observables. In addition to using H&#945; and H&#946; to measure attenuation-corrected SFR, we make the first spatially resolved measurements in distant galaxies of Pa&#945;, the gold standard indicator of SFR.</p><p>TEMPLATES also spatially resolves the PAH 3.3 &#956;m line (B. <ref type="bibr">Siana et al. 2009)</ref>, which is observable by JWST out to z = 7, and is 3 times brighter than Pa&#945;. Together, these measurements of spatially resolved, attenuation-robust star formation diagnostics provide common observables across a broad sample of distant galaxies.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.">Map Star Formation in Distant Galaxies</head><p>A generic prediction of simulations is that cold gas should accrete onto galactic disks. Some models predict that at cosmic noon (z &#8764; 1), high accretion rates of cold gas should lead to high gas surface densities, resulting in unstable disks that violently fragment into kiloparsec-scale clumps (D. <ref type="bibr">Kere&#353; et al. 2005;</ref><ref type="bibr">A. Dekel &amp; Y. Birnboim 2006;</ref><ref type="bibr">R. Genzel et al. 2011)</ref>. Indeed, HST deep fields have revealed that more than half of 1 &lt; z &lt; 3 star-forming galaxies appear to have large  T. <ref type="bibr">Shibuya et al. 2016</ref>), which might be evidence for cold flow accretion. Determining the properties of such clumps provides critical tests of these theoretical models. However, these clump sizes are uncomfortably close to the HST diffraction limit. In fact, HST studies of gravitationally lensed galaxies found no preferred size at 1 kpc, instead resolving star-forming regions on spatial scales as small as could be probed, r &#8764; 30-100 pc (T. A. <ref type="bibr">Jones et al. 2010;</ref><ref type="bibr">R. C. Livermore et al. 2012</ref><ref type="bibr">R. C. Livermore et al. , 2015;;</ref><ref type="bibr">T. L. Johnson et al. 2017</ref><ref type="bibr">T. L. Johnson et al. , 2017;;</ref><ref type="bibr">A. Cava et al. 2018;</ref><ref type="bibr">M. Dessauges-Zavadsky et al. 2019;</ref><ref type="bibr">E. Iani et al. 2021;</ref><ref type="bibr">J. S. Spilker et al. 2022)</ref>. Absent lensing, HST&#700;s normal spatial resolution will blur this highly clumpy star formation into an apparently smooth exponential disk (see Figure <ref type="figure">2</ref> of J. R. <ref type="bibr">Rigby et al. 2017)</ref>. Moreover, any highly extincted regions drop out in such data.</p><p>The interstellar medium (ISM) pressure is significantly higher in high-redshift galaxies than in local star-forming galaxies, which facilitates the formation of H 2 , allowing molecular clouds to cool and collapse (e.g., <ref type="bibr">Popping et al. 2014)</ref>. While giant molecular clouds in the Milky Way and local galaxies follow well-known scaling relations, such as that between the cloud size and line width, the limited observations of cloud-like structures at high redshift indicate that they lie significantly above the local relations (A. M. <ref type="bibr">Swinbank et al. 2015;</ref><ref type="bibr">M. Dessauges-Zavadsky et al. 2019;</ref><ref type="bibr">J. S. Spilker et al. 2022)</ref>, likely as a consequence of the increased ISM pressure. Direct, detailed studies of star formation at high redshift are extremely important and relevant for models of galaxy evolution.</p><p>To produce the extreme SFRs observed in high-redshift SMGs, theoretical models have appealed to a diverse range of processes, such as gas-rich major mergers (e.g., S. <ref type="bibr">Chakrabarti et al. 2008;</ref><ref type="bibr">D. Narayanan et al. 2010)</ref>, violent disk instabilities (e.g., D. <ref type="bibr">Ceverino et al. 2015;</ref><ref type="bibr">C. G. Lacey et al. 2016</ref>), significant gas infall from the intergalactic medium (D. <ref type="bibr">Narayanan et al. 2015;</ref><ref type="bibr">C. C. Lovell et al. 2021)</ref>, or hybrid processes (C. C. <ref type="bibr">Hayward et al. 2011</ref><ref type="bibr">Hayward et al. , 2012</ref><ref type="bibr">Hayward et al. , 2013))</ref>. Even then, producing a realistic population of SMGs is challenging (C. C. <ref type="bibr">Hayward et al. 2021)</ref>.</p><p>From spatially resolved observations of H&#945; and Pa&#945;, TEMPLATES will measure the morphology, clump luminosity distribution, and clump size distribution of attenuationcorrected star formation in four highly magnified galaxies. TEMPLATES will characterize the sizes and luminosities of star-forming clumps as small as 30 Doradus and Carina, and enable spatially resolved measurements of the physical conditions of star-forming regions.</p><p>This science goal requires mapping the attenuation inside galaxies, which prior to the JWST era, had not been done for field galaxies in the distant Universe except by stacking at 0.5 kpc resolution (E. J. <ref type="bibr">Nelson et al. 2016)</ref>. Attenuation is starting to be mapped using JWST slitless spectroscopy and the Balmer decrement on spatial scales down to 0.3 kpc for field galaxies <ref type="bibr">(J. Matharu et al. 2023)</ref>, with larger samples coming. The only way to measure attenuation on smaller spatial scales for distant galaxies is with strongly lensed galaxies (e.g., V. <ref type="bibr">Patricio et al. 2019;</ref><ref type="bibr">A. Claeyssens et al. 2023)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3.">Compare the Young and Old Stellar Populations</head><p>A key result from the Sloan Digital Sky Survey (SDSS) and Spitzer is the so-called "star formation main sequence:" that a galaxy&#700;s stellar mass predicts its total SFR <ref type="bibr">(J. Brinchmann et al. 2004;</ref><ref type="bibr">K. G. Noeske et al. 2007</ref>). TEMPLATES will, for the first time at these redshifts, obtain the attenuation-robust specific star formation rates (sSFR &#8801; SFR/M * ) for both LBGs and SMGs, thus placing them in the SFR-M * plane, and contextualizing their stages of galaxy evolution. Due to extreme dust obscuration, stellar masses of SMGs could not be reliably measured with pre-JWST facilities <ref type="bibr">(Micha&#322;owski et al. 2012;</ref><ref type="bibr">J. Ma et al. 2015)</ref>. Furthermore, SFRs are typically measured heterogeneously, preventing direct, robust comparisons between various star formation observables, and calling into question the very concept of a main sequence of star formation.</p><p>By resolving the sSFR relation in these galaxies, the TEMPLATES data will shed light on the origin of these scaling relations that link a galaxy's past and present. Comparing the spatial distribution of SFR and stellar mass will show how star formation progresses spatially over time and whether galaxies form from the inside out or the outside in (P. <ref type="bibr">S&#225;nchez-Bl&#225;zquez et al. 2007</ref>; E. <ref type="bibr">P&#233;rez et al. 2013)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.4.">Measure the Physical Conditions of Star Formation, and their Spatial Variation</head><p>We set the NIRSpec integration times to ensure adequate SNR in H&#946; and H&#945; for individual regions within the target galaxies. Such integrations are sufficiently deep to also obtain the full suite of diagnostics from rest-frame 0.44 to 0.80 &#956;m, for two of the four TEMPLATES targets. These diagnostics measure the metallicity, ionization parameter, and pressure of the nebular regions of these galaxies. The TEMPLATES spatially resolved JWST spectra also measure how much these diagnostics vary spatially within each galaxy. This enables an estimate of the extent to which gradients may bias integratedgalaxy measurements; stacking of HST grism spectra (J. R. <ref type="bibr">Trump et al. 2011)</ref>, and now JWST NIRISS grism spectra <ref type="bibr">(J. Matharu et al. 2023)</ref>, indicate the effect may be significant.</p><p>For the LBGs these observations will improve upon the spatial resolution and SNR available from the ground. Due to the extreme dust content in SMGs, optical spectroscopy has been notoriously difficult and biased toward galaxies with unobscured sight lines at lower redshift (e.g., A. M. <ref type="bibr">Swinbank et al. 2004;</ref><ref type="bibr">T. Takata et al. 2006;</ref><ref type="bibr">C. M. Casey et al. 2014b</ref><ref type="bibr">C. M. Casey et al. , 2017;;</ref><ref type="bibr">A. L. R. Danielson et al. 2017)</ref>. Basic measurements, like metallicity and reddening, had to wait for TEMPLATES. In addition to providing the first robust, unbiased optical spectroscopic study of SMGs, TEMPLATES provides the first spatially resolved, rest-frame optical spectra of dusty, luminous galaxies.</p><p>In addition, by comparing the rest-frame optical emission line diagnostics to the mid-infrared continuum and PAH strengths, TEMPLATES can quantify any contribution from active galactic nuclei (AGN) to the observed energy output. The mid-infrared continuum, which is emitted by hot dust grains around the central engine of a supermassive black hole, is one of the most distinctive ways of identifying AGN, including those that are heavily obscured by dust.</p><p>For the two TEMPLATES targets that are SMGs (SPT0418 -47 and SPT2147-50), the NIRSpec, MIRI/MRS, and NIRCam data from TEMPLATES were partially analyzed by J. <ref type="bibr">Cathey et al. (2024)</ref>, J. E. <ref type="bibr">Birkin et al. (2024)</ref>, and J. S. <ref type="bibr">Spilker et al. (2023)</ref>. H&#945; and the [N II] doublet are detected at high SNR in the integrated NIRSpec spectra; the [N II]/H&#945; ratio, and thus the metallicity, are spatially resolved for these galaxies. Both sources show apparently near-solar metallicities, and SPT2147-50 in particular displays regions where [N II]/H&#945; is greater than unity, which is interpreted as evidence for previously undetected AGN emission. Previous analysis of SPT0418-47 suggested that it was a kinematically cold rotating disk (F. <ref type="bibr">Rizzo et al. 2020)</ref>, but the improved spatial resolution from NIRCam allowed J. <ref type="bibr">Cathey et al. (2024)</ref> to identify an interacting companion at a separation of 4.4 kpc, with a mass ratio of approximately 4-1. The 3.3 &#956;m PAH feature was also detected in this source by the MIRI/MRS (J. S. <ref type="bibr">Spilker et al. 2023)</ref>, currently the most distant and only spatially resolved PAH detection at high redshift. The MIRI data suggest that SPT0418-47 does not obviously host an obscured AGN, and that large spatial variations in the ratio of PAH to IR luminosity make this PAH feature a complicated tracer of star formation (at best).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.5.">Ancillary Science</head><p>The JWST data and rich ancillary data sets enable additional science beyond these four science goals. Some of these include: comparison of the dust mass and gas mass as revealed by the Atacama Large Millimeter/submillimeter Array (ALMA) with the current star formation as revealed by JWST; comparison of the galactic outflows seen in H&#945; by JWST with outflows seen in rest-frame UV spectra from Keck and Magellan and molecular absorption from ALMA; determination of whether outflows depend on star formation surface density; searches for dwarf galaxies and dark matter substructure in the foreground lenses; determination of the AGN contribution to the midinfrared emission from SMGs; and studies of the lenses themselves (two galaxy clusters and two early-type galaxies).</p><p>We look forward to and encourage papers using TEM-PLATES data that will be written by the community beyond our team, enabled by the high-level data products we are providing.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Technical Goals</head><p>In addition to scientific merit, the ERS programs were chosen to obtain representative data sets early in the life cycle of the JWST mission, to obtain information that would help the community prepare observing proposals, and to engage a broad cross section of astronomers and planetary scientists. As such, TEMPLATES had two technical and community-oriented goals, which we now discuss.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1.">Optimize the JWST Spectroscopic Pipeline</head><p>Based on our experience with the early days of the Spitzer mission, we anticipated that generating science-ready spectroscopic data cubes would be the most challenging aspect of this program. We expected, at the least, to have to tune the parameters in the pipeline that control background subtraction, removal of fringing and stray light from MRS data, removal of the microshutter array (MSA) imprints from NIRSpec/IFS data, and outlier detection. In addition, before launch it was not at all clear how impactful would be the optional IFS calibration frames (dedicated off-source backgrounds for both MIRI and NIRSpec, and MSA leak calibration frames for NIRSpec). Therefore, TEMPLATES set the technical goal of shaking out and optimizing the JWST spectroscopic pipeline for both MIRI/MRS and NIRSpec/IFS. We have done so, and describe our best practices in Section 6.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.">Establish Best Practices for Integral Field Unit</head><p>Spectroscopy with JWST Following the best practices described by JDox before launch (JWST User Documentation (JDox) 2016), our observations included off-source background observations for both MIRI and NIRSpec, as well as NIRSpec leak calibration files, which were intended to correct light leaking through the closed MSA onto the detector. Before launch, it was not at all clear whether dedicated background observations are required, or whether it would be possible to derive the background from the periphery of on-source frames. Similarly, it was not clear before launch how necessary were MSA leak calibrations; we therefore obtained MSA leak calibrations for every dither position, with the idea that we could test whether on-source dithering alone, or dithering plus a smaller number of leakcals, could sufficiently correct IFS data for leaks from stuck open MSA shutters and print through. Our plan was to determine best practices for these types of observations, such that future IFS observations could be streamlined to the extent possible. Section 7.4 presents our proposed best practices for observing galaxies with NIRSpec IFS mode.</p><p>Table 1 Target List Short Target Name Full Target Name R.A. (J2000) Decl. (J2000) SPT0418-47 SPT-S J041839-4751.8 04:18:39.6790 -47:51:52.68 SGAS1723+34 SGAS J1723+3411 17:23:36.4060 +34:11:54.69 SGAS1226+21 SGAS J122651.3+215220 12:26:51.2960 +21:52:19.97 SPT2147-50 SPT-S J214720-5035.9 21:47:19.0120 -50:35:54.50 Note. Coordinates are for the center of the NIRSpec/IFS pointing. considered all far-infrared-selected lensed systems (e.g., Herschel and Planck selected). To be considered, we required (a) a spectroscopic redshift; (b) high-resolution imaging with ALMA and HST; (c) a robust lens model; (d) Einstein radius small enough (&lt;1 5) to fit inside the NIRSpec integral field unit (IFU) field of view (FOV); (e) high spatial resolution resolved spectroscopy of molecular lines with ALMA; and (f) visibility within the ERS window. The two selected targets are SPT0418-47 and SPT2147-50. Table <ref type="table">2</ref> lists the properties of these targets. The table shows that these four targets span a range of luminosity, SFR, stellar mass, and attenuation. All targets have published lens models (J. S. <ref type="bibr">Spilker et al. 2016</ref><ref type="bibr">Spilker et al. , 2020;;</ref><ref type="bibr">K. Sharon et al. 2022)</ref>, and extensive imaging and spectroscopic ancillary data (including HST, ALMA, Keck, and Magellan).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2.">Observations</head><p>Table <ref type="table">3</ref> lists the observations that comprise the TEM-PLATES program. In all, there were 53.7 hr of successful observations, plus 10 hr of observations that failed due to a bug in the ground system, and were reobserved. Here, we summarize the strategy for each observing mode. Further details can be found in the Astronomer's Proposal Tool (APT) file for our program, which can be retrieved using APT from STScI by querying for PID 1355.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2.1.">Imaging</head><p>We designed imaging observations for TEMPLATES using the NIRCam (M. J. <ref type="bibr">Rieke et al. 2023)</ref> and MIRI (G. S. <ref type="bibr">Wright et al. 2023</ref>) instruments, covering 4-6 NIRCam filters and seven MIRI filters per target, to efficiently (in terms of observing time) obtain photometry sufficient to measure stellar mass, constrain the presence of an AGN, and map the PAH features. For the two LBGs, observed fluxes from SDSS were used to estimate the integration time, conservatively assuming an even flux distribution; depths were adjusted to achieve SNR &gt; 30 per spatial resolution element. For many filters, this was achieved in the shortest practical integration time. For the SMGs, CIGALE SED fits were used to estimate the integration time, and the depth set to an SNR &gt; 10 per resolution element. For both the LBGs and SMGs we relax the SNR thresholds for the few cases where the integration per filter would exceed 10 minutes.</p><p>For the NIRCam observations, we selected filters for each target that span a broad wavelength range and would enable robust, resolved SED fitting when used in combination with MIRI imaging. The original plan was to use six filters for all targets (F115W, F150W, F200W, F277W, F356W, and F444W); however, after receiving the data for SPT0418-47, we decided, given the low SNR in the SW filters, that it would be better to instead go deeper in F200W, dropping the F115W and F150W observations. The total exposure times ranged from 290 to 2750 s for targets with six-filter data; for SPT2147-50 the F200W total exposure time was 5840 s. The associated total execution times can be found in Table <ref type="table">3</ref>. Observations were taken using the INTRASCA dither type with 2-3 primary dithers. Observations were taken with readout patterns BRIGHT 1/2 or SHALLOW2 to avoid saturation of nearby galaxies.</p><p>All four targets were imaged by MIRI in seven imaging filters (F560W, F770W, F1000W, F1280W, F1500W, F1800W, and F2100W). The total execution times for all filters are listed in Table <ref type="table">3</ref>. Across the four targets and seven filters our exposure times vary from 1 to 14 minutes. All four targets were supposed to use a dither pattern optimized for a point source, as the sources were small in size compared to the imaging FOV. On examining the MIRI imaging data for the first two targets (SGAS1226+21 and SGAS1723+34), we noticed an implementation issue with the dither pattern, where the source was not centered in the imaging FOV, and was instead closer to the edge by the last filter in our observation sequence, which was the longest wavelength filter (F2100W). Our program instrument scientist for MIRI suggested we change the dither pattern to be optimized for extended sources for the remaining two targets</p><p>Table 2 Properties of the Targets property SGAS1723+34 SGAS1226+21 SPT2147-50 SPT0418-47 Kind of galaxy LBG LBG SMG SMG Redshift 1.3293 &#177; 0.0002 2.9252 &#177; 0.0009 3.7604 &#177; 0.0002 4.2246 &#177; 0.0004 J. R. Rigby et al. (2021) J. R. Rigby et al. (2018b) C. Reuter et al. (2020) C. Reuter et al. (2020) Magnification (&#956;) -+ 52.7 1.2 3.3 Table 3 JWST Observation Log for ERS Program TEMPLATES (PID 1355) Observation Target Template Execution Time (hr) Start Date and Time (UT) Settings Note Successful observations SPT0418-47 NIRCam Imaging 1.00 2022 Aug 11 16:05:20 F115W, F150W, F200W, F277W, F356W, F444W SPT0418-47 MIRI Imaging 2.10 2022 Aug 22 05:27:35 F560W, F770W, F1000W, F1280W, F1500W, F1800W, F2100W SPT0418-47 NIRSpec/IFS 3.16 2022 Oct 7 03:15:45 G395M/F290LP Sky NIRSpec/IFS 2.53 2022 Oct 7 05:29:45 G395M/F290LP B SPT0418-47 MIRI/MRS 2.72 2022 Jul 27 11:12:21 Setting B A SPT0418-47 MIRI/MRS 2.67 2022 Aug 8 04:45:24 Setting C A SGAS1226+21 NIRCam Imaging 0.94 2022 Dec 16 11:28:55 F115W, F150W, F200W, F277W, F356W, F444W SGAS1226+21 MIRI Imaging 1.33 2022 Jun 21 00:55:07 F560W, F770W, F1000W, F1280W, F1500W, F1800W, F2100W SGAS1226+21 NIRSpec/IFS 3.82 2022 Dec 31 11:37:48 G235H/F170LP Sky NIRSpec/IFS 3.10 2022 Dec 31 14:20:08 G235H/F170LP B SGAS1226+21 MIRI/MRS 1.64 2022 Dec 16 12:36:06 Setting C Sky MIRI/MRS 1.50 2022 Dec 16 13:52:56 Setting C, with on-source F560W simultaneous imaging B SGAS1723+34 NIRCam Imaging 1.38 2022 Jun 28 10:18:15 F115W, F150W, F200W, F277W, F356W, F444W SGAS1723+34 MIRI Imaging 1.79 2022 Jun 29 23:37:44 F560W, F770W, F1000W, F1280W, F1500W, F1800W, F2100W SGAS1723+34 NIRSpec/IFS 5.67 2022 Aug 31 04:57:03 G140H/F100LP, G395H/F290LP Sky NIRSpec/IFS 5.04 2022 Aug 31 09:25:42 G140H/F100LP, G395H/F290LP B SPT2147-50 NIRCam Imaging 0.99 2022 Sep 5 21:07:35 F200W, F277W, F356W, F444W SPT2147-50 MIRI Imaging 2.03 2022 Sep 7 01:55:02 F560W, F770W, F1000W, F1280W, F1500W, F1800W, F2100W SPT2147-50 NIRSpec/IFS 2.78 2022 Oct 16 04:02:49 G395M/F290LP Sky NIRSpec/IFS 2.16 2022 Oct 16 06:04:41 G395M/F290LP B SPT2147-50 MIRI/MRS 1.77 2023 Jun 9 10:12:56 Setting B Sky MIRI/MRS 1.10 2023 Jun 9 12:05:40 Setting B, with on-source F1000W simultaneous imaging B SPT2147-50 MIRI/MRS 1.25 2023 Jun 12 06:23:11 Setting C Sky MIRI/MRS 1.25 2023 Jun 12 07:56:06 Setting C, with on-source F560W simultaneous imaging B Failed observations, later reobserved successfully SGAS1723+34 NIRSpec/IFS 9.88 2022 Jul 15 13:39:18 G140H/F100LP, G395H/F290LP A; C Note. JWST observations are ordered by status (succeeded or failed), then target, then observing mode. Note A: observation includes dedicated offset background. Note B: observation is a dedicated offset background. Note C: rescheduled by WOPR 88493 as observation 27 in this program.</p><p>(SPT0418-47 and SPT2147-50), as the fix for the dither implementation issue was not going to be in place before these targets were observed.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2.2.">NIRSpec Spectroscopy</head><p>For each of the four galaxies in our sample, we used the NIRSpec IFU (T. <ref type="bibr">B&#246;ker et al. 2022)</ref>, which provides spatially resolved imaging spectroscopy for a 3&#8243; &#215; 3&#8243; FOV, with 0 1 &#215; 0 1 spatial sampling. Each galaxy had IFS observations taken with one grating to target their rest-frame optical/nearinferred light. The lowest-redshift galaxy in the sample, SGAS1723+34, was observed with a second NIRSpec grating setting to cover Pa&#945;.</p><p>The NIRSpec/IFS observations for each source, including grating-filter pair, exposure times, etc., are summarized in Table <ref type="table">3</ref>. For the two LBGs, we used the high-resolution gratings (R &#8764; 2700) to achieve the highest spectral resolution possible with this instrument, to resolve kinematics within these sources. For the two SMGs, we used the mediumresolution gratings (R &#8764; 1000) to achieve higher throughput for these fainter sources. This was a conservative choice, given that the attenuation of these objects was not well known prior to JWST.</p><p>NIRSpec/IFS observations were taken with the NIRSIRS2 readout pattern (B. J. <ref type="bibr">Rauscher et al. 2017)</ref>, as our sources are faint, and used small-size cycling dithers. Following prelaunch guidance from JDox, we obtained dedicated off-source background pointings and leak calibrations for all sources at each dither position.</p><p>The initial NIRSpec observations of SGAS1723+34 did not complete successfully. The telescope pointing drifted, causing the target to fall outside the IFU FOV. This issue was quickly noticed, and the full set of SGAS1723+34 NIRSpec observations were scheduled to be retaken (WOPR 88493). However, we found that the first set of exposures taken with the G140H grating on the science target completed successfully before the drift began. We therefore ended up with twice the exposure time in this grating. We include this extra set of G140H in our final data reduction.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2.3.">MIRI MRS Spectroscopy</head><p>TEMPLATES uses the MIRI MRS integral field observing mode for three galaxies, primarily targeting Pa&#945; for all targets except the lowest-redshift source (SGAS1723+34, for which NIRSpec rather than MIRI captured Pa&#945;), and 3.3 &#956;m PAH emission for both SMGs. Given the faint expected fluxes, we did not attempt to capture the PAH emission in MRS for the two LBGs.</p><p>Given the expected observed redshifts of the targeted emission lines, SGAS1226+21 was observed using only the LONG ("C") MRS grating, while SPT0418-47 and SPT2147 -50 were observed using both the LONG and MEDIUM ("B") gratings; see Table <ref type="table">3</ref>. Because the MRS observes four disjoint wavelength ranges in each grating setting, several other spectral lines such as Brackett &#945;, Brackett &#946;, Paschen &#946;, and molecular hydrogen rotation lines fall in the observed bandpass for each galaxy, although these features are typically expected to be fainter than the primary lines of interest.</p><p>All MIRI/MRS observations used the SLOWR1 detector readout pattern and a standard four-point extended-source dither pattern. The total on-source exposure times varied between about 40 and 60 minutes, depending on the predicted flux of the targeted line. The MRS observations were accompanied by four-point dedicated background observations for an equal integration time. The MIRI imager in the F560W or F1000W filter was used during the background exposures. For SPT2147-50, we realized that we could use target offset coordinates to ensure that the source was covered by the imager during the MRS background exposures, resulting in very deep F560W and F1000W imaging (&#8764;2400 and 2800 s, compared to &#8764;100 s in the dedicated imaging exposures). We did the same for the SGAS1226+21 MIRI/MRS observations and obtained a deep F560W image (&#8764;1 hr). Although the dither pattern is not optimized to sample the imager point-spread function (PSF), the extra depth will prove useful in the future to verify the astrometric registration and provide very deep observations of the target sources.</p><p>Since the MRS FOVs are not fully concentric at all wavelengths it was not possible to simultaneously center the targets in every spectral channel. We adopted a mixture of centroiding optimized for all four channels ("primary channel" set to "ALL") and optimized for individual channels containing the spectral line of interest. Ultimately, due to the effects of cosmic-ray shower artifacts (see Section 6.5), it would have been more advantageous to always center the targets in the respective target channels, because our shower removal technique relies on having source-free areas on all sides of the source.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.">Data Reduction and Calibration</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.1.">Downloading Raw Data</head><p>We downloaded the processed raw data (level 1b) from MAST. The TEMPLATES github site publishes a simple script, adapted from one written by Richard Shaw of STScI, which downloads any given data set given the proposal ID and type of data desired. We have found this script much easier to use than the JWST MAST interface that was available for the first 1.5 yr of the JWST science mission.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.2.">MIRI Imaging</head><p>Given TEMPLATES' focus on spectroscopy, the MIRI imaging was shallow compared to other JWST ERS programs. Initial inspection of the level 3 products from MAST portal showed vertical striping patterns in all the filters and targets, indicating the presence of detector 1/f noise. We experimented with several of the striping methods being used by the community to determine the best way to destripe our data. Uncalibrated images were downloaded from the MAST portal and processed through the jwst calibration pipeline (H. <ref type="bibr">Bushouse et al. 2023</ref>) version 1.11.3 using calibration reference data system pipeline (CRDS) mapping (pmap) 1106. We implemented stripe removal for the imaging data by removing column and row trends after stage 2 of the pipeline ( * cal.fits files).<ref type="foot">foot_4</ref> These destriped stage 2 data were processed through the stage 3 pipeline, and the images after stage 3 were used for all analysis.</p><p>Apart from the striping issue, we also came across an issue with persistence arising from a strong cosmic-ray hit that is not currently addressed by the automatic pipeline. A cosmic-ray hit during the F770W observation of SGAS1226+21 at an oblique angle. This was flagged correctly in the pipeline for the processing of the F770W images, but created a nonlinear response in the same region of the detector for the observations of subsequent filters (F1000W through F2100W). The cosmic ray was not identified in the subsequent filters because it did not produce a "jump" in the count rate ramps during those later filters; it was present throughout the exposure. To mitigate this issue, we changed the data quality flag in stage 1 of the observations for filters F1000W through F2100W, using a DS9 region file in detector coordinates. Dithering helped get acceptable level 3 products for this source despite this issue. The function to implement this fix is available on our team&#700;s github.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.3.">NIRCam Imaging</head><p>For the NIRCam imaging, we started with the level 2a data products. The first step in our processing workflow is to perform a custom destriping of the level 2a data, as the 1/f detector noise is significant for these short exposures. This procedure also corrects for residual amplitude offsets between different amplifiers in the detector. The destriping proceeded as follows: (1) an object mask of the individual frame was created by thresholding an initial version of the processed and stacked science image, which was then propagated back to the individual frame level assuming the initial astrometric solution;</p><p>(2) all unmasked pixels were used to compute and subtract a median value for each of the four amplifier regions; and then (3) each masked pedestal-corrected amplifier region was filtered using a horizontal median filter 512 &#215; 1 pixels in extent, the result of which was then subtracted. Figure <ref type="figure">3</ref> shows single exposure images of SGAS1723+34 before and after the destriping procedure.</p><p>The destriped images were then processed using the standard jwst pipeline (version 1.11.0). We have posted in the TEMPLATES github repository the parameter files used to reduce each source. The NIRCam Jupyter notebooks we publish show how to generate these parameter files.</p><p>Most parameters for NIRCam reduction did not need tweaking; however, initially we found it necessary to turn off alignment to Gaia in the pipeline, as that led to considerable astrometric offsets between filters. With newer pipeline and reference file updates, astrometric alignment using Gaia Data Release 3 (DR3) as the absolute reference catalog shows astrometric registration at the subpixel level in the NIRCam LW filters. However, NIRCam SW still has issues with astrometric registration. <ref type="foot">37</ref> To overcome this issue we created a catalog with the Gaia DR3 registered shortest wavelength filter of NIRCam LW (i.e., F277W) and used it as the absolute reference catalog in the tweakreg step of stage 3 in the imaging pipeline. We found it necessary to do this correction for each module separately and hope that future reference file updates will fix this issue. Ongoing updates to the calibration data have also led to increasingly unified photometry between instruments and improved consistency with HST. We defined the photometric calibration files that were released 2022 October 3 to be the standard, and have either updated the photom values for earlier reductions, or rereduced the data. Finally, we used WebbPSF (M. D. <ref type="bibr">Perrin et al. 2014)</ref> to generate model PSFs based on wave-front sensing data from before and after each of our NIRCam observations. The JWST wave front is measured roughly every 2 days (J. <ref type="bibr">Rigby et al. 2023)</ref>. In modeling galaxy morphology <ref type="bibr">(J. Cathey et al. 2024</ref>, submitted to the Astrophysical Journal) using GALFIT (C. Y. <ref type="bibr">Peng et al. 2006)</ref>, we found no appreciable difference as to whether the "before" or "after" PSF was used; this makes sense given the excellent stability of the JWST PSF (C.-P. <ref type="bibr">Lajoie et al. 2023;</ref><ref type="bibr">M. W. McElwain et al. 2023</ref>).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4.">NIRSpec Spectroscopy</head><p>We reduced the NIRSpec/IFS data using the jwst calibration pipeline version 1.11.3, using CRDS pmap 1105. The pipeline processes the data in the following order: (1) stage 1: detector-level corrections and ramp fitting made to the individual raw data products from the instrument; (2) stage 2: instrument mode-specific calibrations, including world coordinate system (WCS) and wavelength solutions, flagging of failed-open MSA shutters, flat-fielding, path loss correction, and flux calibration, made to individual exposures; and (3) stage 3: data combined from multiple exposures for a given observation, resampled onto a common grid and coadded into a single data cube.</p><p>The jwst pipeline offers many customization options, and we outline our parameter choices here. For stage 1, pipeline versions 1.9.6 and later include an expand_large_events option, which is designed to expand large jump detections to eliminate "snowball" artifacts. This step is turned off by default, but here we choose to include it to better mask snowballs. The stage 2 pipeline is nominally where dedicated leakcals would be subtracted from the data. However, we choose not to subtract the leakcals taken as part of this observing program. The observed fields do not contain many bright stars, so fairly little light leaks through the MSA onto the detectors. Including leakcals therefore only adds detector noise, so we choose not to use them.</p><p>Finally, for stage 3, we use a two-pronged approach in removing outliers from the data. First, we use the updated outlier_detection step in the pipeline (in jwst versions 1.11.3 and later) to remove the majority of the outliers present. However, additional outliers remain after this step that require further processing. We developed a layered sigma-clipping routine to postprocess the final reduced data cubes and remove the remaining outliers. In brief, this routine sigma clips the offgalaxy spaxels in a uniform manner, then takes the galaxy spaxels and clips them in layers, separated into 3-4 bins set by the SNR of the brightest line in the spectrum. We briefly describe this routine in Section 6.4.3 and further detail the algorithm and code release in T. A. <ref type="bibr">Hutchison et al. (2024)</ref>.</p><p>The NIRSpec pipeline cube building step involves a 3D drizzling step that combines multiple dithers into a single data cube (D. R. E. <ref type="bibr">Law et al. 2023)</ref>. The standard cube building step produces a final cube with 0 1 square spaxels, however the spaxel size is tunable through the scalexy parameter. Many of the TEMPLATES sources have an abundance of substructure visible in the high-resolution imaging; some of this structure is not well resolved with the undersampled 0 1 native spaxel size. We therefore additionally produced cubes with 0 05 pixels. We find that these higher spatial resolution data cubes better resolve small structures in our lensed arcs without introducing additional artifacts.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4.1.">Residual Pattern Noise from NIRSpec Data</head><p>The NIRSpec data show correlated pattern noise along columns. This noise is caused by millikelvin temperature fluctuations in the SIDECAR ASIC chips that control and read out the NIRSpec detectors (B. Rauscher 2024, private communication) The resulting residual pattern noise is not removed by the IRS 2 noise-reduction readout mode (B. J. <ref type="bibr">Rauscher et al. 2017)</ref>. In our data, the rms of this noise is about 2 e -in each of the two detectors. This pattern noise changes on short timescales, such that one exposure cannot be used to correct the noise in the next exposure, because the noise has changed too much. As a result, dedicated background observations cannot remove this noise; instead, it must be removed at the exposure level.</p><p>This noise is most problematic for IFS mode, since there can be no subtraction of spectra from nearby rows, as is the case for fixed-slit mode or for MOS mode when a source is nodded up and down among several shutters. However, it has also proven beneficial to correct MSA data for this pattern noise (A. L. <ref type="bibr">Strom et al. 2023;</ref><ref type="bibr">J. Chisholm 2024, private communication)</ref>.</p><p>In the spirit of developing best practices for observing and data reduction, in the next subsection we describe in detail how we corrected for this noise, including our tests of algorithms developed by three different groups.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4.2.">Removing Residual Pattern Noise: The Great NIRSpec Bake Off</head><p>We tested three different methods of removing the residual NIRSpec pattern noise, and visually compared both the 2D count rate images and the final 1D spectra to determine which method works best. We wanted to test the methods on both NIRSpec detectors, NRS2 and NRS1, since they have different noise properties; NRS2 is noisier. This required examining highresolution spectra, which cover both detectors, rather than medium-resolution spectra, which span only NRS1. We therefore chose the SGAS1723+34 data for these experiments, since that TEMPLATES target has NIRSpec observations taken with two different high-resolution gratings. The pattern noise is most prominent in the G140H grating, since the zodiacal background is relatively low at those blue wavelengths (J. R. <ref type="bibr">Rigby et al. 2023)</ref>. We applied the pattern noise removal methods after the stage 1 pipeline is run, on the output count rate * rate.fits files.</p><p>The first noise removal method we tested was the "basic median" approach, developed by Stephan Birkmann of the NIRSpec instrument development team, and provided to TEMPLATES by STScI's JWST help desk. This method calculates a column-by-column median, then subtracts that median from each pixel in the column. To avoid removing signal, this method utilizes only the dark pixels located between the IFU traces and the fixed-slit region. This region is covered by the support structure around the NIRSpec slits, and is thus blind to astrophysical light. However, relatively few rows are utilized compared to the full size of the detector.</p><p>The second strategy we tested was a "rolling median" approach, developed by Ian Wong and provided to TEM-PLATES through private communication. This method applies a median filter of length 201 pixels to each column. The median filter allows for variation across the width of the detector, which should provide a more accurate representation of the detector background than the basic median approach. This method requires that the detector backgrounds be sampled across the full span of the detector face, and thus must first mask out all illuminated pixels. The mask is created using a combination of the data quality flags from the rate files (to mask out cosmic-ray snowballs) and the spectral traces in the stage 2 pipeline output calibrated cal.fits files, which mark all nonilluminated pixels as NaN. The fixed slits must be masked manually, as they are not captured in the cal files. The median filter length of 201 pixels was chosen to be long enough to span the largest masked sections of the detector, and thus produce a smooth background to be subtracted.</p><p>The third and final strategy we tested is the NSClean software, described by B. <ref type="bibr">J. Rauscher (2024)</ref>. This method models the detector noise in Fourier space for each pixel column. Like the rolling median, this method samples the full width of the detector, providing a robust estimate of the instrument backgrounds.</p><p>Properly masking the illuminated pixels is critical for the success of the NSClean method. We use a similar masking technique as described above for the rolling median method, in which we remove IFU spectral traces using the cal files, and manually remove fixed slits, to produce a mask that blocks out all illuminated pixels. Masking snowball artifacts caused by cosmic-ray impacts is also important. We tested two methods to remove these artifacts prior to running NSClean-removing every flagged jump detection from the pipeline-produced data quality array, and manually removing large snowballs identified by eye. We found that masking all pixels with a flagged jump detection caused additional artifacts to appear in the rate files after applying NSClean, likely from large sections of detector pixel columns being masked leading to underconstrained fitting. Therefore, when running NSClean, we do not mask snowballs using the data quality flags, but instead visually inspect each rate file for prominent snowballs prior to fitting. Any large snowballs found are masked manually.</p><p>We visually compared the cleaned rate files that emerged from each of the three noise-reduction methods; see Figure <ref type="figure">5</ref>. Each method provides a marked improvement over the original rate images, offering some correction to both the overall detector bias and the vertical banding. Of the three methods, NSClean best removes the pattern noise. In second place is the rolling median, which also produces an acceptable result. The basic median approach leaves the most residual detector noise of our three tested strategies.</p><p>Ultimately, we want to know how each of these solutions translates to a final reduced spectrum. We therefore ran each cleaned set of * rate.fits files through the stage 2 and stage 3 pipelines, following the same standard procedure for each set (i.e., not subtracting leak calibrations or background exposures). Visual inspection of the resulting spectra lead to the same conclusion as the rate files, namely that NSClean provides the cleanest end product (Figure <ref type="figure">6</ref>). The basic median cleans the spectra considerably relative to the initial product, however some residual correlated noise features remain. The rolling median approach removes the vertical striping in the rate files (and thus the "wiggles" in the final spectra). However we found it to be a less reliable method than NSClean to remove overall offsets in the continuum level (e.g., the original negative continuum flux seen in the blue spectrum in Figure <ref type="figure">6</ref>). We therefore conclude that NSClean provides the best result of the three methods. We therefore apply NSClean to all our NIRSpec/IFS observations, and recommend its use for other programs (as discussed in Section 7).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4.3.">Custom Outlier Rejection of the NIRSpec Data Cubes</head><p>For the first year of JWST science operations, the outlier detection and rejection step of the jwst pipeline, which works on the individual dithers, was not working correctly for NIRSpec/IFS data. Initially this was due to issues with the NIRSpec astrometric solution, such that the algorithm was comparing source brightness for pixels that should sample the same sky position in multiple dithers, but in fact were not. For the remainder of the first year, the main issue was overzealous behavior by the algorithm, such that real, valid strong emission lines were being flagged and removed from our data. In 2023 July, an update dramatically improved the performance of the jwst pipeline's outlier rejection <ref type="bibr">(versions 1.11.3 and later)</ref>.</p><p>In order to be able to work with the TEMPLATES data for the first year, our team developed a custom method of outlier rejection (T. A. <ref type="bibr">Hutchison et al. 2024)</ref>, which works on the drizzled data cubes (D. R. E. <ref type="bibr">Law et al. 2023)</ref>. Now that the pipeline's default outlier rejection is working much better, this custom approach is less essential. That said, we find that using the pipeline's updated outlier rejection, and then a final cleanup of the drizzled data cubes using our custom method, produces better results than does the pipeline alone. T. A. <ref type="bibr">Hutchison et al. (2024)</ref> describe our algorithm, and quantitatively compare the effectiveness of the two outlier detection approaches for TEMPLATES NIRSpec/IFS data. We release the outlier rejection code itself on GitHub. 38  We release final outlier-rejected data cubes as deliverables; see Section 8. We also release the masks that separate target spaxels from the rest of the cubes, which are used by our custom outlier rejection code. The creation and use of these masks are described in T. A. <ref type="bibr">Hutchison et al. (2024)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.5.">MIRI MRS</head><p>Our basic data reduction workflow is described in more detail in J. S. <ref type="bibr">Spilker et al. (2023)</ref>, including our implementation of a method to remove the so-called cosmic-ray shower artifacts (I. <ref type="bibr">Argyriou et al. 2023)</ref>. In brief, we generally followed the default jwst pipeline procedures as of version 1.8.4, with a few additional processing steps. After the Detector1 pipeline was run, we used the dedicated background exposures to identify and flag additional bad pixels not already masked by the pipeline bad pixel map. In the Spec2 pipeline, we performed a 2D pixel-by-pixel background subtraction by median combining the individual background exposures. This allows for the removal of detector and flat-field systematic effects that otherwise limit our ability to recover faint, extended emission. We ran the Spec3 pipeline in its default configuration to produce a 3D data cube for each of the four MRS channels in each observed grating setting (D. R. E. <ref type="bibr">Law et al. 2023)</ref>.</p><p>By far the dominant instrumental systematic that remains in the data after pipeline processing is residual unflagged pixels resulting from the cosmic-ray showers. These artifacts, illustrated in Figure <ref type="figure">7</ref>, limit the sensitivity of the data. Showers are present in both the on-and off-source exposures, resulting in both positive and negative artifacts in the final data cubes. While a preliminary treatment of these artifacts in the jwst pipeline has significantly improved these artifacts for some science programs, this treatment does not currently work well for SLOW-mode data such as ours. Due to the geometry of the showers and the MRS slicing optics, the showers result in stripes in the 3D cubes that are mostly aligned with the cube's x-dimension. As described in detail in J. S. <ref type="bibr">Spilker et al. (2023)</ref>, we removed these artifacts by estimating the level of the stripes using a series of rows in the cube x-dimension after masking regions with real source emission and subtracting this "stripe template" from the cube.</p><p>Our current data processing produced MRS cubes that are science ready (e.g., J. S. <ref type="bibr">Spilker et al. 2023</ref>), but we are continuing to investigate improved data reduction methods. Among these include alternative methods to identify and remove the effects of showers, which we expect will be an active area of research in the coming years. We also continue to investigate the best method of obtaining and using dedicated background exposures for MRS science data.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.">Lessons Learned</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.1.">Use the Latest Versions of Pipeline and Calibration Products</head><p>The jwst pipeline code and calibration files changed frequently, with considerable impact on the results of data reduction, during the first 1.5 yr of JWST science operations. Odd results (such as flux densities changing by several orders of magnitude) can occur if an older pipeline version is run using the latest calibration products. This mismatch can easily happen, since the calibration products are updated automatically from the calibration server (see below), but the user must manually update the pipeline. We therefore recommend that users regularly update the pipeline using the method specified in the documentation. 39 It also seems important, after updating either the pipeline or the calibration files, to rerun all steps of the pipeline, rather than "mixing and matching" versions.</p><p>To keep the calibration files up-to-date, one should set the environment variable CRDS_SERVER_URL to point to the CRDS webpage. 40 This will cause the calibration files to automatically update each time the pipeline is run, assuming the computer is connected to the Internet. The TEMPLATES NIRSpec reduction notebook demonstrates how to set this environmental variable. 38 github.com/aibhleog/baryon-sweep (DOI:10.5281/zenodo.10668905).</p><p>39 <ref type="url">https://jwst-pipeline.readthedocs.io/en/latest/getting_started/install.html</ref> 40 <ref type="url">https://jwst-crds.stsci.edu/</ref> 7.2. 1/f Noise in Short Imaging Exposures TEMPLATES spent most of its observing time on spectroscopy. Imaging exposure times were designed to reach SNR goals given the expected range of SEDs. As such, given the fantastic sensitivity of JWST <ref type="bibr">(J. Rigby et al. 2023)</ref>, these integration times were short, only a few hundred seconds per NIRCam filter. These short imaging times also helped TEMPLATES fit into the &#8764;50 hr average size of ERS programs. However, such short integration times are especially subject to 1/f noise, which required custom destriping routines to mitigate. In retrospect, such extremely short integration times may not have been a good idea. We therefore recommend that users consider requesting more than the bare minimum of imaging integration time needed for bright extragalactic targets, since longer integration times make the data easier to reduce, as well as support ancillary science.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.3.">Correcting Residual Detector Noise in NIRSpec Spectroscopy</head><p>As detailed in Section 6.4.2, the NIRSpec detector shows pattern noise, measured at a level of &#8764;2 e -rms in our data, which if not corrected, will dominate the noise in integral field mode, and may contribute substantially to noise in the multiobject and fixed-slit modes. In IFS mode, if not corrected, this pattern noise alters-substantially so, for our targets-the flux density and shape of the extracted continuum. We therefore recommend that users apply the NSClean algorithm (B. J. Rauscher 2024). Indeed, for v1.13.0 and later, NSClean has now been integrated as an optional step in the NIRSpec pipeline, based in part on our demonstration of its effectiveness for the TEMPLATES data.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.4.">Strategies for NIRSpec Integral Field Spectroscopy Mode</head><p>When planning the TEMPLATES program, from the information available before launch, we could not determine by how much dedicated background observations and leak calibrations would improve the quality of the data. In the spirit of ERS, we therefore decided to take these calibrations, measure their effect, and then recommend to other users whether these calibrations were in fact needed.</p><p>When a dedicated "background" observation is used in spectroscopy, it is usually intended to subtract one or both of two very different effects: (a) the real astrophysical background on the sky, and (b) residual detector noise. For NIRSpec, it was not understood before launch which, if either, of these effects might require dedicated backgrounds, so the JDox documentation recommended taking these calibrations. Below, we explain why we believe that dedicated backgrounds are not needed for NIRSpec/IFS observations like those made with TEMPLATES.</p><p>For NIRSpec, the relative contributions of astrophysical background and detector background will depend on the filter and grating. NIRSpec prism mode will be dominated by Poisson noise from the background sky emission (a combination of zodiacal light, Galactic emission, and scattered light; see J. R. <ref type="bibr">Rigby et al. 2023)</ref>, not detector readout noise. By contrast, for the medium and high spectral resolution gratings, detector noise (aka, read noise) will dominate; this is especially obvious in the blue highresolution modes, where the zodiacal background levels are relatively low. As such, for the medium-and high-resolution gratings used in TEMPLATES, it is far more important to address the residual detector noise, than to precisely subtract out the astrophysical backgrounds.</p><p>TEMPLATES demonstrates that dedicated background observations are not required to remove the astrophysical backgrounds from NIRSpec data for sparse extragalactic fields, for two reasons. First, the infrared astrophysical backgrounds are sufficiently well known (T. <ref type="bibr">Kelsall et al. 1998)</ref>, and the scattered light, stray light, and self-emission properties of the observatory are sufficiently well understood (J. R. <ref type="bibr">Rigby et al. 2023)</ref>, that the background spectrum can be reliably predicted using the JWST Background tool. <ref type="foot">41</ref> Second, out of the plane of the Galaxy, the astrophysical backgrounds are generally dominated by zodiacal light, which is smooth on arcsecond scales; thus, so long as the target does not completely fill the small (&#8764;3&#8243;) FOV of the NIRSpec IFU, the background levels can be measured from the periphery. Thus, for extragalactic targets that do not completely fill the NIRSpec IFU FOV, dedicated off-target background observations need not be obtained.</p><p>The other justification for taking dedicated backgrounds would be to remove residual detector noise. However, the onorbit reality is that the NIRSpec pattern noise changes completely from exposure to exposure, since the pattern noise is caused by small rapid fluctuations in the temperature of the readout and control chips (B. J. Rauscher 2024). Thus, dedicated backgrounds are utterly useless for removing the residual detector noise, because the noise in the science exposures will be completely different from the noise in the background exposures. Instead, the noise must be corrected within each exposure, as we demonstrate in Section 6.4.2.</p><p>We therefore recommend that users not take dedicated background observations when using NIRSpec with the medium-or high-resolution gratings longward of 1.2 &#956;m for extragalactic targets. Only for the low-resolution (prism) mode may it make sense, since these observations will be dominated by background noise; or when the spectral shape at &#955; &lt; 1.2 &#956;m is important to the science goals. Even in these two cases, dedicated backgrounds may not be necessary since the background levels can be predicted using the JWST background tool, and can be measured from the periphery of the data cube, assuming the source does not fill the entire IFU.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.5.">Effect of Showers on MIRI MRS Spectroscopy</head><p>One unexpected result of cosmic-ray hits on the MIRI detectors has been the so-called shower artifacts. Current understanding suggests these showers arise as charge diffuses outward from the location of cosmic-ray hits, but unlike the near-infrared detectors, in MIRI these showers are typically not circular (or elliptical). Because the counts from the showers are much lower than typical cosmic-ray hits and can persist for long periods of time (in some cases even between integrations), the showers themselves are often not automatically identified and flagged by the pipeline's outlier detection strategies. Showers are long-duration events, and in severe cases can persist through a detector reset into the next exposure.</p><p>The TEMPLATES MRS data are severely impacted by these showers, which limit our ability to reach the full expected depth of the observations suggested by the ETC and other tools. In principle the effect of these showers should be able to be mitigated by using shorter integration times, since the number of pixels impacted by showers increases in longer exposures and only uncommonly severe showers persist through a detector reset. A larger number of short exposures, however, must be balanced against the read noise penalty. While TEMPLATES used a standard four-point dither pattern with individual integration times ranging from 600 to 900 s, shorter integration times would likely have resulted in lessened shower impacts. Before launch, STScI asked us to switch the MRS observations to the SLOWR1 detector readout pattern to lower data volume. In hindsight, a faster readout pattern would have allowed a more precise time sampling (and potential for flagging and removal) of showers, which would have decreased the fraction of data affected, although this is likely to be a small fraction of the total on-source time for most programs.</p><p>Although the current pipeline contains a preliminary algorithm that attempts to identify and flag cosmic-ray showers by approximating them as elliptical regions following strong cosmic-ray hits, we found that residual effects of the showers were still the limiting factor in our attempts to detect very faint spectral features. TEMPLATES has developed an algorithm, described more fully in J. S. <ref type="bibr">Spilker et al. (2023)</ref>, to fit for and remove these showers in the 3D data cube space. Due to the typical size of the showers on the detectors and the geometry of the slicing optics, the showers appear as horizontal stripes in the IFU-aligned cubes. The stripes can be both positive and negative, since showers in the dedicated background exposures are subtracted from the on-source data.</p><p>Briefly, we mask the region of the cube where real source emission was expected based on preexisting ALMA data. We then fit for a "stripe template" consisting of horizontal rows in the cube using a 25-channel running average in the spectral dimension. We allow for a linear slope from the left to the right half of each row, since the slicing optics are not perfectly aligned with the 2D detector coordinates and the showers have complex morphologies. The resulting cube after subtraction of the stripe template preserves the source flux but removes the strong striping artifacts. This technique only works if sufficient source-free pixels exist on either side of the source location. As such, it would have been better if the TEMPLATES sources had been centered in the FOV of the MRS channel of interest instead of a position optimized for the FOV of all four channels.</p><p>Clearly the best way to address the shower artifacts is to mitigate them before data are taken. Unfortunately shower mitigation, which drives toward a larger number of short exposures, conflicts with overall noise considerations pushing for few long exposures. For the TEMPLATES data specifically, a larger number of shorter integrations would likely have resulted in higher-quality data, but we stress that this may not be the case for all science programs. Future investigations into the statistics and prevalence of showers will be needed before concrete recommendations can be made.</p><p>We recommend that MRS users carefully consider the tradeoffs between cosmic-ray shower mitigation (favoring more short integrations) and overall detector noise (favoring few long integrations). We also recommend that the source be placed at the center of the aperture of the channel of primary interest (assuming only a single channel is of primary interest), to allow for a more robust estimate of the shower-induced striping in the cube from source-free pixels. If showers are present, our technique is able to remove the shower artifacts for cases where every bit of SNR is needed. We hope that continued improvements to the pipeline software will one day render our technique unnecessary. 7.6. Discovery of a Bug Affecting Target Groups Our observation 7, which executed on 2022 July 15 UT, was corrupted by an until-then-undiscovered bug in the ground system affecting the APT feature known as a target group, which allows a given observing sequence to be repeated for multiple targets within a target group, which minimizes the movement of mechanisms within the science instruments. The bug was not found in commissioning, which did not use target groups. Due to the bug, instead of chopping back and forth between the source and the off-source position, as the observation worked through the grating-filter combinations, the observation instead dithered further and further away from the source. We requested reobservation; the observation was rescheduled as observations 27 and 28, with a work-around of using separate source and sky targets to avoid the target group bug. The ground system was patched 2022 September to fix this bug (T. Keyes &amp; K. Peterson 2024, private communication). The other NIRSpec/IFS observations in this program also used the work-around.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.">Deliverables</head><p>TEMPLATES delivers two main kinds of products to the science user community.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.1.">Cookbooks</head><p>Concurrent with the publication of this overview paper, TEMPLATES is delivering how-to cookbooks, which show exactly how we reduced all of our data into science-ready form. These are Jupyter Python notebooks that use the jwst pipeline as well as our custom software. Our intent is that other users with similar data, especially MIRI/MRS and NIRSpec/IFS data, can simply follow our step-by-step notebooks to efficiently produce science-ready data products.</p><p>All our data reduction notebooks are available online. <ref type="foot">42</ref> We request that researchers follow the citation guidelines in each notebook.</p><p>Also in the notebook repository, we release a step-by-step guide to reducing the NIRSpec/IFS data from our program, which is intended to be digestible by researchers of any level of experience. This guide covers all relevant steps beginning with installing the JWST data reduction pipelines, through to producing generating sigma-clipped NIRSpec/IFS data cubes.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.2.">Science-ready JWST Data Products</head><p>TEMPLATES will release high-level science-ready data products such as fully reduced images and reduced spectral data cubes, as well as derived data products such as attenuation maps and lens models. The reduced data products will be made available on our MAST page in 2024 July. <ref type="foot">43</ref> The derived data products will be released as science papers using these products are published by our team.</p><p>Figure <ref type="figure">4</ref> shows continuum imaging in NIRCam and MIRI for our four sources. Details of the processing can be found in J. <ref type="bibr">Cathey et al. (2024)</ref>. Thanks to the spatial resolution of JWST and the magnification afforded by gravitational lensing, the galaxies are highly spatially resolved. The heterogeneity between the sources in our sample can clearly be seen by eye, along with resolved knots of star-forming regions. Figure <ref type="figure">8</ref> shows the integrated intensity (moment 0) of H&#945; and Pa&#945; for the four sources. All four sources are robustly detected and spatially resolved in H&#945;. Pa&#945; is detected in all sources except SGAS1226+21. The ratio of the H&#945; to Pa&#945;, as well as SED modeling the continuum, will allow us to construct resolved extinction maps of these sources. Details on the moment 0 maps can be found in J. E. <ref type="bibr">Birkin et al. (2023)</ref>, J. S. <ref type="bibr">Spilker et al. (2023)</ref>, and forthcoming publications.</p><p>The nondetection of Pa&#945; in SGAS1226+21 appears to be due to very low attenuation in this source, as indicated by the ratio of H&#946; to H&#945;. This hypothesis will be explored in future NIRCam short-wavelength (SW) filters F200W, F150W, and F115W were used for the two LBG sources, whereas long-wavelength (LW) filters F444W, F356W, and F277W were used for the two SMGs as the red, green, and blue (RGB) channels. For MIRI imaging, F1000W, F770W, and F560W were selected as the filters for RGB for all sources but one. The exception, SGAS1226+21, is only detected in F560W, so only that filter image is shown using the color map "bone." All images have been aligned with north up and east left, with a common scale bar of 0.&#8243;5 shown. papers both on a spatially integrated and spatially resolved basis.</p><p>8.3. Supporting Data from HST, Spitzer, and ALMA High-level science products from HST, Spitzer, and ALMA were delivered to STScI in 2022 July and released on MAST<ref type="foot">foot_9</ref> as part of Delivery 1 on 2022 October 5. <ref type="foot">45</ref> This first delivery includes pre-JWST lens models, and fully reduced, high-level HST, Spitzer, and ALMA data. We briefly describe these data products in this section.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.3.1.">SGAS1226+2152</head><p>We delivered reduced HST imaging data in Advanced Camera for Surveys F606W and F814W; and WFC3-IR F110W, F140W, and F160W. The details of the observation and data reduction are given in K. <ref type="bibr">Sharon et al. (2022)</ref>, and a map of the HST mosaic of the three main cluster cores that make up the foreground lens is given in Figure <ref type="figure">1</ref> of that paper. The Channel 1 and Channel 2 Spitzer data reduction process is described in M. K. <ref type="bibr">Florian et al. (2021)</ref>.</p><p>We provided two versions of strong lens model outputs for this cluster. Each model package contains the deflection, magnification, convergence, and shear maps, aligned to the same WCS solution as the HST imaging, for the best-fit model as well as a suite of 100 models taken from the Markov Chain Monte Carlo sampling of the parameter space, for the purpose of estimating uncertainties. Version 1 is our "best effort" pre-JWST lensing analysis, which is based all the existing HST imaging, and all the available spectroscopic information from the literature. The model is described in K. <ref type="bibr">Sharon et al. (2022)</ref>. For completeness, we also make public a previous version of the lens model, version 0, which was used in several publications <ref type="bibr">(Tejos et al. 2021;</ref><ref type="bibr">Dai et al. 2020;</ref><ref type="bibr">Solimano et al. 2021;</ref><ref type="bibr">M. Solimano et al. 2022)</ref>, and is described in <ref type="bibr">Tejos et al. (2021)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.3.2.">SGAS1723+34</head><p>We delivered reduced HST imaging data in WFC3-UVIS F390W and F775W and WFC3-IR F110W and F160W, and Channel 1 and Channel 2 Spitzer data. K. <ref type="bibr">Sharon et al. (2020)</ref> describe the HST data, data reduction, and strong lensing analysis. The Spitzer data are described in M. K. <ref type="bibr">Florian et al. (2021)</ref>, who also use this lens model in their analysis of the physical properties of the lensed galaxy.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.3.3.">SPT0418-47 and SPT2147-50</head><p>We provided reduced HST imaging data in WFC3-IR F140W of both fields, described in J. <ref type="bibr">Ma et al. (2015)</ref>. ALMA data of both targets are described in J. S. <ref type="bibr">Spilker et al. (2016)</ref>. SPT0418-47 has continuum data at rest-frame 120 &#956;m, 160 &#956;m, and 380 &#956;m, and SPT2147-50 has data at rest-frame 160 &#956;m, 300 &#956;m, 380 &#956;m, and 450 &#956;m. Both also have extensive (sub)millimeter spectroscopy from the same data sets. The right hand panels show the off-source spectra for each grating, created using the inverse of the source aperture. In each panel, blue lines show the extracted spectra before applying any 1/f noise correction, while orange lines show spectra after applying NSClean. Black dashed lines show the expected background calculated from the JWST Backgrounds Tool. The original spectra show both fluctuations and overall offsets in the continuum level caused by the 1/f noise in the detectors, while these noise features are removed by NSClean. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9.">Final Thoughts</head><p>This paper describes TEMPLATES, a JWST ERS program that was designed to optimize the study of galaxies with the JWST IFUs, by studying four very bright lensed galaxies. We intend this overview paper to serve as a definitive description of the observations, the data reduction methods, the Jupyter Python notebooks that document our reduction steps, and the high-level data product deliverables.</p><p>JWST is a transformative telescope that exceeds its (high) design expectations <ref type="bibr">(J. Rigby et al. 2023)</ref>, and has powerful multiplexed spectroscopic capabilities. It is therefore reasonable to expect that the most impactful discoveries from JWST, especially discoveries based on spectroscopic data, are still to come, as the scientific community learns how to fully harvest these complex data sets. We look forward to discoveries about the nature of star formation in galaxies from the TEMPLATES data set. We share the data reduction methods and code we have developed for TEMPLATES (Sections 6 and 8), and lessons learned including recommendations for users (Section 7), in the hopes that our efforts are broadly helpful to other researchers as they work with and publish results from JWST data. </p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="31" xml:id="foot_0"><p>https://sites.google.com/view/jwst-templates/</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="32" xml:id="foot_1"><p>https://github.com/JWST-Templates</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_2"><p>The Astrophysical Journal, 978:108 (19pp), 2025 January 01 Rigby et al.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_3"><p>The Astrophysical Journal, 978:108 (19pp), 2025 January 01Rigby et al.   </p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="36" xml:id="foot_4"><p>Following notebook https://github.com/STScI-MIRI/Imaging_ExampleNB/ blob/main/helpers/miri_clean.py.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="37" xml:id="foot_5"><p>https://github.com/spacetelescope/jwst/issues/7993</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="41" xml:id="foot_6"><p>https://jwst-docs.stsci.edu/jwst-other-tools/jwst-backgrounds-tool. This statement is true for wavelengths &#955; &gt; 1.2 &#956;m; the underlying background model used by the background tool is currently incorrectly extrapolating blueward of COBE's short-wavelength cutoff at 1.2 &#956;m.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="42" xml:id="foot_7"><p>github.com/JWST-Templates/Notebooks (DOI:10.5281/zenodo.10737011).</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="43" xml:id="foot_8"><p>https://archive.stsci.edu/hlsp/templates</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="44" xml:id="foot_9"><p>https://archive.stsci.edu/hlsp/templates/</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="45" xml:id="foot_10"><p>DOI:10.17909/zqax-2y86</p></note>
		</body>
		</text>
</TEI>
