Skip to content

Commit 7cc8d8b

Browse files
committed
TST: addressing more review comments
1 parent 4a13dd6 commit 7cc8d8b

File tree

4 files changed

+44
-51
lines changed

4 files changed

+44
-51
lines changed

astroquery/desi/core.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
class DESILegacySurveyClass(BaseQuery):
2020

21-
def query_region(self, coordinates, radius=0.5*u.arcmin, *, data_release=9):
21+
def query_region(self, coordinates, *, width=0.5*u.arcmin, data_release=9):
2222
"""
2323
Queries a region around the specified coordinates.
2424
2525
Parameters
2626
----------
2727
coordinates : `~astropy.coordinates.SkyCoord`
2828
coordinates around which to query.
29-
radius : `~astropy.units.Quantity`, optional
30-
the radius of the region. If missing, set to default
29+
width : `~astropy.units.Quantity`, optional
30+
the width of the region. If missing, set to default
3131
value of 0.5 arcmin.
32-
data_release: int
32+
data_release : int
3333
the data release of the LegacySurvey to use.
3434
3535
Returns
@@ -41,9 +41,9 @@ def query_region(self, coordinates, radius=0.5*u.arcmin, *, data_release=9):
4141
coordinates_transformed = coordinates.transform_to(coord.ICRS)
4242

4343
qstr = (f"SELECT all * FROM ls_dr{data_release}.tractor WHERE "
44-
f"dec<{(coordinates_transformed.dec + radius).to_value(u.deg)} and "
45-
f"ra>{coordinates_transformed.ra.to_value(u.deg) - radius.to_value(u.deg) / np.cos(coordinates_transformed.dec)} and "
46-
f"ra<{coordinates_transformed.ra.to_value(u.deg) + radius.to_value(u.deg) / np.cos(coordinates_transformed.dec)}")
44+
f"dec<{(coordinates_transformed.dec + width).to_value(u.deg)} and "
45+
f"ra>{coordinates_transformed.ra.to_value(u.deg) - width.to_value(u.deg) / np.cos(coordinates_transformed.dec)} and "
46+
f"ra<{coordinates_transformed.ra.to_value(u.deg) + width.to_value(u.deg) / np.cos(coordinates_transformed.dec)}")
4747

4848
tap_result = tap_service.run_sync(qstr)
4949
tap_result = tap_result.to_table()
@@ -53,32 +53,32 @@ def query_region(self, coordinates, radius=0.5*u.arcmin, *, data_release=9):
5353

5454
return filtered_table
5555

56-
def get_images(self, position, pixels=None, radius=0.5*u.arcmin, *, data_release=9, show_progress=True, image_band='g'):
56+
def get_images(self, position, *, pixels=None, width=0.5*u.arcmin, data_release=9, show_progress=True, image_band='g'):
5757
"""
5858
Downloads the images for a certain region of interest.
5959
6060
Parameters
61-
-------
62-
position: `astropy.coordinates`.
61+
----------
62+
position : `astropy.coordinates`.
6363
coordinates around which we define our region of interest.
64-
radius: `~astropy.units.Quantity`, optional
65-
the radius of our region of interest.
66-
data_release: int, optional
64+
width : `~astropy.units.Quantity`, optional
65+
the width of our region of interest.
66+
data_release : int, optional
6767
the data release of the LegacySurvey to use.
68-
show_progress: bool, optional
68+
show_progress : bool, optional
6969
Whether to display a progress bar if the file is downloaded
7070
from a remote server. Default is True.
71-
image_band: str, optional
71+
image_band : str, optional
7272
Default to 'g'
7373
7474
Returns
7575
-------
76-
list: A list of `~astropy.io.fits.HDUList` objects.
76+
list : A list of `~astropy.io.fits.HDUList` objects.
7777
"""
7878

7979
position_transformed = position.transform_to(coord.ICRS)
8080

81-
image_size_arcsec = radius.arcsec
81+
image_size_arcsec = width.arcsec
8282
pixsize = 2 * image_size_arcsec / pixels
8383

8484
image_url = (f"{conf.legacysurvey_service_url}?"

astroquery/desi/tests/test_desi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222

2323
coords = coord.SkyCoord('11h04m27s +38d12m32s', frame='icrs')
24-
radius = coord.Angle(0.5, unit='arcmin')
24+
width = coord.Angle(0.5, unit='arcmin')
2525
pixels = 60
2626
data_release = 9
2727
emispheres_list = ['north', 'south']
@@ -101,15 +101,15 @@ def image_tester(images, filetype):
101101
assert np.array_equal(images[0][0].data, data[0].data)
102102

103103

104-
def test_coords_query_region(patch_tap, coords=coords, radius=radius):
105-
result = desi.DESILegacySurvey.query_region(coords, radius)
104+
def test_coords_query_region(patch_tap):
105+
result = desi.DESILegacySurvey.query_region(coords, width=width)
106106
data = Table.read(data_path(DATA_FILES['dummy_tap_table']),
107107
format='ascii.csv', comment='#')
108108
data['objid'] = data['objid'].astype(np.int64)
109109
compare_result_data(result, data)
110110

111111

112112
def test_coords_get_images(patch_get_readable_fileobj, dr=data_release):
113-
images_list = desi.DESILegacySurvey.get_images(coords, data_release=dr, radius=radius, pixels=pixels)
113+
images_list = desi.DESILegacySurvey.get_images(coords, data_release=dr, width=width, pixels=pixels)
114114

115115
image_tester(images_list, 'dummy_hdu_list_fits')

astroquery/desi/tests/test_desi_remote.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,26 @@ def test_query_region(self):
1616
dec = 38.209
1717
coordinates = SkyCoord(ra, dec, unit='degree')
1818

19-
radius = Angle(5, unit='arcmin')
19+
width = Angle(15, unit='arcsec')
2020

21-
query1 = DESILegacySurvey.query_region(coordinates, radius=radius, data_release=9)
21+
query1 = DESILegacySurvey.query_region(coordinates, width=width, data_release=9)
2222

2323
assert isinstance(query1, Table)
2424

25-
@pytest.mark.parametrize("valid_inputs", [True, False])
26-
def test_get_images(self, valid_inputs):
25+
@pytest.mark.parametrize(('ra', 'dec', 'width', 'pixels'),
26+
((166.1125, 38.209, 0.5, 60),))
27+
def test_get_images(self, ra, dec, width, pixels):
28+
pos = SkyCoord(ra, dec, unit='degree')
29+
width = Angle(width, unit='arcmin')
2730

28-
if valid_inputs:
29-
ra = 166.1125
30-
dec = 38.209
31-
radius_input = 0.5
32-
pixels = 60
33-
else:
34-
ra = 86.633212
35-
dec = 22.01446
36-
radius_input = 3
37-
pixels = 1296000
31+
query1 = DESILegacySurvey.get_images(pos, pixels=pixels, width=width, data_release=9)
32+
assert isinstance(query1, list)
33+
assert isinstance(query1[0], HDUList)
3834

39-
pos = SkyCoord(ra, dec, unit='degree')
40-
radius = Angle(radius_input, unit='arcmin')
41-
42-
if valid_inputs:
43-
query1 = DESILegacySurvey.get_images(pos, pixels, radius, data_release=9)
44-
assert isinstance(query1, list)
45-
assert isinstance(query1[0], HDUList)
46-
else:
47-
with pytest.raises(NoResultsWarning):
48-
DESILegacySurvey.get_images(pos, pixels, radius, data_release=9)
35+
def test_noresults_warning(self):
36+
# Using position with no coverage
37+
pos = SkyCoord(86.633212, 22.01446, unit='degree')
38+
width = Angle(3, unit='arcmin')
39+
40+
with pytest.warns(NoResultsWarning):
41+
DESILegacySurvey.get_images(pos, width=width, pixels=100)

docs/desi/desi.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Query a region
1616

1717
This example shows how to query a certain region with DesiLegacySurvey.
1818
We'll use a set of coordinates that define the region of interest,
19-
and search within a 5 arcmin radius.
19+
and search within a 15 arcsec box.
2020

2121
.. doctest-remote-data::
2222

@@ -25,9 +25,9 @@ and search within a 5 arcmin radius.
2525
>>> ra = Angle('11h04m27s', unit='hourangle').degree
2626
>>> dec = Angle('+38d12m32s', unit='hourangle').degree
2727
>>> coordinates = SkyCoord(ra, dec, unit='degree')
28-
>>> radius = Angle(5, unit='arcmin')
29-
>>> table_out = DESILegacySurvey.query_region(coordinates, radius, data_release=9)
30-
>>> print(table_out[:5])
28+
>>> width = Angle(15, unit='arcsec')
29+
>>> table_out = DESILegacySurvey.query_region(coordinates, width=width, data_release=9)
30+
>>> print(table_out[:5]) # doctest: +IGNORE_OUTPUT
3131
ls_id dec ra ... type wise_coadd_id
3232
...
3333
---------------- ----------------- ------------------ ... ---- -------------
@@ -56,8 +56,8 @@ we can define our region in the same way used in the example above.
5656
>>> pixels = 60
5757
>>>
5858
>>> pos = SkyCoord(ra, dec, unit='degree')
59-
>>> radius = Angle(radius_input, unit='arcmin')
60-
>>> im = DESILegacySurvey.get_images(pos, pixels, radius, data_release=9)
59+
>>> width = Angle(radius_input, unit='arcmin')
60+
>>> im = DESILegacySurvey.get_images(pos, pixels=pixels, width=width, data_release=9)
6161

6262
All the information we need can be found within the object "im".
6363

0 commit comments

Comments
 (0)