Skip to content

Commit cf7fe2e

Browse files
authored
Merge pull request #2250 from oda-hub/heasarc-unit-issue
Fixed failing test in HEASARC module, adding local test data
2 parents a03f301 + d421fcb commit cf7fe2e

24 files changed

+9462
-25
lines changed

astroquery/heasarc/core.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3+
from typing import Union
34
import warnings
45
from io import StringIO, BytesIO
56
from astropy.table import Table
@@ -15,6 +16,13 @@
1516
__all__ = ['Heasarc', 'HeasarcClass']
1617

1718

19+
def Table_read(*args, **kwargs):
20+
if commons.ASTROPY_LT_5_1:
21+
return Table.read(*args, **kwargs)
22+
else:
23+
return Table.read(*args, **kwargs, unit_parse_strict='silent')
24+
25+
1826
@async_to_sync
1927
class HeasarcClass(BaseQuery):
2028

@@ -86,8 +94,10 @@ def query_mission_cols(self, mission, cache=True, get_query_payload=False,
8694
All other parameters have no effect
8795
"""
8896

89-
response = self.query_region_async(position='0.0 0.0', mission=mission,
90-
radius='361 degree', cache=cache,
97+
response = self.query_region_async(position=coordinates.SkyCoord(10, 10, unit='deg', frame='fk5'),
98+
mission=mission,
99+
radius='361 degree',
100+
cache=cache,
91101
get_query_payload=get_query_payload,
92102
resultsmax=1,
93103
fields='All')
@@ -127,8 +137,8 @@ def query_object_async(self, object_name, mission,
127137

128138
return self.query_async(request_payload, cache=cache)
129139

130-
def query_region_async(self, position, mission, radius,
131-
cache=True, get_query_payload=False,
140+
def query_region_async(self, position: Union[coordinates.SkyCoord, str],
141+
mission, radius, cache=True, get_query_payload=False,
132142
**kwargs):
133143
"""
134144
Query around specific set of coordinates within a given mission
@@ -138,7 +148,7 @@ def query_region_async(self, position, mission, radius,
138148
139149
Parameters
140150
----------
141-
position : `astropy.coordinates` or str
151+
position : `astropy.coordinates.SkyCoord` or str
142152
The position around which to search. It may be specified as a
143153
string in which case it is resolved using online services or as
144154
the appropriate `astropy.coordinates` object. ICRS coordinates
@@ -188,7 +198,7 @@ def _old_w3query_fallback(self, content):
188198
f.writeto(I)
189199
I.seek(0)
190200

191-
return Table.read(I)
201+
return Table_read(I)
192202

193203
def _fallback(self, text):
194204
"""
@@ -218,7 +228,8 @@ def _fallback(self, text):
218228
new_table.append("".join(newline))
219229

220230
data = StringIO(text.replace(old_table, "\n".join(new_table)))
221-
return Table.read(data, hdu=1)
231+
232+
return Table_read(data, hdu=1)
222233

223234
def _parse_result(self, response, verbose=False):
224235
# if verbose is False then suppress any VOTable related warnings
@@ -239,8 +250,7 @@ def _parse_result(self, response, verbose=False):
239250

240251
try:
241252
data = BytesIO(response.content)
242-
table = Table.read(data, hdu=1)
243-
return table
253+
return Table_read(data, hdu=1)
244254
except ValueError:
245255
try:
246256
return self._fallback(response.text)

astroquery/heasarc/tests/data/0f36aba7.dat

Lines changed: 1001 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
SIMPLE = T / BROWSE (FITSDISPLAY V0.1) BITPIX = 8 NAXIS = 0 / DUMMY HDU EXTEND = T / EXTENSIONS ALLOWED END XTENSION= 'TABLE ' / ASCII TABLE EXTENSION BITPIX = 8 / MANDATORY VALUE NAXIS = 2 / MANDATORY VALUE NAXIS1 = 84 / LENGTH OF ROW NAXIS2 = 63 / NUMBER OF ROWS PCOUNT = 0 / MANDATORY VALUE GCOUNT = 1 / MANDATORY VALUE TFIELDS = 7 / NUMBER OF FIELDS EXTNAME = 'ROSMASTER' / EXTENSION NAME TABLE = 'HEASARC_ROSMASTER' / TABLE DESIGNATOR TAB_DESC= 'ROSAT ARCHIVAL DATA' TAB_URL = 'HTTPS://HEASARC.GSFC.NASA.GOV/W3BROWSE/ROSAT/ROSMASTER.HTML' TTYPE1 = 'SEQ_ID' TFORM1 = 'A11 ' TBCOL1 = 1 TTYPE2 = 'INSTRUMENT' TFORM2 = 'A10 ' TBCOL2 = 13 TTYPE3 = 'EXPOSURE' TFORM3 = 'I8 ' TUNIT3 = 'S' TBCOL3 = 24 TTYPE4 = 'RA' TFORM4 = 'F8.0 ' TUNIT4 = 'DEGREE' TDISP4 = 'F8.4' TBCOL4 = 33 TTYPE5 = 'DEC' TFORM5 = 'F6.0 ' TUNIT5 = 'DEGREE' TDISP5 = 'F6.4' TBCOL5 = 42 TTYPE6 = 'NAME' TFORM6 = 'A20 ' TBCOL6 = 49 TTYPE7 = 'SEARCH_OFFSET_' TFORM7 = 'A14 ' TBCOL7 = 70 END RH701576N00 HRI 68154 187.2800 2.0500 3C 273 0.190 (3C273)
2+
RP600242A01 PSPCB 24822 186.9300 1.6000 GIOVANELLI-HAYNES CL 34.236 (3C273)
3+
RH700234N00 HRI 17230 187.2800 2.0500 3C 273 0.190 (3C273)
4+
RP700191N00 PSPCB 6140 187.2700 2.0500 3C273 0.496 (3C273)
5+
RH702682N00 HRI 4896 187.2700 2.0500 3C 273 0.496 (3C273)
6+
RH702681N00 HRI 4416 187.2700 2.0500 3C 273 0.496 (3C273)
7+
RH702684N00 HRI 4105 187.2700 2.0500 3C 273 0.496 (3C273)
8+
RH702680N00 HRI 4063 187.2700 2.0500 3C 273 0.496 (3C273)
9+
RH702683N00 HRI 3986 187.2700 2.0500 3C 273 0.496 (3C273)
10+
RH702679N00 HRI 3662 187.2700 2.0500 3C 273 0.496 (3C273)
11+
RP141509N00 PSPCB 3330 187.2700 2.0500 3C273 0.496 (3C273)
12+
RF700191N00 PSPCB 3279 187.2700 2.0500 3C273 0.496 (3C273)
13+
RP600242N00 PSPCB 3078 186.9300 1.6000 GIOVANELLI-HAYNES CL 34.236 (3C273)
14+
RH702678N00 HRI 2866 187.2700 2.0500 3C 273 0.496 (3C273)
15+
RH701661N00 HRI 2702 187.2800 2.0500 3C 273 0.190 (3C273)
16+
RH701966N00 HRI 2652 187.2800 2.0500 3C273 0.190 (3C273)
17+
RH702677N00 HRI 2424 187.2700 2.0500 3C 273 0.496 (3C273)
18+
RH701975N00 HRI 2209 187.2800 2.0500 3C273 0.190 (3C273)
19+
RH701973N00 HRI 2176 187.2800 2.0500 3C273 0.190 (3C273)
20+
RH701961N00 HRI 2088 187.2800 2.0500 3C273 0.190 (3C273)
21+
RH701963N00 HRI 2053 187.2800 2.0500 3C273 0.190 (3C273)
22+
RH701962N00 HRI 2019 187.2800 2.0500 3C273 0.190 (3C273)
23+
RP701256N00 PSPCB 2002 187.2800 2.0500 3C273 0.190 (3C273)
24+
RP701269N00 PSPCB 1974 187.2800 2.0500 3C273 0.190 (3C273)
25+
RP701255N00 PSPCB 1973 187.2800 2.0500 3C273 0.190 (3C273)
26+
RP701268N00 PSPCB 1970 187.2800 2.0500 3C273 0.190 (3C273)
27+
RH701968N00 HRI 1931 187.2800 2.0500 3C273 0.190 (3C273)
28+
RH701969N00 HRI 1889 187.2800 2.0500 3C273 0.190 (3C273)
29+
RP701267N00 PSPCB 1874 187.2800 2.0500 3C273 0.190 (3C273)
30+
RH701976N00 HRI 1866 187.2800 2.0500 3C273 0.190 (3C273)
31+
RH701970N00 HRI 1864 187.2800 2.0500 3C273 0.190 (3C273)
32+
RP701266N00 PSPCB 1840 187.2800 2.0500 3C273 0.190 (3C273)
33+
RH701957N00 HRI 1831 187.2800 2.0500 3C273 0.190 (3C273)
34+
RH701964N00 HRI 1823 187.2800 2.0500 3C273 0.190 (3C273)
35+
RH701960N00 HRI 1815 187.2800 2.0500 3C273 0.190 (3C273)
36+
RP701265N00 PSPCB 1784 187.2800 2.0500 3C273 0.190 (3C273)
37+
RH701959N00 HRI 1751 187.2800 2.0500 3C273 0.190 (3C273)
38+
RP701260N00 PSPCB 1744 187.2800 2.0500 3C273 0.190 (3C273)
39+
RH701971N00 HRI 1720 187.2770 2.0519 3C273 0.062 (3C273)
40+
RP701264N00 PSPCB 1705 187.2800 2.0500 3C273 0.190 (3C273)
41+
RH701956N00 HRI 1704 187.2800 2.0500 3C273 0.190 (3C273)
42+
RH701958N00 HRI 1659 187.2800 2.0500 3C273 0.190 (3C273)
43+
RH701965N00 HRI 1644 187.2800 2.0500 3C273 0.190 (3C273)
44+
RH701955N00 HRI 1586 187.2800 2.0500 3C273 0.190 (3C273)
45+
RH701972N00 HRI 1563 187.2800 2.0500 3C273 0.190 (3C273)
46+
RH701953N00 HRI 1533 187.2800 2.0500 3C273 0.190 (3C273)
47+
RH701967N00 HRI 1511 187.2800 2.0500 3C273 0.190 (3C273)
48+
RP701263N00 PSPCB 1503 187.2800 2.0500 3C273 0.190 (3C273)
49+
RH701257N00 HRI 1473 187.2800 2.0500 3C273 0.190 (3C273)
50+
RH701954N00 HRI 1373 187.2800 2.0500 3C273 0.190 (3C273)
51+
RP701262N00 PSPCB 1324 187.2800 2.0500 3C273 0.190 (3C273)
52+
RH701952N00 HRI 1189 187.2800 2.0500 3C273 0.190 (3C273)
53+
RP701261N00 PSPCB 1122 187.2800 2.0500 3C273 0.190 (3C273)
54+
RP701259N00 PSPCB 1048 187.2800 2.0500 3C273 0.190 (3C273)
55+
RP701258N00 PSPCB 1040 187.2800 2.0500 3C273 0.190 (3C273)
56+
RH701974N00 HRI 982 187.2800 2.0500 3C273 0.190 (3C273)
57+
RP120000N00 PSPCC 916 187.2700 2.0500 XRT/PSPC NORTH DUMMY 0.496 (3C273)
58+
RH141520N00 HRI 765 187.2700 2.0500 3C273 0.496 (3C273)
59+
RH701978N00 HRI 671 187.2800 2.0500 3C273 0.190 (3C273)
60+
RH701981N00 HRI 498 187.2800 2.0500 3C273 0.190 (3C273)
61+
RP141520N00 PSPCB 485 187.2700 2.0500 3C273 0.496 (3C273)
62+
RH701979N00 HRI 354 187.2800 2.0500 3C273 0.190 (3C273)
63+
RH120001N00 HRI 0 187.2700 2.0500 XRT/HRI NORTH DUMMY 0.496 (3C273)
64+

0 commit comments

Comments
 (0)