Skip to content

Commit f5ff578

Browse files
authored
Merge pull request #2444 from eerovaher/svo-unit-conversion
Perform unit conversion in `svo_fps` `get_filter_index()`
2 parents 2543cc2 + 23b8ad1 commit f5ff578

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ oac
6262
- Fix bug in parsing events that contain html tags (e.g. in their alias
6363
field). [#2423]
6464

65+
svo_fps
66+
^^^^^^^
67+
68+
- The wavelength limits in ``get_filter_index()`` can now be specified using any
69+
length unit, not just angstroms. [#2444]
70+
6571
gaia
6672
^^^^
6773

astroquery/svo_fps/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def get_filter_index(self, wavelength_eff_min=0*u.angstrom,
6868
6969
Parameters
7070
----------
71-
wavelength_eff_min : `~astropy.units.Quantity` having units of angstrom, optional
71+
wavelength_eff_min : `~astropy.units.Quantity` with units of length, optional
7272
Minimum value of Wavelength Effective (default is 0 angstrom)
73-
wavelength_eff_max : `~astropy.units.Quantity` having units of angstrom, optional
73+
wavelength_eff_max : `~astropy.units.Quantity` with units of length, optional
7474
Maximum value of Wavelength Effective (default is a very large
7575
quantity FLOAT_MAX angstroms i.e. maximum value of np.float64)
7676
kwargs : dict
@@ -81,8 +81,8 @@ def get_filter_index(self, wavelength_eff_min=0*u.angstrom,
8181
astropy.table.table.Table object
8282
Table containing data fetched from SVO (in response to query)
8383
"""
84-
query = {'WavelengthEff_min': wavelength_eff_min.value,
85-
'WavelengthEff_max': wavelength_eff_max.value}
84+
query = {'WavelengthEff_min': wavelength_eff_min.to_value(u.angstrom),
85+
'WavelengthEff_max': wavelength_eff_max.to_value(u.angstrom)}
8686
error_msg = 'No filter found for requested Wavelength Effective range'
8787
return self.data_from_svo(query=query, error_msg=error_msg, **kwargs)
8888

astroquery/svo_fps/tests/test_svo_fps.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ def get_mockreturn(method, url, params=None, timeout=10, cache=None, **kwargs):
4646

4747

4848
def test_get_filter_index(patch_get):
49-
table = SvoFps.get_filter_index(TEST_LAMBDA*u.angstrom, (TEST_LAMBDA+100)*u.angstrom)
49+
lambda_min = TEST_LAMBDA*u.angstrom
50+
lambda_max = lambda_min + 100*u.angstrom
51+
table = SvoFps.get_filter_index(lambda_min, lambda_max)
5052
# Check if column for Filter ID (named 'filterID') exists in table
5153
assert 'filterID' in table.colnames
54+
# Results should not depend on the unit of the wavelength: #2443. If they do then
55+
# `get_mockreturn` raises `NotImplementedError`.
56+
SvoFps.get_filter_index(lambda_min.to(u.m), lambda_max)
5257

5358

5459
def test_get_transmission_data(patch_get):

astroquery/svo_fps/tests/test_svo_fps_remote.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import astropy.io.votable.exceptions
3+
from astropy import units as u
34

45
from ..core import SvoFps
56

@@ -8,7 +9,7 @@
89
class TestSvoFpsClass:
910

1011
def test_get_filter_index(self):
11-
table = SvoFps.get_filter_index()
12+
table = SvoFps.get_filter_index(12_000*u.angstrom, 12_100*u.angstrom)
1213
# Check if column for Filter ID (named 'filterID') exists in table
1314
assert 'filterID' in table.colnames
1415

0 commit comments

Comments
 (0)