Conversation
nabobalis
added a commit
that referenced
this pull request
Sep 28, 2026
| from ndcube import NDCube | ||
| from sunpy.coordinates import HeliographicStonyhurst, Helioprojective | ||
|
|
||
| import irispy.io.spectrograph as spectrograph_io |
|
|
||
| from ndcube.utils.exceptions import NDCubeUserWarning | ||
|
|
||
| import irispy.io._raster_combine as raster_combine |
This was referenced Sep 28, 2026
Merged
nabobalis
force-pushed
the
gwcs_raster_v2
branch
from
September 28, 2026 02:31
942364c to
97c5efa
Compare
| cube = read_spectrograph_lvl2(raster_sg_file, spectral_windows="Si IV 1403")["Si IV 1403"] | ||
|
|
||
| with pytest.raises((IndexError, ValueError)): | ||
| cube[item] |
nabobalis
force-pushed
the
gwcs_raster_v2
branch
2 times, most recently
from
September 28, 2026 03:28
c0aa132 to
ea1f7ed
Compare
This was referenced Sep 28, 2026
_create_raster_gwcs describes one spectral window with dkist's varying celestial transforms. Each exposure has its own pointing (XCENIX, YCENIX), PC matrix and T_OBS time from the auxiliary table. Its reference pixel is its own step and the 0-based slit reference pixel CRPIX2 - 1. For sit-and-stare windows the AUX PC is an unscaled rotation, so the step axis uses the slit scale CDELT2. The last table row is repeated once, because dkist rounds half to even and would otherwise give the far pixel edge of an even number of steps no coordinates. Rows with all-zero or non-finite pointing or PC values, and non-finite times, are interpolated from the neighbouring exposures, or extrapolated from the two nearest ones at the ends, with a warning; only a table with no usable row raises. _time_lookup extends the time table to the outer pixel edges and gives NaN beyond them. The module also holds the crop-bounds hook that the next commit attaches to SpectrogramCube. Nothing calls the builder yet; the tests here cover the parts that need no reader.
read_spectrograph_lvl2 and read_files now return one SpectrogramCube per spectral window instead of a SpectrogramCubeSequence: a 3D cube for a single raster file or a sit-and-stare observation, and a 4D cube with a leading raster scan axis for a multi-file observation. Each window's WCS comes from the builder of the previous commit. The FITS -TAB WCS that main built stays available as cube.fits_wcs, derived from the slice of each file's WCS kept in meta. - The reader reverses a v34 file's AUX table once and reads the flipped data, so the mask, uncertainty and PC step column follow from it. AUX rows with unusable pointing, PC or times are interpolated with a warning. A file whose exposure times are all non-finite keeps the planned start times. A window whose WCS cannot be built raises an error naming the window and file instead of being dropped. - io/_raster_combine.py stacks the per-file cubes and their WCS tables along the scan axis, padding a short final raster, and with memmap=True gives one lazy, dask-backed cube that reads each file on demand. - SpectrogramCube gains raster_slice, split_rasters, time, celestial_frame, the crop-bounds hook for partial crops, native pixel scales for rebinned cubes and exposure-time corrections with two exposure axes. axis_world_coords returns C-ordered Time arrays, which works around an astropy bug that prints non-C-ordered times out of order. - radiometric_calibration uses apply_exposure_time_correction and accepts a cube that is already in units per second. - SpectrogramCubeSequence and IRISSequencePlotter are removed. The partial-crop tests need ndcube's crop-bounds hook and skip visibly without it; the devdeps and docs envs use nabobalis/ndcube@irispy-devdeps, which has the hook. The tests, the tutorial doctests and the gallery examples move to the new API.
…mages With a gWCS, raster plots gain step, scan and time axes. The sliders for them now read "Raster step" and "Scan number", and a time offset axis is labelled "Seconds from Start". When axes_coordinates asks for longitude, it goes on the bottom edge (and a requested latitude on the left), the time, step and scan coordinates that were not asked for are hidden, and this survives moving the slider. Axes are matched by physical type as well as by label, so a cube built from a user WCS with its own axis names is styled too. Images and animations default to nearest-neighbour interpolation, so each slit position shows as a pixel.
docs/migration.rst shows the old and new versions of the common raster patterns: indexing, getting individual rasters, crops, times, the FITS WCS, the removed sequence and SJI names, and memmapped data.
nabobalis
force-pushed
the
gwcs_raster_v2
branch
from
September 28, 2026 06:38
ea1f7ed to
860174b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each spectral window is now one
SpectrogramCubewith a gWCS built from the AUX pointing, roll and T_OBS time of every exposure:This replaces
SpectrogramCubeSequence.docs/migration.rstshows the old and new versions of the common patterns, and thechangelog/182.*fragments list the breaking changes.Reviewing
The pieces that did not depend on the rewrite are already on main: #184 (minimum versions and figure hashes), #185 (
SGMeta.observer) and #186 (negative indices,SJICube.fits_wcs). What is left is four commits, each of which passes the tests on its own:irispy/_spectrograph_wcs.py, with the tests that need no reader). This is where the coordinates come from, including sit-and-stare.SpectrogramCube: the reader, combining files along the scan axis, the cube class, and moving the tests, tutorial doctests and gallery examples to the new API.What changes for users
raster_slice(k)andsplit_rasters()give individual rasters.cube[0]now indexes the first array axis: raster step 0 on a single file, scan 0 on a combined cube.cube.fits_wcsis main's FITS-TAB WCS, built per file.cube.timegives the exposure times, with shape (scan, step) on a combined cube.cube.celestial_frameworks on spectrograph cubes, as it already does on SJI cubes, and on any slice.SpectrogramCubeSequenceandIRISSequencePlotter.radiometric_calibrationalso accepts a cube that is already in units per second.Coordinates
I compared the gWCS against main's FITS-TAB WCS on every exposure, several slit rows and 3 wavelengths. On 7 cached observations the largest difference is 1.25e-5″ and 0 non-finite values:
At the slit centre, each exposure matches the AUX XCENIX/YCENIX to 2.4e-10″. For sit-and-stare, the along-slit offsets equal CDELT2·dy·(PC3_2, PC2_2) to 5e-7″. Tests guard both at 0.01″ and 0.001″.
dkist picks each exposure's table row with
np.round, which rounds half to even, so the far pixel edge of an even number of steps had no coordinates. The builder repeats the last table row, which makes those pixel corners finite. Every other coordinate is unchanged bitwise.ndcube
Partial crops need ndcube's
_get_crop_boundshook. That hook isn't in a release yet, and it waits on sunpy/ndcube#977. Until then:nabobalis/ndcube@irispy-devdeps, which is ndcube main plus the hook, Fix crop world-object order for WCSes with non-contiguous components sunpy/ndcube#977, #979, #980 and #982. It carries upstream'sv2.5devtag, so it builds as ndcube 2.5.dev.Known cost: plots across exposures are slow
dkist's varying celestial transforms loop over every exposure, and dkist 1.18.1 still does. The figures below are for the 1600-exposure sit-and-stare, main vs this branch:
axis_world_coords()We are accepting this for the merge and will decide before the release. The fix is a vectorised
_map_transformin dkist.Tests
Every commit passes all of these environments, and none of them changes a figure. The counts are for the last commit:
irispy-devdepswith remote data: 433 passed, including the doc tests.-W) passes, and all 20 gallery examples run from commit 2 onwards.Other notes
SpectrogramCube.axis_world_coordsreturns C-orderedTimearrays. It works around ndcube returning N-D coordinates transposed, together with an astropy bug that prints non-C-orderedTimearrays out of order (issue to follow).