1
1
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2
2
3
+ from typing import Union
3
4
import warnings
4
5
from io import StringIO , BytesIO
5
6
from astropy .table import Table
15
16
__all__ = ['Heasarc' , 'HeasarcClass' ]
16
17
17
18
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
+
18
26
@async_to_sync
19
27
class HeasarcClass (BaseQuery ):
20
28
@@ -86,8 +94,10 @@ def query_mission_cols(self, mission, cache=True, get_query_payload=False,
86
94
All other parameters have no effect
87
95
"""
88
96
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 ,
91
101
get_query_payload = get_query_payload ,
92
102
resultsmax = 1 ,
93
103
fields = 'All' )
@@ -127,8 +137,8 @@ def query_object_async(self, object_name, mission,
127
137
128
138
return self .query_async (request_payload , cache = cache )
129
139
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 ,
132
142
** kwargs ):
133
143
"""
134
144
Query around specific set of coordinates within a given mission
@@ -138,7 +148,7 @@ def query_region_async(self, position, mission, radius,
138
148
139
149
Parameters
140
150
----------
141
- position : `astropy.coordinates` or str
151
+ position : `astropy.coordinates.SkyCoord ` or str
142
152
The position around which to search. It may be specified as a
143
153
string in which case it is resolved using online services or as
144
154
the appropriate `astropy.coordinates` object. ICRS coordinates
@@ -188,7 +198,7 @@ def _old_w3query_fallback(self, content):
188
198
f .writeto (I )
189
199
I .seek (0 )
190
200
191
- return Table . read (I )
201
+ return Table_read (I )
192
202
193
203
def _fallback (self , text ):
194
204
"""
@@ -218,7 +228,8 @@ def _fallback(self, text):
218
228
new_table .append ("" .join (newline ))
219
229
220
230
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 )
222
233
223
234
def _parse_result (self , response , verbose = False ):
224
235
# if verbose is False then suppress any VOTable related warnings
@@ -239,8 +250,7 @@ def _parse_result(self, response, verbose=False):
239
250
240
251
try :
241
252
data = BytesIO (response .content )
242
- table = Table .read (data , hdu = 1 )
243
- return table
253
+ return Table_read (data , hdu = 1 )
244
254
except ValueError :
245
255
try :
246
256
return self ._fallback (response .text )
0 commit comments