91 """Construct transmission curve representation from the data that was
97 This is raised if no table data exists in the calibration,
98 if there are array length mismatches, or if the wavelength
99 sampling for multi-amp tables differ.
101 if self.
data is None:
102 raise RuntimeError(
"No table data was found to convert to a transmission curve!")
105 if 'wavelength' not in self.
data.columns:
106 raise RuntimeError(
"Expected column [wavelength] not found.")
107 if 'efficiency' in self.
data.columns:
108 throughputKey =
'efficiency'
109 elif 'throughput' in self.
data.columns:
110 throughputKey =
'throughput'
112 raise RuntimeError(
"Expected columns [throughput|efficiency] not found.")
114 doAverageCurves =
False
115 if 'amp_name' in self.
data.columns:
116 doAverageCurves =
True
125 amplifierNames = set(self.
data[
'amp_name'])
126 comparisonIndices = np.where(self.
data[
'amp_name'] == next(iter(amplifierNames)))
127 wavelengths = self.
data[comparisonIndices][
'wavelength']
129 for amplifier
in amplifierNames:
130 indices = np.where(self.
data[
'amp_name'] == amplifier)
131 if len(self.
data[indices]) != len(self.
data[comparisonIndices]):
132 raise RuntimeError(
"Incompatible lengths in average.")
133 if not np.array_equal(self.
data[indices][
'wavelength'], wavelengths):
134 raise RuntimeError(
"Mismatch in wavelength samples.")
136 if curveStack
is not None:
137 curveStack = np.column_stack((curveStack, self.
data[indices][throughputKey]))
139 curveStack = self.
data[indices][throughputKey]
140 throughput = np.mean(curveStack, 1)
143 throughput = throughput * self.
data[throughputKey].unit
145 wavelengths = self.
data[
'wavelength']
146 throughput = self.
data[throughputKey]
152 wavelengths = wavelengths.to(u.Angstrom).to_value()
154 if throughput.unit != u.dimensionless_unscaled
and throughput.unit != u.UnrecognizedUnit(
'-'):
156 throughput = throughput.to(u.dimensionless_unscaled).to_value()
159 throughput.astype(np.float64),
160 wavelengths.astype(np.float64),