Repository navigation
Correct the pointing of XRT images with the co-alignment databases of SolarSoft, by default from the cross-correlation with AIA. - #5
Merged
Conversation
… SolarSoft, by default from the cross-correlation with AIA. Ports xrt_read_coaldb.pro (with and without /aia_cc) and xrt_rollangle.pro as the `coalign` option of `hinode.xrt.open` and `Filtergram`: "aia" (the default) uses coaldb_c and falls back to coaldb_u, "ufss" uses coaldb_u, and None keeps the headers. `Filtergram.coalignment` records the CALIBRATION_TYPE of each image. The Level 1 files already carry the UFSS pointing, so "aia" moves the 2019-09-30 18:08:00 image by -0.34", +0.68", and the roll is recomputed, which changes the files made in 2022 from the pre-anomaly roll by more than a degree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VGPHLGJi8acbuLYSfBHTk
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
==========================================
+ Coverage 99.79% 99.84% +0.05%
==========================================
Files 16 18 +2
Lines 1432 1968 +536
==========================================
+ Hits 1429 1965 +536
Misses 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…mages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VGPHLGJi8acbuLYSfBHTk
…, use cached copies offline, and warn when the roll is extrapolated. The listing now keeps when each file last changed, so a complete file before a gap is no longer downloaded every day, and files the server rewrites are noticed, with the listings checked again after a month for any image. A download which fails keeps the copy from before with a warning, and the roll past the last measurement is extrapolated as in xrt_rollangle.pro but with a warning. A wrong coalign is caught before anything is downloaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VGPHLGJi8acbuLYSfBHTk
roytsmart
added a commit
that referenced
this pull request
Oct 10, 2026
hinode.xrt.open now corrects the pointing with the AIA co-alignment database by default (#5), so the manual cell that read the database and shifted CRVAL is replaced by showing xrt.coalignment. The pointing is the same to 5e-7 arcsec, so the numbers in the text are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VGPHLGJi8acbuLYSfBHTk
2 of 3 tasks
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.
Corrects the pointing of every XRT image as SolarSoft's
xrt_read_coaldb.prodoes. By default it uses the co-alignment database from the cross-correlation of XRT with AIA 335 Å (Yoshimura & McKenzie 2015), so the images line up with AIA without the manual step in the DEM tutorial.API
coalignonhinode.xrt.open,Filtergram.from_time_rangeandFiltergram.from_fits:"aia"(the default):coaldb_c, falling back tocoaldb_ufor images it has no entry for, asxrt_read_coaldb, /aia_ccdoes."ufss":coaldb_ualone, SolarSoft's default.None: the pointing of the headers, the behavior before this PR.Filtergram.coalignment: theCALIBRATION_TYPEof each image, numbered as inxrt_read_coaldb.pro(1 AIA cross-correlation, 2 G-band limb, 3 UFSS, 4 X-ray limb, 6 other, −1 no entry). It isNonewhencoalign=None. It is indexed with the images.from_fitsalso takesnum_retrynow, for the database downloads.coalignraisesValueErrorbefore anything is downloaded or read.What the correction does
This is a port of
xrt_read_coaldb.pro(v2016.07.06) andxrt_rollangle.pro(v2022.09.06):DATE_OBSis within 0.1 s of its own.CRVAL = (XCEN, YCEN)from the database,CRPIX = NAXIS // 2 + 0.5(IDL integer division) andCDELT= 1.0286″ (X-ray) or 1.0302″ (G-band) ×CHIP_SUM.xrt_rollangle.pro. That is the piecewise fits before the attitude anomaly of 2021-12-27, the model during it, and after it a linear interpolation inxrt_rollangle_db.geny.interpoldoes, but with a warning. Measurements reach the server days after the images (the copy downloaded on 2026-10-10 ends on 2026-10-04). The roll can change by degrees in days: it went from 2.38° on 2024-08-06 to 0.31° on 2024-08-12, so extrapolating that slope for ten days would be off by about 3.5°.What the Level 1 files already have
Every file I checked (2007, 2012, 2015, 2019, 2022, 2025, 2026) says
(XRT_READ_COALDB) Coaligned using UFSS data. Calib. type: 3. Soxrt_prepalready applied the UFSS database, without/aia_cc."ufss"reproduces the centers in the headers."aia"moves the 2019-09-30 18:08:00 Al_poly image by −0.34″, +0.68″, the same shift the tutorial applies by hand. It moves a 2022-06-01 Al_poly image by +4.4″, +2.5″.The roll in some headers is stale
xrt_rollangle.pronowSo with either database those images rotate. I haven't checked AIA independently; this reproduces what current SolarSoft gives.
One more to check against AIA some time: the roll database starts on 2022-03-03 10:02 with 28.86°, then 2.78° a day later. So the first images after the anomaly (2022-03-03 11:30) get a roll of about −27°, against −0.25° in their headers. XRT has no images between 2021-12-27 15:02 and then, so the backward extrapolation before the first measurement never applies.
Downloads and caching
The databases come from
https://sohoftp.nascom.nasa.gov/sdb/hinode/xrt/xrt_msu_coalign/and are stored underdirectory(by defaulthinode.directory_default) at the same paths.coaldb_clisting is 4.7 MB (about 3 s). Solisting.txtkeeps each file's name, the time the listing says it last changed, and when we first saw that version.coaldb_u).ConnectionErrorsays to passcoalign=None. Old data that was loaded once loads offline."aia"load of the 2019 images took 17 s, mostly the listings. After that it took about 2 s.Behavior change
Because it's on by default, coordinates change for existing code: by about an arcsecond in 2019, several arcseconds and degrees of roll for 2022, and 23° during the anomaly. A load needs sohoftp the first time it touches a database file, and recent images check again after a day.
coalign=Nonerestores the old behavior.Other changes
downloadis split into_path_local,_writeand_download_file, so the databases (IDL save files, signatureSR\x00\x04) use the same atomic write and retries as the FITS files.scipy, imported lazily forscipy.io.readsav. It was already a dependency ofxrtpy.refs.bibwill need a trivial merge with whichever lands second.Follow-up
Once this merges, the DEM tutorial in PR #4 can drop its manual co-alignment cell. Its shift would then come out as zero.
Test plan
pytest hinodepasses locally. New tests in_coalign_test.py:ConnectionErrorwhen nothing was downloaded.Filtergramandopenwith eachcoalign(exact calibration types),coalignmentafter indexing, the databases saved indirectory, a wrongcoaligncaught before downloads, and the astropy WCS comparison with and without the correction._coalign.pyis 100% covered locally.ruff check .andblack --check .pass.main(astropyTimeoverloads); CI pins 1.1.411.sphinx-build -b html docssucceeds with every example executing.🤖 Generated with Claude Code
https://claude.ai/code/session_011VGPHLGJi8acbuLYSfBHTk