Skip to content

WCS.all_world2pix ignores a detector-to-image (D2IM) correction present on only one axis #20577

Open

Description

@ChenziqiAdam

Description

If a WCS has a detector-to-image lookup table on only one axis (det2im1 set, det2im2 left as None), all_pix2world applies the correction but all_world2pix does not. The inverse is off by the full size of the correction, and no NoConvergence is raised. A one-axis D2IM table is a normal FITS distortion setup: it is what you get from a header that has only D2IMDIS1, as in the HST/ACS column-width correction (AXISCORR = 1).

Expected behavior

No response

How to Reproduce

import numpy as np
from astropy.wcs import WCS, DistortionLookupTable

w = WCS(naxis=2)
w.wcs.crpix = [1, 1]
# detector-to-image correction on the x axis only (+0.5 px everywhere)
w.det2im1 = DistortionLookupTable(np.full((5, 5), 0.5, np.float32), (1, 1), (1, 1), (1, 1))

pix = np.array([[2.0, 2.0]])
world = w.all_pix2world(pix, 0)
print("world         :", world)
print("round trip err:", w.all_world2pix(world, 0, tolerance=1e-12) - pix)
print("has_distortion:", w.has_distortion)
world         : [[2.5 2. ]]
round trip err: [[0.5 0. ]]
has_distortion: False

Versions

import astropy
astropy.system_info()
# Paste the result here

Activity

  1. mcara commented on Oct 16, 2026

    @mcara
    Contributor

    This is not an issue for HST images as there are no images that have either only D2IMDIS1 or D2IMDIS2. How have you encountered this error?

  2. ChenziqiAdam commented on Oct 18, 2026

    @ChenziqiAdam
    Author

    Thanks for the comment, and sorry for the late reply. My statement linking this configuration to HST/ACS was incorrect.

    The example sets only det2im1: all_pix2world applies the correction, but all_world2pix skips it because has_distortion returns False. Is a single-axis D2IM configuration intended to be supported? If so, this seems to be a forward/inverse inconsistency. If not, would rejecting that configuration be appropriate?

  3. mcara commented on Oct 18, 2026

    @mcara
    Contributor

    The example sets only det2im1

    That's a theoretical example but I am curious how did you encounter it in real life? What data are you working on?

  4. ChenziqiAdam commented on Oct 18, 2026

    @ChenziqiAdam
    Author

    Actually it is not a real example. I was just debugging my code and tried different settings.

  5. pllim commented on Oct 19, 2026

    @pllim
    Member

    debugging my code

    What we really want to know is how this affects your real work. So what code were you debugging and how was that relevant to this issue?

  6. added
    Close?Tell stale bot that this issue/PR is stale
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions