question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

wcs.to_header() function giving mixed up header keywords

See original GitHub issue

Description

There are three ways to specify the rotation/scale information. The two can be combined into one matrix (CD1_1 through CD2_2) or the rotation matrix can be given as PC1_1 through PC2_2 and the pixel scale as CDELT1/CDELT2. The third way is to give CDELT1/CDELT2 and a rotation angle as CROTA2.

What wcs.to_header() outputs looks like the second but the values of the PC matrix are actually what should be in a CD matrix and the CDELT value are nonsensical (1x1 degree pixels).

Here are the adjustments that need to be made to the headers to make them work properly:

fname, extension = os.path.splitext(file)
fits.delval(file, 'CDELT1')
fits.delval(file, 'CDELT2')
pc1_1 = fits.getval(file, 'PC1_1')
pc1_2 = fits.getval(file, 'PC1_2')
pc2_1 = fits.getval(file, 'PC2_1')
pc2_2 = fits.getval(file, 'PC2_2')
fits.setval(file, 'CD2_2', value=pc2_2, after='CRPIX2')
fits.setval(file, 'CD2_1', value=pc2_1, after='CRPIX2')
fits.setval(file, 'CD1_2', value=pc1_2, after='CRPIX2')
fits.setval(file, 'CD1_1', value=pc1_1, after='CRPIX2')
fits.delval(file, 'PC1_1')
fits.delval(file, 'PC1_2')
fits.delval(file, 'PC2_1')

Expected behavior

Actual behavior

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on…]
# Put your Python code snippet here.

System Details

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
saimncommented, Oct 4, 2019

The discussion in question is probably #1084.

0reactions
astropy-bot[bot]commented, Nov 13, 2019

I’m going to close this issue as per my previous message, but if you feel that this issue should stay open, then feel free to re-open and remove the Close? label.

If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial wcs module — Kapteyn Package (home)
An object of this class is created using the header of the FITS file for which we want WCS transformations. It accepts also...
Read more >
WCS — Astropy v5.2
When None , only the standard image header keywords are considered (and the underlying wcspih() C function is called). To use binary table...
Read more >
Tutorial wcs module — Kapteyn 3.0.0-beta documentation
Support for 'mixed' coordinates; Support for conversions between different celestial systems; Objects have useful attributes; Easy to combine with other ...
Read more >
WCS — Astropy v1.0.4
When None, only the standard image header keywords are considered (and the underlying wcspih() C function is called). To use binary table image...
Read more >
CIAO 2.0 Release Notes - Chandra X-ray Center
Supported functions include those in the standard math library and conditional ... If the DEFOCUS header keyword is absent, the tool will give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found