# Geometric distortion and astrometric calibration of the JWST MIRI Medium Resolution Spectrometer

Polychronis Patapis, Ioannis Argyriou, David R. Law, Adrian M. Glauser, Alistair Glasse, Alvaro Labiano, Javier Álvarez-Márquez, Patrick J. Kavanagh, Danny Gasman, Michael Mueller, et al.

► To cite this version:

Polychronis Patapis, Ioannis Argyriou, David R. Law, Adrian M. Glauser, Alistair Glasse, et al. Geometric distortion and astrometric calibration of the JWST MIRI Medium Resolution Spectrometer. Astronomy & Astrophysics - A&A, 2024, 682, 10.1051/0004-6361/202347339. insu-04851595

HAL Id: insu-04851595

https://insu.hal.science/insu-04851595v1

Submitted on 20 Dec 2024

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Geometric distortion and astrometric calibration of the JWST MIRI Medium Resolution Spectrometer

Polychronis Patapis<fnref n="1" />, Ioannis Argyriou<fnref n="2" />, David R. Law<fnref n="3" />, Adrian M. Glauser<fnref n="1" />,
Alistair Glasse<fnref n="4" />, Alvaro Labiano<fnref n="5" />,<fnref n="6" />, Javier Álvarez-Márquez<fnref n="5" />, Patrick J. Kavanagh<fnref n="7" />,
Danny Gasman<fnref n="2" />, Michael Mueller<fnref n="8" />,<fnref n="9" />, Kirsten Larson<fnref n="3" />, Bart Vandenbussche<fnref n="2" />, David Lee<fnref n="4" />,
Pamela Klaassen<fnref n="4" />, Pierre Guillard<fnref n="10" />,<fnref n="11" /> and Gillian S. Wright<fnref n="4" />

Received 3 July 2023 / Accepted 13 October 2023

## ABSTRACT

**Context.** The Medium Resolution integral field Spectrometer (MRS) of the Mid-Infrared Instrument (MIRI) on board the James Webb Space Telescope (JWST) performs spectroscopy between 5 and 28 µm, with a field of view varying from ~13 to ~56 sq. arcsec. The optics of the MRS introduce substantial distortion and this needs to be rectified in order to reconstruct the observed astrophysical scenario.

**Aims.** We aim to use data from the JWST/MIRI commissioning and cycle 1 calibration phase to derive the MRS geometric distortion and astrometric solution, a critical step in the calibration of MRS data. These solutions come in the form of transform matrices that map the detector pixels to spatial coordinates of a local MRS coordinate system called α/β, to the global JWST observatory coordinates V2 and V3 (V2+V3).

**Methods.** For every MRS spectral band and each slice dispersed on the detector, we fit the transform of detector pixels to α/β by a two-dimensional (2D) polynomial, using a raster of point source observations. The dispersed trace of the point source on the detector was initially estimated by fitting a one-dimensional (1D) empirical function and then iterating on the first distortion solution using forward modelling of the point spread function model based on the *webbpsf python* package. A polynomial transform was used to map the coordinates from α/β to V2+V3.

**Results.** We calibrated the distortion of all 198 discrete slices of the MIRI/MRS integral field units and derived an updated field of view (FoV) for each MRS spectral band. The precision of the distortion solution is estimated to be better than one-tenth of a spatial resolution element, with a root mean square (rms) of 10 milli-arc-second (mas) at 5 µm, to 23 mas at 27 µm. Finally, we found that the wheel positioning repeatability causes an additional astrometric rms error of 30 mas.

**Conclusions.** We demonstrate the application of the MRS astrometric calibration strategy and analysis for all four integral field units and all spectral bands of the MRS that enable the calibration of MRS spectra. This is a critical step in the data pipeline of every MRS observation. The distortion calibration was folded into the JWST pipeline in the Calibration Reference Data System (CRDS) context (jwst_1094.pmap), meeting the pre-launch requirement, with an estimated total astrometric uncertainty of 50 mas.

**Key words.** instrumentation: spectrographs – techniques: imaging spectroscopy – methods: data analysis – infrared: general

## 1. Introduction

The Mid-Infrared Instrument (MIRI; Wright et al. 2015, 2023; Rieke et al. 2015b) is one of four science instruments on board the James Webb Space Telescope (JWST; Gardner et al. 2023) and it is the only instrument operating in the mid-infrared (MIR). The MIRI Medium Resolution Spectrometer (MRS; Wells et al. 2015; Argyriou et al. 2023) is an integral field spectrometer (IFS)

providing moderate-resolution spectroscopy (R ~ 4000 – 1500; Jones et al. 2023) over the wavelength range from 4.9 to 27.9 µm (Labiano et al. 2021; Argyriou et al. 2023). In the near-infrared (NIR; 0.6–5.3 µm) the Near Infrared Spectrometer (NIRSpec; Böker et al. 2023) also provides an IFS mode that is similar to the MRS.

The advantage of an IFS is that it retains information for both spatial coordinates of the astronomical scene being observed

<footnote n="1">¹ Institute of Particle Physics and Astrophysics, ETH Zürich, Wolfgang-Pauli-Str 27, 8093 Zürich, Switzerland
e-mail: polychronis.patapis@phys.ethz.ch</footnote>

<footnote n="2">² Institute of Astronomy, KU Leuven, Celestijnenlaan 200D, 3001 Leuven, Belgium</footnote>

<footnote n="3">³ Space Telescope Science Institute, 3700 San Martin Drive, Baltimore, MD, 21218, USA</footnote>

<footnote n="4">⁴ UK Astronomy Technology Centre, Royal Observatory, Blackford Hill Edinburgh, EH9 3HJ, Scotland, UK</footnote>

<footnote n="5">⁵ Telespazio UK for the European Space Agency, ESAC, Camino Bajo del Castillo s/n, 28692 Villanueva de la Cañada, Spain</footnote>

<footnote n="6">⁶ Centro de Astrobiología (CAB), CSIC-INTA, Ctra. de Ajalvir km 4, Torrejón de Ardoz, E-28850, Madrid, Spain</footnote>

<footnote n="7">⁷ Department of Experimental Physics, Maynooth University, Maynooth, Co. Kildare, Ireland</footnote>

<footnote n="8">⁸ SRON Netherlands Institute for Space Research, PO Box 800, 9700 AV Groningen, The Netherlands</footnote>

<footnote n="9">⁹ Sterrewacht Leiden, PO Box 9513, 2300 RA Leiden, The Netherlands</footnote>

<footnote n="10">¹⁰ Sorbonne Université, CNRS, UMR 7095, Institut d'Astrophysique de Paris, 98bis bd Arago, 75014 Paris, France</footnote>

<footnote n="11">¹¹ Institut Universitaire de France, Ministère de l'Enseignement Supérieur et de la Recherche, 1 rue Descartes, 75231 Paris Cedex 05,
France</footnote>
<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Illustration of MRS coordinate systems. Left: detector coordinates contain the 2D spectra projected by the IFU on the MIRI detectors as curved slices. Middle: local MRS slicer coordinates are changing from band to band and represent the alignment of the slicer optic, with α being the along-slice and β the across-slice coordinate. Right: JWST coordinate system V2+V3 is defined by the JWST Optical Telescope Element (OTE) and is shared among all instruments. Note: this panel is not to scale with the actual dimensions since the MRS FoV is very small.</figcaption></figure>

using image slicers (Allington-Smith 2006). The MRS employs one image slicer for each spectral channel (see Figs. 1 and 2). Each image slicer splits one of the spatial dimensions into distinct slices before dispersing the light. The number of slices depends on the physical geometry of the image slicer, optimised for the spectral and spatial resolution element of each MRS channel. The data that are imaged on the MRS detectors are akin to having multiple single slit spectra, one for each slice in a spectral channel. In order to reconstruct the scene observed on the sky one must map each pixel of the detector to a position in right ascension (RA), declination (Dec), and wavelength, accounting for the optical distortion that is typically present in IFS.

In this work, we present the derivation of the geometric distortion and astrometric calibration of the MRS, an essential product of the JWST data processing pipeline. The MRS is spatially and spectrally under-sampled at all wavelengths by design, and requires at least two dithered exposures to be Nyquist sampled. The sampling artefacts and cube reconstruction algorithm are detailed in Law et al. (2023). The optical distortion itself needs to be corrected to sub-pixel precision, since even small residuals can introduce systematic errors in the science products, given the under-sampled point spread function (PSF) core. A well calibrated distortion over the full field of view (FoV) and spectral range is required to maximise the optical quality of the instrument and restore the diffraction-limited performance provided by JWST that is distorted by the optics of the MRS. An accurate plate scale enables a consistent spectro-photometric calibration over the full FoV and reduces errors in the surface brightness estimation for extended sources (Gordon et al. 2022).

In Sect. 2, we introduce the relevant coordinate frames and transforms used in the JWST calibration pipeline and discuss the origin of the optical distortion in the MRS. In Sect. 3, we describe the different data sources used to derive the distortion calibration and the methods used to estimate the point source

traces on the detector. In Sect. 4, we detail the analysis steps that were used to derive the geometric and astrometric distortion transforms. Finally, in Sect. 5, we discuss the precision of the distortion solution achieved through this work, the astrometric stability due to the repeatability of the grating wheel, and the lessons learned for the astrometric calibration of an IFU instrument for application in future projects.

