@@ -28,7 +28,7 @@ class IntegralClass(BaseVOQuery, BaseQuery):
28
28
Class to init ESA Integral Module and communicate with isla
29
29
"""
30
30
31
- def __init__ (self , tap_handler = None , auth_session = None ):
31
+ def __init__ (self , auth_session = None ):
32
32
super ().__init__ ()
33
33
34
34
# Checks if auth session has been defined. If not, create a new session
@@ -38,16 +38,22 @@ def __init__(self, tap_handler=None, auth_session=None):
38
38
self ._auth_session = esautils .ESAAuthSession ()
39
39
40
40
self ._auth_session .timeout = conf .TIMEOUT
41
+ self ._tap = None
42
+ self ._tap_url = conf .ISLA_TAP_SERVER
41
43
42
- if tap_handler is None :
43
- self .tap = pyvo .dal .TAPService (
44
+ self .instruments = []
45
+ self .bands = []
46
+ self .instrument_band_map = {}
47
+
48
+ @property
49
+ def tap (self ) -> pyvo .dal .TAPService :
50
+ if self ._tap is None :
51
+ self ._tap = pyvo .dal .TAPService (
44
52
conf .ISLA_TAP_SERVER , session = self ._auth_session )
45
- else :
46
- self .tap = tap_handler
47
- self ._data = None
53
+ # Retrieve the instruments and bands available within ISLA Archive
54
+ self .get_instrument_band_map ()
48
55
49
- # Retrieve the instruments and bands available within ISLA Archive
50
- self .instruments , self .bands , self .instrument_band_map = self .get_instrument_band_map ()
56
+ return self ._tap
51
57
52
58
def get_tables (self , * , only_names = False ):
53
59
"""
@@ -217,13 +223,15 @@ def get_sources(self, target_name, *, async_job=False, output_file=None, output_
217
223
# Second attempt, resolve using a Resolver Service and cone search to the source catalogue
218
224
try :
219
225
coordinates = esautils .resolve_target (conf .ISLA_TARGET_RESOLVER , self .tap ._session , target_name , 'ALL' )
220
- query = conf .ISLA_CONE_TARGET_CONDITION .format (coordinates .ra .degree , coordinates .dec .degree , 0.0833 )
221
- result = self .query_tap (query = query , async_job = async_job , output_file = output_file ,
222
- output_format = output_format )
226
+ if coordinates :
227
+ query = conf .ISLA_CONE_TARGET_CONDITION .format (coordinates .ra .degree , coordinates .dec .degree , 0.0833 )
228
+ result = self .query_tap (query = query , async_job = async_job , output_file = output_file ,
229
+ output_format = output_format )
223
230
224
- if len (result ) > 0 :
225
- return result [0 ]
231
+ if len (result ) > 0 :
232
+ return result [0 ]
226
233
234
+ raise ValueError (f"Target { target_name } cannot be resolved for ISLA" )
227
235
except ValueError :
228
236
raise ValueError (f"Target { target_name } cannot be resolved for ISLA" )
229
237
@@ -900,20 +908,39 @@ def get_instrument_band_map(self):
900
908
"""
901
909
Maps the bands and instruments included in ISLA
902
910
"""
903
- instrument_band_table = self .query_tap (conf .ISLA_INSTRUMENT_BAND_QUERY )
904
- instrument_band_map = {}
905
911
906
- for row in instrument_band_table :
907
- instrument_band_map [row ['instrument' ]] = {'band' : row ['band' ],
908
- 'instrument_oid' : row ['instrument_oid' ],
909
- 'band_oid' : row ['band_oid' ]}
910
- instrument_band_map [row ['band' ]] = {'instrument' : row ['instrument' ],
911
- 'instrument_oid' : row ['instrument_oid' ],
912
- 'band_oid' : row ['band_oid' ]}
912
+ if len (self .instrument_band_map ) == 0 :
913
+ instrument_band_table = self .query_tap (conf .ISLA_INSTRUMENT_BAND_QUERY )
914
+ instrument_band_map = {}
915
+
916
+ for row in instrument_band_table :
917
+ instrument_band_map [row ['instrument' ]] = {'band' : row ['band' ],
918
+ 'instrument_oid' : row ['instrument_oid' ],
919
+ 'band_oid' : row ['band_oid' ]}
920
+ instrument_band_map [row ['band' ]] = {'instrument' : row ['instrument' ],
921
+ 'instrument_oid' : row ['instrument_oid' ],
922
+ 'band_oid' : row ['band_oid' ]}
923
+
924
+ instruments = instrument_band_table ['instrument' ]
925
+ bands = instrument_band_table ['band' ]
926
+
927
+ self .instruments = instruments
928
+ self .bands = bands
929
+ self .instrument_band_map = instrument_band_map
913
930
914
- instruments = instrument_band_table ['instrument' ]
915
- bands = instrument_band_table ['band' ]
916
- return instruments , bands , instrument_band_map
931
+ def get_instruments (self ):
932
+ """
933
+ Get the instruments available in ISLA
934
+ """
935
+ self .get_instrument_band_map ()
936
+ return self .instruments
937
+
938
+ def get_bands (self ):
939
+ """
940
+ Get the bands available in ISLA
941
+ """
942
+ self .get_instrument_band_map ()
943
+ return self .bands
917
944
918
945
def __get_instrument_or_band (self , instrument , band ):
919
946
if instrument and band :
@@ -928,12 +955,16 @@ def __get_instrument_or_band(self, instrument, band):
928
955
else :
929
956
value = band
930
957
958
+ # Retrieve the available instruments or bands if not loaded yet
959
+ self .get_instrument_band_map ()
960
+
961
+ # Validate the value is in the list of allowed ones
931
962
if value in self .instrument_band_map :
932
963
return value
933
964
934
965
raise ValueError (f"This is not a valid value for instrument or band. Valid values are:\n "
935
- f"Instruments: { self .instruments } \n "
936
- f"Bands: { self .bands } " )
966
+ f"Instruments: { self .get_instruments () } \n "
967
+ f"Bands: { self .get_bands () } " )
937
968
938
969
def __get_oids (self , value ):
939
970
"""
@@ -1027,7 +1058,7 @@ def __get_science_window_parameter(self, science_windows, observation_id, revolu
1027
1058
1028
1059
def __log_warning_message (self , get_method , download_method , show_warning = True ):
1029
1060
if show_warning :
1030
- warnings . warn (
1061
+ log . warning (
1031
1062
f"The plots and data provided by '{ get_method } ' have been developed using the automatic reduction "
1032
1063
f"pipeline at ISDC, using INTEGRAL OSA version 11.2. No manual scientific validation has been "
1033
1064
f"performed on these outputs. They should be examined and validated before being used for scientific "
0 commit comments