@@ -41,8 +41,26 @@ class EuclidClass(TapPlus):
41
41
42
42
__VALID_DATALINK_RETRIEVAL_TYPES = conf .VALID_DATALINK_RETRIEVAL_TYPES
43
43
44
- def __init__ (self , * , tap_plus_conn_handler = None , datalink_handler = None , cutout_handler = None , environment = 'PDR' ,
45
- verbose = False , show_server_messages = True ):
44
+ def __init__ (self , * , environment = 'PDR' , tap_plus_conn_handler = None , datalink_handler = None , cutout_handler = None ,
45
+ euclid_tap_server = None , euclid_data_server = None , euclid_cutout_server = None , verbose = False ,
46
+ show_server_messages = True ):
47
+ """Constructor for EuclidClass.
48
+
49
+ Parameters
50
+ ----------
51
+ environment : str, mandatory if no tap, data or cutout hosts is specified, default 'PDR'
52
+ The Euclid Science Archive environment: 'PDR', 'IDR', 'OTF' and 'REG'
53
+ euclid_tap_server : str, optional, default None
54
+ TAP URL
55
+ euclid_data_server : str, optional, default None
56
+ data URL
57
+ euclid_cutout_server : str, optional, default None
58
+ cutout URL
59
+ verbose : bool, optional, default 'True'
60
+ flag to display information about the process
61
+ show_server_messages : bool, optional, default 'True'
62
+ show the messages to inform users about the status of Euclid TAP
63
+ """
46
64
47
65
if environment not in conf .ENVIRONMENTS :
48
66
raise ValueError (
@@ -457,8 +475,7 @@ def login(self, *, user=None, password=None, credentials_file=None, verbose=Fals
457
475
flag to display information about the process
458
476
"""
459
477
try :
460
- log .info ("Login to Euclid TAP server" )
461
- log .info (f"Euclid TAP server url: { self ._TapPlus__getconnhandler ().get_host_url ()} " )
478
+ log .info (f"Login to Euclid TAP server: { self ._TapPlus__getconnhandler ().get_host_url ()} " )
462
479
super ().login (user = user , password = password , credentials_file = credentials_file , verbose = verbose )
463
480
except HTTPError as err :
464
481
log .error ('Error logging in TAP server: %s' % (str (err )))
@@ -468,11 +485,9 @@ def login(self, *, user=None, password=None, credentials_file=None, verbose=Fals
468
485
tap_password = self ._TapPlus__pwd
469
486
470
487
try :
471
- log .info ("Login to Euclid data service" )
472
- log .info (f"Euclid data server url: { self .__eucliddata ._TapPlus__getconnhandler ().get_host_url ()} " )
488
+ log .info (f"Login to Euclid data service: { self .__eucliddata ._TapPlus__getconnhandler ().get_host_url ()} " )
473
489
self .__eucliddata .login (user = tap_user , password = tap_password , verbose = verbose )
474
- log .info ("Login to Euclid cutout service" )
475
- log .info (f"Euclid cutout server url: { self .__euclidcutout ._TapPlus__getconnhandler ().get_host_url ()} " )
490
+ log .info (f"Login to Euclid cutout service: { self .__euclidcutout ._TapPlus__getconnhandler ().get_host_url ()} " )
476
491
self .__euclidcutout .login (user = tap_user , password = tap_password , verbose = verbose )
477
492
except HTTPError as err :
478
493
log .error ('Error logging in data or cutout services: %s' % (str (err )))
@@ -491,8 +506,7 @@ def login_gui(self, verbose=False):
491
506
flag to display information about the process
492
507
"""
493
508
try :
494
- log .info ("Login to Euclid TAP server" )
495
- log .info (f"Euclid TAP server url: { self ._TapPlus__getconnhandler ().get_host_url ()} " )
509
+ log .info (f"Login to Euclid TAP server: { self ._TapPlus__getconnhandler ().get_host_url ()} " )
496
510
TapPlus .login_gui (self , verbose = verbose )
497
511
except HTTPError as err :
498
512
log .error ('Error logging in TAP server: %s' % (str (err )))
@@ -502,17 +516,15 @@ def login_gui(self, verbose=False):
502
516
tap_password = self ._TapPlus__pwd
503
517
504
518
try :
505
- log .info ("Login to Euclid data server" )
506
- log .info (f"Euclid data server url: { self .__eucliddata ._TapPlus__getconnhandler ().get_host_url ()} " )
519
+ log .info (f"Login to Euclid data server: { self .__eucliddata ._TapPlus__getconnhandler ().get_host_url ()} " )
507
520
self .__eucliddata .login (user = tap_user , password = tap_password , verbose = verbose )
508
521
except HTTPError as err :
509
522
log .error ('Error logging in data server: %s' % (str (err )))
510
523
log .error ("Logging out from TAP server" )
511
524
TapPlus .logout (self , verbose = verbose )
512
525
513
526
try :
514
- log .info ("Login to Euclid cutout server" )
515
- log .info (f"Euclid cutout server url: { self .__euclidcutout ._TapPlus__getconnhandler ().get_host_url ()} " )
527
+ log .info (f"Login to Euclid cutout server: { self .__euclidcutout ._TapPlus__getconnhandler ().get_host_url ()} " )
516
528
self .__euclidcutout .login (user = tap_user , password = tap_password , verbose = verbose )
517
529
except HTTPError as err :
518
530
log .error ('Error logging in cutout server: %s' % (str (err )))
@@ -1159,16 +1171,18 @@ def get_spectrum(self, *, source_id, schema='sedm', retrieval_type="ALL", output
1159
1171
-----------
1160
1172
Downloads a spectrum with datalink.
1161
1173
1162
- The spectrum associated to the source_id is downloaded as fits file, and returned in a list. The file is
1163
- saved in the local path given by output_file. If this parameter is not set, the result is saved in the
1164
- file "<working directory>/temp_<%Y%m%d_%H%M%S>/<source_id>.fits"
1174
+ The spectrum associated to the source_id is downloaded as a compressed fits file, and the files it contains
1175
+ are returned in a list. The compressed fits file is saved in the local path given by output_file. If this
1176
+ parameter is not set, the result is saved in the file "<working
1177
+ directory>/temp_<%Y%m%d_%H%M%S>/<source_id>.fits.zip". In any case, the content of the zip file is
1178
+ automatically extracted.
1165
1179
1166
1180
Parameters
1167
1181
----------
1168
1182
source_id : str, mandatory, default None
1169
1183
source id for the spectrum
1170
1184
schema : str, mandatory, default 'sedm'
1171
- the data release, 'sedm'
1185
+ the data release
1172
1186
retrieval_type : str, optional, default 'ALL' to retrieve all data from the list of sources
1173
1187
retrieval type identifier. Possible values are: 'SPECTRA_BGS' for the blue spectrum and 'SPECTRA_RGS' for
1174
1188
the red one.
@@ -1180,7 +1194,10 @@ def get_spectrum(self, *, source_id, schema='sedm', retrieval_type="ALL", output
1180
1194
1181
1195
Returns
1182
1196
-------
1183
- A list of files.
1197
+ A list of files: the files contained in the downloaded compressed fits file. The format of the file is
1198
+ SPECTRA_<colour>-<schema> <source_id>.fits', where <colour> is BGS or RGS, and <schema> and <source_id> are
1199
+ taking from the input parameters.
1200
+
1184
1201
"""
1185
1202
1186
1203
if source_id is None or schema is None :
@@ -1202,7 +1219,22 @@ def get_spectrum(self, *, source_id, schema='sedm', retrieval_type="ALL", output
1202
1219
1203
1220
fits_file = source_id + '.fits.zip'
1204
1221
1222
+ if output_file is not None :
1223
+ if not output_file .endswith ('.zip' ):
1224
+ output_file = output_file + '.zip'
1225
+
1226
+ if os .path .dirname (output_file ) == '' :
1227
+ output_file = os .path .join (os .getcwd (), output_file )
1228
+
1229
+ if verbose :
1230
+ print (f"output file: { output_file } " )
1231
+
1205
1232
output_file_full_path , output_dir = self .__set_dirs (output_file = output_file , observation_id = fits_file )
1233
+
1234
+ if os .listdir (output_dir ):
1235
+ log .error (f'The directory is not empty: { output_dir } ' )
1236
+ return
1237
+
1206
1238
try :
1207
1239
self .__eucliddata .load_data (params_dict = params_dict , output_file = output_file_full_path , verbose = verbose )
1208
1240
except HTTPError as err :
0 commit comments