Skip to content

WCS.all_world2pix reports convergence while off by several pixels from its requested tolerance #20405

Description

@ChenziqiAdam

Description

WCS.all_world2pix(world, origin, tolerance=...) is documented to iterate until the residual is within tolerance, or raise NoConvergence otherwise.

Expected behavior

Either the result should be within the requested tolerance=1e-4, or NoConvergence should be raised.

How to Reproduce

import numpy as np
from astropy.wcs import WCS

wcs = WCS(naxis=2)
wcs.wcs.crpix = [1.0, 1.0]
wcs.wcs.cdelt = [1e-10, 1e-10]
wcs.wcs.crval = [15.0, -20.0]
wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"]

pixel = np.array([[1e14, 2e14]])
world = wcs.all_pix2world(pixel, 0)
recon = wcs.all_world2pix(world, 0, tolerance=1e-4)

print(np.linalg.norm(recon - pixel))  # 4.311622419765557

Versions

0.1.dev41760+g95c20c73b

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions