# Problems about using 'relax' keyword in WCS

**URL:** <https://community.openastronomy.org/t/problems-about-using-relax-keyword-in-wcs/505>\
**Category:** Astropy\
**Tags:** astropy, fits, question\
**Created:** [November 11, 2022, 8:35pm UTC](https://community.openastronomy.org/t/problems-about-using-relax-keyword-in-wcs/505 "2022-11-11T20:35:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![palfeng](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/palfeng/32/299_2.png) [@palfeng](https://community.openastronomy.org/u/palfeng)\
**Post date:** [November 11, 2022, 8:35pm UTC](https://community.openastronomy.org/t/problems-about-using-relax-keyword-in-wcs/505/1 "2022-11-11T20:35:03Z")

</div>

Hello all, I’m reading the WCS coordinates from a image.fits files as:

from astropy.wcs import WCS  
hdul = fits.open(files[i])  
wcs = WCS(header=hdul[0].header)

But since my fits file is old (from ~20 years ago), the format is not standard, so Python pops several warnings and the coordinates are not correctly read:

WARNING: FITSFixedWarning: PC001001= -0.84620247 / Pixel Coordinate translation matrix  
this form of the PCi\_ja keyword is deprecated, use PCi\_ja. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: PC001002= -0.53286151 / Pixel Coordinate translation matrix  
this form of the PCi\_ja keyword is deprecated, use PCi\_ja. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: PC002001= 0.53286151 / Pixel Coordinate translation matrix  
this form of the PCi\_ja keyword is deprecated, use PCi\_ja. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: PC002002= -0.84620247 / Pixel Coordinate translation matrix  
this form of the PCi\_ja keyword is deprecated, use PCi\_ja. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: RADECSYS= 'FK5 ’ / The equatorial coordinate system  
the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: ‘datfix’ made the change ‘Set MJD-OBS to 51577.000000 from DATE-OBS.  
Set DATE-END to ‘2000-02-03T09:45:00’ from MJD-END’. [astropy.wcs.wcs]  
WARNING: FITSFixedWarning: ‘unitfix’ made the change 'Changed units:  
‘degree’ → ‘deg’,  
‘degree’ → ‘deg’. [astropy.wcs.wcs]

I did some searches and I think the keyword “relax” can solve these warnings ([Header-reading relaxation constants — Astropy v5.1.1](https://docs.astropy.org/en/stable/wcs/relax.html)). But I didn’t find an example how to use it. Obviously, directly adding it does not work, e.g.,

wcs = WCS(header=hdul[0].header, relax = WCS.WCSHDR\_PC00i00j)

I would appreciate a lot if anyone can provide some help here!!! Thanks!

---

<div class="post-metadata">

**Author:** ![dhomeier](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/dhomeier/32/65_2.png) [@dhomeier](https://community.openastronomy.org/u/dhomeier)\
**Post date:** [November 14, 2022, 3:32pm UTC](https://community.openastronomy.org/t/problems-about-using-relax-keyword-in-wcs/505/2 "2022-11-14T15:32:10Z")

</div>

It is passed as a keyword argument just as above, but `WCSHDR_*` are constants directly in `wcs`, not the `WCS` class, i.e. you’d need to do

```auto
from astropy.wcs import WCS, WCSHDR_PC00i00j
wcs = WCS(header=hdul[0].header, relax=WCSHDR_PC00i00j)

```

or alternatively could just try `relax=True`.

---

<div class="post-metadata">

**Author:** ![palfeng](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/palfeng/32/299_2.png) [@palfeng](https://community.openastronomy.org/u/palfeng)\
**Post date:** [November 17, 2022, 4:17pm UTC](https://community.openastronomy.org/t/problems-about-using-relax-keyword-in-wcs/505/3 "2022-11-17T16:17:20Z")

</div>

Thanks a lot! I find the coordinates are still read incorrectly with relax = True, and I’m checking further…
