-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterCurveClass.py
More file actions
executable file
·26 lines (20 loc) · 1.19 KB
/
Copy pathFilterCurveClass.py
File metadata and controls
executable file
·26 lines (20 loc) · 1.19 KB
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
import numpy as np
import scipy.interpolate as interpolate
from cantrips import readInFileLineByLine
class FilterCurve:
def getThroughput(self, wavelengths):
wavelengths = np.array(wavelengths)
if len(np.shape(wavelengths)) > 0:
throughputs = [self.throughput_interp(wavelength) if (wavelength > self.wavelength_range[0] and wavelength < self.wavelength_range[1]) else 0.0
for wavelength in wavelengths
]
else:
throughputs = self.throughput_interp(wavelengths) if (wavelengths > self.wavelength_range[0] and wavelengths < self.wavelength_range[1]) else 0.0
return throughputs
def __init__(self, filter_file, filter_file_dir, split_char = ' '):
rows = readInFileLineByLine(filter_file, filter_file_dir)
rows = [row.split(split_char) for row in rows]
self.wavelengths = [float(row[0]) for row in rows]
self.wavelength_range = [min(self.wavelengths), max(self.wavelengths)]
self.throughputs = [float(row[1]) for row in rows]
self.throughput_interp = interpolate.interp1d(self.wavelengths, self.throughputs)