## 2. The MIRI MRS

### 2.1. Brief optical description of the MRS

The optical layout of the MRS is shown in Fig. 2. The light enters the MRS from the JWST focal plane via a pick-off mirror and is relayed to a series of three dichroic filters (D) that split the light into the four MRS spectral channels (1–4) denoted with the different colours in Fig. 2. The dichroic filters are always configured in such a way that the same sub-band (SHORT, MEDIUM, LONG or A, B, C) is observed at one time<fnref n="1" />. The dichroic-filtered light is fed to the input of the four MRS integral field units (IFU), while two blocking filters and corresponding light traps prevent unwanted stray-light from entering the spectrometer.

When entering the IFU of one of the four MRS spectral channels, the input focal plane is anamorphically magnified and re-imaged onto the image slicer of that channel. The image slicer consists of thin mirrors, diamond turned onto a common substrate in a pyramid-like manner (see Fig. 6 in Wells et al. 2015). Each channel has a different number of slicing mirrors, with 21, 17, 16, and 12 for channels 1, 2, 3, and 4, respectively. Each slice is separated spatially by the angle of the slicer mirrors towards a re-imaging mirror with a pupil mask placed in

<footnote n="1">¹ For sub-band B, the MRS will simultaneously observe spectral bands 1B, 2B, 3B, and 4B.</footnote>
<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Optical layout diagram of the MRS. Blue, green, orange, and red identify the paths of the four spectral channels, from 1 to 4, respectively. D stands for dichroic filters, G for diffraction gratings, and FPA is the focal plane assembly where the detectors are located. The figure is adopted from Wright et al. (2023).</figcaption></figure>

the intermediate pupil plane to control the stray-light. The re-imaging mirrors create an image of each slice on a slit-let mask that defines the output of the spectral channel IFU. The beams from the slits are then collimated by a mirror and diffracted by the diffraction grating (G) that is located on the reverse side of the same wheel as the dichroic filter that transmitted the wavelengths for the specific spectral channel. The MRS incorporates two wheels, denoted as the dichroic grating wheel assembly A (DGA-A) and dichroic grating wheel assembly B (DGA-B). The first diffraction order of the grating-diffracted beam is imaged onto the detector. The MRS camera optics combine the beams of two channels (1 and 2 and then 3 and 4) and focus the light onto the short wavelength (MIRIFUSHORT) and the long wavelength (MIRIFULONG) Si:As IBC detectors (Rieke et al. 2015a; Argyriou et al. 2020a), respectively<fnref n="2" />.

## 2.2. MRS coordinate systems

There are three coordinate systems that are relevant for this work and the MRS, illustrated in Fig. 1. These are (i) the MRS detector coordinates, (ii) the local MRS coordinates, and (iii) the JWST telescope coordinates which are connected to the right ascension (RA) and declination (Dec) of an astronomical object in the sky.

First, the detector coordinates are defined by the pixels of the detector arrays that have a dimension of (1032, 1024). The horizontal axis of the detector is roughly aligned with the MRS IFU image slicer along-slice (denoted as $\alpha$) spatial coordinate, and the vertical axis is roughly aligned with the dispersion direction, shown on the left panel of Fig. 1. We note that we assume zero-indexed arrays and therefore define the centre of the lower left pixel as $(x, y) = (0, 0)$.

Second, the local MRS coordinates are aligned to the image slicer along- and across-slice direction, denoted as local due to the fact that they are unique to each MRS sub-band. Due to small alignment differences of the slicer optic and the dichroic filters, the slicer location of each MRS sub-band projected on the sky are not perfectly concentric, yielding small boresight and rotation offsets. The along-slice coordinate is defined as $\alpha$ and the across-slice coordinate as $\beta$, and both have units of arcseconds. The coordinate $\beta$ is often used interchangeably with the term “slice,” referring to an individual sliced image created by the slicer and dispersed onto the detector. While it does not have a physical connection to the slicer, a third coordinate referring to the wavelength and denoted as $\lambda$, is often used in conjunction with $\alpha/\beta$ to complete the three dimensional (3D) coordinate system of the MRS IFU. In the context of the overall MRS instrument calibration, such as optical distortion, wavelength calibration, fringing, stray-light, and PSF (Wells et al. 2015; Argyriou et al. 2020b; Labiano et al. 2021); together with the detector coordinates, the vector $(\alpha, \beta, \lambda)$ operates as a

<footnote n="2">² A video illustrating the optical path of the MRS can be found at https://www.esa.int/esearch?q=MIRI+Medium+Resolution+Spectrometer</footnote>
self-contained coordinate system as it offers an intuitive view of the optics.

Third, the JWST Observatory coordinate system is defined and shared among all instruments. It is defined by two orthogonal coordinates on the JWST primary aperture plane called V3, that points towards the secondary mirror support structure, and V2 orthogonal to V3³, as shown in the right panel of Fig. 1. A third coordinate, V1, which is the telescope symmetry axis completes the coordinate system. These coordinates enable the observatory to slew towards a target on-sky and align the target with the instrument selected for the observation. Additionally, it enables dithering strategies and pointing offsets that are essential to some observing modes like coronagraphy and IFU spectroscopy. The coordinates (V2+V3) are given in units of arcseconds. The JWST coordinate system connects to RA and Dec through the V3 position angle (PA), that measures the rotation of the observatory with respect to north when projected on sky. All this information is contained in the JWST Science Instrument Aperture File (SIAF) on board the observatory, with V2+V3 also often referred to as SIAF coordinates. The MRS FoV is located on the far right of the JWST FoV at a distance of 20 arc-seconds from the top right corner of the MIRI Imager, as seen in the right panel of Fig. 1. The FoV of MIRI are rotated with respect to V3 by an angle of ~4.8° for the imager, and ~7.6° to ~8.8° for the MRS, as shown in Fig. 1.

## 2.3. Geometric distortion

Ideally, the optics would disperse and image the spectra of each slice orthogonal to the detector, and similar to most conventional spectrographs, this is not the case for the MRS. The anamorphic optics, as well as the slicer and camera optics introduce significant optical distortion to the imaged field, resulting in the spectra being projected onto the detector as curved lines. This curvature is illustrated in the left panel of Fig. 1 and is typical for slit spectrometers, usually referred to as keystone and smile distortion (Yokoya et al. 2010). The distortion in the along-slice spatial direction is more subtle than just a curved spectrum on the detector; the plate scale (detector pixel subtended angle on the sky), is changing non-linearly as a function of position in the field and wavelength, differently for each slice. This intra-slice distortion appears in both the dispersion and the spatial direction, and the rectification of these coordinates, from detector pixels to MRS local coordinates (α, β, λ), is a crucial step in the JWST calibration pipeline in order to reconstruct the observed astronomical scene and conserve the optical quality of the MRS.

We define two terms. First, lines on the detector that trace a constant value of α are denoted as iso-α lines. Second, lines that trace constant wavelength (λ) are denoted as iso-λ lines (the wavelength distortion calibration based on ground test data is described in detail by Labiano et al. 2021). The transformation of pixel coordinates to local MRS coordinates is referred to as a “detector-to-cube” transformation and is described by a set of polynomial transforms for each sub-band (1A to 4C). Each transform maps the coordinates (x, y) to α, λ as:

$$ \alpha_s(x, y) = \sum_{i,j}^{2,4} K_{\alpha,s}(i, j)(x - x_s)^j y^i, \quad (1) $$

$$ \lambda_s(x, y) = \sum_{i,j}^{4,4} K_{\lambda,s}(i, j)(x - x_s)^j y^i, \quad (2) $$

<table><caption>**Table 1.** MRS across slice parameters. Values are taken from Wells et al. (2015).</caption><thead><tr><th>Channel</th><th># slices</th><th>Δβ [arcsec]</th><th>β<sub>0</sub> [arcsec]</th></tr></thead><tbody><tr><td>1</td><td>21</td><td>0.177</td><td>-1.77</td></tr><tr><td>2</td><td>17</td><td>0.280</td><td>-2.24</td></tr><tr><td>3</td><td>16</td><td>0.390</td><td>-2.92</td></tr><tr><td>4</td><td>12</td><td>0.656</td><td>-3.61</td></tr></tbody></table>

with $K_{\alpha,s}$ and $K_{\lambda,s}$ denoting the polynomial coefficient matrices and $x_s$ as a reference pixel in the middle of each slice. The polynomial orders were estimated by minimising the residuals of the spectral trace without introducing extrapolation artefacts at the edges of the slices. The $β$ coordinate is discrete and only depends on the slice number since it is collapsed when dispersing the light on the detector. The value of $β$ is given by Eq. (3).

$$ \beta(s) = \beta_0 + (s - 1)\Delta\beta, \quad (3) $$

where $β_0$ is the $β$ coordinate of the centre of slice 1 and $Δβ$ the slice width of each channel in arc-seconds. The specific values for each of the MRS spectral channels are tabulated in Table 1, taken from Wells et al. (2015). We define $s = 1$ at the centre of the first slice, with the edges of the slice being $s \pm 0.5$.

