90 """Construct transmission curve representation from the data that was
96 This is raised if no table data exists in the calibration,
97 if there are array length mismatches, or if the wavelength
98 sampling for multi-amp tables differ.
100 if self.
data is None:
101 raise RuntimeError(
"No table data was found to convert to a transmission curve!")
104 if 'wavelength' not in self.
data.columns:
105 raise RuntimeError(
"Expected column [wavelength] not found.")
106 if 'efficiency' in self.
data.columns:
107 throughputKey =
'efficiency'
108 elif 'throughput' in self.
data.columns:
109 throughputKey =
'throughput'
111 raise RuntimeError(
"Expected columns [throughput|efficiency] not found.")
113 doAverageCurves =
False
114 if 'amp_name' in self.
data.columns:
115 doAverageCurves =
True
124 amplifierNames = set(self.
data[
'amp_name'])
125 comparisonIndices = np.where(self.
data[
'amp_name'] == next(iter(amplifierNames)))
126 wavelengths = self.
data[comparisonIndices][
'wavelength']
128 for amplifier
in amplifierNames:
129 indices = np.where(self.
data[
'amp_name'] == amplifier)
130 if len(self.
data[indices]) != len(self.
data[comparisonIndices]):
131 raise RuntimeError(
"Incompatible lengths in average.")
132 if not np.array_equal(self.
data[indices][
'wavelength'], wavelengths):
133 raise RuntimeError(
"Mismatch in wavelength samples.")
135 if curveStack
is not None:
136 curveStack = np.column_stack((curveStack, self.
data[indices][throughputKey]))
138 curveStack = self.
data[indices][throughputKey]
139 throughput = np.mean(curveStack, 1)
142 throughput = throughput * self.
data[throughputKey].unit
144 wavelengths = self.
data[
'wavelength']
145 throughput = self.
data[throughputKey]
151 wavelengths = wavelengths.to(u.Angstrom).to_value()
153 if throughput.unit != u.dimensionless_unscaled
and throughput.unit != u.UnrecognizedUnit(
'-'):
155 throughput = throughput.to(u.dimensionless_unscaled).to_value()
158 throughput.astype(np.float64),
159 wavelengths.astype(np.float64),