Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50013c1
commit 0852ac9
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
""" Link to the SVO filter profile service | ||
http://svo2.cab.inta-csic.es/theory/fps/ | ||
If your research benefits from the use of the SVO Filter Profile Service, include the following acknowledgement in your publication: | ||
> This research has made use of the SVO Filter Profile Service | ||
> (http://svo2.cab.inta-csic.es/theory/fps/) supported from the Spanish MINECO | ||
> through grant AYA2017-84089. | ||
and please include the following references in your publication: | ||
* The SVO Filter Profile Service. Rodrigo, C., Solano, E., Bayo, A., 2012; https://ui.adsabs.harvard.edu/abs/2012ivoa.rept.1015R/abstract | ||
* The SVO Filter Profile Service. Rodrigo, C., Solano, E., 2020; https://ui.adsabs.harvard.edu/abs/2020sea..confE.182R/abstract | ||
Example | ||
------- | ||
>>> lst = "2MASS/2MASS.J 2MASS/2MASS.H 2MASS/2MASS.Ks HST/ACS_WFC.F475W HST/ACS_WFC.F814W".split() | ||
objects = [get_pyphot_filter(k) for k in lst] | ||
""" | ||
from io import BytesIO | ||
import requests | ||
from astropy.io import votable | ||
|
||
QUERY_URL = "http://svo2.cab.inta-csic.es/theory/fps/fps.php" | ||
DETECTOR_TYPE = ['energy', 'photon'] # svo returns 0, 1 | ||
|
||
|
||
def get_pyphot_astropy_filter(identifier: str): | ||
""" Query the SVO filter profile service and return the filter object | ||
Parameters | ||
---------- | ||
identifier : str | ||
SVO identifier of the filter profile | ||
e.g., 2MASS/2MASS.Ks HST/ACS_WFC.F475W | ||
The identifier is the first column on the webpage of the facilities. | ||
Returns | ||
------- | ||
filter : pyphot.astropy.UnitFilter | ||
Filter object | ||
""" | ||
from .astropy import UnitFilter | ||
query = {'ID': identifier} | ||
response = requests.get(QUERY_URL, params=query) | ||
response.raise_for_status() | ||
table = votable.parse_single_table(BytesIO(response.content)) | ||
params = {p.name: p.value for p in table.params} | ||
tab = table.to_table() | ||
return UnitFilter(tab['Wavelength'].to('nm'), | ||
tab['Transmission'], | ||
name=params['filterID'].replace('/', '_'), | ||
dtype=DETECTOR_TYPE[int(params['DetectorType'])]) | ||
|
||
|
||
def get_pyphot_filter(identifier: str): | ||
""" Query the SVO filter profile service and return the filter object | ||
Parameters | ||
---------- | ||
identifier : str | ||
SVO identifier of the filter profile | ||
e.g., 2MASS/2MASS.Ks HST/ACS_WFC.F475W | ||
The identifier is the first column on the webpage of the facilities. | ||
Returns | ||
------- | ||
filter : pyphot.astropy.UnitFilter | ||
Filter object | ||
""" | ||
from .sandbox import UnitFilter | ||
query = {'ID': identifier} | ||
response = requests.get(QUERY_URL, params=query) | ||
response.raise_for_status() | ||
table = votable.parse_single_table(BytesIO(response.content)) | ||
params = {p.name: p.value for p in table.params} | ||
tab = table.to_table() | ||
return UnitFilter(tab['Wavelength'].to('nm'), | ||
tab['Transmission'], | ||
name=params['filterID'].replace('/', '_'), | ||
dtype=DETECTOR_TYPE[int(params['DetectorType'])]) |