Skip to content

Commit b7e6f70

Browse files
committed
cache and get query payload keywords and fix up catalog storage
1 parent d60842b commit b7e6f70

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

astroquery/lcogt/core.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ class LcogtClass(BaseQuery):
9191
LCOGT_URL = conf.server
9292
TIMEOUT = conf.timeout
9393
ROW_LIMIT = conf.row_limit
94-
catalogs = ['lco_img', 'lco_cat']
9594

96-
def query_object_async(self, objstr, catalog=None):
95+
@property
96+
def catalogs(self):
97+
""" immutable catalog listing """
98+
return {'lco_cat' : 'Photometry archive from LCOGT',
99+
'lco_img' : 'Image metadata archive from LCOGT'}
100+
101+
def query_object_async(self, objstr, catalog=None, cache=True,
102+
get_query_payload=False):
97103
"""
98104
Serves the same function as `query_object`, but
99105
only collects the reponse from the LCOGT IPAC archive and returns.
@@ -119,14 +125,19 @@ def query_object_async(self, objstr, catalog=None):
119125

120126
request_payload = self._args_to_payload(catalog)
121127
request_payload['objstr'] = objstr
128+
if get_query_payload:
129+
return request_payload
130+
122131
response = self._request(method='GET', url=self.LCOGT_URL,
123-
params=request_payload, timeout=self.TIMEOUT)
132+
params=request_payload, timeout=self.TIMEOUT,
133+
cache=cache)
124134
return response
125135

126136

127137
def query_region_async(self, coordinates=None, catalog=None,
128138
spatial='Cone', radius=10*u.arcsec, width=None,
129-
polygon=None, get_query_payload=False):
139+
polygon=None, get_query_payload=False, cache=True,
140+
):
130141
"""
131142
This function serves the same purpose as
132143
:meth:`~astroquery.irsa.LcogtClass.query_region`, but returns the raw
@@ -188,7 +199,8 @@ def query_region_async(self, coordinates=None, catalog=None,
188199
if get_query_payload:
189200
return request_payload
190201
response = self._request(method='GET', url=self.LCOGT_URL,
191-
params=request_payload, timeout=self.TIMEOUT)
202+
params=request_payload, timeout=self.TIMEOUT,
203+
cache=cache)
192204
return response
193205

194206
def _parse_spatial(self, spatial, coordinates, radius=None, width=None,
@@ -350,16 +362,13 @@ def list_catalogs(self):
350362
be used in query functions, and the value is the verbose description
351363
of the catalog.
352364
"""
353-
catalogs = {'lco_cat' : 'Photometry archive from LCOGT',
354-
'lco_img' : 'Image metadata archive from LCOGT'}
355-
return catalogs
365+
return self.catalogs
356366

357367
def print_catalogs(self):
358368
"""
359369
Display a table of the catalogs in the LCOGT Gator tool.
360370
"""
361-
catalogs = self.list_catalogs()
362-
for catname in catalogs:
371+
for catname in self.catalogs:
363372
print("{:30s} {:s}".format(catname, catalogs[catname]))
364373

365374
Lcogt = LcogtClass()

0 commit comments

Comments
 (0)