Skip to content

Commit

Permalink
Merge pull request #2250 from oda-hub/heasarc-unit-issue
Browse files Browse the repository at this point in the history
Fixed failing test in HEASARC module, adding local test data
  • Loading branch information
bsipocz authored Mar 25, 2022
2 parents a03f301 + d421fcb commit cf7fe2e
Show file tree
Hide file tree
Showing 24 changed files with 9,462 additions and 25 deletions.
28 changes: 19 additions & 9 deletions astroquery/heasarc/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from typing import Union
import warnings
from io import StringIO, BytesIO
from astropy.table import Table
Expand All @@ -15,6 +16,13 @@
__all__ = ['Heasarc', 'HeasarcClass']


def Table_read(*args, **kwargs):
if commons.ASTROPY_LT_5_1:
return Table.read(*args, **kwargs)
else:
return Table.read(*args, **kwargs, unit_parse_strict='silent')


@async_to_sync
class HeasarcClass(BaseQuery):

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

response = self.query_region_async(position='0.0 0.0', mission=mission,
radius='361 degree', cache=cache,
response = self.query_region_async(position=coordinates.SkyCoord(10, 10, unit='deg', frame='fk5'),
mission=mission,
radius='361 degree',
cache=cache,
get_query_payload=get_query_payload,
resultsmax=1,
fields='All')
Expand Down Expand Up @@ -127,8 +137,8 @@ def query_object_async(self, object_name, mission,

return self.query_async(request_payload, cache=cache)

def query_region_async(self, position, mission, radius,
cache=True, get_query_payload=False,
def query_region_async(self, position: Union[coordinates.SkyCoord, str],
mission, radius, cache=True, get_query_payload=False,
**kwargs):
"""
Query around specific set of coordinates within a given mission
Expand All @@ -138,7 +148,7 @@ def query_region_async(self, position, mission, radius,
Parameters
----------
position : `astropy.coordinates` or str
position : `astropy.coordinates.SkyCoord` or str
The position around which to search. It may be specified as a
string in which case it is resolved using online services or as
the appropriate `astropy.coordinates` object. ICRS coordinates
Expand Down Expand Up @@ -188,7 +198,7 @@ def _old_w3query_fallback(self, content):
f.writeto(I)
I.seek(0)

return Table.read(I)
return Table_read(I)

def _fallback(self, text):
"""
Expand Down Expand Up @@ -218,7 +228,8 @@ def _fallback(self, text):
new_table.append("".join(newline))

data = StringIO(text.replace(old_table, "\n".join(new_table)))
return Table.read(data, hdu=1)

return Table_read(data, hdu=1)

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

try:
data = BytesIO(response.content)
table = Table.read(data, hdu=1)
return table
return Table_read(data, hdu=1)
except ValueError:
try:
return self._fallback(response.text)
Expand Down
1,001 changes: 1,001 additions & 0 deletions astroquery/heasarc/tests/data/0f36aba7.dat

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions astroquery/heasarc/tests/data/157a5015.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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)
RP600242A01 PSPCB 24822 186.9300 1.6000 GIOVANELLI-HAYNES CL 34.236 (3C273)
RH700234N00 HRI 17230 187.2800 2.0500 3C 273 0.190 (3C273)
RP700191N00 PSPCB 6140 187.2700 2.0500 3C273 0.496 (3C273)
RH702682N00 HRI 4896 187.2700 2.0500 3C 273 0.496 (3C273)
RH702681N00 HRI 4416 187.2700 2.0500 3C 273 0.496 (3C273)
RH702684N00 HRI 4105 187.2700 2.0500 3C 273 0.496 (3C273)
RH702680N00 HRI 4063 187.2700 2.0500 3C 273 0.496 (3C273)
RH702683N00 HRI 3986 187.2700 2.0500 3C 273 0.496 (3C273)
RH702679N00 HRI 3662 187.2700 2.0500 3C 273 0.496 (3C273)
RP141509N00 PSPCB 3330 187.2700 2.0500 3C273 0.496 (3C273)
RF700191N00 PSPCB 3279 187.2700 2.0500 3C273 0.496 (3C273)
RP600242N00 PSPCB 3078 186.9300 1.6000 GIOVANELLI-HAYNES CL 34.236 (3C273)
RH702678N00 HRI 2866 187.2700 2.0500 3C 273 0.496 (3C273)
RH701661N00 HRI 2702 187.2800 2.0500 3C 273 0.190 (3C273)
RH701966N00 HRI 2652 187.2800 2.0500 3C273 0.190 (3C273)
RH702677N00 HRI 2424 187.2700 2.0500 3C 273 0.496 (3C273)
RH701975N00 HRI 2209 187.2800 2.0500 3C273 0.190 (3C273)
RH701973N00 HRI 2176 187.2800 2.0500 3C273 0.190 (3C273)
RH701961N00 HRI 2088 187.2800 2.0500 3C273 0.190 (3C273)
RH701963N00 HRI 2053 187.2800 2.0500 3C273 0.190 (3C273)
RH701962N00 HRI 2019 187.2800 2.0500 3C273 0.190 (3C273)
RP701256N00 PSPCB 2002 187.2800 2.0500 3C273 0.190 (3C273)
RP701269N00 PSPCB 1974 187.2800 2.0500 3C273 0.190 (3C273)
RP701255N00 PSPCB 1973 187.2800 2.0500 3C273 0.190 (3C273)
RP701268N00 PSPCB 1970 187.2800 2.0500 3C273 0.190 (3C273)
RH701968N00 HRI 1931 187.2800 2.0500 3C273 0.190 (3C273)
RH701969N00 HRI 1889 187.2800 2.0500 3C273 0.190 (3C273)
RP701267N00 PSPCB 1874 187.2800 2.0500 3C273 0.190 (3C273)
RH701976N00 HRI 1866 187.2800 2.0500 3C273 0.190 (3C273)
RH701970N00 HRI 1864 187.2800 2.0500 3C273 0.190 (3C273)
RP701266N00 PSPCB 1840 187.2800 2.0500 3C273 0.190 (3C273)
RH701957N00 HRI 1831 187.2800 2.0500 3C273 0.190 (3C273)
RH701964N00 HRI 1823 187.2800 2.0500 3C273 0.190 (3C273)
RH701960N00 HRI 1815 187.2800 2.0500 3C273 0.190 (3C273)
RP701265N00 PSPCB 1784 187.2800 2.0500 3C273 0.190 (3C273)
RH701959N00 HRI 1751 187.2800 2.0500 3C273 0.190 (3C273)
RP701260N00 PSPCB 1744 187.2800 2.0500 3C273 0.190 (3C273)
RH701971N00 HRI 1720 187.2770 2.0519 3C273 0.062 (3C273)
RP701264N00 PSPCB 1705 187.2800 2.0500 3C273 0.190 (3C273)
RH701956N00 HRI 1704 187.2800 2.0500 3C273 0.190 (3C273)
RH701958N00 HRI 1659 187.2800 2.0500 3C273 0.190 (3C273)
RH701965N00 HRI 1644 187.2800 2.0500 3C273 0.190 (3C273)
RH701955N00 HRI 1586 187.2800 2.0500 3C273 0.190 (3C273)
RH701972N00 HRI 1563 187.2800 2.0500 3C273 0.190 (3C273)
RH701953N00 HRI 1533 187.2800 2.0500 3C273 0.190 (3C273)
RH701967N00 HRI 1511 187.2800 2.0500 3C273 0.190 (3C273)
RP701263N00 PSPCB 1503 187.2800 2.0500 3C273 0.190 (3C273)
RH701257N00 HRI 1473 187.2800 2.0500 3C273 0.190 (3C273)
RH701954N00 HRI 1373 187.2800 2.0500 3C273 0.190 (3C273)
RP701262N00 PSPCB 1324 187.2800 2.0500 3C273 0.190 (3C273)
RH701952N00 HRI 1189 187.2800 2.0500 3C273 0.190 (3C273)
RP701261N00 PSPCB 1122 187.2800 2.0500 3C273 0.190 (3C273)
RP701259N00 PSPCB 1048 187.2800 2.0500 3C273 0.190 (3C273)
RP701258N00 PSPCB 1040 187.2800 2.0500 3C273 0.190 (3C273)
RH701974N00 HRI 982 187.2800 2.0500 3C273 0.190 (3C273)
RP120000N00 PSPCC 916 187.2700 2.0500 XRT/PSPC NORTH DUMMY 0.496 (3C273)
RH141520N00 HRI 765 187.2700 2.0500 3C273 0.496 (3C273)
RH701978N00 HRI 671 187.2800 2.0500 3C273 0.190 (3C273)
RH701981N00 HRI 498 187.2800 2.0500 3C273 0.190 (3C273)
RP141520N00 PSPCB 485 187.2700 2.0500 3C273 0.496 (3C273)
RH701979N00 HRI 354 187.2800 2.0500 3C273 0.190 (3C273)
RH120001N00 HRI 0 187.2700 2.0500 XRT/HRI NORTH DUMMY 0.496 (3C273)

Loading

0 comments on commit cf7fe2e

Please sign in to comment.