@@ -40,12 +40,13 @@ class JwstClass(object):
4040
4141 def __init__ (self , tap_plus_handler = None , data_handler = None ):
4242 if tap_plus_handler is None :
43- self .__jwsttap = TapPlus (url = "http://jwstdummytap.com" )
43+
44+ self .__jwsttap = TapPlus (url = "http://jwstdummytap.com" , data_context = 'data' )
4445 else :
4546 self .__jwsttap = tap_plus_handler
4647
4748 if data_handler is None :
48- self .__jwstdata = JwstDataHandler ( base_url = "http://jwstdummydata.com" ) ;
49+ self .__jwstdata = self . __jwsttap ;
4950 else :
5051 self .__jwstdata = data_handler ;
5152
@@ -617,7 +618,7 @@ def get_product_list(self, plane_id, product_type=None):
617618 job = self .__jwsttap .launch_job (query = query )
618619 return job .get_results ()
619620
620- def get_product (self , artifact_id = None ):
621+ def get_product (self , artifact_id = None , file_name = None ):
621622 """Get a JWST product given its Artifact ID.
622623
623624 Parameters
@@ -630,19 +631,41 @@ def get_product(self, artifact_id=None):
630631 local_path : str
631632 Returns the local path that the file was download to.
632633 """
633-
634- if artifact_id is None :
635- raise ValueError ("Missing required argument: 'artifact_id'" )
636-
637- url = self .__jwstdata .base_url + "RETRIEVAL_TYPE=PRODUCT&DATA_RETRIEVAL_ORIGIN=ASTROQUERY" + \
638- "&ARTIFACTID=" + artifact_id
639-
634+
635+ params_dict = {}
636+ params_dict ['RETRIEVAL_TYPE' ] = 'PRODUCT'
637+ params_dict ['DATA_RETRIEVAL_ORIGIN' ] = 'ASTROQUERY'
638+
639+ if artifact_id is None and file_name is None :
640+ raise ValueError ("Missing required argument: 'artifact_id' or file_name" )
641+ else :
642+ if file_name is None :
643+ output_file_name = str (artifact_id )
644+ err_msg = str (artifact_id )
645+ else :
646+ output_file_name = str (file_name )
647+ err_msg = str (file_name )
648+
649+ if artifact_id is not None :
650+ params_dict ['ARTIFACTID' ] = str (artifact_id )
651+ else :
652+ params_dict ['ARTIFACT_URI' ] = 'mast:JWST/product/' + str (file_name )
653+
654+ #url=self.__jwstdata.base_url+"RETRIEVAL_TYPE=PRODUCT&DATA_RETRIEVAL_ORIGIN=ASTROQUERY" +\
655+ # "&ARTIFACTID=" + artifact_id
656+ #
657+ #try:
658+ # file = self.__jwstdata.download_file(url)
659+ #except:
660+ # raise ValueError('Product ' + artifact_id + ' not available')
661+ #return file
640662 try :
641- file = self .__jwstdata . download_file ( url )
663+ self .__jwsttap . load_data ( params_dict = params_dict , output_file = output_file_name )
642664 except :
643- raise ValueError ('Product ' + artifact_id + ' not available' )
644- return file
645-
665+ raise ValueError ('Product ' + err_msg + ' not available' )
666+ print ("Product saved at: %s" % (output_file_name ))
667+ return output_file_name
668+
646669 def __get_quantity_input (self , value , msg ):
647670 if value is None :
648671 raise ValueError ("Missing required argument: '" + str (msg )+ "'" )
0 commit comments