There are two transformations to be made. The first is from detector pixels $(x, y, s)$ to $(α, β, λ)$ to account for the MRS specific distortion of each sub-band and, in a second step, we transform the local MRS coordinates $(α, β, λ)$ to the JWST global coordinates (V2+V3). This second transform accounts for distortion introduced by the JWST Optical Telescope Element (OTE), which all instruments are subject to, as well as placing the FoV of the MRS $(α, β)$, that is slightly rotated, onto V2+V3. This is shown in the right panel of Fig. 1. The coordinate transform from $(α, β)$ to V2 + V3 is given by a second order polynomial:

$$ V2_{Ch}(α, β) = \sum_{i,j=0,0}^{2,2} T_{Ch,V2}(i, j)α^jβ^i, \quad (4) $$

$$ V3_{Ch}(α, β) = \sum_{i,j=0,0}^{2,2} T_{Ch,V3}(i, j)α^jβ^i, \quad (5) $$

where $T_{Ch,V2}$, $T_{Ch,V3}$ are the polynomial coefficient matrices for V2 and V3, respectively. The polynomial order was determined on prior modelling of the distortion at the field location of the MRS and the minimisation of residuals.

# 3. Data and methods

## 3.1. Commissioning and cycle 1 calibration

Over the course of the JWST commissioning, the dedicated observations listed in Table 2 were executed to validate and update the distortion of MIRI. For the MRS, the goal was to check the geometric distortion, derive the field transform from local MRS coordinates to the JWST SIAF, update the boresight offsets with respect to the MIRI Imager, and test the MRS dither patterns. The first programme that was used is JWST programme identifier (PID) 1012, consisting of exposures of the MRS internal calibration lamp, which fully illuminates the detector slices and was used to derive the detector slice mask.

<footnote n="3">³ https://jwst-docs.stsci.edu/jwst-observatory-characteristics/jwst-observatory-coordinate-system-and-field-of-regard</footnote>
<table><caption>**Table 2.** Commissioning and cycle 1 calibration programmes and stars used for the in-flight calibration.</caption><thead><tr><th>Programme ID</th><th>Name</th><th>Type</th><th><i>K</i> mag</th></tr></thead><tbody><tr><td>1024</td><td>2M J05220207-6930388</td><td>LMC star</td><td>10.0</td></tr><tr><td>1049</td><td>SMP LMC-58</td><td>PN</td><td>14.5</td></tr><tr><td>1050</td><td>HD 163466</td><td>A2</td><td>5.1</td></tr><tr><td>1050</td><td>HD 159222</td><td>G1</td><td>4.9</td></tr><tr><td>1524</td><td>10 Lac</td><td>O9</td><td>5.5</td></tr><tr><td>1536</td><td>HD 2811</td><td>A3V</td><td>7.0</td></tr><tr><td>1536</td><td>del UMi</td><td>A1</td><td>4.2</td></tr><tr><td>1538</td><td>16 Cyg B</td><td>G3V</td><td>4.6</td></tr><tr><td>1538</td><td>HD 167060</td><td>G3V</td><td>7.4</td></tr><tr><td>1538</td><td>HD 37962</td><td>G2V</td><td>6.2</td></tr><tr><td>1012</td><td>Internal calibration lamp</td><td></td><td>—</td></tr></tbody></table>

To help derive the astrometric calibration, the strategy was to observe bright stars with the MRS, including simultaneous MIRI imaging and parallel FGS observations. Both FGS and the MIRI Imager, with their large FoV, contained many stars with very precise astrometric information from Gaia (Lindegren et al. 2016; Gaia Collaboration 2018). PID 1049 and 1050 were part of the PSF measurement and provided very bright sources for channels 3/4 and channels 1/2, respectively. For PID 1049 a red planetary nebula (SMP LMC-58) was observed in the dither patterns optimised for the long channels (3, 4) of the MRS. In PID 1050 a photometric standard A-star (HD 163466) was observed in the point source optimised dither pattern of the channel 1, as well in an extended source dither pattern and at the instrument boresight.

As described in Sect. 4, additional observations were needed in order to improve the distortion solution of the MRS. A cycle 1 calibration programme (PID 1524, observation 16) was designed and executed as one of the first calibration programmes post-commissioning, with the goal of characterising the MRS distortion in detail. A custom dither pattern of a bright O-star, 10 Lac, was uploaded to the observatory, which would place the point source to three or more positions in the along-slice direction $\alpha$ for most slices of each channel. This enables the fitting of the plate scale for each slice with the required second-order polynomial (Glauser et al. 2010). The custom dither pattern that includes 57 points is shown in Fig. 3, which shows its overlap with the slicer of each channel. More specifically, 10 Lac was chosen as the target since it was bright enough to be time efficiently observed with 20 frames (~55 s) per integration, provided sufficient S/N up to channel 4C, and had emission lines that could be used to calibrate the wavelength distortion of the MRS. Finally, subsequent observations of 10 Lac (PID 1524, observation 17) and observations of standard A and G stars through cycle 1 photometric calibration programmes (1536, 1538) that included target acquisition (TA) enabled the astrometric precision monitoring of the MRS.

The standard JWST MIRI MRS pipeline<fnref n="4" /> (Labiano et al. 2016; Bushouse et al. 2022) was used to process the raw data files from the observations. First the Detector1Pipeline was ran to obtain rate files, namely, slope images (Morrison et al. 2023). From the Spec2Pipeline that deals with the calibration of spectroscopic modes of JWST (for the MRS see Argyriou

<figure><img src="image_4.png" /><figcaption>**Fig. 3.** Dither points from commissioning and cycle 1 calibration, with each panel illustrating the outline of each channel's slicer. The black crosses correspond to the dither pattern of 10 Lac executed during PID 1524 (observation 16), optimised to characterise the intra-slice distortion. The red points correspond to the point and extended dither pattern optimised for channel 1 (PID 1050, observation 9), and the violet points correspond to the point source dither pattern of channel 3 (PID 1049, observation 2).</figcaption></figure>

et al. 2023), we applied processing steps straylight_step and fringe_flat, that mitigate the scattered light and detector fringing effects since these might have biased our analysis. The distortion and astrometric calibration folds into the first step of Spec2Pipeline, that is the assign_wcs. For the derivation of the MRS distortion this step was not applied, and the distortion was derived based on measuring the spectral traces on the detector, as described in Sect. 3.2. Dedicated background observations

<footnote n="4">⁴ jwst pipeline version 1.9, Calibration Reference Data System (CRDS) version: 11.16.3, CRDS context: jwst_0932.pmap.</footnote>
<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Detector tracing for MRS point sources. Top row: detector images of bright star 10 Lac from PID 1524 showing left the IFUSHORT detector (channels 1 and 2), and right IFULONG (channels 3 and 4). Bottom left: single row of detector showing the PSF projected on it and fit with pseudo-Voigt function (inset) to estimate the centre in the detector *x* (corresponding to *α*) coordinate. The centre of the trace for the brightest slice (core of the PSF) coincides with the centre of the PSF. Bottom right: collapsed signal over a given number of detector rows in each slice is fitted with a pseudo-Voigt profile to estimate the across slice coordinate *s* (equivalent to *β*).</figcaption></figure>

for each observation were subtracted on the detector level as rate files.

## 3.2. Detector-based point source tracing

Here, we briefly present the methods used to trace a point source on the detector of the MRS, also shown in Fig. 4. These form the basis of the whole subsequent distortion calibration. There are two quantities that are extracted from the detector: (i) the across-slice position $\beta$ of the point source, and (ii) the along-slice, iso-$\alpha$ trace as a function of detector position (*x*, *y*).

As per point (i) in the across-slice direction the point source is sampled by the IFU image slicer mirror slices and the goal of the detector-fitting is to estimate the sub-slice position (or slicer coordinate $\beta$) of the source. The signal in each slice on the detector is summed, to effectively integrate over the along-slice direction $\alpha$, and fitted against the slice index *s* with a pseudo-Voigt profile<fnref n="5" />. The validity of this method was tested by taking a theoretical PSF model, sampling it by the number and width of the slices for each MRS band, and comparing the estimated parameter with the input coordinate. The error of the fit in the

simulated tests was approximately of the order of a few percent of the slice width. In the bottom right panel of Fig. 4, an example of the slicer coordinate estimation in channel 3 using the bright star from PID 1524 is shown.

As per point (ii) the iso-$\alpha$ can be traced in each slice in two different ways. First, using an empirical PSF profile fit directly on the detector signal. This can be done in a row-by-row manner, or along an iso-$\lambda$, with the pixels belonging to a given wavelength bin of a slice identified and fitted by the profile. Both a Gaussian and a pseudo-Voigt function were tested with the Voigt function resulting in a better fit (shown in Labiano et al. 2021, Fig. 4). The pseudo-Voigt function is motivated by the fact that the light scattered within the MIRI detectors (Gáspár et al. 2021) produces elongated wings for the MRS PSF (Argyriou et al. 2023; Patapis et al., in prep.), and a similar behaviour is also seen in the MIRI Imager (Dicken et al., in prep.). For slices that contain a significant fraction of the PSF core the iso-$\alpha$ traces are well fitted this way, since the PSF is symmetric, the centre of the empirical profile coincides with the centre of the PSF.

For slices illuminated by the PSF wings and not containing a significant part of the PSF core (mainly in channels 3 and 4), we estimate the iso-$\alpha$ traces on the detector using forward modelling of the theoretical MRS PSF as shown in Fig. 5. The MRS PSF was modelled using the python package `webbpsf`

