@@ -1140,13 +1140,13 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
11401140 if tile_index is not None :
11411141 return self .__get_tile_catalogue_list (tile_index = tile_index , product_type = product_type , verbose = verbose )
11421142
1143- dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 )
1144- extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1145-
11461143 query = None
11471144 if product_type in conf .OBSERVATION_STACK_PRODUCTS :
11481145 table = 'sedm.observation_stack'
11491146
1147+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'observation_stack' )
1148+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1149+
11501150 query = (f"SELECT observation_stack.file_name, observation_stack.observation_stack_oid, "
11511151 f"observation_stack.observation_id, observation_stack.ra, observation_stack.dec, "
11521152 f"observation_stack.instrument_name, observation_stack.filter_name, "
@@ -1158,6 +1158,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
11581158
11591159 if product_type in conf .BASIC_DOWNLOAD_DATA_PRODUCTS :
11601160 table = 'sedm.basic_download_data'
1161+
1162+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'basic_download_data' )
1163+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1164+
11611165 query = (
11621166 f"SELECT basic_download_data.basic_download_data_oid, basic_download_data.product_type, "
11631167 f"basic_download_data.product_id, CAST(basic_download_data.observation_id_list as text) AS "
@@ -1170,6 +1174,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
11701174
11711175 if product_type in conf .MER_SEGMENTATION_MAP_PRODUCTS :
11721176 table = 'sedm.mer_segmentation_map'
1177+
1178+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'mer_segmentation_map' )
1179+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1180+
11731181 query = (
11741182 f"SELECT mer_segmentation_map.file_name, mer_segmentation_map.segmentation_map_oid, "
11751183 f"mer_segmentation_map.ra, mer_segmentation_map.dec, mer_segmentation_map.stc_s, "
@@ -1183,6 +1191,9 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
11831191 if product_type in conf .RAW_FRAME_PRODUCTS :
11841192 table = 'sedm.raw_frame'
11851193
1194+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'raw_frame' )
1195+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1196+
11861197 if product_type == "dpdNispRawFrame" :
11871198 instrument_name = "NISP"
11881199 else :
@@ -1198,6 +1209,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
11981209
11991210 if product_type in conf .CALIBRATED_FRAME_PRODUCTS :
12001211 table = 'sedm.calibrated_frame'
1212+
1213+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'calibrated_frame' )
1214+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1215+
12011216 query = (
12021217 f"SELECT calibrated_frame.file_name, calibrated_frame.calibrated_frame_oid, "
12031218 f"calibrated_frame.observation_id, calibrated_frame.instrument_name, calibrated_frame.filter_name, "
@@ -1208,6 +1223,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
12081223
12091224 if product_type in conf .FRAME_CATALOG_PRODUCTS :
12101225 table = 'sedm.frame_catalog'
1226+
1227+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'frame_catalog' )
1228+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1229+
12111230 query = (
12121231 f"SELECT frame_catalog.file_name, frame_catalog.catalog_oid, frame_catalog.observation_id, "
12131232 f"frame_catalog.instrument_name, frame_catalog.filter_name, frame_catalog.ra, frame_catalog.dec, "
@@ -1218,6 +1237,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
12181237
12191238 if product_type in conf .COMBINED_SPECTRA_PRODUCTS :
12201239 table = 'sedm.combined_spectra'
1240+
1241+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'combined_spectra' )
1242+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1243+
12211244 query = (
12221245 f"SELECT combined_spectra.combined_spectra_oid, combined_spectra.lambda_range, "
12231246 f"combined_spectra.tile_index, combined_spectra.stc_s, combined_spectra.product_type, "
@@ -1229,6 +1252,10 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
12291252
12301253 if product_type in conf .SIR_SCIENCE_FRAME_PRODUCTS :
12311254 table = 'sedm.sir_science_frame'
1255+
1256+ dsr_condition = self .get_data_set_release_condition (dsr_part1 , dsr_part2 , dsr_part3 , 'sir_science_frame' )
1257+ extra_condition = '' if dsr_condition is None else f'AND { dsr_condition } '
1258+
12321259 instrument_name = "NISP"
12331260
12341261 query = (
@@ -1245,23 +1272,26 @@ def get_product_list(self, *, observation_id=None, tile_index=None, product_type
12451272 format_with_results_compressed = ('votable_gzip' ,))
12461273 return job .get_results ()
12471274
1248- def get_data_set_release_condition (self , dsr_1_value = None , dsr_2_value = None , dsr_3_value = None ):
1275+ def get_data_set_release_condition (self , dsr_1_value = None , dsr_2_value = None , dsr_3_value = None , alias = None ):
12491276
12501277 query = None
12511278 if dsr_1_value is not None :
1252- query = f"{ self .dsr_1 } = '{ dsr_1_value } '"
1279+ dsr_1_final = '.' .join (filter (None , [alias , self .dsr_1 ]))
1280+ query = f"{ dsr_1_final } = '{ dsr_1_value } '"
12531281
12541282 if dsr_2_value is not None :
1283+ dsr_2_final = '.' .join (filter (None , [alias , self .dsr_2 ]))
12551284 if query is not None :
1256- query = f"{ query } AND { self . dsr_2 } = { dsr_2_value } "
1285+ query = f"{ query } AND { dsr_2_final } = ' { dsr_2_value } ' "
12571286 else :
1258- query = f"{ self . dsr_2 } = { dsr_2_value } "
1287+ query = f"{ dsr_2_final } = ' { dsr_2_value } ' "
12591288
12601289 if dsr_3_value is not None :
1290+ dsr_3_final = '.' .join (filter (None , [alias , str (self .dsr_3 )]))
12611291 if query is not None :
1262- query = f"{ query } AND { self . dsr_3 } = { dsr_3_value } "
1292+ query = f"{ query } AND { dsr_3_final } = { dsr_3_value } "
12631293 else :
1264- query = f"{ self . dsr_3 } = { dsr_3_value } "
1294+ query = f"{ dsr_3_final } = { dsr_3_value } "
12651295
12661296 return query
12671297
@@ -1360,7 +1390,6 @@ def get_cutout(self, *, file_path=None, instrument=None, id=None, coordinate, ra
13601390 the radius of the cutout to generate
13611391 output_file : str, optional
13621392 output file. If no value is provided, a temporary one is created
1363-
13641393 verbose : bool, optional, default 'False'
13651394 flag to display information about the process
13661395
@@ -1475,6 +1504,8 @@ def get_spectrum(self, *, source_id, schema='sedm', retrieval_type="ALL", output
14751504 if os .listdir (output_dir ):
14761505 raise IOError (f'The directory is not empty: { output_dir } ' )
14771506
1507+ files = []
1508+
14781509 try :
14791510 self .__eucliddata .load_data (params_dict = params_dict , output_file = output_file_full_path , verbose = verbose )
14801511 except HTTPError as err :
@@ -1484,7 +1515,6 @@ def get_spectrum(self, *, source_id, schema='sedm', retrieval_type="ALL", output
14841515 log .error (f'Cannot retrieve spectrum for source_id { source_id } , schema { schema } : { str (exx )} ' )
14851516 return None
14861517
1487- files = []
14881518 self .__extract_file (output_file_full_path = output_file_full_path , output_dir = output_dir , files = files )
14891519
14901520 if files :
0 commit comments