Skip to content

Commit 2f18931

Browse files
Oliverbsipocz
authored andcommitted
Make radius defaut smarter, using 0.3 degrees only when coordinates or objectname are passed, and None otherwise
1 parent 82e4d08 commit 2f18931

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

CHANGES.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ mast
4141
- Added ``Observations.download_file`` method to download a single file from MAST given an input
4242
data URI. [#1825]
4343
- Added case for passing a row to ``Observations.download_file` [#1881]
44-
- Removed deprecated ``Observations.get_hst_s3_uris()``, ``Observations.get_hst_s3_uri()``,
45-
``Core.get_token()``, ``Core.enable_s3_hst_dataset()``, ``Core.disable_s3_hst_dataset()`` and
44+
- Removed deprecated ``Observations.get_hst_s3_uris()``, ``Observations.get_hst_s3_uri()``,
45+
``Core.get_token()``, ``Core.enable_s3_hst_dataset()``, ``Core.disable_s3_hst_dataset()`` and
4646
variables obstype and silent [#1884]
4747
- Added Zcut functionality to astroquery [#1911]
4848
- Fixed error causing empty products passed to ``Observations.get_product_list()`` to yeild a
@@ -56,6 +56,7 @@ esa/hubble
5656
- Module added to query eHST TAP based on a set of specific criteria and
5757
asynchronous jobs are now supported. [#1723]
5858

59+
5960
esa/xmm_newton
6061
^^^^^^^^^^^^^^
6162

@@ -75,15 +76,15 @@ Gemini
7576
- get_file() support for downloading files [#1778]
7677
- fix syntax error in query_criteria() [#1823]
7778
- If QA and/or engineering parameters are explicitly passed, remove the add defaults of `notengineering` and/or
78-
`NotFail` [#1996]
79+
- Smarter defaulting of radius to None unless coordinates are specified, in
80+
which case defaults to 0.3 degrees. [#1995]
7981

8082
heasarc
8183
^^^^^^^
8284

8385
- A ``NoResultsWarning`` is now returned when there is no matching rows were
8486
found in query. [#1829]
8587

86-
8788
SVO FPS
8889
^^^^^^^
8990

astroquery/gemini/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def query_object(self, objectname, radius=0.3*units.deg):
182182
return self.query_criteria(objectname=objectname, radius=radius)
183183

184184
@class_or_instance
185-
def query_criteria(self, *rawqueryargs, coordinates=None, radius=0.3*units.deg, pi_name=None, program_id=None, utc_date=None,
185+
def query_criteria(self, *rawqueryargs, coordinates=None, radius=None, pi_name=None, program_id=None, utc_date=None,
186186
instrument=None, observation_class=None, observation_type=None, mode=None,
187187
adaptive_optics=None, program_text=None, objectname=None, raw_reduced=None,
188188
orderby=None, **rawquerykwargs):
@@ -199,7 +199,7 @@ def query_criteria(self, *rawqueryargs, coordinates=None, radius=0.3*units.deg,
199199
The target around which to search. It may be specified as a
200200
string or as the appropriate `~astropy.coordinates` object.
201201
radius : str or `~astropy.units.Quantity` object, optional
202-
Default 0.3 degrees.
202+
Default 0.3 degrees if coordinates are set, else None
203203
The string must be parsable by `~astropy.coordinates.Angle`. The
204204
appropriate `~astropy.units.Quantity` object from
205205
`~astropy.units` may also be used. Defaults to 0.3 deg.
@@ -319,6 +319,9 @@ def query_criteria(self, *rawqueryargs, coordinates=None, radius=0.3*units.deg,
319319
for (k, v) in rawquerykwargs.items():
320320
kwargs[k] = v
321321

322+
# If coordinates is set but we have no radius, set a default
323+
if (coordinates or objectname) and radius is None:
324+
radius = 0.3 * units.deg
322325
# Now consider the canned criteria
323326
if radius is not None:
324327
kwargs["radius"] = radius

astroquery/gemini/tests/test_gemini.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ def patch_get(request):
4040
return mp
4141

4242

43+
# to inspect behavior, updated when the mock get call is made
44+
saved_request = None
45+
46+
4347
def get_mockreturn(url, *args, **kwargs):
4448
""" generate the actual mock textual data from our included datafile with json results """
49+
global saved_request
50+
saved_request = {'url': url, 'args': args, 'kwargs': kwargs}
4551
filename = data_path(DATA_FILES['m101'])
4652
f = open(filename, 'r')
4753
text = f.read()
@@ -76,6 +82,26 @@ def test_observations_query_criteria(patch_get):
7682
assert len(result) > 0
7783

7884

85+
def test_observations_query_criteria_radius_defaults(patch_get):
86+
""" test query against an instrument/program via criteria """
87+
result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-CAL20191122',
88+
observation_type='BIAS')
89+
global saved_request
90+
assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2)
91+
assert('/sr=' not in saved_request['args'][1])
92+
saved_request = None
93+
result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9',
94+
observation_type='BIAS', coordinates=coords)
95+
assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2)
96+
assert('/sr=0.300000d' in saved_request['args'][1])
97+
saved_request = None
98+
result = gemini.Observations.query_criteria(instrument='GMOS-N', program_id='GN-2016A-Q-9',
99+
observation_type='BIAS', objectname='m101')
100+
assert(saved_request is not None and 'args' in saved_request and len(saved_request['args']) >= 2)
101+
assert('/sr=0.300000d' in saved_request['args'][1])
102+
103+
104+
79105
def test_observations_query_raw(patch_get):
80106
""" test querying raw """
81107
result = gemini.Observations.query_raw('GMOS-N', 'BIAS', progid='GN-CAL20191122')

docs/gemini/gemini.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ Observation Criteria Queries
6060
----------------------------
6161

6262
Additional search terms are available as optional arguments to the `~astroquery.gemini.ObservationsClass.query_criteria`
63-
call. These all have default values of None, in which case they will not be considered during the search.
63+
call. These all have default values of None, in which case they will not be considered during the search. The one
64+
exception is `radius`, which will be set to 0.3 degrees by default if either `coordinates` or `objectname` are
65+
specified.
6466

6567
Some examples of available search fields are the instrument used, such as GMOS-N, the observation_type, such as BIAS,
6668
and the program ID. For a complete list of available search fields, see

0 commit comments

Comments
 (0)