<footnote n="5">⁵ The pseudo-Voigt function, a linear combination of a Gaussian and Lorentzian.</footnote>
<figure><img src="image_6.png" /><figcaption>**Fig. 5.** Forward modelling of the MRS webbPSF used for the estimation of iso-α trace. The detector trace is determined by collapsing the corresponding slice in the webbPSF model along β and projecting the α profile of the PSF to the detector using the estimated distortion solution. The centre of the webbPSF model is optimised to match the data on the detector and estimate the centre of the given point source exposure. For accurately centred slices this works well, while for slices further from the PSF centre, the discrepancy between model and data is larger; however, the source centre estimation is not significantly affected.</figcaption></figure>

(Perrin et al. 2016) and was broadened by convolution with a Gaussian kernel to match the optical quality observed in flight. The detailed description of this model and the commissioning PSF analysis for the MRS is described in Patapis et al. in prep. The PSF model is then interpolated onto the detector using the distortion model and iterating with each update of the distortion. In Fig. 5, we show that the PSF model and distortion solution from ground are sufficient to reproduce the profile of a point source on the detector within 5% for slices close to the PSF core (top-right panel in Fig. 5) and worsening to residual error of ~20% for slices further away (bottom right panel in Fig. 5). Even with higher residuals, the error on the centre is in the order to 10% of a pixel. This validity of the fitting was tested for multiple locations in the FoV, different rows on the detector, and for all bands.

# 4. In-flight astrometric and distortion calibration

## 4.1. Systematic errors from ground calibration

A preliminary calibration of the MRS geometric distortion was performed using the ground calibration data (Glauser et al. 2010; Wells et al. 2015), based on the optical design model of the MRS (modelled using the ray tracing software Zemax OpticStudio). That original analysis was performed using reconstructed cubes, median-collapsed in wavelength, while applying slice to slice corrections. The solution from the tweaked Zemax OpticStudio model was precise to approximately 0.5–1 resolution element depending on the band, however, the following issues observed in ground and flight data have motivated a new derivation of the distortion solution for the MRS.

First, the initial calibration used the cubes median-collapsed in wavelength to correct the MRS optical design model. This collapsing in wavelength left a significant systematic error in α as a function of wavelength, of the order of a pixel (see Sect. 3.2.3 in Argyriou 2021). The systematic error was partially corrected by

re-fitting the ground data on the detector level which mitigated the issue (see Appendix A). However, when tested on flight data, at the top of the detector and for all available points a similar systematic was present, underestimating the iso-α trace compared to the middle and bottom of the detector by half a pixel. With comparisons between bands pointing towards a global distortion systematic error, it potentially stems from issues in the optics of the test illumination source setup used in ground testing.

Second, by comparing the commanded offsets in V2+V3 coordinates with the ones estimated from fitting the point source centre on the detector, we found misalignment between slices in some bands, while in other bands (especially those in channel 3) there was evident magnification errors within the slices. All these systematic errors are probably tied to discrepancies in the estimated coordinate transforms using the ground test data, given the low S/N, non-diffraction-limited and asymmetric PSF and distortion of optical test setup, and a lack of point source data for more recent observatory level campaigns. These errors are of the order of 1 pixel.

In order to minimise these systematic residuals in the alpha distortion calibration and to derive the astrometric calibration that maps the local MRS coordinates to the V2+V3 coordinate frame, we use the PID 1524 cycle 1 calibration observations of the O-star 10 Lac shown in Fig. 3. The updated distortion transforms are then tested on the commissioning observations to estimate the residual error in the distortion, as well as the estimated absolute astrometric error.

## 4.2. Correction of telescope attitude matrix

Although target acquisition can reliably place a star in the MIRI MRS to an accuracy of about 30 mas<fnref n="6" />, the absolute position

<footnote n="6">⁶ https://jwst-docs.stsci.edu/jwst-mid-infrared-instrument/miri-operations/miri-target-acquisition/miri-mrs-target-acquisition</footnote>
information of the world coordinate solution (WCS) association with any given observation is typically only accurate to about 300 mas due to a combination of errors in the guide star catalogue and uncertainty in the spacecraft roll angle. For the purposes of calibrating the absolute location of the MRS within the telescope focal plane we therefore obtained simultaneous FGS and MIRI imaging data in parallel with the dithered MRS observations.

Using 25 bright stars in the FGS imaging field with Gaia DR3 (Gaia Collaboration 2018) astrometry, we re-derived the telescope attitude matrix for each of our exposures, improving the absolute positional accuracy of the WCS to 30 mas. The FGS and MIRI imaging data likewise were used to confirm that the relative accuracy of the commanded dither offsets was good to 10 mas or better, which was deemed more than sufficient for our analysis.

### 4.3. Detector slice mask

We began the analysis by deriving the detector slice mask that maps the projected slits on the MRS detectors. For a spatially homogeneous extended source illumination of the MRS, the signal within a slice is flat across the MRS FoV, dropping off rapidly at the edges. This allows for the derivation of the FoV limits along these slices (x-direction) for each detector row. We did so solely on the basis of the signal values on the detector and no other calibration information was required. The extended illumination was provided by flight observations of the internal calibration source from PID 1012.

To derive the FoV limits on the detector plane for each slice, we have to measure the drop in throughput at the slice edges. The deviation of the overall throughput in each slice from an ideal boxcar function, however, makes this a non-trivial challenge. The derivation of an accurate slice mask is thus limited by the accurate definition of the throughput at the slice edges.

The algorithm to derive a slice mask performs the following three steps for all slices in a MRS channel for each detector row. Firstly, the minima (troughs) in the signal separating the slices are identified as shown in the top plot of Fig. 6. These minima bound the slices in each channel. Secondly, the throughput of each slice is determined by first fitting a 3rd order polynomial to the signal values of the pixels that are well within the slice (5 pixels from the slice edges). This is shown in the middle right plot of Fig. 6. The signal between two minima surrounding the slice is then divided by the fitted 3rd order polynomial, this yields an estimation of the slice throughput as shown middle left plot of Fig. 6. Thirdly, a throughput criterion is used to define the left-most and right-most pixel that contributes to a slice (edges of the MRS FoV). We show the result for one detector row in channel 1, in the bottom plot of Fig. 6.

Iterating the above steps for each detector row produces a 2D slice mask. In fact, we have defined not one, but nine slice masks using this method. These nine slice masks correspond to different slice throughput levels, from 10% throughput to 90% throughput. The JWST MIRI/MRS pipeline uses an 80% transmission cut-off by default. This value was chosen due to the steep throughput decline and the fact that our spectro-photometric calibration uncertainty gets larger at the edges of the slices.

### 4.4. Field of view definition

As seen in Fig. 3, not every slice of the dither pattern in PID 1524 (observation 16) has point sources centred on it. We identified which exposures had signal in a given slice by iterating through

<figure><img src="image_7.png" /><figcaption>Fig. 6. Slice-masking process based on internal calibration source exposures measured in flight (PID 1012). Top: signal of single detector row of calibration source, and finding the minima of the extended illumination correspond to the slice gaps. Middle: normalising the illumination in order to calculate the transmission factors. Bottom: with the normalised slices, the pixel locations of various transmission levels for each slice and each row are calculated.</figcaption></figure>

all exposures, and finding the three along $\alpha$ that had the maximum signal in the slice. These exposures were then selected to calculate the $V2+V3$ to $\alpha/\beta$ transform. We fitted their slicer coordinate on the detector using the pseudo-Voigt profile fitting shown in Fig. 4. Then, using the matrix form of a coordinate rotation Eqs. (6) and (7), the FoV was defined based on the $V2 + V3$ coordinates reported in the metadata.

$$ \begin{bmatrix} \alpha \\ \beta \end{bmatrix} = \begin{bmatrix} \alpha \\ \beta_0 + (s-1) * \Delta\beta \end{bmatrix} = \begin{bmatrix} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{bmatrix} \begin{bmatrix} V2 - V2_0 \\ V3 - V3_0 \end{bmatrix}, \quad (6) $$

$$ \beta_0 + (s-1) * \Delta\beta = -\sin(\theta)(V2 - V2_0) + \cos(\theta)(V3 - V3_0). \quad (7) $$

This assumes that the $V2 + V3$ field is not significantly distorted over the size of the FoV of the MRS. Even if the field distortion is not negligible, we implicitly incorporate this distortion term in the $\alpha$ distortion model. The absolute $\alpha$ coordinate does not need to be correct in this step since we are mainly interested in $\Delta\alpha$, the distance of the points along the $\alpha$ coordinate in order to calibrate the slice specific distortion. The final $\alpha+\beta$ system is defined after the new $\alpha$ distortion is derived.

### 4.5. Along-slice $\alpha$ distortion calibration

With the relative astrometry derived from the $V2+V3$ transform derived in Sect. 4.4, we can measure and fit the distortion in the iso-$\alpha$ traces for every slice in each of the 12 spectral sub-bands (1A-4C). As described in Sect. 3.2, with the forward modelling of the PSF, we were able to fit the signal on the detector even for slices that do not contain the core of the PSF. We fit the $\alpha$ distortion with a $(Nx, Ny) = (2, 4)$ order polynomial. These values for
<figure><img src="image_8.png" /><figcaption>**Fig. 7.** MRS band footprints in V2+V3 coordinates. This corresponds to the FoV of the MRS on sky, information that is used for pointing and dithering with the MRS.</figcaption></figure>

