Skip to content

Add Spectral support - #6

Open
timj wants to merge 23 commits into
u/timj/phase3-fitschan-writefrom
u/timj/phase4-spectral
Open

timj wants to merge 23 commits into
u/timj/phase3-fitschan-writefrom
u/timj/phase4-spectral

Conversation

@timj

@timj timj commented Nov 17, 2026

Copy link
Copy Markdown
Member

No description provided.

timj and others added 22 commits November 16, 2026 08:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Add SpecMap from specmap.c (via the Rust port): every spectral system
conversion, the changes of rest frame through PAL with the
1-dimensional frequency correction factor kept in the step's
arguments as C keeps it, 3-dimensional SpecMaps taking the source
position from axes 2 and 3, C's argument checks and errors, MapMerge,
Rate, dump and load. Register it for loading.

Translate test_specmap.rs and test_specmap_3d.rs (with the
specmap_3d C oracle converted to JSON), add the SpecMap cases of the
NaN, round-trip, constructor-check and API tests, and drop
"SpecMap" from the deferred lists. The simplify regression harness
now dumps before it transforms, since a transformation can store the
correction factor in the input as C does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
A step that is not a change of rest frame returns before the switch,
so its default is unreachable and throws as the project's rule says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port specframe.c Match, SubFrame and MakeSpecMapping: a SpecFrame
template finds the first SpecFrame axis of a target, and the Mapping
goes through frequency, the standards of rest and the alignment System
and StdOfRest as C's does, between the two Frames' units and
SpecOrigins, with C's AST__INTFLAG rule for FrameSet integrity.

Convert the spec_convert and spec_origin_sor C probe tables, translate
the conversion tests of test_specframe.rs, test_spec_convert.rs,
test_spec_origin_sor.rs and testspecframe.c with C values, and run the
SpecFrame cases of the match_axes, overlay, integrity,
frameset_variants, spec_use_defs and unit_mapper oracles and the
find_frame, convert and frame_geometry tests that needed a SpecFrame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Each chain stands in for a match over the velocity Systems, so a
System it does not expect now throws, and VREL needs no step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
DSBSpecFrame (dsbspecframe.c, with Rust frames/dsbspecframe.rs): the
SideBand, DSBCentre, IF, AlignSideBand and ImagFreq attributes as C has
them, the DSBCentre converted to and from topocentric frequency through
TopoMap, the sideband Mappings, Match, SubFrame and Overlay, the dump and
loader, and jniast's public API. A SpecFrame of a subclass casts into a
SpecFrame. FITS writing refuses a world Frame with a SpecFrame axis until
spectral axes are written.

Tests: DSBSpecFrameTest (test_dsbspecframe.rs and the frames/dsbspecframe.rs
unit tests, against a C probe), DsbTopoOracleTest (dsb_topo oracle), and
the DSBSpecFrame cases of the spec_convert, spec_origin_sor, spec_use_defs,
class_attrs, frame_class, frame_axis, integrity and section_load oracles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
FluxFrame (fluxframe.c, with Rust frames/fluxframe.rs): the FLXDN, FLXDNW,
SFCBR and SFCBRW Systems (SRCBR read as SFCBRW, as the pinned C reads it),
the System a Unit implies, the Unit recorded for each System, SpecVal and
the SpecFrame it is given in, MakeFluxMapping's conversions between flux
systems, Match, SubFrame and Overlay, the dump and loader, and jniast's
public API.

Tests: FluxFrameTest (test_fluxframe.rs, test_flux.rs from testflux.c and
the frames/fluxframe.rs unit tests, against a C probe), FluxBadunOracleTest
and FluxUnitSystemOracleTest (flux_badun and flux_unit_system oracles), and
the FluxFrame cases of the class_attrs, frame_class, frame_axis, frame_load,
integrity, overlay, system_change and frame_api oracles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port C's WcsSpectral (FitsWcsSpectral): each axis whose CTYPE names a
FITS-WCS paper III spectral system becomes a SpecFrame, or a DSBSpecFrame
set up by DSBSetUp when the header gives IMAGFREQ, with the keyword
settings in C's order, and its Mapping is linear or C's NonLinSpecWcs
-X2P form; -LOG and -GRI/-GRA axes stop with needs MathMap and needs
GrismMap. FitsWcsRead builds the world Frame and IWC units with the
spectral stage between the celestial and other axes, as WcsMapFrm does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port C's SpectralAxes (FitsSpectralAxes): the linear, -X2P, -LOG, grism
and -TAB algorithms tried as C tries them, through the FrameSet being
written, with CTYPE, CRVAL, CUNIT, CNAME, OBSGEO, RESTFRQ or RESTWAV,
IMAGFREQ, SPECSYS, ZSOURCE, SSYSSRC and VELOSYS. -LOG needs MathMap and
-TAB needs FitsTable where C builds them.

MakeFitsFrameSet now handles a SpecFrame as C does (celestial axes for
its reference position, RefRA and RefDec from the celestial fiducial
point, no FrameSet for two SpecFrames) and calls AddEncodingFrame,
replacing the interim refusal of spectral FrameSets.

The SpecFrame entries of the test-local exclusion lists, the write rows
of deferred/wcsconv.txt and the write entries of rust-tests.txt now pass
as C, but for the FITS-CLASS writes, which FitsEncClass still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port C's ClassTrans into the FITS-CLASS read and the whole of
CLASSFromStore (velocities, azimuth and elevation, the one-pixel-axis
NAXIS rewrite); every FITS-CLASS wcsconv row, header oracle fixture and
encodings oracle write now matches C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
CmpFrame.cast now copies a CmpFrame into any class of the CmpFrame
family, as cmpframe.c Cast does through astCastCopy: a SpecFluxFrame
cast into a CmpFrame no longer throws AST__INTER, and the CmpFrame a
FluxFrame or SpecFrame match gives is cast into a SpecFluxFrame and
reaches MakeSFMapping (needs RateMap, or C's AST__ATSER).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
WcsCelestial returns the reference longitude and latitude separately,
as C does, so a header with only one celestial CRVAL gives the
SpecFrame that coordinate (C's astSetRefPos in WcsSpectral); only the
SkyRef setting needs both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Record the final review, its fixes and rulings, and the C quirks and
defects it found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
@timj
timj added this pull request to stack #4 November 17, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant