22 Photodiode storage class.
25 from astropy.table
import Table
30 __all__ = [
"PhotodiodeCalib"]
34 """Independent current measurements from photodiode for linearity
39 timeSamples : `list` or `numpy.ndarray`
40 List of samples the photodiode was measured at.
41 currentSamples : `list` or `numpy.ndarray`
42 List of current measurements at each time sample.
43 log : `lsst.log.Log`, optional
44 Log to write messages to.
46 Additional parameters. These will be passed to the parent
47 constructor with the exception of:
49 ``"integrationMethod"``
50 Name of the algorithm to use to integrate the current
51 samples. Allowed values are ``DIRECT_SUM`` and
52 ``TRIMMED_SUM`` (`str`).
55 _OBSTYPE =
'PHOTODIODE'
56 _SCHEMA =
'Photodiode'
59 def __init__(self, timeSamples=None, currentSamples=None, **kwargs):
60 if timeSamples
is not None and currentSamples
is not None:
61 if len(timeSamples) != len(currentSamples):
62 raise RuntimeError(f
"Inconsitent vector lengths: {len(timeSamples)} vs {len(currentSamples)}")
72 if 'integrationMethod' in kwargs:
77 if 'day_obs' in kwargs:
79 if 'seq_num' in kwargs:
86 """Construct a PhotodiodeCalib from a dictionary of properties.
91 Dictionary of properties.
95 calib : `lsst.ip.isr.PhotodiodeCalib`
96 Constructed photodiode data.
101 Raised if the supplied dictionary is for a different
106 if calib._OBSTYPE != dictionary[
'metadata'][
'OBSTYPE']:
107 raise RuntimeError(f
"Incorrect photodiode supplied. Expected {calib._OBSTYPE}, "
108 f
"found {dictionary['metadata']['OBSTYPE']}")
110 calib.setMetadata(dictionary[
'metadata'])
112 calib.timeSamples = np.array(dictionary[
'timeSamples'])
113 calib.currentSamples = np.array(dictionary[
'currentSamples'])
114 calib.integrationMethod = dictionary.get(
'integrationMethod',
"DIRECT_SUM")
116 calib.updateMetadata()
120 """Return a dictionary containing the photodiode properties.
122 The dictionary should be able to be round-tripped through.
128 Dictionary of properties.
133 outDict[
'metadata'] = self.
getMetadatagetMetadata()
135 outDict[
'timeSamples'] = self.
timeSamplestimeSamples.tolist()
136 outDict[
'currentSamples'] = self.
currentSamplescurrentSamples.tolist()
144 """Construct calibration from a list of tables.
146 This method uses the `fromDict` method to create the
147 calibration after constructing an appropriate dictionary from
152 tableList : `list` [`astropy.table.Table`]
153 List of tables to use to construct the crosstalk
158 calib : `lsst.ip.isr.PhotodiodeCalib`
159 The calibration defined in the tables.
161 dataTable = tableList[0]
163 metadata = dataTable.meta
165 inDict[
'metadata'] = metadata
166 inDict[
'integrationMethod'] = metadata.pop(
'INTEGRATION_METHOD',
'DIRECT_SUM')
168 inDict[
'timeSamples'] = dataTable[
'TIME']
169 inDict[
'currentSamples'] = dataTable[
'CURRENT']
174 """Construct a list of tables containing the information in this
177 The list of tables should create an identical calibration
178 after being passed to this class's fromTable method.
182 tableList : `list` [`astropy.table.Table`]
183 List of tables containing the photodiode calibration
187 catalog = Table([{
'TIME': self.
timeSamplestimeSamples,
190 outMeta = {k: v
for k, v
in inMeta.items()
if v
is not None}
191 outMeta.update({k:
"" for k, v
in inMeta.items()
if v
is None})
193 catalog.meta = outMeta
199 """Construct a PhotodiodeCalib by reading the simple column format.
204 File to read samples from.
208 calib : `lsst.ip.isr.PhotodiodeCalib`
209 The calibration defined in the file.
213 rawData = np.loadtxt(filename, dtype=[(
'time',
'float'), (
'current',
'float')])
215 basename = os.path.basename(filename)
216 cleaned = os.path.splitext(basename)[0]
217 _, _, day_obs, seq_num = cleaned.split(
"_")
219 return cls(timeSamples=rawData[
'time'], currentSamples=rawData[
'current'],
220 day_obs=int(day_obs), seq_num=int(seq_num))
223 """Integrate the current.
228 Raised if the integration method is not known.
235 raise RuntimeError(f
"Unknown integration method {self.integrationMethod}")
240 This uses numpy's trapezoidal integrator.
245 Total charge measured.
250 """Integrate points with a baseline level subtracted.
252 This uses numpy's trapezoidal integrator.
257 Total charge measured.
261 lsst.eotask.gen3.eoPtc
265 lowValueIndices = np.where(self.
currentSamplescurrentSamples < currentThreshold)
266 baseline = np.median(self.
currentSamplescurrentSamples[lowValueIndices])
def requiredAttributes(self, value)
def updateMetadata(self, camera=None, detector=None, filterName=None, setCalibId=False, setCalibInfo=False, setDate=False, **kwargs)
def requiredAttributes(self)
def fromTable(cls, tableList)
def integrateTrimmedSum(self)
def fromDict(cls, dictionary)
def __init__(self, timeSamples=None, currentSamples=None, **kwargs)
def integrateDirectSum(self)
def readTwoColumnPhotodiodeData(cls, filename)