@@ -40,7 +40,12 @@ def wrapper(*args, **kwargs):
4040 if telescope_config .upper () not in Nrao .telescope_config :
4141 raise ValueError ("'telescope_config' must be one of {!s}"
4242 .format (Nrao .telescope_config ))
43- if obs_band .upper () not in Nrao .obs_bands :
43+ if isinstance (obs_band , (list , tuple )):
44+ for ob in obs_band :
45+ if ob not in Nrao .obs_bands :
46+ raise ValueError ("'obs_band' must be one of {!s}"
47+ .format (Nrao .obs_bands ))
48+ elif obs_band not in Nrao .obs_bands :
4449 raise ValueError ("'obs_band' must be one of {!s}"
4550 .format (Nrao .obs_bands ))
4651 if sub_array not in Nrao .subarrays and sub_array != 'all' :
@@ -69,7 +74,7 @@ class NraoClass(QueryWithLogin):
6974 telescope_config = ['ALL' , 'A' , 'AB' , 'BnA' , 'B' , 'BC' , 'CnB' , 'C' ,
7075 'CD' , 'DnC' , 'D' , 'DA' ]
7176
72- obs_bands = ['ALL' , '4' , 'P' , 'L' , 'S' , 'C' , 'X' , 'U' , 'K' , 'Ka' , 'Q' , 'W' ]
77+ obs_bands = ['ALL' , 'all' , ' 4' , 'P' , 'L' , 'S' , 'C' , 'X' , 'U' , 'K' , 'Ka' , 'Q' , 'W' ]
7378
7479 subarrays = ['ALL' , 1 , 2 , 3 , 4 , 5 ]
7580
@@ -167,6 +172,12 @@ def _args_to_payload(self, **kwargs):
167172 else :
168173 freq_str = ""
169174
175+ obs_bands = kwargs .get ('obs_band' , 'all' )
176+ if isinstance (obs_bands , six .string_types ):
177+ obs_bands = obs_bands .upper ()
178+ elif isinstance (obs_bands , (list ,tuple )):
179+ obs_bands = [x .upper () for x in obs_bands ]
180+
170181 request_payload = dict (
171182 QUERYTYPE = kwargs .get ('querytype' , "OBSSUMMARY" ),
172183 PROTOCOL = kwargs .get ('protocol' ,"VOTable-XML" ),
@@ -195,7 +206,7 @@ def _args_to_payload(self, **kwargs):
195206 SRAD = str (
196207 commons .parse_radius (kwargs .get ('radius' , "1.0m" )).deg ) + 'd' ,
197208 TELESCOPE_CONFIG = kwargs .get ('telescope_config' , 'all' ).upper (),
198- OBS_BANDS = kwargs . get ( 'obs_band' , 'all' ). upper () ,
209+ OBS_BANDS = obs_bands ,
199210 SUBARRAY = kwargs .get ('subarray' , 'all' ).upper (),
200211 SOURCE_ID = kwargs .get ('source_id' , '' ),
201212 SRC_SEARCH_TYPE = 'SIMBAD or NED' ,
@@ -332,12 +343,15 @@ def query_async(self,
332343
333344 response .raise_for_status ()
334345
335- if not response .content :
346+ # fail if response is entirely whitespace or if it is empty
347+ if not response .content .strip ():
336348 if cache :
337349 last_pickle = self ._last_query .hash ()+ ".pickle"
338350 cache_fn = os .path .join (self .cache_location , last_pickle )
339351 os .remove (cache_fn )
340352 if retry > 0 :
353+ log .warning ("Query resulted in an empty result. Retrying {0}"
354+ " more times." .format (retry ))
341355 self .query_async (cache = cache , retry = retry - 1 , ** kwargs )
342356 else :
343357 raise ValueError ("Query resulted in an empty result but "
@@ -351,6 +365,7 @@ def query_region_async(self, coordinates, radius=1 * u.deg,
351365 end_date = "" , freq_low = None , freq_up = None ,
352366 telescope_config = 'all' , obs_band = 'all' ,
353367 querytype = 'OBSSUMMARY' , sub_array = 'all' ,
368+ project_code = None ,
354369 protocol = 'VOTable-XML' ,
355370 retry = False ,
356371 get_query_payload = False , cache = True ):
0 commit comments