@@ -149,6 +149,34 @@ def _validate_criteria(self, **criteria):
149
149
)
150
150
raise InvalidQueryError (error_msg )
151
151
152
+ def _build_params_from_criteria (self , params , ** criteria ):
153
+ """
154
+ Build the parameters for the API request based on the provided criteria.
155
+
156
+ Parameters
157
+ ----------
158
+ params : dict
159
+ Dictionary to store the parameters for the API request.
160
+ **criteria
161
+ Keyword arguments representing criteria filters to apply.
162
+ """
163
+ # Add each criterion to the params dictionary
164
+ params ['conditions' ] = []
165
+ for prop , value in criteria .items ():
166
+ if prop not in self ._search_option_fields :
167
+ if isinstance (value , list ):
168
+ # Convert to comma-separated string if passed as a list
169
+ value = ',' .join (str (item ) for item in value )
170
+ params ['conditions' ].append ({prop : value })
171
+ else :
172
+ if prop == 'sort_by' and isinstance (value , str ):
173
+ # Convert to list if passed as a string
174
+ value = [value ]
175
+ if prop == 'sort_desc' and isinstance (value , bool ):
176
+ # Convert to list if passed as a boolean
177
+ value = [value ]
178
+ params [prop ] = value
179
+
152
180
@class_or_instance
153
181
def query_region_async (self , coordinates , * , radius = 3 * u .arcmin , limit = 5000 , offset = 0 ,
154
182
select_cols = None , ** criteria ):
@@ -172,12 +200,15 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs
172
200
Optional and default is 0
173
201
the number of records you wish to skip before selecting records.
174
202
select_cols: list, None
175
- Default None. Names of columns that will be included in the astropy table
203
+ Default None. Names of columns that will be included in the result table.
204
+ If None, a default set of columns will be returned.
176
205
**criteria
177
206
Other mission-specific criteria arguments.
178
207
All valid filters can be found using `~astroquery.mast.missions.MastMissionsClass.get_column_list`
179
208
function.
180
209
For example, one can specify the output columns(select_cols) or use other filters(conditions).
210
+ To filter by multiple values for a single column, pass in a list of values or
211
+ a comma-separated string of values.
181
212
182
213
Returns
183
214
-------
@@ -210,13 +241,7 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs
210
241
'offset' : offset ,
211
242
'select_cols' : select_cols }
212
243
213
- params ['conditions' ] = []
214
- # adding additional user specified parameters
215
- for prop , value in criteria .items ():
216
- if prop not in self ._search_option_fields :
217
- params ['conditions' ].append ({prop : value })
218
- else :
219
- params [prop ] = value
244
+ self ._build_params_from_criteria (params , ** criteria )
220
245
221
246
return self ._service_api_connection .missions_request_async (self .service , params )
222
247
@@ -245,7 +270,8 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
245
270
Optional and default is 0.
246
271
the number of records you wish to skip before selecting records.
247
272
select_cols: list, None
248
- Default None. Names of columns that will be included in the astropy table
273
+ Default None. Names of columns that will be included in the result table.
274
+ If None, a default set of columns will be returned.
249
275
resolver : str, optional
250
276
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
251
277
If not specified, the default resolver order will be used. Please see the
@@ -259,6 +285,8 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
259
285
and all fields listed in the column documentation for the mission being queried.
260
286
List of all valid fields that can be used to match results on criteria can be retrieved by calling
261
287
`~astroquery.mast.missions.MastMissionsClass.get_column_list` function.
288
+ To filter by multiple values for a single column, pass in a list of values or
289
+ a comma-separated string of values.
262
290
263
291
Returns
264
292
-------
@@ -296,12 +324,7 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
296
324
if not self ._service_api_connection .check_catalogs_criteria_params (criteria ):
297
325
raise InvalidQueryError ("At least one non-positional criterion must be supplied." )
298
326
299
- params ['conditions' ] = []
300
- for prop , value in criteria .items ():
301
- if prop not in self ._search_option_fields :
302
- params ['conditions' ].append ({prop : value })
303
- else :
304
- params [prop ] = value
327
+ self ._build_params_from_criteria (params , ** criteria )
305
328
306
329
return self ._service_api_connection .missions_request_async (self .service , params )
307
330
@@ -327,7 +350,8 @@ def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offse
327
350
Optional and default is 0.
328
351
the number of records you wish to skip before selecting records.
329
352
select_cols: list, None
330
- Default None. Names of columns that will be included in the astropy table
353
+ Default None. Names of columns that will be included in the result table.
354
+ If None, a default set of columns will be returned.
331
355
resolver : str, optional
332
356
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
333
357
If not specified, the default resolver order will be used. Please see the
@@ -338,6 +362,8 @@ def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offse
338
362
All valid filters can be found using `~astroquery.mast.missions.MastMissionsClass.get_column_list`
339
363
function.
340
364
For example, one can specify the output columns(select_cols) or use other filters(conditions).
365
+ To filter by multiple values for a single column, pass in a list of values or
366
+ a comma-separated string of values.
341
367
342
368
Returns
343
369
-------
0 commit comments