-
Notifications
You must be signed in to change notification settings - Fork 3
/
passbands.py
49 lines (40 loc) · 1.56 KB
/
passbands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
from argparse import ArgumentParser
parser = ArgumentParser(description="""
Plots filter profiles retrieved from the Spanish Virtual Observatory's
(SVO) Filter Profile Service (FPS).
http://svo2.cab.inta-csic.es/theory/fps/
""")
parser.add_argument('filters', type=str, nargs='+',
help="Names of filters, as on SVO FPS. "
"e.g. Generic/Bessell.U")
parser.add_argument('--legend', type=str, nargs='+', default=[],
help="Add a legend. If arguments are given, use "
"those. Otherwise, use the part of filter names "
"after '/'.")
parser.add_argument('--interp', type=str, default='none',
choices={'none', 'pchip'})
args = parser.parse_args()
import matplotlib.pyplot as pl
from astroquery.svo_fps import SvoFps
if args.interp == 'pchip':
import numpy as np
from scipy.interpolate import PchipInterpolator as interp
for name in args.filters:
data = SvoFps.get_transmission_data(name)
if args.interp != 'none':
x = np.linspace(data['Wavelength'].min(),
data['Wavelength'].max(),
len(data)*10)
y = interp(data['Wavelength']/10, data['Transmission'])(x/10)
pl.plot(x, y)
else:
pl.plot(data['Wavelength']/10, data['Transmission'])
if len(args.legend) > 0:
pl.legend(args.legend)
else:
pl.legend([filter.split('/')[-1] for filter in args.filters])
pl.xlabel('wavelength (nm)')
pl.ylabel('transmission fraction')
pl.ylim(0, 1.05)
pl.show()