@@ -32,6 +32,7 @@ class JwstClass(object):
3232 Proxy class to default TapPlus object (pointing to JWST Archive)
3333 """
3434 JWST_MAIN_TABLE = conf .JWST_MAIN_TABLE
35+ JWST_ARTIFACT_TABLE = conf .JWST_ARTIFACT_TABLE
3536 JWST_OBSERVATION_TABLE = conf .JWST_OBSERVATION_TABLE
3637 JWST_OBSERVATION_TABLE_RA = conf .JWST_OBSERVATION_TABLE_RA
3738 JWST_OBSERVATION_TABLE_DEC = conf .JWST_OBSERVATION_TABLE_DEC
@@ -248,7 +249,7 @@ def __query_region(self, coordinate, radius=None, width=None, height=None,
248249 -------
249250 The job results (astropy.table).
250251 """
251- coord = self .__getCoordInput (coordinate , "coordinate" )
252+ coord = self .__get_coord_input (coordinate , "coordinate" )
252253 job = None
253254 if radius is not None :
254255 job = self .__cone_search (coord , radius ,
@@ -258,13 +259,13 @@ def __query_region(self, coordinate, radius=None, width=None, height=None,
258259 else :
259260 raHours , dec = commons .coord_to_radec (coord )
260261 ra = raHours * 15.0 # Converts to degrees
261- widthQuantity = self .__getQuantityInput (width , "width" )
262- heightQuantity = self .__getQuantityInput (height , "height" )
262+ widthQuantity = self .__get_quantity_input (width , "width" )
263+ heightQuantity = self .__get_quantity_input (height , "height" )
263264 widthDeg = widthQuantity .to (units .deg )
264265 heightDeg = heightQuantity .to (units .deg )
265266
266- cal_level_condition = self .__getCalLevelCondition (cal_level )
267- public_condition = self .__getPublicCondition (only_public )
267+ cal_level_condition = self .__get_callevel_condition (cal_level )
268+ public_condition = self .__get_public_condition (only_public )
268269
269270 query = "SELECT DISTANCE(POINT('ICRS'," + \
270271 str (self .JWST_OBSERVATION_TABLE_RA ) + "," + \
@@ -396,15 +397,15 @@ def __cone_search(self, coordinate, radius,
396397 -------
397398 A Job object
398399 """
399- coord = self .__getCoordInput (coordinate , "coordinate" )
400+ coord = self .__get_coord_input (coordinate , "coordinate" )
400401 raHours , dec = commons .coord_to_radec (coord )
401402 ra = raHours * 15.0 # Converts to degrees
402403
403- cal_level_condition = self .__getCalLevelCondition (cal_level )
404- public_condition = self .__getPublicCondition (only_public )
404+ cal_level_condition = self .__get_callevel_condition (cal_level )
405+ public_condition = self .__get_public_condition (only_public )
405406
406407 if radius is not None :
407- radiusQuantity = self .__getQuantityInput (radius , "radius" )
408+ radiusQuantity = self .__get_quantity_input (radius , "radius" )
408409 radiusDeg = commons .radius_to_unit (radiusQuantity , unit = 'deg' )
409410 query = "SELECT DISTANCE(POINT('ICRS'," + \
410411 str (self .JWST_OBSERVATION_TABLE_RA ) + "," + \
@@ -588,6 +589,34 @@ def logout(self, verbose=False):
588589 """
589590 return self .__jwsttap .logout (verbose )
590591
592+ def get_product_list (self , plane_id , product_type = None ):
593+ """Get the list of products of a given JWST plane.
594+
595+ Parameters
596+ ----------
597+ plane_id : str, mandatory
598+ Plane ID of the products.
599+ product_type : str, optional, default None
600+ List only products of the given type. If None, all products are \
601+ listed. Possible values: 'thumbnail', 'preview', 'auxiliary', \
602+ 'science'.
603+
604+ Returns
605+ -------
606+ The list of products (astropy.table).
607+ """
608+ if plane_id is None :
609+ raise ValueError ("Missing required argument: 'plane_id'" )
610+
611+ prodtype_condition = self .__get_producttype_condition (product_type )
612+ query = "SELECT * " + \
613+ "FROM " + str (self .JWST_ARTIFACT_TABLE ) + \
614+ " WHERE planeid='" + plane_id + "' " + \
615+ prodtype_condition + \
616+ "ORDER BY producttype ASC"
617+ job = self .__jwsttap .launch_job (query = query )
618+ return job .get_results ()
619+
591620 def get_product (self , artifact_id = None ):
592621 """Get a JWST product given its Artifact ID.
593622
@@ -614,7 +643,7 @@ def get_product(self, artifact_id=None):
614643 raise ValueError ('Product ' + artifact_id + ' not available' )
615644 return file
616645
617- def __getQuantityInput (self , value , msg ):
646+ def __get_quantity_input (self , value , msg ):
618647 if value is None :
619648 raise ValueError ("Missing required argument: '" + str (msg )+ "'" )
620649 if not (isinstance (value , str ) or isinstance (value , units .Quantity )):
@@ -626,7 +655,7 @@ def __getQuantityInput(self, value, msg):
626655 else :
627656 return value
628657
629- def __getCoordInput (self , value , msg ):
658+ def __get_coord_input (self , value , msg ):
630659 if not (isinstance (value , str ) or isinstance (value , commons .CoordClasses )):
631660 raise ValueError (
632661 str (msg ) + " must be either a string or astropy.coordinates" )
@@ -636,26 +665,42 @@ def __getCoordInput(self, value, msg):
636665 else :
637666 return value
638667
639- def __getCalLevelCondition (self , cal_level ):
640- cal_level_condition = ""
668+ def __get_callevel_condition (self , cal_level ):
669+ condition = ""
641670 if (cal_level is not None ):
642671 if (isinstance (cal_level , str ) and cal_level is 'Top' ):
643- cal_level_condition = " AND max_cal_level=calibrationlevel "
672+ condition = " AND max_cal_level=calibrationlevel "
644673 elif (isinstance (cal_level , int )):
645- cal_level_condition = " AND max_cal_level =" + \
674+ condition = " AND calibrationlevel =" + \
646675 str (cal_level )+ " "
647676 else :
648677 raise ValueError ("cal_level must be either 'Top' or \
649678 an integer. " )
650- return cal_level_condition
679+ return condition
651680
652- def __getPublicCondition (self , only_public ):
653- public_condition = ""
681+ def __get_public_condition (self , only_public ):
682+ condition = ""
654683 if (not isinstance (only_public , bool )):
655684 raise ValueError ("only_public must be boolean" )
656685 elif (only_public is True ):
657- public_condition = " AND public='true' "
658- return public_condition
686+ condition = " AND public='true' "
687+ return condition
688+
689+ def __get_producttype_condition (self , product_type = None ):
690+ condition = ""
691+ if (product_type is not None ):
692+ if (not isinstance (product_type , str )):
693+ raise ValueError ("product_type must be string" )
694+ elif (product_type is not 'thumbnail' and
695+ product_type is not 'preview' and
696+ product_type is not 'auxiliary' and
697+ product_type is not 'science' ):
698+ raise ValueError ("product_type must be one of: " + \
699+ "'thumbnail', 'preview', 'auxiliary', " + \
700+ "'science'" )
701+ else :
702+ condition = " AND producttype='" + product_type + "' "
703+ return condition
659704
660705
661706Jwst = JwstClass ()
0 commit comments