lsst::pex::exceptions::RuntimeError: 'WCS does not have an attached FITS approximation.'

I have run CalibrateImageTask on a single detector / visit combo from HSC. The task completes without error but when I attempt to display the image in firefly using

afwDisplay.setDefaultBackend('firefly')
afw_display = afwDisplay.Display(frame=1)
afw_display.mtv(calexp)
afw_display.setMaskTransparency(90)

I get the error lsst::pex::exceptions::RuntimeError: 'WCS does not have an attached FITS approximation.'

I’ve tried various things but have not been successful in getting calibrateImage to insert a SkyWcs that hasFitsApproximation as ‘True’ and thus can’t use the default approach to displaying the image.

Does afwDisplay only work on Exposure objects that have a wcs that can be approximated?

How do I see what an approximateWcs is not be written into the header?

Thanks for any guidance.

Which version of the software are you using?

This message is a bit odd because for HSC data we’ve not had a problem generating the SIP header from our accurate internal WCS.

@jbosch is it possible that the new code that first checks for the attached approximation is not falling back to asking AST for the approximation?

I see this as well for some exposures, but not others even from the same visit.
A workaround I use is to display just the masked image of the exposure:

afwDisplay.setDefaultBackend('firefly')
afw_display = afwDisplay.Display(frame=1)
afw_display.mtv(calexp.maskedImage)
afw_display.setMaskTransparency(90)

Hi,

@isullivan switching to calexp.maskedImage works around the issue, thanks.

@timj I’m running the lsst science pipeline version that is in sciplat-lab:d_2025_10_22, so the daily build which is something link v29.X?

JJ

Were you running with --no-raise-on-partial-error (I believe that’s in the defaults for BPS nowadays, but not pipetask run). That would cause it to do as much processing as it can and exit without error (there’ll be some log message about a success with caveats), but it could leave the image without an updated WCS if there is a failure in the astrometry. We use this mode to keep individual detector failures from blocking visit-level gather stages (etc.).

That’d be the easiest way to get a non-FITS WCS for HSC images, because the original raw WCS is not FITS-compatible, and we don’t have any code to add FITS approximations to that running in production yet.

I see this for images that did not have failures and partial outputs, and were not run with --no-raise-on-partial-error. For example, visit=2024111100094, detector=3 of the ap_verify_ci_dp1_ecdfs ComCam CI dataset has this issue while visit=2024111600297, detector=4 does not.
To reproduce:
setup -jr /sdf/data/rubin/shared/data/test_data/ap_verify_ci_dp1_ecdfs
ap_verify.py --dataset ap_verify_ci_dp1_ecdfs --output debug/fits
Then attempt to load and display the images with firefly.
If run before weekly 45 is out, I believe you will also need to clone and setup main of ap_verify

I would expect this problem to appear virtually all the time for any image with a WCS produced by GBDES, jointcal, or FitAffineWcsTask, which would include all LSSTCam and ComCam processed images. DP1 is an exception because I manually added SIP approximations to those.

I was surprised to see them here because this is HSC data, and AFAIK HSC is still configured to use FitTanSipWcsTask, which always produces a FITS-friendly SIP WCS.