Skip to content

Commit ae23215

Browse files
authored
Merge pull request astropy#3528 from cgobat/main
ENH: SVO FPS - add method to easily retrieve filter metadata
2 parents c9f2538 + 459ed3a commit ae23215

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ mast
4141
Service fixes and enhancements
4242
------------------------------
4343

44+
svo_fps
45+
^^^^^^^
46+
47+
- Add ``get_filter_metadata`` to allow retrieval of filter metadata. [#3528]
48+
4449
heasarc
4550
^^^^^^^
4651
- Add ``query_constraints`` to allow querying of different catalog columns. [#3403]

astroquery/svo_fps/core.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,41 @@ def get_filter_index(self, wavelength_eff_min, wavelength_eff_max, **kwargs):
108108
"succeed. Try increasing the timeout limit if a large range is needed."
109109
)
110110

111+
def get_filter_metadata(self, filter_id, *, cache=True, timeout=None):
112+
"""Get metadata/parameters for the requested Filter ID from SVO
113+
114+
Parameters
115+
----------
116+
filter_id : str
117+
Filter ID in the format SVO specifies it: 'facilty/instrument.filter'.
118+
This is returned by `get_filter_list` and `get_filter_index` as the
119+
``filterID`` column.
120+
cache : bool
121+
Defaults to True. If set overrides global caching behavior.
122+
See :ref:`caching documentation <astroquery_cache>`.
123+
timeout : int
124+
Timeout in seconds. If not specified, defaults to ``conf.timeout``.
125+
126+
Returns
127+
-------
128+
params : dict
129+
Dictionary of VOTable PARAM names and values.
130+
"""
131+
query = {'ID': filter_id, 'VERB': 0}
132+
response = self._request("GET", self.SVO_MAIN_URL, params=query,
133+
timeout=timeout or self.TIMEOUT,
134+
cache=cache)
135+
response.raise_for_status()
136+
response_content = io.BytesIO(response.content)
137+
votable = parse_single_table(response_content)
138+
params = {}
139+
for param in votable.iter_fields_and_params():
140+
if param.unit is not None:
141+
params[param.name] = param.value*param.unit
142+
else:
143+
params[param.name] = param.value
144+
return params
145+
111146
def get_transmission_data(self, filter_id, **kwargs):
112147
"""Get transmission data for the requested Filter ID from SVO
113148

astroquery/svo_fps/tests/test_svo_fps_remote.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ def test_get_transmission_data(self, test_filter_id):
2323
# Check if data is downloaded properly, with > 0 rows
2424
assert len(table) > 0
2525

26+
@pytest.mark.parametrize('test_filter_id',
27+
['NewHorizons/MVIC.Blue', 'Palomar/ZTF.r'])
28+
def test_get_filter_metadata(self, test_filter_id):
29+
params = SvoFps.get_filter_metadata(test_filter_id)
30+
# Check if expected keys are present
31+
assert "WavelengthEff" in params
32+
assert "ZeroPoint" in params
33+
# Check existence and value of what should be a constant
34+
assert params.get("FilterProfileService") == "ivo://svo/fps"
35+
2636
@pytest.mark.parametrize('test_facility, test_instrument',
2737
[('HST', 'WFPC2'), ('Keck', None)])
2838
def test_get_filter_list(self, test_facility, test_instrument):

docs/svo_fps/svo_fps.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ These are the data needed to plot the transmission curve for filter:
173173

174174
The 2MASS H-band transmission curve
175175

176+
Get metadata for a specific filter
177+
----------------------------------
178+
179+
Given a ``filterID``, a dictionary of metadata associated with that filter can be retrieved
180+
from the FPS using `~astroquery.svo_fps.SvoFpsClass.get_filter_metadata`:
181+
182+
.. doctest-remote-data::
183+
184+
>>> info = SvoFps.get_filter_metadata('PAN-STARRS/PS1.r')
185+
>>> print(info['WavelengthEff'])
186+
6155.4659814728 Angstrom
187+
>>> print(info['FWHM'])
188+
1397.7332085088 Angstrom
189+
>>> print(info['components'])
190+
Filter + Instrument + Atmosphere
191+
176192

177193
Troubleshooting
178194
===============

0 commit comments

Comments
 (0)