@@ -124,36 +124,36 @@ def _args_to_payload(self, **kwargs):
124
124
if kwargs .get ('band' ) is not None :
125
125
if kwargs .get ('channel' ) is not None :
126
126
raise ValueError ("Either 'channel' or 'band' values may be provided but not both." )
127
-
127
+
128
128
band = kwargs .get ('band' )
129
- if not isinstance (band , (list ,tuple )) or len (band ) != 2 :
129
+ if not isinstance (band , (list , tuple )) or len (band ) != 2 :
130
130
raise ValueError ("The 'band' value must be a list of 2 wavelength or frequency values." )
131
131
if (band [0 ] is not None and not isinstance (band [0 ], u .Quantity )) or (band [1 ] is not None and not isinstance (band [1 ], u .Quantity )):
132
132
raise ValueError ("The 'band' value must be a list of 2 wavelength or frequency values." )
133
133
if band [0 ] is not None and band [1 ] is not None and band [0 ].unit .physical_type != band [1 ].unit .physical_type :
134
134
raise ValueError ("The 'band' values must have the same kind of units." )
135
135
if band [0 ] is not None or band [1 ] is not None :
136
136
unit = band [0 ].unit if band [0 ] is not None else band [1 ].unit
137
- if unit .physical_type == 'length' :
137
+ if unit .physical_type == 'length' :
138
138
min_band = '-Inf' if band [0 ] is None else str (band [0 ].to (u .m ).value )
139
139
max_band = '+Inf' if band [1 ] is None else str (band [1 ].to (u .m ).value )
140
- elif unit .physical_type == 'frequency' :
140
+ elif unit .physical_type == 'frequency' :
141
141
# Swap the order when changing frequency to wavelength
142
142
min_band = '-Inf' if band [1 ] is None else str (band [1 ].to (u .m , equivalencies = u .spectral ()).value )
143
143
max_band = '+Inf' if band [0 ] is None else str (band [0 ].to (u .m , equivalencies = u .spectral ()).value )
144
144
else :
145
145
raise ValueError ("The 'band' values must be wavelengths or frequencies." )
146
-
146
+
147
147
request_payload ['BAND' ] = '{} {}' .format (min_band , max_band )
148
148
149
149
if kwargs .get ('channel' ) is not None :
150
150
channel = kwargs .get ('channel' )
151
- if not isinstance (channel , (list ,tuple )) or len (channel ) != 2 :
151
+ if not isinstance (channel , (list , tuple )) or len (channel ) != 2 :
152
152
raise ValueError ("The 'channel' value must be a list of 2 integer values." )
153
153
if (not isinstance (channel [0 ], int )) or (not isinstance (channel [1 ], int )):
154
154
raise ValueError ("The 'channel' value must be a list of 2 integer values." )
155
155
request_payload ['CHANNEL' ] = '{} {}' .format (channel [0 ], channel [1 ])
156
-
156
+
157
157
return request_payload
158
158
159
159
# the methods above implicitly call the private _parse_result method.
@@ -194,7 +194,6 @@ def filter_out_unreleased(self, table):
194
194
now = str (datetime .now (timezone .utc ).strftime ('%Y-%m-%dT%H:%M:%S.%f' ))
195
195
return table [(table ['obs_release_date' ] != '' ) & (table ['obs_release_date' ] < now )]
196
196
197
-
198
197
def _create_job (self , table , service_name , verbose ):
199
198
# Use datalink to get authenticated access for each file
200
199
tokens = []
@@ -218,7 +217,7 @@ def _create_job(self, table, service_name, verbose):
218
217
job_url = self ._create_soda_job (tokens , soda_url = soda_url )
219
218
if verbose :
220
219
log .info ("Created data staging job " + job_url )
221
-
220
+
222
221
return job_url
223
222
224
223
def _complete_job (self , job_url , verbose ):
@@ -262,19 +261,18 @@ def stage_data(self, table, verbose=False):
262
261
return []
263
262
264
263
job_url = self ._create_job (table , 'async_service' , verbose )
265
-
266
- return self ._complete_job (job_url , verbose )
267
264
265
+ return self ._complete_job (job_url , verbose )
268
266
269
267
def cutout (self , table , coordinates = None , radius = None , height = None , width = None , band = None , channel = None , verbose = False ):
270
268
"""
271
- Produce a cutout from each selected file. All requests for data must use authentication. If you have access to
272
- the data, the requested files will be brought online, a cutout produced from each file and a set of URLs to
269
+ Produce a cutout from each selected file. All requests for data must use authentication. If you have access to
270
+ the data, the requested files will be brought online, a cutout produced from each file and a set of URLs to
273
271
download the cutouts will be returned.
274
272
275
- If a set of coordinates is provided along with either a radius or a box height and width, then CASDA will produce a
276
- spatial cutout at that location from each data file specified in the table. If a band or channel pair is provided
277
- then CASDA will produce a spectral cutout of that range from each data file. These can be combined to produce
273
+ If a set of coordinates is provided along with either a radius or a box height and width, then CASDA will produce a
274
+ spatial cutout at that location from each data file specified in the table. If a band or channel pair is provided
275
+ then CASDA will produce a spectral cutout of that range from each data file. These can be combined to produce
278
276
subcubes with restrictions in both spectral and spatial axes.
279
277
280
278
Parameters
@@ -422,10 +420,9 @@ def _create_soda_job(self, authenticated_id_tokens, soda_url=None):
422
420
resp .raise_for_status ()
423
421
return resp .url
424
422
425
-
426
423
def _add_cutout_params (self , job_location , verbose , cutout_spec ):
427
424
"""
428
- Add a cutout specification to an async SODA job. This will change the job
425
+ Add a cutout specification to an async SODA job. This will change the job
429
426
from just retrieving the full file to producing a cutout from the target file.
430
427
431
428
Parameters
@@ -437,7 +434,6 @@ def _add_cutout_params(self, job_location, verbose, cutout_spec):
437
434
cutout_spec: map
438
435
The map containing the POS parameter defining the cutout.
439
436
"""
440
- #params = list(map((lambda value: (param_key, value)), cutout_spec))
441
437
if verbose :
442
438
log .info ("Adding parameters: " + str (cutout_spec ))
443
439
resp = self ._request ('POST' , job_location + '/parameters' , data = cutout_spec , cache = False )
0 commit comments