diff --git a/CHANGES.rst b/CHANGES.rst index d2fc3fb30d..1a46bd7fdb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -341,6 +341,12 @@ esa.xmm_newton - Use astroquery downloader tool to get progressbar, caching, and prevent memory leaks. [#2087] +observations +^^^^^^^^^^^^ + +- Renamed and deprecated Observations and ObservationsClass in MAST + and GEMINI modules. [#1885] + gaia ^^^^ diff --git a/astroquery/gemini/__init__.py b/astroquery/gemini/__init__.py index 0f70f67069..e3fbc6da69 100644 --- a/astroquery/gemini/__init__.py +++ b/astroquery/gemini/__init__.py @@ -18,6 +18,6 @@ class Conf(_config.ConfigNamespace): conf = Conf() -from .core import ObservationsClass, Observations +from .core import GeminiObservationsClass, GeminiObservations -__all__ = ['Observations', 'ObservationsClass', 'conf'] +__all__ = ['GeminiObservations', 'GeminiObservationsClass', 'conf'] diff --git a/astroquery/gemini/core.py b/astroquery/gemini/core.py index c7c92ee0e0..6ff59b3825 100644 --- a/astroquery/gemini/core.py +++ b/astroquery/gemini/core.py @@ -11,6 +11,7 @@ from astroquery import log from astropy import units from astropy.table import Table, MaskedColumn +from astropy.utils import deprecated from astroquery.gemini.urlhelper import URLHelper import numpy as np @@ -21,7 +22,7 @@ from ..exceptions import AuthenticationWarning -__all__ = ['Observations', 'ObservationsClass'] # specifies what to import +__all__ = ['GeminiObservations', 'GeminiObservationsClass'] # specifies what to import __valid_instruments__ = [ @@ -97,7 +98,7 @@ ] -class ObservationsClass(QueryWithLogin): +class GeminiObservationsClass(QueryWithLogin): server = conf.server url_helper = URLHelper(server) @@ -526,4 +527,11 @@ def _gemini_json_to_table(json): "release", "dec"] + +@deprecated(since='v0.4.3', alternative='GeminiObservationsClass') +class ObservationsClass(GeminiObservationsClass): + pass + + +GeminiObservations = GeminiObservationsClass() Observations = ObservationsClass() diff --git a/astroquery/gemini/tests/test_gemini.py b/astroquery/gemini/tests/test_gemini.py index 985970672a..4c5b7b8fe8 100644 --- a/astroquery/gemini/tests/test_gemini.py +++ b/astroquery/gemini/tests/test_gemini.py @@ -66,14 +66,14 @@ def data_path(filename): def test_observations_query_region(patch_get): """ test query against a region of the sky """ - result = gemini.Observations.query_region(coords, radius=0.3 * units.deg) + result = gemini.GeminiObservations.query_region(coords, radius=0.3 * units.deg) assert isinstance(result, Table) assert len(result) > 0 def test_observations_query_criteria(patch_get): """ test query against an instrument/program via criteria """ - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', observation_type='BIAS', utc_date=(date(2019, 10, 1), date(2019, 11, 25))) assert isinstance(result, Table) @@ -82,18 +82,18 @@ def test_observations_query_criteria(patch_get): def test_observations_query_criteria_radius_defaults(patch_get): """ test query against an instrument/program via criteria """ - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', observation_type='BIAS') global saved_request assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2) assert('/sr=' not in saved_request['args'][1]) saved_request = None - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9', observation_type='BIAS', coordinates=coords) assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2) assert('/sr=0.300000d' in saved_request['args'][1]) saved_request = None - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9', observation_type='BIAS', objectname='m101') assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2) assert('/sr=0.300000d' in saved_request['args'][1]) @@ -101,7 +101,7 @@ def test_observations_query_criteria_radius_defaults(patch_get): def test_observations_query_raw(patch_get): """ test querying raw """ - result = gemini.Observations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') + result = gemini.GeminiObservations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') assert isinstance(result, Table) assert len(result) > 0 diff --git a/astroquery/gemini/tests/test_remote.py b/astroquery/gemini/tests/test_remote.py index e5c5c9bd12..3bbb2830f0 100644 --- a/astroquery/gemini/tests/test_remote.py +++ b/astroquery/gemini/tests/test_remote.py @@ -28,20 +28,20 @@ class TestGemini: def test_observations_query_region(self): """ test query against a region of the sky against actual archive """ - result = gemini.Observations.query_region(coords, radius=0.3 * units.deg) + result = gemini.GeminiObservations.query_region(coords, radius=0.3 * units.deg) assert isinstance(result, Table) assert len(result) > 0 def test_observations_query_criteria(self): """ test query against an instrument/program via criteria against actual archive """ - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', observation_type='BIAS') assert isinstance(result, Table) assert len(result) > 0 def test_observations_query_criteria_ascending_sort(self): """ test query against an instrument/program via criteria against actual archive """ - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', observation_type='BIAS', orderby='filename_asc') assert isinstance(result, Table) assert len(result) > 0 @@ -52,7 +52,7 @@ def test_observations_query_criteria_ascending_sort(self): def test_observations_query_criteria_descending_sort(self): """ test query against an instrument/program via criteria against actual archive """ - result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', + result = gemini.GeminiObservations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122', observation_type='BIAS', orderby='filename_desc') assert isinstance(result, Table) assert len(result) > 0 @@ -62,7 +62,7 @@ def test_observations_query_criteria_descending_sort(self): def test_observations_query_raw(self): """ test querying raw against actual archive """ - result = gemini.Observations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') + result = gemini.GeminiObservations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') assert isinstance(result, Table) assert len(result) > 0 @@ -70,7 +70,7 @@ def test_get_file(self): """ test querying raw against actual archive """ tempdir = tempfile.mkdtemp('_gemini_test') filename = '20190105_GN-CAL20190105_obslog.txt' - gemini.Observations.get_file(filename, download_dir=tempdir) + gemini.GeminiObservations.get_file(filename, download_dir=tempdir) filepath = os.path.join(tempdir, filename) assert os.path.isfile(filepath) assert os.stat(filepath).st_size == 7624 diff --git a/astroquery/mast/__init__.py b/astroquery/mast/__init__.py index 0a43e4dbc2..d514c6afcf 100644 --- a/astroquery/mast/__init__.py +++ b/astroquery/mast/__init__.py @@ -31,13 +31,13 @@ class Conf(_config.ConfigNamespace): conf = Conf() from .cutouts import TesscutClass, Tesscut, ZcutClass, Zcut -from .observations import Observations, ObservationsClass, MastClass, Mast +from .observations import MastObservations, MastObservationsClass, MastClass, Mast from .collections import Catalogs, CatalogsClass from .missions import MastMissions, MastMissionsClass from .core import MastQueryWithLogin from . import utils -__all__ = ['Observations', 'ObservationsClass', +__all__ = ['MastObservations', 'MastObservationsClass', 'Catalogs', 'CatalogsClass', 'MastMissions', 'MastMissionsClass', 'Mast', 'MastClass', diff --git a/astroquery/mast/observations.py b/astroquery/mast/observations.py index 7c75a57b41..dd5de29985 100644 --- a/astroquery/mast/observations.py +++ b/astroquery/mast/observations.py @@ -1,7 +1,7 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst """ -MAST Observations -================= +MAST MastObservations +===================== This module contains various methods for querying MAST observations. """ @@ -37,14 +37,14 @@ from . import conf, utils from .core import MastQueryWithLogin -__all__ = ['Observations', 'ObservationsClass', +__all__ = ['MastObservations', 'MastObservationsClass', 'MastClass', 'Mast'] @async_to_sync -class ObservationsClass(MastQueryWithLogin): +class MastObservationsClass(MastQueryWithLogin): """ - MAST Observations query class. + MAST MastObservations query class. Class for querying MAST observational data. """ @@ -173,7 +173,7 @@ def _parse_caom_criteria(self, **criteria): # if radius is just a number we assume degrees radius = coord.Angle(radius, u.deg) - # build the coordinates string needed by ObservationsClass._caom_filtered_position + # build the coordinates string needed by MastObservationsClass._caom_filtered_position position = ', '.join([str(x) for x in (coordinates.ra.deg, coordinates.dec.deg, radius.deg)]) return position, mashup_filters @@ -327,7 +327,7 @@ def query_region_count(self, coordinates, *, radius=0.2*u.deg, pagesize=None, pa response : int """ - # build the coordinates string needed by ObservationsClass._caom_filtered_position + # build the coordinates string needed by MastObservationsClass._caom_filtered_position coordinates = commons.parse_coordinates(coordinates) # if radius is just a number we assume degrees @@ -807,7 +807,7 @@ class MastClass(MastQueryWithLogin): MAST query class. Class that allows direct programatic access to the MAST Portal, - more flexible but less user friendly than `ObservationsClass`. + more flexible but less user friendly than `MastObservationsClass`. """ def _parse_result(self, responses, *, verbose=False): # Used by the async_to_sync decorator functionality @@ -864,5 +864,5 @@ def service_request_async(self, service, params, *, pagesize=None, page=None, ** return self._portal_api_connection.service_request_async(service, params, pagesize, page, **kwargs) -Observations = ObservationsClass() +MastObservations = MastObservationsClass() Mast = MastClass() diff --git a/astroquery/mast/tests/test_mast.py b/astroquery/mast/tests/test_mast.py index e94fcdc5b3..5f8de8f4ff 100644 --- a/astroquery/mast/tests/test_mast.py +++ b/astroquery/mast/tests/test_mast.py @@ -67,8 +67,8 @@ def patch_post(request): mp.setattr(mast.services.ServiceAPI, '_request', service_mockreturn) mp.setattr(mast.auth.MastAuth, 'session_info', session_info_mockreturn) - mp.setattr(mast.Observations, '_download_file', download_mockreturn) - mp.setattr(mast.Observations, 'download_file', download_mockreturn) + mp.setattr(mast.MastObservations, '_download_file', download_mockreturn) + mp.setattr(mast.MastObservations, 'download_file', download_mockreturn) mp.setattr(mast.Catalogs, '_download_file', download_mockreturn) mp.setattr(mast.Tesscut, '_download_file', tesscut_download_mockreturn) mp.setattr(mast.Zcut, '_download_file', zcut_download_mockreturn) @@ -269,7 +269,7 @@ def test_missions_query_criteria_async_with_missing_results(patch_post): def test_list_missions(patch_post): - missions = mast.Observations.list_missions() + missions = mast.MastObservations.list_missions() assert isinstance(missions, list) for m in ['HST', 'HLA', 'GALEX', 'Kepler']: assert m in missions @@ -322,7 +322,7 @@ def test_session_info(patch_post): ########################### -# ObservationsClass tests # +# MastObservationsClass tests # ########################### @@ -331,120 +331,120 @@ def test_session_info(patch_post): # query functions def test_observations_query_region_async(patch_post): - responses = mast.Observations.query_region_async(regionCoords, radius=0.2) + responses = mast.MastObservations.query_region_async(regionCoords, radius=0.2) assert isinstance(responses, list) def test_observations_query_region(patch_post): - result = mast.Observations.query_region(regionCoords, radius=0.2 * u.deg) + result = mast.MastObservations.query_region(regionCoords, radius=0.2 * u.deg) assert isinstance(result, Table) def test_observations_query_object_async(patch_post): - responses = mast.Observations.query_object_async("M103", radius="0.2 deg") + responses = mast.MastObservations.query_object_async("M103", radius="0.2 deg") assert isinstance(responses, list) def test_observations_query_object(patch_post): - result = mast.Observations.query_object("M103", radius=".02 deg") + result = mast.MastObservations.query_object("M103", radius=".02 deg") assert isinstance(result, Table) def test_query_observations_criteria_async(patch_post): # without position - responses = mast.Observations.query_criteria_async(dataproduct_type=["image"], + responses = mast.MastObservations.query_criteria_async(dataproduct_type=["image"], proposal_pi="Ost*", s_dec=[43.5, 45.5]) assert isinstance(responses, list) # with position - responses = mast.Observations.query_criteria_async(filters=["NUV", "FUV"], + responses = mast.MastObservations.query_criteria_async(filters=["NUV", "FUV"], objectname="M101") assert isinstance(responses, list) def test_observations_query_criteria(patch_post): # without position - result = mast.Observations.query_criteria(dataproduct_type=["image"], + result = mast.MastObservations.query_criteria(dataproduct_type=["image"], proposal_pi="Ost*", s_dec=[43.5, 45.5]) assert isinstance(result, Table) # with position - result = mast.Observations.query_criteria(filters=["NUV", "FUV"], + result = mast.MastObservations.query_criteria(filters=["NUV", "FUV"], objectname="M101") assert isinstance(result, Table) with pytest.raises(InvalidQueryError) as invalid_query: - mast.Observations.query_criteria(objectname="M101") + mast.MastObservations.query_criteria(objectname="M101") assert "least one non-positional criterion" in str(invalid_query.value) with pytest.raises(InvalidQueryError) as invalid_query: - mast.Observations.query_criteria(objectname="M101", coordinates=regionCoords, intentType="science") + mast.MastObservations.query_criteria(objectname="M101", coordinates=regionCoords, intentType="science") assert "one of objectname and coordinates" in str(invalid_query.value) # count functions def test_observations_query_region_count(patch_post): - result = mast.Observations.query_region_count(regionCoords, radius="0.2 deg") + result = mast.MastObservations.query_region_count(regionCoords, radius="0.2 deg") assert result == 599 def test_observations_query_object_count(patch_post): - result = mast.Observations.query_object_count("M8", radius=0.2*u.deg) + result = mast.MastObservations.query_object_count("M8", radius=0.2*u.deg) assert result == 599 def test_observations_query_criteria_count(patch_post): - result = mast.Observations.query_criteria_count(dataproduct_type=["image"], + result = mast.MastObservations.query_criteria_count(dataproduct_type=["image"], proposal_pi="Ost*", s_dec=[43.5, 45.5]) assert result == 599 - result = mast.Observations.query_criteria_count(dataproduct_type=["image"], + result = mast.MastObservations.query_criteria_count(dataproduct_type=["image"], proposal_pi="Ost*", s_dec=[43.5, 45.5], coordinates=regionCoords) assert result == 599 with pytest.raises(InvalidQueryError) as invalid_query: - mast.Observations.query_criteria_count(coordinates=regionCoords, objectname="M101", proposal_pi="Ost*") + mast.MastObservations.query_criteria_count(coordinates=regionCoords, objectname="M101", proposal_pi="Ost*") assert "one of objectname and coordinates" in str(invalid_query.value) # product functions def test_observations_get_product_list_async(patch_post): - responses = mast.Observations.get_product_list_async('2003738726') + responses = mast.MastObservations.get_product_list_async('2003738726') assert isinstance(responses, list) - responses = mast.Observations.get_product_list_async('2003738726,3000007760') + responses = mast.MastObservations.get_product_list_async('2003738726,3000007760') assert isinstance(responses, list) - observations = mast.Observations.query_object("M8", radius=".02 deg") - responses = mast.Observations.get_product_list_async(observations[0]) + observations = mast.MastObservations.query_object("M8", radius=".02 deg") + responses = mast.MastObservations.get_product_list_async(observations[0]) assert isinstance(responses, list) - responses = mast.Observations.get_product_list_async(observations[0:4]) + responses = mast.MastObservations.get_product_list_async(observations[0:4]) assert isinstance(responses, list) def test_observations_get_product_list(patch_post): - result = mast.Observations.get_product_list('2003738726') + result = mast.MastObservations.get_product_list('2003738726') assert isinstance(result, Table) - result = mast.Observations.get_product_list('2003738726,3000007760') + result = mast.MastObservations.get_product_list('2003738726,3000007760') assert isinstance(result, Table) - observations = mast.Observations.query_object("M8", radius=".02 deg") - result = mast.Observations.get_product_list(observations[0]) + observations = mast.MastObservations.query_object("M8", radius=".02 deg") + result = mast.MastObservations.get_product_list(observations[0]) assert isinstance(result, Table) - result = mast.Observations.get_product_list(observations[0:4]) + result = mast.MastObservations.get_product_list(observations[0:4]) assert isinstance(result, Table) def test_observations_filter_products(patch_post): - products = mast.Observations.get_product_list('2003738726') - result = mast.Observations.filter_products(products, + products = mast.MastObservations.get_product_list('2003738726') + result = mast.MastObservations.filter_products(products, productType=["SCIENCE"], mrp_only=False) assert isinstance(result, Table) @@ -453,14 +453,14 @@ def test_observations_filter_products(patch_post): def test_observations_download_products(patch_post, tmpdir): # actually download the products - result = mast.Observations.download_products('2003738726', + result = mast.MastObservations.download_products('2003738726', download_dir=str(tmpdir), productType=["SCIENCE"], mrp_only=False) assert isinstance(result, Table) # just get the curl script - result = mast.Observations.download_products('2003738726', + result = mast.MastObservations.download_products('2003738726', download_dir=str(tmpdir), curl_flag=True, productType=["SCIENCE"], @@ -468,18 +468,18 @@ def test_observations_download_products(patch_post, tmpdir): assert isinstance(result, Table) # passing row product - products = mast.Observations.get_product_list('2003738726') - result1 = mast.Observations.download_products(products[0]) + products = mast.MastObservations.get_product_list('2003738726') + result1 = mast.MastObservations.download_products(products[0]) assert isinstance(result1, Table) def test_observations_download_file(patch_post, tmpdir): # pull a single data product - products = mast.Observations.get_product_list('2003738726') + products = mast.MastObservations.get_product_list('2003738726') uri = products['dataURI'][0] # download it - result = mast.Observations.download_file(uri) + result = mast.MastObservations.download_file(uri) assert result == ('COMPLETE', None, None) diff --git a/astroquery/mast/tests/test_mast_remote.py b/astroquery/mast/tests/test_mast_remote.py index 71578c3585..1bf08b0af7 100644 --- a/astroquery/mast/tests/test_mast_remote.py +++ b/astroquery/mast/tests/test_mast_remote.py @@ -73,26 +73,26 @@ def test_mast_session_info(self): assert sessionInfo['ezid'] == 'anonymous' assert sessionInfo['token'] is None - ########################### - # ObservationsClass tests # - ########################### + ############################### + # MastObservationsClass tests # + ############################### def test_observations_list_missions(self): - missions = mast.Observations.list_missions() + missions = mast.MastObservations.list_missions() assert isinstance(missions, list) for m in ['HST', 'HLA', 'GALEX', 'Kepler']: assert m in missions def test_get_metadata(self): # observations - meta_table = mast.Observations.get_metadata("observations") + meta_table = mast.MastObservations.get_metadata("observations") assert isinstance(meta_table, Table) assert "Column Name" in meta_table.colnames assert "Mission" in meta_table["Column Label"] assert "obsid" in meta_table["Column Name"] # products - meta_table = mast.Observations.get_metadata("products") + meta_table = mast.MastObservations.get_metadata("products") assert isinstance(meta_table, Table) assert "Column Name" in meta_table.colnames assert "Observation ID" in meta_table["Column Label"] @@ -101,57 +101,57 @@ def test_get_metadata(self): # query functions def test_observations_query_region_async(self): - responses = mast.Observations.query_region_async("322.49324 12.16683", radius="0.005 deg") + responses = mast.MastObservations.query_region_async("322.49324 12.16683", radius="0.005 deg") assert isinstance(responses, list) def test_observations_query_region(self): # clear columns config - mast.Observations._column_configs = dict() + mast.MastObservations._column_configs = dict() - result = mast.Observations.query_region("322.49324 12.16683", radius="0.005 deg") + result = mast.MastObservations.query_region("322.49324 12.16683", radius="0.005 deg") assert isinstance(result, Table) assert len(result) > 500 assert result[np.where(result['obs_id'] == '00031992001')] - result = mast.Observations.query_region("322.49324 12.16683", radius="0.005 deg", + result = mast.MastObservations.query_region("322.49324 12.16683", radius="0.005 deg", pagesize=1, page=1) assert isinstance(result, Table) assert len(result) == 1 def test_observations_query_object_async(self): - responses = mast.Observations.query_object_async("M8", radius=".02 deg") + responses = mast.MastObservations.query_object_async("M8", radius=".02 deg") assert isinstance(responses, list) def test_observations_query_object(self): # clear columns config - mast.Observations._column_configs = dict() + mast.MastObservations._column_configs = dict() - result = mast.Observations.query_object("M8", radius=".04 deg") + result = mast.MastObservations.query_object("M8", radius=".04 deg") assert isinstance(result, Table) assert len(result) > 150 assert result[np.where(result['obs_id'] == 'ktwo200071160-c92_lc')] def test_observations_query_criteria_async(self): # without position - responses = mast.Observations.query_criteria_async(dataproduct_type=["image"], + responses = mast.MastObservations.query_criteria_async(dataproduct_type=["image"], proposal_pi="*Ost*", s_dec=[43.5, 45.5]) assert isinstance(responses, list) # with position - responses = mast.Observations.query_criteria_async(filters=["NUV", "FUV"], + responses = mast.MastObservations.query_criteria_async(filters=["NUV", "FUV"], objectname="M101") assert isinstance(responses, list) def test_observations_query_criteria(self): # clear columns config - mast.Observations._column_configs = dict() + mast.MastObservations._column_configs = dict() # without position - result = mast.Observations.query_criteria(instrument_name="*WFPC2*", + result = mast.MastObservations.query_criteria(instrument_name="*WFPC2*", proposal_id=8169, t_min=[49335, 51499]) @@ -160,7 +160,7 @@ def test_observations_query_criteria(self): assert ((result['obs_collection'] == 'HST') | (result['obs_collection'] == 'HLA')).all() # with position - result = mast.Observations.query_criteria(filters=["NUV", "FUV"], + result = mast.MastObservations.query_criteria(filters=["NUV", "FUV"], obs_collection="GALEX", objectname="M101") assert isinstance(result, Table) @@ -168,28 +168,28 @@ def test_observations_query_criteria(self): assert (result['obs_collection'] == 'GALEX').all() assert sum(result['filters'] == 'NUV') == 6 - result = mast.Observations.query_criteria(objectname="M101", + result = mast.MastObservations.query_criteria(objectname="M101", dataproduct_type="IMAGE", intentType="calibration") assert (result["intentType"] == "calibration").all() # count functions def test_observations_query_region_count(self): - maxRes = mast.Observations.query_criteria_count() - result = mast.Observations.query_region_count("322.49324 12.16683", radius="0.4 deg") + maxRes = mast.MastObservations.query_criteria_count() + result = mast.MastObservations.query_region_count("322.49324 12.16683", radius="0.4 deg") assert isinstance(result, (np.int64, int)) assert result > 1800 assert result < maxRes def test_observations_query_object_count(self): - maxRes = mast.Observations.query_criteria_count() - result = mast.Observations.query_object_count("M8", radius=".02 deg") + maxRes = mast.MastObservations.query_criteria_count() + result = mast.MastObservations.query_object_count("M8", radius=".02 deg") assert isinstance(result, (np.int64, int)) assert result > 150 assert result < maxRes def test_observations_query_criteria_count(self): - maxRes = mast.Observations.query_criteria_count() - result = mast.Observations.query_criteria_count(proposal_pi="*Osten*", + maxRes = mast.MastObservations.query_criteria_count() + result = mast.MastObservations.query_criteria_count(proposal_pi="*Osten*", proposal_id=8880) assert isinstance(result, (np.int64, int)) assert result == 7 @@ -198,40 +198,40 @@ def test_observations_query_criteria_count(self): # product functions def test_observations_get_product_list_async(self): - test_obs = mast.Observations.query_criteria(filters=["NUV", "FUV"], objectname="M101") + test_obs = mast.MastObservations.query_criteria(filters=["NUV", "FUV"], objectname="M101") - responses = mast.Observations.get_product_list_async(test_obs[0]["obsid"]) + responses = mast.MastObservations.get_product_list_async(test_obs[0]["obsid"]) assert isinstance(responses, list) - responses = mast.Observations.get_product_list_async(test_obs[2:3]) + responses = mast.MastObservations.get_product_list_async(test_obs[2:3]) assert isinstance(responses, list) - observations = mast.Observations.query_object("M8", radius=".02 deg") - responses = mast.Observations.get_product_list_async(observations[0]) + observations = mast.MastObservations.query_object("M8", radius=".02 deg") + responses = mast.MastObservations.get_product_list_async(observations[0]) assert isinstance(responses, list) - responses = mast.Observations.get_product_list_async(observations[0:4]) + responses = mast.MastObservations.get_product_list_async(observations[0:4]) assert isinstance(responses, list) def test_observations_get_product_list(self): # clear columns config - mast.Observations._column_configs = dict() + mast.MastObservations._column_configs = dict() - observations = mast.Observations.query_object("M8", radius=".04 deg") + observations = mast.MastObservations.query_object("M8", radius=".04 deg") test_obs_id = str(observations[0]['obsid']) mult_obs_ids = str(observations[0]['obsid']) + ',' + str(observations[1]['obsid']) - result1 = mast.Observations.get_product_list(test_obs_id) - result2 = mast.Observations.get_product_list(observations[0]) + result1 = mast.MastObservations.get_product_list(test_obs_id) + result2 = mast.MastObservations.get_product_list(observations[0]) filenames1 = list(result1['productFilename']) filenames2 = list(result2['productFilename']) assert isinstance(result1, Table) assert len(result1) == len(result2) assert set(filenames1) == set(filenames2) - result1 = mast.Observations.get_product_list(mult_obs_ids) - result2 = mast.Observations.get_product_list(observations[0:2]) + result1 = mast.MastObservations.get_product_list(mult_obs_ids) + result2 = mast.MastObservations.get_product_list(observations[0:2]) filenames1 = result1['productFilename'] filenames2 = result2['productFilename'] assert isinstance(result1, Table) @@ -239,22 +239,22 @@ def test_observations_get_product_list(self): assert set(filenames1) == set(filenames2) obsLoc = np.where(observations["obs_id"] == 'ktwo200071160-c92_lc') - result = mast.Observations.get_product_list(observations[obsLoc]) + result = mast.MastObservations.get_product_list(observations[obsLoc]) assert isinstance(result, Table) assert len(result) == 1 obsLocs = np.where((observations['target_name'] == 'NGC6523') & (observations['obs_collection'] == "IUE")) - result = mast.Observations.get_product_list(observations[obsLocs]) + result = mast.MastObservations.get_product_list(observations[obsLocs]) obs_collection = np.unique(list(result['obs_collection'])) assert isinstance(result, Table) assert len(obs_collection) == 1 assert obs_collection[0] == 'IUE' def test_observations_filter_products(self): - observations = mast.Observations.query_object("M8", radius=".04 deg") + observations = mast.MastObservations.query_object("M8", radius=".04 deg") obsLoc = np.where(observations["obs_id"] == 'ktwo200071160-c92_lc') - products = mast.Observations.get_product_list(observations[obsLoc]) - result = mast.Observations.filter_products(products, + products = mast.MastObservations.get_product_list(observations[obsLoc]) + result = mast.MastObservations.filter_products(products, productType=["SCIENCE"], mrp_only=False) assert isinstance(result, Table) @@ -264,7 +264,7 @@ def test_observations_filter_products(self): @pytest.mark.skip("Tests should not download this much data. Skipping until revised.") def test_observations_download_products(self, tmpdir): test_obs_id = OBSID - result = mast.Observations.download_products(test_obs_id, + result = mast.MastObservations.download_products(test_obs_id, download_dir=str(tmpdir), productType=["SCIENCE"], mrp_only=False) @@ -274,7 +274,7 @@ def test_observations_download_products(self, tmpdir): assert os.path.isfile(row['Local Path']) # just get the curl script - result = mast.Observations.download_products(test_obs[0]["obsid"], + result = mast.MastObservations.download_products(test_obs[0]["obsid"], download_dir=str(tmpdir), curl_flag=True, productType=["SCIENCE"], @@ -283,8 +283,8 @@ def test_observations_download_products(self, tmpdir): assert os.path.isfile(result['Local Path'][0]) # check for row input - result1 = mast.Observations.get_product_list(test_obs[0]["obsid"]) - result2 = mast.Observations.download_products(result1[0]) + result1 = mast.MastObservations.get_product_list(test_obs[0]["obsid"]) + result2 = mast.MastObservations.download_products(result1[0]) assert isinstance(result2, Table) assert os.path.isfile(result2['Local Path'][0]) assert len(result2) == 1 @@ -292,38 +292,38 @@ def test_observations_download_products(self, tmpdir): def test_observations_download_file(self, tmpdir): # enabling cloud connection - mast.Observations.enable_cloud_dataset(provider='AWS') + mast.MastObservations.enable_cloud_dataset(provider='AWS') # get observations from GALEX instrument with query_criteria - observations = mast.Observations.query_criteria(objectname='M1', + observations = mast.MastObservations.query_criteria(objectname='M1', radius=0.2, instrument_name='GALEX') assert len(observations) > 0, 'No results found for GALEX query.' # pull data products from a single observation - products = mast.Observations.get_product_list(observations['obsid'][0]) + products = mast.MastObservations.get_product_list(observations['obsid'][0]) # pull the URI of a single product uri = products['dataURI'][0] # download it - result = mast.Observations.download_file(uri, cloud_only=True) + result = mast.MastObservations.download_file(uri, cloud_only=True) assert result == ('COMPLETE', None, None) def test_get_cloud_uri(self): test_obs_id = '25568122' # get a product list - product = mast.Observations.get_product_list(test_obs_id)[24] + product = mast.MastObservations.get_product_list(test_obs_id)[24] assert len(product) > 0, f'No product found for OBSID {test_obs_id}. Unable to move forward with getting URIs from the cloud.' # enable access to public AWS S3 bucket - mast.Observations.enable_cloud_dataset() + mast.MastObservations.enable_cloud_dataset() # get uri - uri = mast.Observations.get_cloud_uri(product) + uri = mast.MastObservations.get_cloud_uri(product) assert len(uri) > 0, f'Product for OBSID {test_obs_id} was not found in the cloud.' @@ -331,15 +331,15 @@ def test_get_cloud_uris(self): test_obs_id = '25568122' # get a product list - products = mast.Observations.get_product_list(test_obs_id)[24:] + products = mast.MastObservations.get_product_list(test_obs_id)[24:] assert len(products) > 0, f'No products found for OBSID {test_obs_id}. Unable to move forward with getting URIs from the cloud.' # enable access to public AWS S3 bucket - mast.Observations.enable_cloud_dataset() + mast.MastObservations.enable_cloud_dataset() # get uris - uris = mast.Observations.get_cloud_uris(products) + uris = mast.MastObservations.get_cloud_uris(products) assert len(uris) > 0, f'Products for OBSID {test_obs_id} were not found in the cloud.' diff --git a/docs/gemini/gemini.rst b/docs/gemini/gemini.rst index b1616b42f2..bca96a6694 100644 --- a/docs/gemini/gemini.rst +++ b/docs/gemini/gemini.rst @@ -19,10 +19,10 @@ Positional queries can be based on a sky position. Radius is an optional parame .. doctest-remote-data:: - >>> from astroquery.gemini import Observations + >>> from astroquery.gemini import GeminiObservations >>> from astropy import coordinates, units >>> coord = coordinates.SkyCoord(210.80242917, 54.34875, unit="deg") - >>> data = Observations.query_region(coordinates=coord, radius=0.3*units.deg) + >>> data = GeminiObservations.query_region(coordinates=coord, radius=0.3*units.deg) >>> print(data[0:5]) exposure_time detector_roi_setting ... release dec ------------- -------------------- ... ---------- --------------- @@ -40,8 +40,8 @@ You may also do a query by the name of the object you are interested in. .. doctest-remote-data:: - >>> from astroquery.gemini import Observations - >>> data = Observations.query_object(objectname='m101') + >>> from astroquery.gemini import GeminiObservations + >>> data = GeminiObservations.query_object(objectname='m101') >>> print(data[0:5]) exposure_time detector_roi_setting ... release dec ------------- -------------------- ... ---------- --------------- @@ -55,21 +55,21 @@ You may also do a query by the name of the object you are interested in. Observation Criteria Queries ---------------------------- -Additional search terms are available as optional arguments to the `~astroquery.gemini.ObservationsClass.query_criteria` +Additional search terms are available as optional arguments to the `~astroquery.gemini.GeminiObservationsClass.query_criteria` call. These all have default values of None, in which case they will not be considered during the search. The one exception is ``radius``, which will be set to 0.3 degrees by default if either ``coordinates`` or ``objectname`` are specified. Some examples of available search fields are the instrument used, such as GMOS-N, the observation_type, such as BIAS, and the program ID. For a complete list of available search fields, see -`~astroquery.gemini.ObservationsClass.query_criteria` +`~astroquery.gemini.GeminiObservationsClass.query_criteria` .. doctest-remote-data:: - >>> from astroquery.gemini import Observations - >>> data = Observations.query_criteria(instrument='GMOS-N', - ... program_id='GN-CAL20191122', - ... observation_type='BIAS') + >>> from astroquery.gemini import GeminiObservations + >>> data = GeminiObservations.query_criteria(instrument='GMOS-N', + ... program_id='GN-CAL20191122', + ... observation_type='BIAS') >>> print(data[0:5]) exposure_time detector_roi_setting detector_welldepth_setting ... release dec ------------- -------------------- -------------------------- ... ---------- --- @@ -88,13 +88,13 @@ The ``orderby`` parameter can be used to pass the desired sort order. .. doctest-remote-data:: - >>> from astroquery.gemini import Observations - >>> data = Observations.query_criteria('centralspectrum', - ... instrument='GMOS-N', - ... program_id='GN-CAL20191122', - ... observation_type='BIAS', - ... filter='r', - ... orderby='data_label_desc') + >>> from astroquery.gemini import GeminiObservations + >>> data = GeminiObservations.query_criteria('centralspectrum', + ... instrument='GMOS-N', + ... program_id='GN-CAL20191122', + ... observation_type='BIAS', + ... filter='r', + ... orderby='data_label_desc') Observation Raw Queries @@ -117,8 +117,8 @@ the *NotFail* or *notengineering* terms respectively. .. doctest-remote-data:: - >>> from astroquery.gemini import Observations - >>> data = Observations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') + >>> from astroquery.gemini import GeminiObservations + >>> data = GeminiObservations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122') >>> print(data[0:5]) exposure_time detector_roi_setting detector_welldepth_setting ... release dec ------------- -------------------- -------------------------- ... ---------- --- @@ -133,13 +133,13 @@ Authenticated Sessions ---------------------- The Gemini module allows for authenticated sessions using your GOA account. This is the same account you login -with on the GOA homepage at `<https://archive.gemini.edu/>`__. The `astroquery.gemini.ObservationsClass.login` +with on the GOA homepage at `<https://archive.gemini.edu/>`__. The `astroquery.gemini.GeminiObservationsClass.login` method returns `True` if successful. .. doctest-skip:: - >>> from astroquery.gemini import Observations - >>> Observations.login(username, password) + >>> from astroquery.gemini import GeminiObservations + >>> GeminiObservations.login(username, password) >>> # do something with your elevated access @@ -152,8 +152,8 @@ proprietary data you may be permissioned for. .. doctest-remote-data:: - >>> from astroquery.gemini import Observations - >>> Observations.get_file("GS2020AQ319-10.fits", download_dir="/tmp") # doctest: +IGNORE_OUTPUT + >>> from astroquery.gemini import GeminiObservations + >>> GeminiObservations.get_file("GS2020AQ319-10.fits", download_dir="/tmp") # doctest: +IGNORE_OUTPUT Reference/API diff --git a/docs/mast/mast.rst b/docs/mast/mast.rst index b9821cfba9..2130775150 100644 --- a/docs/mast/mast.rst +++ b/docs/mast/mast.rst @@ -20,9 +20,9 @@ The observation fields are documented .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> obs_table = Observations.query_region("322.49324 12.16683") + >>> obs_table = MastObservations.query_region("322.49324 12.16683") >>> print(obs_table[:10]) # doctest: +IGNORE_OUTPUT intentType obs_collection provenance_name ... srcDen obsid distance ---------- -------------- --------------- ... ------ ----------- -------- @@ -41,9 +41,9 @@ Radius is an optional parameter and the default is 0.2 degrees. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> obs_table = Observations.query_object("M8",radius=".02 deg") + >>> obs_table = MastObservations.query_object("M8",radius=".02 deg") >>> print(obs_table[:10]) # doctest: +IGNORE_OUTPUT intentType obs_collection provenance_name ... srcDen obsid distance ---------- -------------- --------------- ... ------ ----------- -------- @@ -63,10 +63,10 @@ Observation Criteria Queries ---------------------------- To search for observations based on parameters other than position or target name, -use `~astroquery.mast.ObservationsClass.query_criteria`. +use `~astroquery.mast.MastObservationsClass.query_criteria`. Criteria are supplied as keyword arguments, where valid criteria are "coordinates", -"objectname", "radius" (as in `~astroquery.mast.ObservationsClass.query_region` and -`~astroquery.mast.ObservationsClass.query_object`), and all observation fields listed +"objectname", "radius" (as in `~astroquery.mast.MastObservationsClass.query_region` and +`~astroquery.mast.MastObservationsClass.query_object`), and all observation fields listed `here <https://mast.stsci.edu/api/v0/_c_a_o_mfields.html>`__. **Note:** The obstype keyword has been replaced by intentType, with valid values @@ -82,11 +82,11 @@ RA and Dec must be given in decimal degrees, and datetimes in MJD. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> obs_table = Observations.query_criteria(dataproduct_type=["image"], - ... proposal_pi="Osten*", - ... s_dec=[43.5,45.5]) + >>> obs_table = MastObservations.query_criteria(dataproduct_type=["image"], + ... proposal_pi="Osten*", + ... s_dec=[43.5,45.5]) >>> print(obs_table) # doctest: +IGNORE_OUTPUT dataproduct_type calib_level obs_collection ... intentType obsid objID ---------------- ----------- -------------- ... ---------- ---------- ---------- @@ -94,7 +94,7 @@ RA and Dec must be given in decimal degrees, and datetimes in MJD. image 1 HST ... science 2003520266 2023816134 image 1 HST ... science 2003520268 2025756935 ... - >>> obs_table = Observations.query_criteria(filters=["*UV","Kepler"],objectname="M101") + >>> obs_table = MastObservations.query_criteria(filters=["*UV","Kepler"],objectname="M101") >>> print(obs_table) # doctest: +IGNORE_OUTPUT dataproduct_type calib_level obs_collection ... objID1 distance ---------------- ----------- -------------- ... ---------- ------------------ @@ -118,44 +118,44 @@ Getting Observation Counts To get the number of observations and not the observations themselves, query_counts functions are available. This can be useful if trying to decide whether the available memory is sufficient for the number of observations. + .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> print(Observations.query_region_count("322.49324 12.16683")) # doctest: +IGNORE_OUTPUT + >>> print(MastObservations.query_region_count("322.49324 12.16683")) # doctest: +IGNORE_OUTPUT 2364 ... - >>> print(Observations.query_object_count("M8",radius=".02 deg")) # doctest: +IGNORE_OUTPUT + >>> print(MastObservations.query_object_count("M8",radius=".02 deg")) # doctest: +IGNORE_OUTPUT 469 ... - >>> print(Observations.query_criteria_count(dataproduct_type="image", - ... filters=["NUV","FUV"], - ... t_max=[52264.4586,54452.8914])) # doctest: +IGNORE_OUTPUT + >>> print(MastObservations.query_criteria_count(dataproduct_type="image", + ... filters=["NUV","FUV"], + ... t_max=[52264.4586,54452.8914])) # doctest: +IGNORE_OUTPUT 59033 - Metadata Queries ---------------- To list data missions archived by MAST and avaiable through `astroquery.mast`, -use the `~astroquery.mast.ObservationsClass.list_missions` function. +use the `~astroquery.mast.MastObservationsClass.list_missions` function. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> print(Observations.list_missions()) + >>> print(MastObservations.list_missions()) ['BEFS', 'EUVE', 'FUSE', 'GALEX', 'HLA', 'HLSP', 'HST', 'HUT', 'IUE', 'JWST', 'K2', 'K2FFI', 'Kepler', 'KeplerFFI', 'OPO', 'PS1', 'SPITZER_SHA', 'SWIFT', 'TESS', 'TUES', 'WUPPE'] To get a table of metadata associated with observation or product lists use the -`~astroquery.mast.ObservationsClass.get_metadata` function. +`~astroquery.mast.MastObservationsClass.get_metadata` function. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> meta_table = Observations.get_metadata("observations") + >>> meta_table = MastObservations.get_metadata("observations") >>> print(meta_table[:5]) # doctest: +IGNORE_OUTPUT Column Name Column Label ... Examples/Valid Values --------------- ---------------- ... ---------------------------------- @@ -165,7 +165,7 @@ To get a table of metadata associated with observation or product lists use the instrument_name Instrument ... E.g. WFPC2/WFC, UVOT, STIS/CCD project Project ... E.g. HST, HLA, EUVE, hlsp_legus ... - >>> meta_table = Observations.get_metadata("products") + >>> meta_table = MastObservations.get_metadata("products") >>> print(meta_table[:3]) # doctest: +IGNORE_OUTPUT Column Name Column Label ... Examples/Valid Values -------------- ---------------- ... ------------------------------------- @@ -182,16 +182,16 @@ Getting Product Lists Each observation returned from a MAST query can have one or more associated data products. Given one or more observations or observation ids ("obsid") -`~astroquery.mast.ObservationsClass.get_product_list` will return +`~astroquery.mast.MastObservationsClass.get_product_list` will return a `~astropy.table.Table` containing the associated data products. The product fields are documented `here <https://mast.stsci.edu/api/v0/_productsfields.html>`__. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> obs_table = Observations.query_object("M8",radius=".02 deg") - >>> data_products_by_obs = Observations.get_product_list(obs_table[0:2]) + >>> obs_table = MastObservations.query_object("M8",radius=".02 deg") + >>> data_products_by_obs = MastObservations.get_product_list(obs_table[0:2]) >>> print(data_products_by_obs) # doctest: +IGNORE_OUTPUT obsID obs_collection dataproduct_type ... size parent_obsid ----------- -------------- ---------------- ... ------- ------------ @@ -220,7 +220,7 @@ The product fields are documented `here <https://mast.stsci.edu/api/v0/_products Length = 1153 rows ... >>> obsids = obs_table[0:2]['obsid'] - >>> data_products_by_id = Observations.get_product_list(obsids) + >>> data_products_by_id = MastObservations.get_product_list(obsids) >>> print(data_products_by_id) # doctest: +IGNORE_OUTPUT obsID obs_collection dataproduct_type ... size parent_obsid ----------- -------------- ---------------- ... ------- ------------ @@ -265,11 +265,11 @@ are either "RAW" or "UNCAL." .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> Observations.download_products('25119363', - ... productType=["SCIENCE", "PREVIEW"], - ... extension="fits") # doctest: +IGNORE_OUTPUT + >>> MastObservations.download_products('25119363', + ... productType=["SCIENCE", "PREVIEW"], + ... extension="fits") # doctest: +IGNORE_OUTPUT <Table length=3> Local Path Status Message URL str47 str8 object object @@ -278,18 +278,19 @@ are either "RAW" or "UNCAL." ./mastDownload/HST/fa2f0101m/fa2f0101m_a2f.fits COMPLETE None None ./mastDownload/HST/fa2f0101m/fa2f0101m_a3f.fits COMPLETE None None + Product filtering can also be applied directly to a table of products without proceeding to the download step. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> data_products = Observations.get_product_list('25588063') + >>> data_products = MastObservations.get_product_list('25588063') >>> print(len(data_products)) 27 - >>> products = Observations.filter_products(data_products, - ... productType=["SCIENCE", "PREVIEW"], - ... extension="fits") + >>> products = MastObservations.filter_products(data_products, + ... productType=["SCIENCE", "PREVIEW"], + ... extension="fits") >>> print(len(products)) 8 @@ -297,17 +298,17 @@ Product filtering can also be applied directly to a table of products without pr Downloading Data Products ------------------------- -Products can be downloaded by using `~astroquery.mast.ObservationsClass.download_products`, +Products can be downloaded by using `~astroquery.mast.MastObservationsClass.download_products`, with a `~astropy.table.Table` of data products, or a list (or single) obsid as the argument. .. doctest-skip:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> single_obs = Observations.query_criteria(obs_collection="IUE", obs_id="lwp13058") - >>> data_products = Observations.get_product_list(single_obs) + >>> single_obs = MastObservations.query_criteria(obs_collection="IUE", obs_id="lwp13058") + >>> data_products = MastObservations.get_product_list(single_obs) ... - >>> manifest = Observations.download_products(data_products, productType="SCIENCE") + >>> manifest = MastObservations.download_products(data_products, productType="SCIENCE") Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=http://archive.stsci.edu/pub/iue/data/lwp/13000/lwp13058.mxlo.gz to ./mastDownload/IUE/lwp13058/lwp13058.mxlo.gz ... [Done] Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=http://archive.stsci.edu/pub/vospectra/iue2/lwp13058mxlo_vo.fits to ./mastDownload/IUE/lwp13058/lwp13058mxlo_vo.fits ... [Done] ... @@ -322,33 +323,33 @@ curl script that can be used to download the files at a later time. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> single_obs = Observations.query_criteria(obs_collection="IUE", obs_id="lwp13058") - >>> data_products = Observations.get_product_list(single_obs) + >>> single_obs = MastObservations.query_criteria(obs_collection="IUE", obs_id="lwp13058") + >>> data_products = MastObservations.get_product_list(single_obs) ... - >>> table = Observations.download_products(data_products, productType="SCIENCE", curl_flag=True) # doctest: +IGNORE_OUTPUT + >>> table = MastObservations.download_products(data_products, productType="SCIENCE", curl_flag=True) # doctest: +IGNORE_OUTPUT Downloading URL https://mast.stsci.edu/portal/Download/stage/anonymous/public/514cfaa9-fdc1-4799-b043-4488b811db4f/mastDownload_20170629162916.sh to ./mastDownload_20170629162916.sh ... [Done] Downloading a Single File ------------------------- -You can download a single data product file using the `~astroquery.mast.ObservationsClass.download_file` +You can download a single data product file using the `~astroquery.mast.MastObservationsClass.download_file` method, and passing in a MAST Data URI. The default is to download the file the current working directory, which can be changed with the ``local_path`` keyword argument. .. doctest-remote-data:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> single_obs = Observations.query_criteria(obs_collection="IUE",obs_id="lwp13058") - >>> data_products = Observations.get_product_list(single_obs) + >>> single_obs = MastObservations.query_criteria(obs_collection="IUE",obs_id="lwp13058") + >>> data_products = MastObservations.get_product_list(single_obs) ... >>> product = data_products[0]["dataURI"] >>> print(product) mast:IUE/url/pub/iue/data/lwp/13000/lwp13058.elbll.gz - >>> result = Observations.download_file(product) # doctest: +IGNORE_OUTPUT + >>> result = MastObservations.download_file(product) # doctest: +IGNORE_OUTPUT Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:IUE/url/pub/iue/data/lwp/13000/lwp13058.elbll.gz to ./lwp13058.elbll.gz ... [Done] ... >>> print(result) @@ -362,18 +363,18 @@ in `public S3 buckets <https://registry.opendata.aws/collab/stsci/>`__. Using AWS resources to process public data no longer requires an AWS account for all AWS regions. To enable cloud data access for the Hubble, Kepler, TESS, and GALEX missions, follow the steps below: -You can enable cloud data access via the `~astroquery.mast.ObservationsClass.enable_cloud_dataset` +You can enable cloud data access via the `~astroquery.mast.MastObservationsClass.enable_cloud_dataset` function, which sets AWS to become the preferred source for data access as opposed to on-premise -MAST until it is disabled with `~astroquery.mast.ObservationsClass.disable_cloud_dataset`. +MAST until it is disabled with `~astroquery.mast.MastObservationsClass.disable_cloud_dataset`. To directly access a list of cloud URIs for a given dataset, use the -`~astroquery.mast.ObservationsClass.get_cloud_uris` +`~astroquery.mast.MastObservationsClass.get_cloud_uris` function (Python will prompt you to enable cloud access if you haven't already). When cloud access is enabled, the standard download function -`~astroquery.mast.ObservationsClass.download_products` preferentially pulls files from AWS when they +`~astroquery.mast.MastObservationsClass.download_products` preferentially pulls files from AWS when they are available. When set to `True`, the ``cloud_only`` parameter in -`~astroquery.mast.ObservationsClass.download_products` skips all data products not available in the cloud. +`~astroquery.mast.MastObservationsClass.download_products` skips all data products not available in the cloud. Getting a list of S3 URIs: @@ -381,26 +382,26 @@ Getting a list of S3 URIs: .. doctest-skip:: >>> import os - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> # Simply call the `enable_cloud_dataset` method from `Observations`. The default provider is `AWS`, but we will write it in manually for this example: - >>> Observations.enable_cloud_dataset(provider='AWS') + >>> # Simply call the `enable_cloud_dataset` method from `MastObservations`. The default provider is `AWS`, but we will write it in manually for this example: + >>> MastObservations.enable_cloud_dataset(provider='AWS') INFO: Using the S3 STScI public dataset [astroquery.mast.core] ... >>> # Getting the cloud URIs - >>> obs_table = Observations.query_criteria(obs_collection='HST', + >>> obs_table = MastObservations.query_criteria(obs_collection='HST', ... filters='F606W', ... instrument_name='ACS/WFC', ... proposal_id=['12062'], ... dataRights='PUBLIC') - >>> products = Observations.get_product_list(obs_table) - >>> filtered = Observations.filter_products(products, + >>> products = MastObservations.get_product_list(obs_table) + >>> filtered = MastObservations.filter_products(products, ... productSubGroupDescription='DRZ') - >>> s3_uris = Observations.get_cloud_uris(filtered) + >>> s3_uris = MastObservations.get_cloud_uris(filtered) >>> print(s3_uris) ['s3://stpubdata/hst/public/jbev/jbeveo010/jbeveo010_drz.fits', 's3://stpubdata/hst/public/jbev/jbeveo010/jbeveo010_drz.fits', 's3://stpubdata/hst/public/jbev/jbevet010/jbevet010_drz.fits', 's3://stpubdata/hst/public/jbev/jbevet010/jbevet010_drz.fits'] ... - >>> Observations.disable_cloud_dataset() + >>> MastObservations.disable_cloud_dataset() Downloading data products from S3: @@ -408,17 +409,17 @@ Downloading data products from S3: .. doctest-skip:: >>> import os - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> # Simply call the `enable_cloud_dataset` method from `Observations`. The default provider is `AWS`, but we will write it in manually for this example: - >>> Observations.enable_cloud_dataset(provider='AWS') + >>> # Simply call the `enable_cloud_dataset` method from `MastObservations`. The default provider is `AWS`, but we will write it in manually for this example: + >>> MastObservations.enable_cloud_dataset(provider='AWS') INFO: Using the S3 STScI public dataset [astroquery.mast.core] ... >>> # Downloading from the cloud - >>> obs_table = Observations.query_criteria(obs_collection=['Kepler'], + >>> obs_table = MastObservations.query_criteria(obs_collection=['Kepler'], ... objectname="Kepler 12b", radius=0) - >>> products = Observations.get_product_list(obs_table[0]) - >>> manifest = Observations.download_products(products[:10], cloud_only=True) + >>> products = MastObservations.get_product_list(obs_table[0]) + >>> manifest = MastObservations.download_products(products[:10], cloud_only=True) manifestDownloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:KEPLER/url/missions/kepler/dv_files/0118/011804465/kplr011804465-01-20160209194854_dvs.pdf to ./mastDownload/Kepler/kplr011804465_lc_Q111111110111011101/kplr011804465-01-20160209194854_dvs.pdf ... |==========================================| 1.5M/1.5M (100.00%) 0s Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:KEPLER/url/missions/kepler/dv_files/0118/011804465/kplr011804465-20160128150956_dvt.fits to ./mastDownload/Kepler/kplr011804465_lc_Q111111110111011101/kplr011804465-20160128150956_dvt.fits ... @@ -454,7 +455,7 @@ Downloading data products from S3: COMPLETE COMPLETE ... - >>> Observations.disable_cloud_dataset() + >>> MastObservations.disable_cloud_dataset() @@ -1134,24 +1135,24 @@ To view tokens accessible through your account, visit https://auth.mast.stsci.ed .. doctest-skip:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> Observations.login(token="12348r9w0sa2392ff94as841") + >>> MastObservations.login(token="12348r9w0sa2392ff94as841") INFO: MAST API token accepted, welcome User Name [astroquery.mast.core] ... - >>> sessioninfo = Observations.session_info() + >>> sessioninfo = MastObservations.session_info() eppn: user_name@stsci.edu ezid: uname ... .. doctest-skip:: - >>> from astroquery.mast import Observations + >>> from astroquery.mast import MastObservations ... - >>> my_session = Observations(token="12348r9w0sa2392ff94as841") + >>> my_session = MastObservations(token="12348r9w0sa2392ff94as841") INFO: MAST API token accepted, welcome User Name [astroquery.mast.core] ... - >>> sessioninfo = Observations.session_info() + >>> sessioninfo = MastObservations.session_info() eppn: user_name@stsci.edu ezid: uname ... @@ -1265,4 +1266,3 @@ Reference/API >>> from astroquery.utils import cleanup_saved_downloads >>> cleanup_saved_downloads(['mastDownload*', 'tess-*', 'lwp13058*', '3dhst*']) -