Distortion fit ============== How the distortion of ESIS-I is fit to the flight data, and how to reproduce the fit committed to the package. The numbers in the tables below are read from the committed tables when this page is built. What the data determine ----------------------- The terms fit are chosen by what each does to the image on the sensor. In each channel the yaw and pitch of the grating translate the spectrum, and with it every line's window; the ruling spacing sets the dispersion; the pitch and yaw of the pointing translate the Sun within the windows; the sensor's distance along the beam sets the plate scale; and its three angles rotate the image and tilt it in the two keystone senses. The other placements repeat one of these motions or leave the image unchanged to first order, and are held at their as-built values. The roll of the field stop moves only the edges of the windows. The displacement of the primary trades against the focus-preserving distance of the sensor. The in-plane position of the sensor trades against the grating's yaw and pitch, and both trade against the pointing: the mapping cannot tell a moved sky from a moved grating. A global search over a set that contains such a null direction lands somewhere along it at random, and two seeds disagree by tens of pixels; over the nine terms, two seeds agree to two hundredths in merit. Two things break the degeneracies the frame leaves. The edges of the windows are the image of the field stop through the optics, and do not move when the pointing does, so they say where the grating and sensor put the image and leave the pointing to explain the rest. Measured in every frame of the flight, they move by up to a pixel and a half end to end while the pointing sweeps seven arcseconds, or nine pixels, and the motion of all four channels' windows is smooth through the flight and carried per frame. And the channels compared with one another on the sky resolve a tenth of a pixel where the proxy scene resolves one. One more motion is visible only in the channels against one another. Each channel views the solar image through its own sector of the primary, so if that image is not exactly at the field stop, each channel sees it shifted along its own dispersion by the sector's offset times the defocus, while the stop's edge, an aperture in the plane the grating images, stays put: 1.6 pixels per 0.1 mm for ESIS-I. A change of the focus through the flight therefore separates the channels' skies without moving their windows, in a pattern no pointing or grating motion can make. What the data do not determine is held rather than fit. The angle between the windows and the sky, which a roll of the instrument or of the field stop would set, changes the merit by less than three thousandths over four degrees and is held at the design. The instrument roll is held at zero, in the reference and in every frame: the merit cannot measure a roll to an arcminute. The displacement of the primary is held at nominal. The merit --------- The fit compares an image of the Sun seen by another instrument (the AIA proxy scene, :func:`esis.flights.f1.data.synth.scene_aia`) with a Level-1 frame, after imaging the scene through the model of one channel. The image is made by :class:`esis.optics.LinearMerit`: the channel is linearized (:meth:`optika.systems.SequentialSystem.linearize`) with its field of view carried as the polygon its stop rays trace, so that every scene cell outside the field stop is blocked before the lines are summed, and the scene is regridded conservatively onto the sensor. The merit is the Pearson correlation with the frame. The edge pixels are 0.37 % of a window. Moving only the edges by a pixel changes the correlation by 0.0003 to 0.0014; moving the whole image by a pixel changes it by 0.005. The merit therefore cannot place the windows, which is why the edges are measured directly. The stages ---------- Each stage is a function of :mod:`esis.flights.f1.optics`, and the free set of every stage is recorded in the table it writes. 1. **Absolute.** :func:`~esis.flights.f1.optics.fit_distortion_channel` fits each channel on its own to the reference frame, 15, with :func:`esis.optics.fit_distortion`: a seeded differential evolution over the nine terms one frame determines (grating yaw and pitch, ruling spacing, pointing pitch and yaw, and the sensor's focus-preserving distance, roll, pitch and yaw), eighty generations of fifteen members per dimension, then a restarted Nelder-Mead polish. Every other term stays at the as-built model (:func:`esis.flights.f1.optics.as_built`). 2. **Edges.** :func:`~esis.flights.f1.optics.measure_window_edges` fits each side of each window's predicted outline, in every frame whose signal is at least half the flight's median, as one blurred straight edge: its position, slope and width are shared along the side, and each row or column crossing it has its own background, step and ramp inside, so that bright structure next to the edge cannot pull it. The crossings are medianed over the frames per row or column. The drift of the windows is read separately, from a step fit to every row and column on its own (:func:`~esis.flights.f1.optics.window_drift`), which follows a side's motion more steadily than its straight edge does. Both are referred to the reference frame: the median edges are moved by the drift there, as a cubic in the frame index smooths it, and the drift is taken from there. The middle window sits on its neighbours and is left out. 3. **Outline.** :func:`~esis.flights.f1.optics.fit_distortion_reference` places each channel's windows on the edges through the grating's yaw and pitch and the roll of the field stop, which move the windows without moving the sky within them, then re-polishes the sky terms against the merit (:func:`esis.optics.fit_distortion_outline`). 4. **Shared.** The primary, the field-stop roll and the payload pitch and yaw belong to the instrument. They are set to their mean over the channels, and each channel's grating and camera placement is polished again with them fixed. 5. **Internal.** :func:`esis.optics.align_channels` samples every channel's frame on a common sky grid through its own distortion at He I 584 and O V 630, reading only the window each line illuminates (:func:`esis.optics.window_mask`), measures the tile shifts against channel 1, and solves for the increments of the same terms whose change of the mapping reproduces the shifts. Using two lines separates a geometric error from a dispersion error. 6. **Focus.** :func:`~esis.flights.f1.optics.fit_defocus_history` measures every channel's sky against channel 1 in every frame, with the windows placed by the smoothed drift, and solves the focus of every sector of the primary from the shifts through the model's pattern, four unknowns from six measured components. A quadratic in the frame index, zero at the reference frame, smooths each sector's history. The proxy scene takes no part: it cannot tell a focus from the internal alignment, but the channels can, to a few microns. 7. **Pointing.** :func:`~esis.flights.f1.optics.fit_distortion_pointing` polishes the pitch and yaw of every frame on the mean merit of the four channels, with the roll held, each channel's grating offset by the drift of its windows and each sector focused by that frame's value. The offsets and the focus ride along in the pointing table for :func:`~esis.flights.f1.optics.distortion_fit` to apply. 8. **Field stop.** The field stop is a regular octagon by design, but its image is not. :func:`~esis.flights.f1.optics.measure_field_stop` measures every side of the O V window in every frame, carries the points back to the plane of the stop through the fit, and fits one shape common to the four channels after each channel's own rotation, translation and scale are taken out. The fit is made with the stop and the stop is measured through the fit, so the two are iterated: the first pass is fit with the regular octagon, each later one with the stop the one before it measured, until a measurement turns the sides of the stop by less than 0.05 deg rms (:func:`~esis.flights.f1.optics.field_stop_converged`). The regular octagon's sides are off by about half a degree; once the stop has settled, a refit turns them again by up to 0.04 deg, the scatter of the fit itself. The offsets of the sides scatter from pass to pass by as much as the octagon is off, about a micron, so they are recorded but do not end the iteration. 9. **Acceptance.** :func:`~esis.flights.f1.optics.acceptance` scores the result on frames across the flight: the merit with each frame's pointing applied on six of them, and in every frame the coalignment metric, the length of the median tile shift of each channel's sky against channel 1 at each aligned line, its component along the channel's dispersion, which is the part a velocity is charged for, and the scatter of the tiles about the median; with the residual of the window outlines against the measured edges. No inversion is involved. Results ------- The correlation of each channel with the reference frame after each stage, the residual of the window outlines against the edges after the outline stage, and the median tile shift against channel 1 after the internal alignment: .. jupyter-execute:: :hide-code: import numpy as np import astropy.table import esis reference = esis.flights.f1.optics.distortion_fit_table("reference") scores = reference.meta["scores"] rows = [ ("absolute", scores["absolute"]), ("outline", scores["outline"]["merit"]), ("edges [px]", scores["outline"]["edges"]), ("shared", scores["shared"]), ("aligned [px]", scores["alignment"]), ] table = astropy.table.Table( rows=[(name, *np.round(values, 3)) for name, values in rows], names=("stage", "ch0", "ch1", "ch2", "ch3"), ) table The reference scored across the flight with each frame's pointing applied: the correlation on six frames, and the coalignment metric over every frame and every channel but channel 1, in detector pixels, with the component along the dispersion as a velocity: .. jupyter-execute:: :hide-code: acceptance = esis.flights.f1.optics.distortion_fit_table("acceptance") scored = acceptance[np.isfinite(acceptance["correlation"])] correlation = astropy.table.Table( rows=[ (t, *np.round(scored["correlation"][scored["frame"] == t], 3)) for t in sorted(set(scored["frame"])) ], names=("frame", "ch0", "ch1", "ch2", "ch3"), ) correlation .. jupyter-execute:: :hide-code: coalignment = acceptance.meta["coalignment"] astropy.table.Table( rows=[ ( line, round(c["rms"], 3), round(c["max"], 3), round(c["rms_along_dispersion"], 3), round(c["rms_along_dispersion"] * c["km_per_s_per_pixel"], 1), ) for line, c in coalignment.items() ], names=("line", "rms [px]", "max [px]", "along dispersion [px]", "[km/s]"), ) Reproducing the committed fit ----------------------------- The fit needs the Level-1 data and the AIA scene, which are downloaded and cached on first use, and more than 100 GB of memory, which loading the Level-1 frames peaks at. On one machine, from ``docs/reports/distortion_fit``:: python reproduce.py run