Skip to content

Commit e59ddd1

Browse files
committed
merge
2 parents ba0ab9a + 4ea05c8 commit e59ddd1

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

astroquery/nrao/core.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
from ..query import BaseQuery, QueryWithLogin, BaseVOQuery
3434
from . import conf, auth_urls, tap_urls
3535
from astroquery.exceptions import CorruptDataWarning
36-
from .tapsql import (_gen_pos_sql, _gen_str_sql, _gen_numeric_sql,
37-
_gen_band_list_sql, _gen_datetime_sql, _gen_pol_sql, _gen_pub_sql,
38-
_gen_science_sql, _gen_spec_res_sql, ALMA_DATE_FORMAT)
36+
from .tapsql import (_gen_pos_sql)
3937

4038
__all__ = {'NraoClass',}
4139

@@ -196,6 +194,29 @@ def query_tap(self, query, maxrec=None):
196194
def _get_dataarchive_url(self):
197195
return tap_urls[0]
198196

197+
def query_object_async(self, object_name, *, payload=None, **kwargs):
198+
"""
199+
Query the archive for a source name.
200+
201+
Parameters
202+
----------
203+
object_name : str
204+
The object name. Will be resolved by astropy.coord.SkyCoord
205+
public : bool
206+
True to return only public datasets, False to return private only,
207+
None to return both
208+
science : bool
209+
True to return only science datasets, False to return only
210+
calibration, None to return both
211+
payload : dict
212+
Dictionary of additional keywords. See `help`.
213+
"""
214+
if payload is not None:
215+
payload['source_name_resolver'] = object_name
216+
else:
217+
payload = {'source_name_resolver': object_name}
218+
return self.query_async(payload=payload, **kwargs)
219+
199220
def query_region_async(self, coordinate, radius, *,
200221
get_query_payload=False,
201222
payload=None, **kwargs):
@@ -260,9 +281,9 @@ def query_async(self, payload, *, get_query_payload=False,
260281
payload[arg] = '{} {}'.format(payload[arg], value)
261282
else:
262283
payload[arg] = value
263-
284+
print(payload)
264285
query = _gen_sql(payload)
265-
286+
print(query)
266287
if get_query_payload:
267288
# Return the TAP query payload that goes out to the server rather
268289
# than the unprocessed payload dict from the python side
@@ -275,25 +296,7 @@ def query_async(self, payload, *, get_query_payload=False,
275296
else:
276297
# Should not happen
277298
raise RuntimeError('BUG: Unexpected result None')
278-
if legacy_columns:
279-
legacy_result = Table()
280-
# add 'Observation date' column
281-
282-
for col_name in _OBSCORE_TO_NRAORESULT:
283-
if col_name in result.columns:
284-
if col_name == 't_min':
285-
legacy_result['Observation date'] = \
286-
[Time(_['t_min'], format='mjd').strftime(
287-
NRAO_DATE_FORMAT) for _ in result]
288-
else:
289-
legacy_result[_OBSCORE_TO_NRAORESULT[col_name]] = \
290-
result[col_name]
291-
else:
292-
log.error("Invalid column mapping in OBSCORE_TO_NRAORESULT: "
293-
"{}:{}. Please "
294-
"report this as an Issue."
295-
.format(col_name, _OBSCORE_TO_NRAORESULT[col_name]))
296-
return legacy_result
299+
297300
return result
298301

299302

0 commit comments

Comments
 (0)