the polynomial provided enough flexibility to fit the distortion everywhere on the detector without suffering from over-fitting especially at the edges of slices. Finally, we set the local MRS coordinate field to be centred around zero. We calculated the α FoV limits for each slice using the detector slice mask and the newly derived α distortion and subtract the mean FoV value from the intercept coefficient of the polynomial transform of each slice.

### 4.6. Local MRS to JWST V2 + V3 coordinates transform

The last step of the analysis is to refine the V2 + V3 to α+β transform, this time using the calibrated α distortion. This yields important parameters for the boresight offsets of the MRS bands in the V2+V3 frame that is used by FGS to guide targets to the MRS and perform dithering offsets. The optimised dither pattern can be re-calculated given the new distortion and V2 + V3 to α+β transform, and a polynomial transform shown in Eqs. (4) and (5) is fitted. In Fig. 7, we show the final footprints of the MRS FoV of each band in the V2+V3 coordinate system and in Table 3, we list the relevant parameters for each band.

### 4.7. Verification and estimated precision

To test the validity of the full chain of calibration we use other point source observations from PID 1049 and PID 1050, comparing their predicted locations in α/β to the ones measured from the data. The results are shown in Fig. 8 and the numbers reported in Table 4. In the top panel, a single observation of the A-star from PID 1050 was used to compare the iso-α trace. For each row, the centre of the point source is fitted using the Voigt profile and transformed into α, λ using the distortion solution from Wells et al. (2015), the pre-launch distortion (Appendix A), and the distortion derived from flight data. Since the star should have a fixed spatial coordinate (α, β) as a function of wavelength, this

<table><caption>**Table 3.** MRS field of view in global JWST coordinate system after finalising the distortion solution based on PID 1524.</caption><thead><tr><th>Band</th><th>V2 boresight<br>(arcsec)</th><th>V3 boresight<br>(arcsec)</th><th>angle<br>(degrees)</th><th>FoV (α, β)<br>(arcsec²)</th></tr></thead><tbody><tr><td>1A</td><td>-503.37</td><td>-319.00</td><td>8.4</td><td>3.3 × 3.7</td></tr><tr><td>1B</td><td>-503.36</td><td>-319.12</td><td>8.3</td><td>3.3 × 3.7</td></tr><tr><td>1C</td><td>-503.30</td><td>-318.85</td><td>8.3</td><td>3.3 × 3.7</td></tr><tr><td>2A</td><td>-503.43</td><td>-319.29</td><td>8.2</td><td>4.1 × 4.8</td></tr><tr><td>2B</td><td>-503.51</td><td>-319.57</td><td>8.2</td><td>4.1 × 4.8</td></tr><tr><td>2C</td><td>-503.35</td><td>-319.50</td><td>8.2</td><td>4.1 × 4.8</td></tr><tr><td>3A</td><td>-503.96</td><td>-319.01</td><td>7.6</td><td>5.4 × 6.2</td></tr><tr><td>3B</td><td>-504.01</td><td>-319.21</td><td>7.6</td><td>5.6 × 6.2</td></tr><tr><td>3C</td><td>-504.02</td><td>-319.17</td><td>7.6</td><td>5.6 × 6.2</td></tr><tr><td>4A</td><td>-502.75</td><td>-319.61</td><td>8.4</td><td>6.9 × 7.9</td></tr><tr><td>4B</td><td>-502.86</td><td>-319.54</td><td>8.3</td><td>6.8 × 7.9</td></tr><tr><td>4C</td><td>-502.89</td><td>-319.54</td><td>8.4</td><td>6.8 × 7.9</td></tr></tbody></table>

**Notes.** The angle refers to the rotation of the MRS slicer coordinate frame with respect to the JWST V3 coordinate. The angle estimate uncertainty is 10% for channels 1–3 and 20% for channel 4.

illustrates the improvement of the latest distortion model. The residual modulation of the iso-α trace that is seen in the bottom panel of Fig. 8, we plot the distribution of the residual between expected α based on the pointing telemetry, and the measured iso-α trace from the detector for all (10–13) individual dithers per band. Since we were interested in the relative error within a given MRS band, we subtracted the mean residual, so that the distributions ended up centred around zero. This removes any global offset which can arise from pointing errors or repeatability issues discussed in Sect. 5.1. The standard deviation of a fitted Gaussian distribution to the residuals is reported, satisfying in all bands the tenth of a resolution element goal set out for the MRS α distortion.

Another example of illustrating that the distortion solution works as intended is to visualise a point source in the reconstructed cube. In Fig. 9, we show an A star (PID 1050, observation 9) in band 1A, with all ten dither positions combined with the size of the pixel in the cube (also referred to as spaxel, see Law et al. 2023 for details) set to 0.05" and binned over a broad wavelength bin of 0.05 µm in order to increase the signal-to-noise ratio (S/N). This oversampling of the MRS PSF is possible because of the number of dithers available in the given observation, but also the fact that a broad wavelength bin naturally samples the PSF better due to the iso-α trace being curved on the detector. The JWST PSF is revealed in detail, and we also observe the wings of the PSF at high S/N.

## 5. Discussion

### 5.1. Repeatability of the grating wheel assembly

During commissioning, it was found that the repeatability of the angular positioning of the wheel induced measurable astrometric offsets. Each time the wheel moves between observations to select a different dichroic filter and grating setting, it returns to a given position with some uncertainty of around 0.5–1 pixels projected on the detector, based on the MIRI optical model. For example, the NIRSpec grating wheel also shows similar repeatability performance, which was already known from
<figure><img src="image_9.png" /><figcaption>**Fig. 8.** Relative distortion residuals. Top: point source trace on the detector was extracted from PID 1050, and the distortion solution from Wells et al. (2015), and this work was used to transform the iso-$\alpha$ trace into $\alpha$, $\lambda$ coordinates. Since the point source should have a fixed spatial coordinate, this illustrates the improvement in the distortion model using the flight data. The residual modulation originates from the under-sampling of the MRS PSF. Bottom: distribution of iso-$\alpha$ residuals for all dither point of PID 1049 and PID 1050, obtained by applying the distortion transforms derived in this work.</figcaption></figure>

ground testing (Böker et al. 2023) and mostly affects the dispersion direction. For NIRSpec, two sensors measure these offsets and accordingly adjust the distortion model to compensate for it (Alves de Oliveira et al. 2022). Unfortunately for the MRS, the positioning sensors do not have the required resolution to measure the changes in the wheel position. We note that the MRS DGA wheels were designed in such a way that repeatability in the dispersion direction would be very precise and no measurable repeatability error has been reported in flight.

In order to assess the repeatability of the astrometric solution we compared results across about ten different observations of standard stars obtained throughout the cycle 1 calibration programme using data from PIDs 1050, 1524, 1536, and 1538. Each

of these programmes used target acquisition to observe well-known point sources in all twelve MRS bands, and all used a standard dither pattern (except PID 1524 Observation 16, which used the custom 57-point pattern). For each observation, we constructed a full 5–28 micron data cube and measured the centroid location of the target star as a function of wavelength in this cube.

We plot the result in Fig. 10, showing the relative offset from the median position in the alpha and beta directions as a function of wavelength. While the $\beta$ direction positions are extremely stable from band to band, we note more significant jumps between individual bands in the $\alpha$ direction, with an rms of about 30 mas. This represents roughly a 1/5 detector pixel or better repeatability overall, albeit with some extreme cases in which the offsets
<table><caption>**Table 4.** Precision of MRS distortion calibration.</caption><thead><tr><th>Band</th><th>α (relative)<br>(pix)</th><th>α (relative)<br>(mas)</th><th>Wavelength<br>(relative) (pix)</th></tr></thead><tbody><tr><td>1A</td><td>0.04</td><td>8</td><td>0.20</td></tr><tr><td>1B</td><td>0.05</td><td>10</td><td>0.23</td></tr><tr><td>1C</td><td>0.06</td><td>11</td><td>0.05</td></tr><tr><td>2A</td><td>0.04</td><td>7</td><td>0.14</td></tr><tr><td>2B</td><td>0.03</td><td>6</td><td>0.11</td></tr><tr><td>2C</td><td>0.03</td><td>5</td><td>0.09</td></tr><tr><td>3A</td><td>0.03</td><td>7</td><td>0.09</td></tr><tr><td>3B</td><td>0.03</td><td>8</td><td>0.13</td></tr><tr><td>3C</td><td>0.04</td><td>9</td><td>0.50</td></tr><tr><td>4A</td><td>0.04</td><td>11</td><td>0.48</td></tr><tr><td>4B</td><td>0.05</td><td>15</td><td>0.48</td></tr><tr><td>4C</td><td>0.08</td><td>23</td><td>0.49</td></tr></tbody></table>

**Notes.** The values for α correspond to the rms of all observations that were tested. Wavelength values are taken from Argyriou et al. (2023) and converted into pixels assuming the central wavelength of the band.

