Skip to content

Commit 4a6a9b5

Browse files
Raul Gutierrezbsipocz
authored andcommitted
Fix doc.
1 parent e1547d0 commit 4a6a9b5

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

astroquery/jwst/core.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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)+"'")

astroquery/jwst/data_access.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class JwstDataHandler(object):
2424
def __init__(self, base_url=None):
2525
if base_url is None:
2626
self.base_url = "http://jwstdummydata.com"
27-
2827
else:
2928
self.base_url = base_url
3029

docs/jwst/jwst.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,5 +604,5 @@ To perform a logout
604604
Reference/API
605605
=============
606606

607-
.. automodapi:: astroquery.gaia
607+
.. automodapi:: astroquery.jwst
608608
:no-inheritance-diagram:

0 commit comments

Comments
 (0)