Skip to content

Commit 56fbc3d

Browse files
committed
Update WCSLIB to version 7.1
1 parent 1daeb80 commit 56fbc3d

74 files changed

Lines changed: 13053 additions & 10739 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGES.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ astropy.visualization
8787
astropy.wcs
8888
^^^^^^^^^^^
8989

90+
9091
API Changes
9192
-----------
9293

@@ -348,6 +349,8 @@ astropy.wcs
348349
Other Changes and Additions
349350
---------------------------
350351

352+
- Updated wcslib to v7.1. [#9829]
353+
351354

352355

353356
4.0 (2019-12-16)

‎astropy/wcs/setup_package.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from astropy_helpers import setup_helpers
1616

1717
WCSROOT = os.path.relpath(os.path.dirname(__file__))
18-
WCSVERSION = "6.4.0"
18+
WCSVERSION = "7.1.0"
1919

2020

2121
def b(s):

‎astropy/wcs/tests/data/header_with_time.fits‎

100644100755
File mode changed.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SIMPLE = F / Conforms to FITS standard? NO! BITPIX = -32 / IEEE single precision floating point NAXIS = 0 / No image data CRPIX1A = 513.0 / Pixel coordinate of reference point CRPIX2A = 513.0 / Pixel coordinate of reference point CRPIX3A = 1025.0 / Pixel coordinate of reference point CRPIX4A = 1.0 / Pixel coordinate of reference point PC1_1A = 0.866025404 / Linear transformation matrix element PC1_2A = 0.500000000 / Linear transformation matrix element PC2_1A = -0.500000000 / Linear transformation matrix element PC2_2A = 0.866025404 / Linear transformation matrix element CDELT1A = -0.10 / [deg] x-scale CUNIT1A = 'deg' / Degree units are required CTYPE1A = 'RA---SZP' / Right ascension in slant zenithal projection CRVAL1A = 150.0 / [deg] Right ascension at the reference point CNAME1A = 'Right ascension (J2000)' / Axis name for labelling purposes CDELT2A = 0.10 / [deg] y-scale CUNIT2A = 'deg' / Degree units are required CTYPE2A = 'DEC--SZP' / Declination in a slant zenithal projection CRVAL2A = -30.0 / [deg] Declination at the reference point CNAME2A = 'Declination (J2000)' / Axis name for labelling purposes PV1_1A = 0.0 / [deg] Native longitude of the reference point PV1_2A = 90.0 / [deg] Native latitude of the reference point PV1_3A = 195.0 / [deg] LONPOLEa by another name (precedence) PV1_4A = 999.0 / [deg] LATPOLEa by another name (precedence) PV2_1A = 0.0 / SZP distance, in spherical radii PV2_2A = 180.0 / [deg] SZP P-longitude PV2_3A = 45.0 / [deg] SZP P-latitude LONPOLEA= 195.0 / [deg] Native longitude of the NCP LATPOLEA= 999.0 / [deg] Native latitude of the NCP RADESYSA= 'FK5' / Mean equatorial coordinates, IAU 1984 system EQUINOXA= 2000.0 / [yr] Equinox of equatorial coordinates CDELT3A = -9.635265432E-6 / [m] Wavelength scale CUNIT3A = 'm' / Wavelength units CTYPE3A = 'WAVE-F2W' / Frequency axis expressed as wavelength CRVAL3A = 0.214982042 / [m] Reference wavelength CNAME3A = 'Wavelength' / Axis name for labelling purposes CRDER3A = 1.0E-11 / [m] Wavelength calibration, random error CSYER3A = 1.0E-12 / [m] Wavelength calibration, systematic error RESTFRQA= 1.42040575E9 / [Hz] HI rest frequency RESTWAVA= 0.211061141 / [m] HI rest wavelength SPECSYSA= 'BARYCENT' / Reference frame of spectral coordinates SSYSOBSA= 'TOPOCENT' / Reference frame of observation VELOSYSA= 1500.0 / [m/s] Bary-topo velocity towards the source SSYSSRCA= 'LSRK' / Reference frame of source redshift ZSOURCEA= 0.0025 / Redshift of the source CDELT4A = 1.0 / [s] Time scale CUNIT4A = 's' / Time units CTYPE4A = 'TIME ' / String value and comment containing quotes (') CRVAL4A = -2E3 / [s] Time at the reference point CNAME4A = 'Time offset' / Axis name for labelling purposes PS4_0A = 'UTC' / Time measurement system DATEREFA= '1858-11-17' / ISO-8601 fiducial time MJDREFIA= 0.0 / [d] MJD of fiducial time, integer part MJDREFFA= 0.0 / [d] MJD of fiducial time, fractional part UNDEF = / Undefined keyvalue TRUE = T / Logical FALSE = F / Logical INT32 = 00000012345 / Not a 64-bit integer INT32 = -000000123456789 / Not a 64-bit integer INT32 = -2147483648 / Not a 64-bit integer (INT_MIN) INT32 = 2147483647 / Not a 64-bit integer (INT_MAX) INT32 = 0000000000000000000000000000000000012345 / Not a very long integer INT32 = -000000000000000000000000000123456789 / Not a very long integer INT64 = -2147483649 / 64-bit integer (INT_MIN - 1) INT64 = +2147483648 / 64-bit integer (INT_MAX + 1) INT64 = +100000000000000000 / 64-bit integer INT64 = -876543210987654321 / 64-bit integer INT64 = -9223372036854775808 / Not a very long integer (LONG_MIN) INT64 = +9223372036854775807 / Not a very long integer (LONG_MAX) INT64 = -000000000000000000000000000000876543210987654321 / 64-bit integer INTVL = -9223372036854775809 / Very long integer (LONG_MIN - 1) INTVL = +9223372036854775808 / Very long integer (LONG_MAX + 1) INTVL = -100000000000000000000000000000876543210987654321 / Very-long integer INTVL = +123456789012345678901234567890123456789012345678901234567890123456789INTVL = 1234567890123456789012345678901234567890123456789012345678901234567890FLOAT = 3.14159265358 / Floating point FLOAT = 1.602176565E-19 / Floating point, lower-case exp allowed FLOAT = 2.99792458E8 / Floating point FLOAT = 6.62606957D-34 / Floating point, lower-case exp allowed FLOAT = 6.02214129D23 / Floating point COMPLEX = (137, -1) / An integer complex keyvalue COMPLEX = (10E5, -0.1) / A floating point complex keyvalue GOODSTR = '"G''DAY" ' / A valid string keyvalue BLANKS = ' ' / An all-blank string equals a single blank LONGSTR = 'The loooooongest possible non-continued string value, 68 characters.'END

‎astropy/wcs/tests/test_wcs.py‎

Lines changed: 107 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import warnings
77
from datetime import datetime
8+
from distutils.version import LooseVersion
89

910
import pytest
1011
import numpy as np
@@ -26,6 +27,24 @@
2627
from astropy.coordinates import SkyCoord
2728

2829

30+
_WCSLIB_VER = LooseVersion(_wcs.__version__)
31+
32+
33+
def _check_v71_dateref_warnings(w, nmax=None):
34+
if _WCSLIB_VER >= '7.1' and w:
35+
if nmax is None:
36+
assert w
37+
else:
38+
assert len(w) == nmax
39+
40+
for item in w:
41+
if (str(item.message) == "'datfix' made the change "
42+
"'Set DATE-REF to '1858-11-17' from MJD-REF'."):
43+
break
44+
else:
45+
assert False, "No 'datfix' warning found"
46+
47+
2948
class TestMaps:
3049
def setup(self):
3150
# get the list of the hdr files that we want to test
@@ -179,24 +198,32 @@ def test_dict_init():
179198
"""
180199

181200
# Dictionary with no actual WCS, returns identity transform
182-
w = wcs.WCS({})
201+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
202+
w = wcs.WCS({})
203+
_check_v71_dateref_warnings(wrng)
183204

184205
xp, yp = w.wcs_world2pix(41., 2., 1)
185206

186207
assert_array_almost_equal_nulp(xp, 41., 10)
187208
assert_array_almost_equal_nulp(yp, 2., 10)
188209

189210
# Valid WCS
190-
w = wcs.WCS({'CTYPE1': 'GLON-CAR',
191-
'CTYPE2': 'GLAT-CAR',
192-
'CUNIT1': 'deg',
193-
'CUNIT2': 'deg',
194-
'CRPIX1': 1,
195-
'CRPIX2': 1,
196-
'CRVAL1': 40.,
197-
'CRVAL2': 0.,
198-
'CDELT1': -0.1,
199-
'CDELT2': 0.1})
211+
hdr = {
212+
'CTYPE1': 'GLON-CAR',
213+
'CTYPE2': 'GLAT-CAR',
214+
'CUNIT1': 'deg',
215+
'CUNIT2': 'deg',
216+
'CRPIX1': 1,
217+
'CRPIX2': 1,
218+
'CRVAL1': 40.,
219+
'CRVAL2': 0.,
220+
'CDELT1': -0.1,
221+
'CDELT2': 0.1
222+
}
223+
if _WCSLIB_VER >= '7.1':
224+
hdr['DATEREF'] = '1858-11-17'
225+
226+
w = wcs.WCS(hdr)
200227

201228
xp, yp = w.wcs_world2pix(41., 2., 0)
202229

@@ -338,8 +365,25 @@ def run():
338365

339366

340367
def test_to_header_string():
341-
header_string = """
342-
WCSAXES = 2 / Number of coordinate axes CRPIX1 = 0.0 / Pixel coordinate of reference point CRPIX2 = 0.0 / Pixel coordinate of reference point CDELT1 = 1.0 / Coordinate increment at reference point CDELT2 = 1.0 / Coordinate increment at reference point CRVAL1 = 0.0 / Coordinate value at reference point CRVAL2 = 0.0 / Coordinate value at reference point LATPOLE = 90.0 / [deg] Native latitude of celestial pole END""" # noqa
368+
hdrstr = (
369+
"WCSAXES = 2 / Number of coordinate axes ",
370+
"CRPIX1 = 0.0 / Pixel coordinate of reference point ",
371+
"CRPIX2 = 0.0 / Pixel coordinate of reference point ",
372+
"CDELT1 = 1.0 / Coordinate increment at reference point ",
373+
"CDELT2 = 1.0 / Coordinate increment at reference point ",
374+
"CRVAL1 = 0.0 / Coordinate value at reference point ",
375+
"CRVAL2 = 0.0 / Coordinate value at reference point ",
376+
"LATPOLE = 90.0 / [deg] Native latitude of celestial pole ",
377+
)
378+
if _WCSLIB_VER >= '7.1':
379+
hdrstr += (
380+
"DATEREF = '1858-11-17' / ISO-8601 fiducial time ",
381+
"MJDREFI = 0.0 / [d] MJD of fiducial time, integer part ",
382+
"MJDREFF = 0.0 / [d] MJD of fiducial time, fractional part "
383+
)
384+
hdrstr += ("END", )
385+
386+
header_string = ''.join(hdrstr)
343387

344388
w = wcs.WCS()
345389
h0 = fits.Header.fromstring(w.to_header_string().strip())
@@ -352,12 +396,13 @@ def test_to_header_string():
352396

353397

354398
def test_to_fits():
399+
nrec = 11 if _WCSLIB_VER >= '7.1' else 8
355400
w = wcs.WCS()
356401
header_string = w.to_header()
357402
wfits = w.to_fits()
358403
assert isinstance(wfits, fits.HDUList)
359404
assert isinstance(wfits[0], fits.PrimaryHDU)
360-
assert header_string == wfits[0].header[-8:]
405+
assert header_string == wfits[0].header[-nrec:]
361406

362407

363408
def test_to_header_warning():
@@ -402,7 +447,7 @@ def test_validate():
402447
results = wcs.validate(get_pkg_data_filename("data/validate.fits"))
403448
results_txt = repr(results)
404449
version = wcs._wcs.__version__
405-
if version[0] == '6':
450+
if version[0] in ['6', '7']:
406451
filename = 'data/validate.6.txt'
407452
elif version[0] == '5':
408453
if version >= '5.13':
@@ -910,18 +955,25 @@ def test_list_naxis():
910955
hdulist = fits.open(path)
911956
# wcslib will complain about the distortion parameters if they
912957
# weren't correctly deleted from the header
913-
w = wcs.WCS(hdulist[1].header, hdulist, naxis=['celestial'])
958+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
959+
w = wcs.WCS(hdulist[1].header, hdulist, naxis=['celestial'])
960+
_check_v71_dateref_warnings(wrng)
961+
914962
assert w.naxis == 2
915963
assert w.wcs.naxis == 2
916964

917965
path = get_pkg_data_filename("data/maps/1904-66_SIN.hdr")
918966
with open(path, 'rb') as fd:
919967
content = fd.read()
920-
w = wcs.WCS(content, naxis=['celestial'])
968+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
969+
w = wcs.WCS(content, naxis=['celestial'])
970+
_check_v71_dateref_warnings(wrng)
921971
assert w.naxis == 2
922972
assert w.wcs.naxis == 2
923973

924-
w = wcs.WCS(content, naxis=['spectral'])
974+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
975+
w = wcs.WCS(content, naxis=['spectral'])
976+
_check_v71_dateref_warnings(wrng)
925977
assert w.naxis == 0
926978
assert w.wcs.naxis == 0
927979
hdulist.close()
@@ -1024,32 +1076,44 @@ def test_inconsistent_sip():
10241076
Test for #4814
10251077
"""
10261078
hdr = get_pkg_data_contents("data/sip-broken.hdr")
1027-
w = wcs.WCS(hdr)
1079+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1080+
w = wcs.WCS(hdr)
1081+
_check_v71_dateref_warnings(wrng)
10281082
with pytest.warns(AstropyWarning):
10291083
newhdr = w.to_header(relax=None)
10301084
# CTYPE should not include "-SIP" if relax is None
1031-
wnew = wcs.WCS(newhdr)
1085+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1086+
wnew = wcs.WCS(newhdr)
1087+
_check_v71_dateref_warnings(wrng)
10321088
assert all(not ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10331089
newhdr = w.to_header(relax=False)
10341090
assert('A_0_2' not in newhdr)
10351091
# CTYPE should not include "-SIP" if relax is False
1036-
wnew = wcs.WCS(newhdr)
1092+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1093+
wnew = wcs.WCS(newhdr)
1094+
_check_v71_dateref_warnings(wrng)
10371095
assert all(not ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10381096
with pytest.warns(AstropyWarning):
10391097
newhdr = w.to_header(key="C")
10401098
assert('A_0_2' not in newhdr)
10411099
# Test writing header with a different key
1042-
wnew = wcs.WCS(newhdr, key='C')
1100+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1101+
wnew = wcs.WCS(newhdr, key='C')
1102+
_check_v71_dateref_warnings(wrng)
10431103
assert all(not ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10441104
with pytest.warns(AstropyWarning):
10451105
newhdr = w.to_header(key=" ")
10461106
# Test writing a primary WCS to header
1047-
wnew = wcs.WCS(newhdr)
1107+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1108+
wnew = wcs.WCS(newhdr)
1109+
_check_v71_dateref_warnings(wrng)
10481110
assert all(not ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10491111
# Test that "-SIP" is kept into CTYPE if relax=True and
10501112
# "-SIP" was in the original header
10511113
newhdr = w.to_header(relax=True)
1052-
wnew = wcs.WCS(newhdr)
1114+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1115+
wnew = wcs.WCS(newhdr)
1116+
_check_v71_dateref_warnings(wrng)
10531117
assert all(ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10541118
assert('A_0_2' in newhdr)
10551119
# Test that SIP coefficients are also written out.
@@ -1058,10 +1122,14 @@ def test_inconsistent_sip():
10581122
# Test that "-SIP" is added to CTYPE if relax=True and
10591123
# "-SIP" was not in the original header but SIP coefficients
10601124
# are present.
1061-
w = wcs.WCS(hdr)
1125+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1126+
w = wcs.WCS(hdr)
1127+
_check_v71_dateref_warnings(wrng)
10621128
w.wcs.ctype = ['RA---TAN', 'DEC--TAN']
10631129
newhdr = w.to_header(relax=True)
1064-
wnew = wcs.WCS(newhdr)
1130+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1131+
wnew = wcs.WCS(newhdr)
1132+
_check_v71_dateref_warnings(wrng)
10651133
assert all(ctyp.endswith('-SIP') for ctyp in wnew.wcs.ctype)
10661134

10671135

@@ -1113,7 +1181,9 @@ def test_sip_with_altkey():
11131181
h1['CTYPE1A'] = "RA---SIN-SIP"
11141182
h1['CTYPE2A'] = "DEC--SIN-SIP"
11151183
h1.update(h2)
1116-
w = wcs.WCS(h1, key='A')
1184+
with catch_warnings(wcs.FITSFixedWarning) as wrng:
1185+
w = wcs.WCS(h1, key='A')
1186+
_check_v71_dateref_warnings(wrng)
11171187
assert (w.wcs.ctype == np.array(['RA---SIN-SIP', 'DEC--SIN-SIP'])).all()
11181188

11191189

@@ -1262,8 +1332,10 @@ def test_cunit():
12621332

12631333
class TestWcsWithTime:
12641334
def setup(self):
1265-
fname = get_pkg_data_filename(
1266-
'data/header_with_time.fits')
1335+
if _WCSLIB_VER >= '7.1':
1336+
fname = get_pkg_data_filename('data/header_with_time_wcslib71.fits')
1337+
else:
1338+
fname = get_pkg_data_filename('data/header_with_time.fits')
12671339
self.header = fits.Header.fromfile(fname)
12681340
with pytest.warns(FITSFixedWarning):
12691341
self.w = wcs.WCS(self.header, key='A')
@@ -1305,8 +1377,12 @@ def test_keywods2wcsprm(self):
13051377
'timeoffs', 'telapse', 'czphs', 'cperi']
13061378

13071379
for key in num_keys:
1308-
assert_allclose(getattr(self.w.wcs, key),
1309-
self.header.get(key, np.nan))
1380+
if key.upper() == 'MJDREF':
1381+
hdrv = [self.header.get('MJDREFIA', np.nan),
1382+
self.header.get('MJDREFFA', np.nan)]
1383+
else:
1384+
hdrv = self.header.get(key, np.nan)
1385+
assert_allclose(getattr(self.w.wcs, key), hdrv)
13101386

13111387
def test_transforms(self):
13121388
assert_allclose(self.w.all_pix2world(*self.w.wcs.crpix, 1),

0 commit comments

Comments
 (0)