<figure><img src="image_10.png" /><figcaption>**Fig. 9.** MRS Optical quality (band 1A) with data from PID 1050 enabled by the distortion solution derived in this work. The cube building step (Law et al. 2023) uses a spaxel size of 0.05" and a wavelength bin of 0.05 µm with the drizzle algorithm in IFALIGN mode, which builds the cube in the α, β coordinate frame. The diffraction pattern (JWST 'petals') of the PSF is revealed.</figcaption></figure>

can be as large as about 1/2 pixel. In Channel 2B for instance, we note a significant difference between -0.05 arcsec and +0.07 arcsec between successive observations of 10 Lac (blue and red points) during which the observatory remained in fine guide status and the only mechanism that moved between two sets of dithers was the DGA wheel. Another fact pointing towards the wheel repeatability being the issue is the fact that the channel 1-4 and 2-3 offsets are anti-correlated, as one would expect from the optics of the MRS. The gratings of these pairs (1-4, 2-3) are respectively located on the same DGA wheel, and due to an additional reflection for channels 3 and 4, an offset in angle

of the wheel will move the beam towards the opposite direction compared to channels 1 and 2.

For calibration purposes, we fit the average offset from the mean for each of the twelve bands and applied this bore-sight offset to the latest distortion reference files. This ensures that the astrometric location of a star is on average consistent across all MRS bands, even if repeatability can sometimes cause deviations from this mean position for individual observations.

The impact of the wheel repeatability on the data reduction and science products of the MRS was tested using the repeated measurement of PID 1524 (observation 17). We compared the exposures for band 2B which showed the worst offset (Fig. 10, 2B in blue and red points). No measurable change in the calibrated iso-α trace, besides a constant astrometric offset, is found. Presumably, the displacement of the beam due to the diffraction grating is still within the linear regime of the distortion. Therefore, with no significant distortion effects, there are some minor issues that arise from the non-repeatability of the source on the detector between different dichroic settings. First, for extended sources where the astrometry cannot be measured in the data, the alignment of the bands in the 3D cube will not be exact and spatial features will appear to shift between bands. Due to the wavelength overlap between the bands, such cases can potentially be mitigated by examining the common wavelengths and the behaviour of any features from one band to the other. Second, dedicated point source fringe flats based on calibration observations would not be directly applicable since the point source fringes change rapidly from pixel to pixel on the detector (Argyriou et al. 2020b; Gasman et al. 2023). Third, astrometric measurements of the same source from different epochs might be biased and should include the repeatability error in its uncertainty. Finally, due to the relatively small FoV, complex scenes involving extended structures of interest or multiple sources need to be planned more carefully, taking into account the additional astrometric uncertainty of 100 mas.

## 5.2. Lessons learned for future calibration

Due to its design and operating wavelengths, the MRS is a challenging instrument to calibrate. A series of instrumental effects are present due to a combination of design choices and peculiarities of the MIRI detectors, such as spectral fringing, scattered light within the detector, under-sampling of the PSF, and optical distortion (Argyriou et al. 2023). The following list identifies some of the insights for testing an IFU, after a decade of calibration work performed by the instrument team.

- Testing the MRS in the lab, at conditions representative of its flight status is challenging. The MIRI Telescope Simulator, built specifically for testing MIRI, could not provide a bright diffraction limited point source at all wavelengths, due to a combination of optical distortions of the test setup and lack of flux of the test light source. Therefore, the early investment and development of a robust testing facility is key.

- For calibrating the distortion and astrometry pre-flight, a well-defined point source that can be steered precisely in the FoV of the IFU is required, correlated to a distortion free reference frame. This could potentially be the steering stage X, Y positions. Even with its limitations the ground testing provided many insights into the distortion of the MRS, and was able to deliver a preliminary calibration.

- Hardware tested in flight will potentially reveal new instrumental systematic errors that were not caught in the instrument testing on ground. Therefore, planning for dedicated commissioning observations for all key parameters is essential.
<figure><img src="image_11.png" /><figcaption>Fig. 10. Change in the PSF centroid location as a function of wavelength for 5–28 µm data cubes constructed from dithered observations of a variety of standard stars observed by PIDs 1050, 1524, 1536, and 1538 (processed using the distortion solution derived in this work). The top panel shows offsets along the α direction, and the lower panel offsets along the β direction. Three different sets of data points are given for 10 Lac Observation 17 as these data were obtained during three complete rotations of the DGA assembly while the guide star remained locked explicitly to test the position repeatability of the DGA. While the typical rms is much better than 10 mas for the β direction, repeatability in the α direction is about 30 mas rms.</figcaption></figure>

Additionally, allowing for the flexible project management of commissioning was valuable in adapting the observations and tests based on the first sets of data that were obtained.

– Finally, careful planning and development of the optimised dither pattern used for PID 1524 (observation 16) enabled the calibration of the distortion efficiently using a bright star. Additionally the same data set could be used for multiple additional tests like wavelength, fringing, optical quality, and photometric calibration as a function of the position in the FoV.

## 5.3. Summary

We have derived the full astrometric distortion solution of the MRS, based on flight data. The calibration of JWST field coordinates $V2 + V3$ to the local MRS slicer coordinates $\alpha/\beta$ is required for the operation of the MRS, used during pointing and dithering of observations. The transform from detector to $\alpha/\beta$ and subsequently $V2 + V3$, enables the pipeline to correct for the optical distortion introduced due to the IFUs, a required step for the rectification of the 2D detector data into 3D cubes, that reconstruct the observed astronomical scene and allow for the extraction of spectra. A good understanding of the distortion might enable modelling of the MRS PSF and application of optimised forward modelling approaches for MRS data. The final precision of the distortion solution ranges from 10 mas in channels 1–3, up to 23 mas in channel 4. The total astrometric uncertainty of a given MRS exposure with target acquisition is estimated to be 50 mas,

given by $\sqrt{\sigma_{\text{distortion}}^2 + \sigma_{\text{TA}}^2 + \sigma_{\text{repeatability}}^2}$.

**Acknowledgements.** This paper is dedicated in memory of Martyn Wells for the legacy of the MRS optics and the science they will enable. Contributions: P.P. lead the calibration work package for the MIRI MRS distortion and astrometry, performed the main analysis, and wrote the manuscript. I.A. co-leads the calibration and analysis of the distortion, and derived the MRS slice mask. D.L. planned the dedicated cycle 1 calibration programme 1524, performed

the astrometric monitoring of the MRS, and implemented the calibration products in the JWST pipeline. I.A., D.L. contributed to the manuscript writing and editing. D.L., A.M.G., A.G., A.L. contributed to the overall calibration and analysis of the distortion. All authors read and provided feedback on the manuscript. This research has made use of the NASA Astrophysics Data System and the python packages numpy (Harris et al. 2020), scipy (Virtanen et al. 2020), matplotlib (Hunter 2007) and astropy (Astropy Collaboration 2013, 2018). The authors want to thank the hundreds of engineers and scientists, whose contributions over 25 years made the JWST mission possible. Polychronis Patapis thanks the Swiss Society for Astrophysics and Astronomy (SSAA) for the MERAC Funding and Travel award. Ioannis Argyriou, Danny Gasman, and Bart Vandenbussche would like to thank the European Space Agency (ESA) and the Belgian Federal Science Policy Office (BEL-SPO) for their support in the framework of the PRODEX Programme. Patrick J. Kavanagh acknowledges support from the Science Foundation Ireland/Irish Research Council Pathway programme under Grant Number 21/PATH-S/9360. Javier Álvarez-Márquez acknowledges support by grant PIB2021-127718NB-100 by the Spanish Ministry of Science and Innovation/State Agency of Research MCIN/AEI/10.13039/501100011033 and by “ERDF A way of making Europe” Alvaro Labiano acknowledges the support from Comunidad de Madrid through the Atracción de Talento Investigador Grant 2017-T1/TIC-5213, and PID2019-106280GB-100 (MCIU/AEI/FEDER,UE). The work presented is the effort of the entire MIRI team and the enthusiasm within the MIRI partnership is a significant factor in its success. MIRI draws on the scientific and technical expertise of the following organisations: Ames Research Center, USA; Airbus Defence and Space, UK; CEA-Irfu, Saclay, France; Centre Spatial de Liège, Belgium; Consejo Superior de Investigaciones Científicas, Spain; Carl Zeiss Optronics, Germany; Chalmers University of Technology, Sweden; Danish Space Research Institute, Denmark; Dublin Institute for Advanced Studies, Ireland; European Space Agency, Netherlands; ETCA, Belgium; ETH Zurich, Switzerland; Goddard Space Flight Center, USA; Institute d'Astrophysique Spatiale, France; Instituto Nacional de Técnica Aeroespacial, Spain; Institute for Astronomy, Edinburgh, UK; Jet Propulsion Laboratory, USA; Laboratoire d'Astrophysique de Marseille (LAM), France; Leiden University, Netherlands; Lockheed Advanced Technology Center (USA); NOVA Opt-IR group at Dwingeloo, Netherlands; Northrop Grumman, USA; Max-Planck Institut für Astronomie (MPIA), Heidelberg, Germany; Laboratoire d'Etudes Spatiales et d'Instrumentation en Astrophysique (LESIA), France; Paul Scherrer Institut, Switzerland; Raytheon Vision Systems, USA; RUAG Aerospace, Switzerland; Rutherford Appleton Laboratory (RAL Space), UK; Space Telescope Science Institute, USA; Toegepast-Natuurwetenschappelijk Onderzoek (TNO-TPD), Netherlands; UK Astronomy Technology Centre, UK; University College London, UK;
University of Amsterdam, Netherlands; University of Arizona, USA; Univer-
sity of Bern, Switzerland; University of Cardiff, UK; University of Cologne,
Germany; University of Ghent; University of Groningen, Netherlands; Univer-
sity of Leicester, UK; University of Leuven, Belgium; University of Stockholm,
Sweden; Utah State University, USA. A portion of this work was carried out at
the Jet Propulsion Laboratory, California Institute of Technology, under a con-
tract with the National Aeronautics and Space Administration. We would like
to thank the following National and International Funding Agencies for their
support of the MIRI development: NASA; ESA; Belgian Science Policy Office;
Centre Nationale D'Etudes Spatiales (CNES); Danish National Space Centre;
Deutsches Zentrum fur Luft-und Raumfahrt (DLR); Enterprise Ireland; Ministe-
rio De Economiá y Competividad; Netherlands Research School for Astronomy
(NOVA); Netherlands Organisation for Scientific Research (NWO); Science and
Technology Facilities Council; Swiss Space Office; Swedish National Space
Board; UK Space Agency. We take this opportunity to thank the ESA JWST
Project team and the NASA Goddard ISIM team for their capable technical
support in the development of MIRI, its delivery and successful integration.

References

Allington-Smith, J. 2006, New Astron. Rev., 50, 244

Alves de Oliveira, C., Lützgendorf, N., Zeidler, P., et al. 2022, *Proc. SPIE*, 12180, 121803S

Argyriou, I. 2021, PhD Thesis, KU Leuven - Faculty of Science, Belgium, https://fys.kuleuven.be/ster/pub/phd-thesis-yannis-argyriou/PhD_Thesis_IoannisArgyriou.pdf

Argyriou, I., Rieke, G. H., Ressler, M. E., Gáspár, A., & Vandenbussche, B. 2020a, SPIE Conf. Ser., 11454, 114541P

Argyriou, I., Wells, M., Glasse, A., et al. 2020b, A&A, 641, A150

Argyriou, I., Glasse, A., Law, D. R., et al. 2023, A&A, 675, A111

Astropy Collaboration (Robitaille, T. P., et al.) 2013, A&A, 558, A33

Astropy Collaboration (Price-Whelan, A. M., et al.) 2018, AJ, 156, 123

Belenguer, T., Alcacera, M. A., Aricha, A., et al. 2008, SPIE Conf. Ser., 7010, 701039

Böker, T., Beck, T. L., Birkmann, S. M., et al. 2023, PASP, 135, 038001

Bushouse, H., Eisenhamer, J., Dencheva, N., et al. 2022, https://zenodo.org/records/6984366

Gaia Collaboration (Brown, A. G. A., et al.) 2018, A&A, 616, A1

Gardner, J. P., Mather, J. C., Abbott, R., et al. 2023, PASP, 135, 068001

Gasman, D., Argyriou, I., Sloan, G. C., et al. 2023, A&A, 673, A102

Gáspár, A., Rieke, G. H., Guillard, P., et al. 2021, PASP, 133, 014504

Glauser, A. M., Glasse, A., Morrison, J. E., et al. 2010, Proc. SPIE, 7731, 77313K

Glazer, S., & Comber, B. 2016, in 46th International Conference on Environmental Systems

Gordon, K. D., Bohlin, R., Sloan, G. C., et al. 2022, AJ, 163, 267

Harris, C. R., Millman, K. J., van der Walt, S. J., et al. 2020, Nature, 585, 357

Herrada, F. J., Eiriz, V., Alcacera, M. A., et al. 2007, New Dev. Optomech., 6665, 66650Y

Hunter, J. D. 2007, Comput. Sci. Eng., 9, 90

Jones, O. C., Álvarez-Márquez, J., Sloan, G. C., et al. 2023, MNRAS, 523, 2519

Labiano, A., Azzollini, R., Bailey, J., et al. 2016, SPIE Conf. Ser., 9910, 99102W

Labiano, A., Argyriou, I., Álvarez-Márquez, J., et al. 2021, A&A, 656, A57

Law, D. R., E. Morrison, J., Argyriou, I., et al. 2023, AJ, 166, 45

Lindegren, L., Lammers, U., Bastian, U., et al. 2016, A&A, 595, A4

Morrison, J. E., Dicken, D., Argyriou, I., et al. 2023, PASP, 135, 075004

Perrin, M. D., Long, J. D., Zimmerman, N. T., & Van Gorkom, K. 2016, in American Astronomical Society Meeting Abstracts, 228, 216.20

Rieke, G. H., Ressler, M. E., Morrison, J. E., et al. 2015a, PASP, 127, 665

Rieke, G. H., Wright, G. S., Böker, T., et al. 2015b, PASP, 127, 584

Virtanen, P., Gommers, R., Oliphant, T. E., et al. 2020, Nat. Methods, 17, 261

Wells, M., Pel, J. W., Glasse, A., et al. 2015, PASP, 127, 646

Wright, G. S., Wright, D., Goodson, G. B., et al. 2015, PASP, 127, 595

Wright, G. S., Rieke, G. H., Glasse, A., et al. 2023, PASP, 135, 048003

Yokoya, N., Miyamura, N., & Iwasaki, A. 2010, SPIE Conf. Ser., 7857, 78570B
# Appendix A: Pre-launch calibration

## Appendix A.1. Ground test data

### MIRI Flight Model test campaign.

The MIRI Flight Model (FM) test campaign took place at the Rutherford Appleton Laboratory in the UK in 2011. The MIRI instrument and its operational modes were tested under cryogenic conditions and dedicated test runs were performed to characterise all aspects of the instrument (optical alignment, performance of electronics and detectors, optical transmission, etc). The FM test campaign included a fine raster scan of a point source with multiple exposures per slice for each sub-band of the MRS, dithered observations for the FoV measurement, and observations with a spatially uniform extended source. A dedicated optical system, the MIRI Telescope Simulator (MTS, Belenguer et al. 2008; Herrada et al. 2007), was built in order to provide the necessary input illumination. A black body source was available operated at a temperature of 400 K, 600 K, and 800 K. For simulating point sources, a 100 µm pinhole mask was placed in the pupil wheel of the MTS and provided a point-like source that could be steered with high precision.

It should be noted that due to a non-uniform illumination of the pupil at the field location of the MRS, the pinhole mask did not produce a diffraction limited PSF but rather an elongated semi-extended source. The flux from the source was also relatively low, with a maximum of three digital numbers per second (DN/s), out of the ~2000 DN/s that an almost saturating source would provide. This resulted in low S/N in the raster and FoV observations of the point source. Finally, the most critical issue for the geometric distortion calibration based on FM data was a field distortion of the MTS itself that introduced a systematic error in the reference coordinate system of the MTS source (MTS-X/MTS-Y). This distortion was measured from MIRI Imager exposures and modelled in Zemax OpticStudio, indicating a significant shear in the MTS field which could not be corrected to the precision required for the MRS distortion calibration. Nonetheless, the FM data provide a starting point for deriving the intra-slice distortion, with a raster scan covering all slices and bands of the MRS. Even with a distorted MTS field, all the spectral bands can be placed onto a common coordinate frame.

### MIRI cryogenic vacuum test campaign

Three cryogenic vacuum (CV) test campaigns were conducted at Goddard Space Flight Center between 2013 and 2016, denoted CV1, CV2, and CV3 (Glazer & Comber 2016). The whole JWST Integrated Science Instrument Module (ISIM) was placed in a cryostat and cooled to operating temperature (this did not include the JWST telescope optics or bus). The testing setup provided a JWST-like point source with high flux but in a very limited wavelength range. For the MRS, the useful signal was limited between 4.9–6.1 µm. The dither patterns observed were associated with the ISIM coordinate system defined by coordinates XAN/YAN, which provided a robust and distortion-free reference frame. Besides a nine-point dither pattern for the PSF measurement in CV2 and CV3, a very useful across slice scan was performed in CV3, where the source was displaced in fixed steps over a slice. This last data set was used to evaluate our fitting routines, as described in Sect. 3.2.

### Ground data processing

The FM and CV data were taken from the Rutherford Appleton Laboratory (RAL) archive, already processed to slope images (units of digital numbers per second; Morrison et al. 2023). All FM and CV data had dedicated backgrounds associated with the science exposures, which were always subtracted.

## Appendix A.2. Astrometric reference frame using sub-band 1A

At the beginning of the analysis to derive the MRS geometric distortion, we address the fact that there is a lack of a reference coordinate system that can connect the FoV of all 12 MRS bands and provide the distance of the FM raster scan points in $\alpha/\beta$ coordinates. These distances would then be fitted to estimate the polynomial coefficients of the distortion transform Eq. 1. Ideally, this reference frame would have been the MTS commanded coordinates (MTS-X/MTS-Y), but due to the distortion of the MTS field itself, the reference would have been biased. First, the MTS distortion needs to be taken into account, and therefore, we consider the XAN/YAN coordinate frame of the CV2 FoV measurement. The XAN/YAN coordinates are assumed to be non-distorted and the CV2 measurement provided nine points in the FoV of 1A. Unfortunately, band 1A is the only band with enough signal from the ISIM point source.

