Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix make_fitswcs_transform error when handling header with no PC #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Mar 20, 2018

Fix #139. (Also threw in some PEP8 clean up for utils as bonus.)

@pllim pllim added the bug label Mar 20, 2018
xy_ans = np.array([120, 100])
radec_deg_ans = (300.2308791294835, 22.691653517073615)

# TODO: Check with Nadia
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nden , I don't understand

  • why w() result can't agree for default rtol=1e-7
  • why w.inverse() would give me original XY + 1 and not XY

Am I using it wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GWCS by default uses 0-based pixel coordinates. CRPIX values are 1-based. So if you want to compare the inverse transform, it's going to return 0-based values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though maybe I'm misunderstanding the problem?

Copy link
Contributor Author

@pllim pllim Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just generally confused... What I am seeing is this:

ra, deg = w(x, y)

but

w.inverse(ra, dec) = x + 1, y + 1

All I want to know is if this is the expected behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdavies-st is correct. When you are mixing FITS and gwcs you have to take care of 0- vs 1- based coordinates. The gwcs transform is 0-based. However, the values of crpix are 1-based. If you change the CRPIX values to be 0-based, i.e. subtract 1 from them , you will get agreement (you'll get better agreement in the forward direction too).

BTW, the header has incorrect FITS WCS to start with. It is not allowed to mix CD matrix and CDELT values and in this case the CDELT values are ignored and assumed to be 1.

I don't want to encourage changes and "fixes" to these functions as I think it's time to implement full conversion between the two objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so I have to -1 from the keyword value, not inputs. Gotcha.

So, should I close this and wait for your "full conversion" then?

@@ -7,15 +7,11 @@
import functools
import numpy as np
from astropy.modeling import models as astmodels
from astropy.modeling.models import Mapping
from astropy.modeling import core, projections
from astropy.modeling import core, projections, is_separable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import is a real bug found by my flake8 checker. If you want, I can put this in as separate PR. Though none of your existing tests caught it, so probably not important?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 81.651% when pulling 75e97e9 on pllim:read-fits-hdr into c1672a5 on spacetelescope:master.

@nden
Copy link
Collaborator

nden commented Mar 22, 2018

Just to clarify, the reason I don't use these functions is that I think that GWCS should not have to parse FITS headers but use the astropy.wcs parser.

@zacharyburnett zacharyburnett requested a review from a team as a code owner April 14, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants