@@ -54,6 +54,7 @@ def __init__(self, *, mission='hst', mast_token=None):
54
54
self .dataset_kwds = { # column keywords corresponding to dataset ID
55
55
'hst' : 'sci_data_set_name' ,
56
56
'jwst' : 'fileSetName' ,
57
+ 'roman' : 'fileSetName' ,
57
58
'classy' : 'Target' ,
58
59
'ullyses' : 'observation_id'
59
60
}
@@ -80,6 +81,37 @@ def mission(self, value):
80
81
self ._mission = value .lower () # case-insensitive
81
82
self ._service_api_connection .set_service_params (self .service_dict , f'search/{ self .mission } ' )
82
83
84
+ def _extract_products (self , response ):
85
+ """
86
+ Extract products from the response of a `~requests.Response` object.
87
+
88
+ Parameters
89
+ ----------
90
+ response : `~requests.Response`
91
+ The response object containing the products data.
92
+
93
+ Returns
94
+ -------
95
+ list
96
+ A list of products extracted from the response.
97
+ """
98
+ def normalize_products (products ):
99
+ """
100
+ Normalize the products list to ensure it is flat and not nested.
101
+ """
102
+ if products and isinstance (products [0 ], list ):
103
+ return products [0 ]
104
+ return products
105
+
106
+ if isinstance (response , list ): # multiple async responses from batching
107
+ combined = []
108
+ for resp in response :
109
+ products = normalize_products (resp .json ().get ('products' , []))
110
+ combined .extend (products )
111
+ return combined
112
+ else : # single response
113
+ return normalize_products (response .json ().get ('products' , []))
114
+
83
115
def _parse_result (self , response , * , verbose = False ): # Used by the async_to_sync decorator functionality
84
116
"""
85
117
Parse the results of a `~requests.Response` objects and return an `~astropy.table.Table` of results.
@@ -105,17 +137,11 @@ def _parse_result(self, response, *, verbose=False): # Used by the async_to_syn
105
137
if len (results ) >= self .limit :
106
138
warnings .warn ("Maximum results returned, may not include all sources within radius." ,
107
139
MaxResultsWarning )
108
- elif self .service == self ._list_products :
109
- # Results from post_list_products endpoint need to be handled differently
110
- if isinstance (response , list ): # multiple async responses from batching
111
- combined_products = []
112
- for resp in response :
113
- combined_products .extend (resp .json ().get ('products' , []))
114
- return Table (combined_products )
115
-
116
- results = Table (response .json ()['products' ]) # single async response
140
+ return results
117
141
118
- return results
142
+ elif self .service == self ._list_products :
143
+ products = self ._extract_products (response )
144
+ return Table (products )
119
145
120
146
def _validate_criteria (self , ** criteria ):
121
147
"""
@@ -537,8 +563,8 @@ def download_file(self, uri, *, local_path=None, cache=True, verbose=True):
537
563
"""
538
564
539
565
# Construct the full data URL based on mission
540
- if self .mission in ['hst' , 'jwst' ]:
541
- # HST and JWST have a dedicated endpoint for retrieving products
566
+ if self .mission in ['hst' , 'jwst' , 'roman' ]:
567
+ # HST, JWST, and RST have a dedicated endpoint for retrieving products
542
568
base_url = self ._service_api_connection .MISSIONS_DOWNLOAD_URL + self .mission + '/api/v0.1/retrieve_product'
543
569
keyword = 'product_name'
544
570
else :
0 commit comments