The dither pattern of CV2 was based on the distortion derived from the FM data and therefore the commanded offsets could not a-priori be assumed to be orthogonal to the slicer of 1A. We used the sampling of CV2 point source by the slices to determine the centre of each pointing in the across-slice position, in units of slice number, s. We then performed an affine transform to offset, rotate and scale the XAN/YAN coordinates to $\alpha/\beta$. The affine transform is given by Eq. 7, which is a least-squares minimisation meant to estimate the parameters $\beta_0$, $\Delta\beta$, $\theta$, $X_0$, and $Y_0$.

The parameters $\beta_0$ and $\Delta\beta$ fully define the $\beta$ coordinate of the local MRS slicer coordinate system, and $\alpha$ is just defined orthogonal to that. The angle $\theta$ provides the rotation of the MRS 1A FoV with respect to the JWST coordinate system $V_2 + V_3$. For the points of the CV2 campaign, we therefore have a valid and unbiased reference frame.

Next, we made use of the Zemax OpticStudio optical model to obtain a set of calibrated slices in the locations where the CV2 data had available points. Since we effectively only have two points per slice from the CV2 FoV measurement, we can only correct the $\alpha$ distortion up to a magnification but cannot check or correct the plate scale gradient (the second order term). By examining the Zemax OpticStudio model prediction as it is, we see that the projected slices on the detector are offset compared to the slice mask derived in Sect. 4.3. We correct that by moving the Zemax OpticStudio slices on the middle of the detector (row 512) to match the measured slice edges. This yields a $\Delta x$ value for each of the slices in band 1A, corresponding to the shift in detector x between Zemax OpticStudio and measured slices.

For each of the slices that have at least two point sources we identified pairs of points that have approximately the same $\beta$ coordinate, and used their $\alpha$ coordinates from the XAN/YAN transform to calculate their distance, $\Delta\alpha_{XAN/YAN}$, in units of arcseconds. We then measured their iso-$\alpha$ on the detector, using the Zemax OpticStudio model we obtained $\alpha_{Zemax}$, and again calculated the distance, denoted $\Delta\alpha_{Zemax}$. In Fig. A.1 we show the difference between $\Delta\alpha_{XAN/YAN}$ and $\Delta\alpha_{Zemax}$ as a function of position along detector columns. This difference reflects a discrepancy in the magnification of the field in the Zemax OpticStudio model, which we correct by multiplying $\alpha_{Zemax}$ by a scaling factor for each slice. Interestingly there seems to be a correlation between detector-X position of the slice and the magnification error. Another systematic effect that can be seen in Fig. A.1 is a difference between pairs in the same slice. The darker colours of the points refer to the point source pairs that are well centred in the slice, while the lighter colours correspond to the half-slice offset of the dither pattern, with the point source centred
<figure><img src="image_12.png" /><figcaption>Fig. A.1. Zemax alpha distortion calibration</figcaption></figure>

<figure><img src="image_13.png" /><figcaption>Fig. A.2. MTS field projected onto α/β of band 1A. The raster scan point of bands 1A+2A+3A+4A are plotted, used for measuring the distortion of the MRS.</figcaption></figure>

in between two slices. Finally, there is a slice dependent offset between Zemax OpticStudio and the reference frame which is expected from slight slit mask offsets which would cover different parts of the field for each slice. This is corrected with a constant α offset for each of the slices, concluding the calibration of slices 3, 4, 8, 9, 13, 14, 17, and 18 (21 slices in total).

## Appendix A.3. MTS to reference frame transform

With several calibrated slices in band 1A, but lacking any reference frame in other bands, we proceeded to derive a transform linking the MTS coordinates to the reference frame defined in Sect. Appendix A.2. This step is essential for enabling the distortion calibration of all other bands (that did not have any useful signal in the CV campaign). We used the main raster scan exposures from the FM campaign, selected the calibrated slices and measured their α/β coordinates from the detector. We then fitted the affine transform in Eq. A.1, including translation, rotation, scale and shear, to map the MTS-X/MTS-Y coordinates to α and β respectively. In Fig. A.2, we show a square field in MTS coordinates projected onto reference 1A α/β frame, as well as the raster scan pointings of each of the SHORT bands 1A, 2A, 3A, and 4A.

where

$$R[\theta] = \begin{bmatrix} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{bmatrix} \quad \text{and} \quad S[\mathbf{s}] = \begin{bmatrix} \sigma_x & s_x \\ s_y & \sigma_y \end{bmatrix}.$$

The parameters σx/y, sx/y correspond to a field magnification and shear between MTS and the local MRS coordinates.

With the raster scans mostly aligned to the IFU image slicer for each band, we can observe the slight differences between the band-to-band boresight and rotation of the slicers. Using a similar model as in Eq. 6, we calculate the transform from the reference frame 1A to the local α/β frame for each band, based on the detector slice coordinates of the raster scans. This yields the β0 and Δβ parameters for defining the β coordinate, as well as the relative rotation and β boresight offset with respect to band 1A, for all 12 sub-bands. The final value of the boresight shift in α between the bands were determined after the final calibration of the alpha distortion in Sect. 4.4.

## Appendix A.4. Along-slice distortion transformation matrix

The procedure was the same for each band. The main raster scan of the given band was used, with each slice having available three exposures centred on the slice. The iso-α trace on the detector was fitted for each exposure using a Gaussian profile on the detector as detailed in Sect. 3.2, going up the detector rows. The derived MTS to local MRS transforms provide the required astrometric information to assign each of the raster scan exposures an α coordinate based on their MTS coordinates. The detector fringes modulate the α centre along the dispersion direction and affect its estimation, and since we expect the distortion to be a smooth function we fitted a two-dimensional polynomial of the order of 2 in detector-X and order of 4 in detector-Y.

## Appendix A.5. Iteration of distortion solution

Having derived a first distortion solution based on the FM data, we used the FM PSF measurement to reconstruct the PSF in α/β space. To do so we need to interpolate the detector pixels onto the MRS local coordinate frame. We used an inverse distance weighting algorithm, with exponential decaying weights (referred to in the pipeline cube building as emsm<fnref n="7" />). The offset of each dither was estimated using its MTS coordinates and transforming them into α/β coordinates. In Fig. A.3, the reconstructed and over-sampled PSF of band 2A is plotted, together with the individually reconstructed dithered exposures. We observe that the PSF is semi-extended and does not show the expected diffraction limited pattern. Not only that, but for the additional purpose of deriving the distortion solution (as seen in Fig. A.3), the centroid estimated by a Gaussian does not match the centre of the PSF.

Therefore, we iterate on the distortion solution by using the reconstructed PSF as a forward model to estimate the centre of a given FM point source observation. This activity was implemented in two ways, illustrated in Fig. A.4. First, for band 1A, we used the 2D PSF to fit the points of the raster scan and to iterate on the MTS to α/β transform. The high-resolution PSF was projected onto the local MRS coordinates with the RegularGrid Interpolator from the scipy package using linear interpolation. The optimisation used the L2 norm as a loss function to minimise the difference between model and the data, with three free parameters of amplitude, offset α, and offset β. To

$$\begin{bmatrix} \alpha \\ \beta \end{bmatrix} = \begin{bmatrix} \alpha \\ \beta_0 + (s-1) * \Delta\beta \end{bmatrix} = R[\theta]S[\mathbf{s}] \begin{bmatrix} MTS_X - X_0 \\ MTS_Y - Y_0 \end{bmatrix}, \quad (A.1)$$

<footnote n="7">⁷ https://jwst-pipeline.readthedocs.io/en/latest/jwst/cube_build/main.html</footnote>
<figure><img src="image_14.png" /><figcaption>**Fig. A.3.** Estimation of the MTS PSF from the FM PSF observations. The individual dithers are combined into a higher resolution PSF, revealing the shape of the MTS point source. This PSF can be used when iterating the distortion solution in order to improve centroid estimation.</figcaption></figure>

ensure the minimisation converged, we restricted the evaluation of the loss function within an aperture of 0.5" around the point source (~3 slices on the image slicer). This process yielded new centroids which were in turn used to calculate the new transform with Eq. A.1.

Second, using the distortion solution derived earlier, the PSF model is projected onto the detector for every row to estimate the iso-α trace accounting for the shape of the PSF. This is repeated for every point in the raster scan, and the distortion was estimated again on the updated traces. The projection uses the estimate of the slice coordinate from the detector to provide the PSF α-profile expected in the slice of interest. Typically this only works for slices either containing the peak of the PSF, or the slices adjacent to that, due to the low S/N of the FM data. Here, the scipy function interp1d was used, once again with a linear interpolation.

With the iso-α traces and MTS to α/β field transform based upon the FM PSF, we re-calculated all the distortion polynomial coefficients as in Sect. Appendix A.4.

<figure><img src="image_15.png" /><figcaption>**Fig. A.4.** Forward modelling of the FM PSF used for the estimation of α, β centroids, and the iso-α trace. Top left: High resolution interpolated model of FM PSF. Top right: Reconstructed cube of a single point source exposure using the initial distortion solution. Bottom right: Model PSF interpolated on the grid of the cube to match the observed data. Bottom left: Difference between the data and projected PSF model.</figcaption></figure>