@@ -38,8 +38,8 @@ class ESAHubbleClass(BaseQuery):
38
38
metadata_url = conf .METADATA_ACTION
39
39
target_url = conf .TARGET_ACTION
40
40
TIMEOUT = conf .TIMEOUT
41
- calibration_levels = {0 : "AUXILIARY" , 1 : "RAW" , 2 : "CALIBRATED" ,
42
- 3 : "PRODUCT" }
41
+ calibration_levels = {"AUXILIARY" : 0 , "RAW" : 1 , "CALIBRATED" : 2 ,
42
+ "PRODUCT" : 3 }
43
43
product_types = ["PRODUCT" , "SCIENCE_PRODUCT" , "POSTCARD" ]
44
44
copying_string = "Copying file to {0}..."
45
45
@@ -629,35 +629,32 @@ def query_criteria(self, calibration_level=None,
629
629
630
630
parameters = []
631
631
if calibration_level is not None :
632
- parameters .append ("p. calibration_level LIKE '%{}%' " .format (
632
+ parameters .append ("calibration_level={} " .format (
633
633
self .__get_calibration_level (calibration_level )))
634
634
if data_product_type is not None :
635
635
if isinstance (data_product_type , str ):
636
- parameters .append ("p. data_product_type LIKE '%{}%'" .format (
636
+ parameters .append ("data_product_type LIKE '%{}%'" .format (
637
637
data_product_type ))
638
638
else :
639
639
raise ValueError ("data_product_type must be a string" )
640
640
if intent is not None :
641
641
if isinstance (intent , str ):
642
- parameters .append ("o. intent LIKE '%{}%'" .format (intent ))
642
+ parameters .append ("intent LIKE '%{}%'" .format (intent . lower () ))
643
643
else :
644
644
raise ValueError ("intent must be a string" )
645
645
if self .__check_list_strings (obs_collection ):
646
- parameters .append ("(o. collection LIKE '%{}%')" .format (
647
- "%' OR o. collection LIKE '%" .join (obs_collection )
646
+ parameters .append ("(collection LIKE '%{}%')" .format (
647
+ "%' OR collection LIKE '%" .join (obs_collection )
648
648
))
649
649
if self .__check_list_strings (instrument_name ):
650
- parameters .append ("(o. instrument_name LIKE '%{}%')" .format (
651
- "%' OR o. instrument_name LIKE '%" .join (instrument_name )
650
+ parameters .append ("(instrument_name LIKE '%{}%')" .format (
651
+ "%' OR instrument_name LIKE '%" .join (instrument_name )
652
652
))
653
653
if self .__check_list_strings (filters ):
654
- parameters .append ("(o. instrument_configuration LIKE '%{}%')"
655
- .format ("%' OR o. instrument_configuration "
654
+ parameters .append ("(instrument_configuration LIKE '%{}%')"
655
+ .format ("%' OR instrument_configuration "
656
656
"LIKE '%" .join (filters )))
657
- query = "select o.*, p.calibration_level, p.data_product_type, " \
658
- "pos.ra, pos.dec from ehst.observation AS o JOIN " \
659
- "ehst.plane as p on o.observation_uuid=p.observation_uuid " \
660
- "JOIN ehst.position as pos on p.plane_id = pos.plane_id"
657
+ query = "select * from ehst.archive"
661
658
if parameters :
662
659
query += " where({})" .format (" AND " .join (parameters ))
663
660
if verbose :
@@ -673,13 +670,13 @@ def query_criteria(self, calibration_level=None,
673
670
def __get_calibration_level (self , calibration_level ):
674
671
condition = ""
675
672
if (calibration_level is not None ):
676
- if isinstance (calibration_level , str ):
677
- condition = calibration_level
678
- elif isinstance (calibration_level , int ):
673
+ if isinstance (calibration_level , int ):
679
674
if calibration_level < 4 :
680
- condition = self . calibration_levels [ calibration_level ]
675
+ condition = calibration_level
681
676
else :
682
677
raise KeyError ("Calibration level must be between 0 and 3" )
678
+ elif isinstance (calibration_level , str ):
679
+ condition = self .calibration_levels [calibration_level ]
683
680
else :
684
681
raise KeyError ("Calibration level must be either "
685
682
"a string or an integer" )
0 commit comments