11# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
3+ from typing import Union
34import warnings
45from io import StringIO , BytesIO
56from astropy .table import Table
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
1927class 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 )
0 commit comments