7
7
import numpy as np
8
8
import astropy .coordinates as coord
9
9
10
+ from astropy import units as u
11
+ from astropy .units import Quantity
10
12
from astroquery .exceptions import NoResultsWarning
11
13
from astroquery .query import BaseQuery
12
- from astroquery .utils import commons , async_to_sync
14
+ from astroquery .utils import commons
13
15
from astroquery .desi import conf
14
16
15
17
__all__ = ['DESILegacySurvey' , 'DESILegacySurveyClass' ]
@@ -25,28 +27,28 @@ def query_region(self, coordinates, radius=None, *, data_release=9):
25
27
----------
26
28
coordinates : `~astropy.coordinates.SkyCoord`
27
29
coordinates around which to query.
28
- radius : `~astropy.coordinates.Angle`, optional
30
+ radius : `~astropy.units.Quantity`, optional
29
31
the radius of the region. If missing, set to default
30
32
value of 0.5 arcmin.
31
33
data_release: int
32
34
the data release of the LegacySurvey to use.
33
35
34
36
Returns
35
37
-------
36
- response : `astropy.table.Table`
38
+ response : `~ astropy.table.Table`
37
39
"""
38
40
39
41
if radius is None :
40
- radius = coord . Angle (0.5 , unit = 'arcmin' )
42
+ radius = Quantity (0.5 , unit = 'arcmin' )
41
43
42
44
tap_service = vo .dal .TAPService (conf .tap_service_url )
43
45
coordinates_transformed = coordinates .transform_to (coord .ICRS )
44
46
45
47
qstr = (f"SELECT all * FROM ls_dr{ data_release } .tractor WHERE "
46
- f"dec>{ coordinates_transformed .dec . deg - radius . deg } and "
47
- f"dec<{ coordinates_transformed .dec . deg + radius . deg } and "
48
- f"ra>{ coordinates_transformed .ra .deg - radius .deg / np .cos (coordinates_transformed .dec .deg * np .pi / 180. )} and "
49
- f"ra<{ coordinates_transformed .ra .deg + radius .deg / np .cos (coordinates_transformed .dec .deg * np .pi / 180 )} " )
48
+ f"dec>{ ( coordinates_transformed .dec - radius ). to ( u . deg ). value } and "
49
+ f"dec<{ ( coordinates_transformed .dec + radius ). to ( u . deg ). value } and "
50
+ f"ra>{ coordinates_transformed .ra .to ( u . deg ). value - radius .to ( u . deg ). value / np .cos (coordinates_transformed .dec .to ( u . deg ). value * np .pi / 180. )} and "
51
+ f"ra<{ coordinates_transformed .ra .to ( u . deg ). value + radius .to ( u . deg ). value / np .cos (coordinates_transformed .dec .to ( u . deg ). value * np .pi / 180 )} " )
50
52
51
53
tap_result = tap_service .run_sync (qstr )
52
54
tap_result = tap_result .to_table ()
@@ -56,24 +58,31 @@ def query_region(self, coordinates, radius=None, *, data_release=9):
56
58
57
59
return filtered_table
58
60
59
- def get_images (self , position , pixels , radius , * , data_release = 9 , show_progress = True , image_band = 'g' ):
61
+ def get_images (self , position , pixels , radius = None , * , data_release = 9 , show_progress = True , image_band = 'g' ):
60
62
"""
61
63
Downloads the images for a certain region of interest.
62
64
63
65
Parameters
64
66
-------
65
- position: `astropy.coordinates`.
67
+ position: `~ astropy.coordinates`.
66
68
coordinates around which we define our region of interest.
67
- radius: `astropy.units.Quantity`.
68
- the radius of the cone search .
69
- data_release: int
69
+ radius: `~ astropy.units.Quantity`, optional
70
+ the radius of our region of interest .
71
+ data_release: int, optional
70
72
the data release of the LegacySurvey to use.
73
+ show_progress: bool, optional
74
+ Whether to display a progress bar if the file is downloaded
75
+ from a remote server. Default is True.
76
+ image_band: str, optional
71
77
72
78
Returns
73
79
-------
74
- list: A list of `astropy.io.fits.HDUList` objects.
80
+ list: A list of `~ astropy.io.fits.HDUList` objects.
75
81
"""
76
82
83
+ if radius is None :
84
+ radius = Quantity (0.5 , u .arcmin )
85
+
77
86
position_transformed = position .transform_to (coord .ICRS )
78
87
79
88
image_size_arcsec = radius .arcsec
@@ -91,9 +100,9 @@ def get_images(self, position, pixels, radius, *, data_release=9, show_progress=
91
100
92
101
try :
93
102
fits_file = file_container .get_fits ()
94
- except (requests .exceptions .HTTPError , urllib .error .HTTPError ) as e :
103
+ except (requests .exceptions .HTTPError , urllib .error .HTTPError ) as exp :
95
104
fits_file = None
96
- warnings .warn (f"{ str (e )} - Problem retrieving the file at the url: { image_url } " , NoResultsWarning )
105
+ warnings .warn (f"{ str (exp )} - Problem retrieving the file at the url: { image_url } " , NoResultsWarning )
97
106
98
107
return [fits_file ]
99
108
0 commit comments