use self._request
"""
Provide astroquery API access to OIR Lab Astro Data Archive (natica).
-This does DB access through web-services. It allows query against ALL
-fields in FITS file headers.
-
-Also possible but not provided here: query through Elasticsearch DSL. ES will
-be much faster but much more limitted in what can be used in query. """
+This does DB access through web-services.
+"""
-# Python library
-# External packages
-import requests
import astropy.table
-# Local packages
-
-# 3. local imports - use relative imports
-# commonly required local imports shown below as example
-# all Query classes should inherit from BaseQuery.
from ..query import BaseQuery
-# has common functions required by most modules
-# #!from ..utils import commons
-# prepend_docstr is a way to copy docstrings between methods
-# #!from ..utils import prepend_docstr_nosections
-# async_to_sync generates the relevant query tools from _async methods
from ..utils import async_to_sync
from ..utils.class_or_instance import class_or_instance
-# import configurable items declared in __init__.py
from . import conf
@@ -49,17 +32,14 @@ class NoaoClass(BaseQuery):
else:
self.url = f'{self.NAT_URL}/api/sia/voimg'
+ super().__init__()
+
@property
def api_version(self):
if self._api_version is None:
- response = requests.get(f'{self.NAT_URL}/api/version')
- # Following gets error:
- # AttributeError: 'NoaoClass' object has
- # no attribute 'cache_location'
- # Don't see documenation saying what that should be.
- # #!response = self._request('GET',
- # #! f'{self.NAT_URL}/api/version',
- # #! cache=False)
+ response = self._request('GET',
+ f'{self.NAT_URL}/api/version',
+ cache=True)
self._api_version = float(response.content)
return self._api_version
@@ -79,8 +59,7 @@ class NoaoClass(BaseQuery):
ra, dec = coordinate.to_string('decimal').split()
size = radius
url = f'{self.url}?POS={ra},{dec}&SIZE={size}&format=json'
- response = requests.get(url)
- # #!response = self._request('GET', url)
+ response = self._request('GET', url, cache=True)
return astropy.table.Table(data=response.json())
def _args_to_payload(self, *args):
