Skip to content

Commit 4fe67df

Browse files
authored
Merge pull request #984 from keflavich/eztean-vista-test
Refactor UKIDSS -> WFAU and add VSA
2 parents 170b598 + 11e0e12 commit 4fe67df

File tree

14 files changed

+1182
-767
lines changed

14 files changed

+1182
-767
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
[#1064, #1077]
88
- New tool ``oac``: Open Astronomy Catalog API to obtain data products on
99
supernovae, TDEs, and kilonovae. [#1053]
10+
- New tool ``wfau`` and ``vsa``: Refactor of the UKIDSS query tool add full
11+
WFAU support. [#984]
1012
- ALMA: Adding support for band and polarization selection. [#1108]
1113
- HEASARC: Add additional functionality and expand query capabilities. [#1047]
1214
- GAIA: Default URL switched to DR2 and made configurable. [#1112]
@@ -18,6 +20,7 @@
1820
- MAST: Added Catalogs class. [#1049]
1921
- MAST: Enable downloading MAST HST data from S3. [#1040]
2022
- SPLATALOGUE: Move to https as old HTTP post requests were broken. [#1076]
23+
- UKIDSS: Update to DR10 as default database. [#984]
2124
- utils.TAP: Add tool to check for phase of background job. [#1073]
2225
- utils.TAP: Added redirect handling to sync jobs. [#1099]
2326
- utils.TAP: Fix jobsIDs assignment. [#1105]

astroquery/ukidss/core.py

Lines changed: 27 additions & 738 deletions
Large diffs are not rendered by default.

astroquery/ukidss/tests/test_ukidss.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ def get_mockreturn(method='GET', url='default_url',
8989
return MockResponse(content=content, url=url, **kwargs)
9090

9191

92-
@pytest.mark.parametrize(('dim', 'expected'),
93-
[(5 * u.arcmin, 5),
94-
(5 * u.degree, 300),
95-
('0d0m30s', 0.5),
96-
]
97-
)
98-
def test_parse_dimension(dim, expected):
99-
out = ukidss.core._parse_dimension(dim)
100-
npt.assert_approx_equal(out, expected, significant=3)
101-
102-
10392
def test_get_images(patch_get, patch_get_readable_fileobj):
10493
image = ukidss.core.Ukidss.get_images(
10594
commons.ICRSCoordGenerator(ra=83.633083, dec=22.0145,
@@ -113,15 +102,17 @@ def test_get_images_async_1():
113102
payload = ukidss.core.Ukidss.get_images_async(
114103
commons.ICRSCoordGenerator(ra=83.633083, dec=22.0145,
115104
unit=(u.deg, u.deg)),
116-
radius=20 * u.arcmin, get_query_payload=True)
105+
radius=20 * u.arcmin, get_query_payload=True,
106+
programme_id='GPS')
117107

118108
assert 'xsize' not in payload
119109
assert 'ysize' not in payload
120110

121111
payload = ukidss.core.Ukidss.get_images_async(
122112
commons.ICRSCoordGenerator(ra=83.633083, dec=22.0145,
123113
unit=(u.deg, u.deg)),
124-
get_query_payload=True)
114+
get_query_payload=True,
115+
programme_id='GPS')
125116
assert payload['xsize'] == payload['ysize']
126117
assert payload['xsize'] == 1
127118

@@ -132,7 +123,8 @@ def test_get_images_async_2(patch_get, patch_get_readable_fileobj):
132123

133124
image_urls = ukidss.core.Ukidss.get_images_async(
134125
commons.ICRSCoordGenerator(ra=83.633083, dec=22.0145,
135-
unit=(u.deg, u.deg)))
126+
unit=(u.deg, u.deg)),
127+
programme_id='GPS')
136128

137129
assert len(image_urls) == 1
138130

@@ -141,7 +133,8 @@ def test_get_image_list(patch_get, patch_get_readable_fileobj):
141133
urls = ukidss.core.Ukidss.get_image_list(
142134
commons.ICRSCoordGenerator(ra=83.633083, dec=22.0145,
143135
unit=(u.deg, u.deg)),
144-
frame_type='all', waveband='all')
136+
frame_type='all', waveband='all',
137+
programme_id='GPS')
145138
print(urls)
146139
assert len(urls) == 1
147140

@@ -156,7 +149,8 @@ def test_query_region(patch_get, patch_get_readable_fileobj):
156149
table = ukidss.core.Ukidss.query_region(
157150
commons.GalacticCoordGenerator(l=10.625, b=-0.38,
158151
unit=(u.deg, u.deg)),
159-
radius=6 * u.arcsec)
152+
radius=6 * u.arcsec,
153+
programme_id='GPS')
160154
assert isinstance(table, Table)
161155
assert len(table) > 0
162156

@@ -165,13 +159,15 @@ def test_query_region_async(patch_get):
165159
response = ukidss.core.Ukidss.query_region_async(
166160
commons.GalacticCoordGenerator(l=10.625, b=-0.38,
167161
unit=(u.deg, u.deg)),
168-
radius=6 * u.arcsec, get_query_payload=True)
162+
radius=6 * u.arcsec, get_query_payload=True,
163+
programme_id='GPS')
169164

170165
assert response['radius'] == 0.1
171166
response = ukidss.core.Ukidss.query_region_async(
172167
commons.GalacticCoordGenerator(l=10.625, b=-0.38,
173168
unit=(u.deg, u.deg)),
174-
radius=6 * u.arcsec)
169+
radius=6 * u.arcsec,
170+
programme_id='GPS')
175171
assert response is not None
176172

177173

astroquery/ukidss/tests/test_ukidss_remote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def test_get_image_list(self):
4141
def test_query_region_async(self):
4242
response = ukidss.core.Ukidss.query_region_async(
4343
SkyCoord(l=10.625, b=-0.38, unit=(u.deg, u.deg), frame='galactic'),
44-
radius=6 * u.arcsec)
44+
radius=6 * u.arcsec, programme_id='GPS')
4545
assert response is not None
4646

4747
def test_query_region(self):
4848
table = ukidss.core.Ukidss.query_region(
4949
SkyCoord(l=10.625, b=-0.38, unit=(u.deg, u.deg), frame='galactic'),
50-
radius=6 * u.arcsec)
50+
radius=6 * u.arcsec, programme_id='GPS')
5151
assert isinstance(table, Table)
5252
assert len(table) > 0

astroquery/vsa/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
"""
3+
VSA Image and Catalog Query Tool
4+
--------------------------------
5+
.. topic:: Revision History
6+
7+
Refactored using common API as a part of Google Summer of Code 2013.
8+
Modified for VSA by @eztean
9+
10+
:Originally contributed by:
11+
12+
Thomas Robitalle ([email protected])
13+
14+
Adam Ginsburg ([email protected])
15+
"""
16+
from astropy import config as _config
17+
18+
19+
class Conf(_config.ConfigNamespace):
20+
"""
21+
Configuration parameters for `astroquery.vsa`.
22+
"""
23+
server = _config.ConfigItem(
24+
['http://horus.roe.ac.uk:8080/vdfs/'],
25+
'Name of the VSA mirror to use')
26+
27+
timeout = _config.ConfigItem(
28+
30,
29+
'Time limit for connecting to VSA server.')
30+
31+
32+
conf = Conf()
33+
34+
from .core import Vsa, VsaClass, clean_catalog
35+
36+
__all__ = ['Vsa', 'VsaClass', 'clean_catalog',
37+
'Conf', 'conf',
38+
]

astroquery/vsa/core.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
from __future__ import print_function
3+
4+
from . import conf
5+
from ..wfau import BaseWFAUClass, clean_catalog
6+
7+
__all__ = ['Vsa', 'VsaClass', 'clean_catalog']
8+
9+
10+
class VsaClass(BaseWFAUClass):
11+
12+
"""
13+
The VsaQuery class. Must instantiate this class in order to make any
14+
queries. Allows registered users to login, but defaults to using the
15+
public Vsa data sets.
16+
"""
17+
BASE_URL = conf.server
18+
LOGIN_URL = BASE_URL + "DBLogin"
19+
IMAGE_URL = BASE_URL + "GetImage"
20+
ARCHIVE_URL = BASE_URL + "ImageList"
21+
REGION_URL = BASE_URL + "WSASQL"
22+
CROSSID_URL = BASE_URL + "CrossID"
23+
TIMEOUT = conf.timeout
24+
IMAGE_FORM = 'VgetImage_form.jsp'
25+
CROSSID_FORM = 'VcrossID_form.jsp'
26+
27+
filters = {'all': 'all', 'Z': 1, 'Y': 2, 'J': 3,
28+
'H': 4, 'Ks': 5, 'NB118': 9, 'NB980': 10}
29+
30+
frame_types = {'tilestack': 'tilestack', 'stack': 'stack',
31+
'normal': 'normal', 'deep_stack': 'deep%stack',
32+
'confidence': 'conf', 'difference': 'diff',
33+
'all': 'all'}
34+
35+
programmes_short = {'VHS': 110,
36+
'VVV': 120,
37+
'VMC': 130,
38+
'VIKING': 140,
39+
'VIDEO': 150,
40+
'UltraVISTA': 160,
41+
'Calibration': 200}
42+
43+
programmes_long = {'VISTA Hemisphere Survey': 110,
44+
'VISTA Variables in the Via Lactea': 120,
45+
'VISTA Magellanic Clouds Survey': 130,
46+
'VISTA Kilo-degree Infrared Galaxy Survey': 140,
47+
'VISTA Deep Extragalactic Observations': 150,
48+
'An ultra-deep survey with VISTA': 160,
49+
'Calibration data': 200}
50+
51+
all_databases = ('VHSDR4', 'VHSDR3', 'VHSDR2', 'VHSDR1', 'VVVDR4',
52+
'VVVDR2', 'VVVDR1', 'VMCDR4', 'VMCDR3', 'VMCDR2',
53+
'VMCDR1', 'VIKINGDR4', 'VIKINGDR3', 'VIKINGDR2',
54+
'VIDEODR5', 'VIDEODR4', 'VIDEODR3', 'VIDEODR2',
55+
'VISTAOPENTIME')
56+
57+
# apparently needed for some queries
58+
archive = 'VSA'
59+
60+
def __init__(self, username=None, password=None, community=None,
61+
database='VVVDR4', programme_id='all'):
62+
super(VsaClass, self).__init__(database=database,
63+
programme_id=programme_id,
64+
username=username,
65+
community=community,
66+
password=password)
67+
68+
self.BASE_URL = 'http://horus.roe.ac.uk:8080/vdfs/'
69+
self.LOGIN_URL = self.BASE_URL + "DBLogin"
70+
self.IMAGE_URL = self.BASE_URL + "GetImage"
71+
self.ARCHIVE_URL = self.BASE_URL + "ImageList"
72+
self.REGION_URL = self.BASE_URL + "WSASQL"
73+
74+
75+
Vsa = VsaClass()

astroquery/vsa/tests/__init__.py

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
from __future__ import print_function
3+
4+
from astropy.tests.helper import remote_data
5+
from astropy.table import Table
6+
from astropy.coordinates import SkyCoord
7+
import astropy.units as u
8+
import requests
9+
import imp
10+
11+
from ... import vsa
12+
13+
imp.reload(requests)
14+
15+
16+
vista = vsa.core.VsaClass()
17+
18+
19+
@remote_data
20+
class TestVista:
21+
22+
def test_get_images(self):
23+
24+
crd = SkyCoord(l=336.489, b=-1.48, unit=(u.deg, u.deg),
25+
frame='galactic')
26+
images = vista.get_images(crd, frame_type='tilestack', image_width=5 *
27+
u.arcmin, waveband='H')
28+
assert images is not None
29+
30+
def test_get_images_async(self):
31+
crd = SkyCoord(l=336.489, b=-1.48, unit=(u.deg, u.deg), frame='galactic')
32+
images = vista.get_images_async(crd, frame_type='tilestack',
33+
image_width=5 * u.arcmin, waveband='H')
34+
assert images is not None
35+
36+
def test_get_image_list(self):
37+
crd = SkyCoord(l=350.488, b=0.949, unit=(u.deg, u.deg), frame='galactic')
38+
urls = vista.get_image_list(crd, frame_type='all', waveband='all')
39+
assert len(urls) > 0
40+
41+
def test_query_region_async(self):
42+
crd = SkyCoord(l=350.488, b=0.949, unit=(u.deg, u.deg), frame='galactic')
43+
response = vista.query_region_async(crd, radius=6 * u.arcsec, programme_id='VVV')
44+
assert response is not None
45+
46+
def test_query_region(self):
47+
crd = SkyCoord(l=350.488, b=0.949, unit=(u.deg, u.deg), frame='galactic')
48+
table = vista.query_region(crd, radius=6 * u.arcsec, programme_id='VVV')
49+
assert isinstance(table, Table)
50+
assert len(table) > 0

astroquery/wfau/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
"""
3+
WFAU Image and Catalog Query Tool
4+
---------------------------------
5+
.. topic:: Revision History
6+
7+
The UKIDSS query tool was refactored using common API as a part of Google
8+
Summer of Code 2013. It was then refactored again to generically apply
9+
to any WFAU archives in late 2017.
10+
11+
:Originally contributed by:
12+
13+
Thomas Robitalle ([email protected])
14+
15+
Adam Ginsburg ([email protected])
16+
"""
17+
from .core import BaseWFAUClass, clean_catalog
18+
19+
__all__ = ['BaseWFAUClass', 'clean_catalog', ]

0 commit comments

Comments
 (0)