Skip to content

Commit 311488d

Browse files
authored
hotfix for cube_cut checking for valid WCS info (#70)
* hotfix for cube_cut checking for valid WCS info * moving astropy note to line 22
1 parent 9425944 commit 311488d

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

astrocut/cube_cut.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
import os
66
import warnings
7-
8-
from time import time
97
from itertools import product
8+
from time import time
109

10+
import astropy
1111
import astropy.units as u
1212
import numpy as np
13-
1413
from astropy import wcs
1514
from astropy.coordinates import SkyCoord
1615
from astropy.io import fits
1716
from astropy.time import Time
1817

19-
from . import __version__
18+
from . import __version__
2019
from .exceptions import InputWarning, InvalidQueryError
2120

2221
# Note: Use the astropy function if available, TODO: fix > 4.3 astropy fitting
23-
import astropy
2422
if astropy.utils.minversion(astropy, "4.0.2") and (float(astropy.__version__[:3]) < 4.3):
2523
from astropy.wcs.utils import fit_wcs_from_points
2624
else:
@@ -115,8 +113,8 @@ def _parse_table_info(self, product, table_data, verbose=False):
115113
table_row = table_data[data_ind]
116114

117115
# Making sure we have a row with wcs info.
118-
wcsaxes_keyword = 'WCSAXES' if product == 'SPOC' else 'WCAX3'
119-
if table_row[wcsaxes_keyword] != 2:
116+
wcsaxes_keyword = 'CTYPE2'
117+
if table_row[wcsaxes_keyword] != 'DEC--TAN-SIP':
120118
table_row = None
121119
data_ind += 1
122120
if data_ind == len(table_data):

astrocut/tests/test_cube_cut.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import pytest
2-
import numpy as np
31
from os import path
42

5-
from astropy.io import fits
3+
import astropy.units as u
4+
import numpy as np
5+
import pytest
66
from astropy import wcs
77
from astropy.coordinates import SkyCoord
8+
from astropy.io import fits
89
from astropy.time import Time
9-
import astropy.units as u
1010

11-
from .utils_for_test import create_test_ffis
12-
from ..make_cube import CubeFactory, TicaCubeFactory
1311
from ..cube_cut import CutoutFactory
14-
from ..exceptions import InvalidQueryError, InputWarning
12+
from ..exceptions import InputWarning, InvalidQueryError
13+
from ..make_cube import CubeFactory, TicaCubeFactory
14+
from .utils_for_test import create_test_ffis
1515

1616

1717
def checkcutout(product, cutfile, pixcrd, world, csize, ecube, eps=1.e-7):
@@ -343,12 +343,12 @@ def test_exceptions(tmpdir, ffi_type):
343343
cube_table = hdu[2].data
344344

345345
# Testing when none of the FFIs have good wcs info
346-
wcsaxes = 'WCSAXES' if ffi_type == 'SPOC' else 'WCAX3'
347-
cube_table[wcsaxes] = 0
346+
wcsaxes = 'CTYPE2'
347+
cube_table[wcsaxes] = 'N/A'
348348
with pytest.raises(Exception, match='No FFI rows contain valid WCS keywords.') as e:
349349
cutout_maker._parse_table_info(product=ffi_type, table_data=cube_table)
350350
assert e.type is wcs.NoWcsKeywordsFoundError
351-
cube_table[wcsaxes] = 2
351+
cube_table[wcsaxes] = 'DEC--TAN-SIP'
352352

353353
# Testing when nans are present
354354
cutout_maker._parse_table_info(product=ffi_type, table_data=cube_table)

0 commit comments

Comments
 (0)