LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Protected Attributes | List of all members
lsst.ip.isr.photodiode.PhotodiodeCalib Class Reference
Inheritance diagram for lsst.ip.isr.photodiode.PhotodiodeCalib:
lsst.ip.isr.calibType.IsrCalib

Public Member Functions

 __init__ (self, timeSamples=None, currentSamples=None, **kwargs)
 
 fromDict (cls, dictionary)
 
 toDict (self)
 
 fromTable (cls, tableList)
 
 toTable (self)
 
 readTwoColumnPhotodiodeData (cls, filename)
 
 integrate (self)
 
 integrateDirectSum (self)
 
 integrateTrimmedSum (self)
 
 integrateChargeSum (self)
 

Public Attributes

 timeSamples
 
 currentSamples
 
 integrationMethod
 
 currentScale
 

Static Protected Attributes

str _OBSTYPE = 'PHOTODIODE'
 
str _SCHEMA = 'Photodiode'
 
float _VERSION = 1.0
 

Detailed Description

Independent current measurements from photodiode for linearity
calculations.

Parameters
----------
timeSamples : `list` or `numpy.ndarray`
    List of samples the photodiode was measured at.
currentSamples : `list` or `numpy.ndarray`
    List of current measurements at each time sample.
log : `lsst.log.Log`, optional
    Log to write messages to.
**kwargs :
    Additional parameters. These will be passed to the parent
    constructor with the exception of:

    ``"integrationMethod"``
        Name of the algorithm to use to integrate the current
        samples. Allowed values are ``DIRECT_SUM``,
        ``TRIMMED_SUM``, and ``CHARGE_SUM`` (`str`).
    ``"currentScale"``
        Scale factor to apply to the current samples for the
        ``CHARGE_SUM`` integration method. A typical value
        would be `-1`, to flip the sign of the integrated charge.

Definition at line 33 of file photodiode.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.ip.isr.photodiode.PhotodiodeCalib.__init__ ( self,
timeSamples = None,
currentSamples = None,
** kwargs )

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 63 of file photodiode.py.

63 def __init__(self, timeSamples=None, currentSamples=None, **kwargs):
64 if timeSamples is not None and currentSamples is not None:
65 if len(timeSamples) != len(currentSamples):
66 raise RuntimeError(f"Inconsitent vector lengths: {len(timeSamples)} vs {len(currentSamples)}")
67 else:
68 self.timeSamples = np.array(timeSamples).ravel()
69 self.currentSamples = np.array(currentSamples).ravel()
70 else:
71 self.timeSamples = np.array([]).ravel()
72 self.currentSamples = np.array([]).ravel()
73
74 super().__init__(**kwargs)
75
76 if 'integrationMethod' in kwargs:
77 self.integrationMethod = kwargs.pop('integrationMethod')
78 else:
79 self.integrationMethod = 'DIRECT_SUM'
80
81 if 'currentScale' in kwargs:
82 self.currentScale = kwargs.pop('currentScale')
83 else:
84 self.currentScale = 1.0
85
86 if 'day_obs' in kwargs:
87 self.updateMetadata(day_obs=kwargs['day_obs'])
88 if 'seq_num' in kwargs:
89 self.updateMetadata(seq_num=kwargs['seq_num'])
90
91 self.requiredAttributes.update(['timeSamples', 'currentSamples', 'integrationMethod'])
92

Member Function Documentation

◆ fromDict()

lsst.ip.isr.photodiode.PhotodiodeCalib.fromDict ( cls,
dictionary )
Construct a PhotodiodeCalib from a dictionary of properties.

Parameters
----------
dictionary : `dict`
    Dictionary of properties.

Returns
-------
calib : `lsst.ip.isr.PhotodiodeCalib`
    Constructed photodiode data.

Raises
------
RuntimeError
    Raised if the supplied dictionary is for a different
    calibration type.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 94 of file photodiode.py.

94 def fromDict(cls, dictionary):
95 """Construct a PhotodiodeCalib from a dictionary of properties.
96
97 Parameters
98 ----------
99 dictionary : `dict`
100 Dictionary of properties.
101
102 Returns
103 -------
104 calib : `lsst.ip.isr.PhotodiodeCalib`
105 Constructed photodiode data.
106
107 Raises
108 ------
109 RuntimeError
110 Raised if the supplied dictionary is for a different
111 calibration type.
112 """
113 calib = cls()
114
115 if calib._OBSTYPE != dictionary['metadata']['OBSTYPE']:
116 raise RuntimeError(f"Incorrect photodiode supplied. Expected {calib._OBSTYPE}, "
117 f"found {dictionary['metadata']['OBSTYPE']}")
118
119 calib.setMetadata(dictionary['metadata'])
120
121 calib.timeSamples = np.array(dictionary['timeSamples']).ravel()
122 calib.currentSamples = np.array(dictionary['currentSamples']).ravel()
123 calib.integrationMethod = dictionary.get('integrationMethod', "DIRECT_SUM")
124
125 calib.updateMetadata()
126 return calib
127

◆ fromTable()

lsst.ip.isr.photodiode.PhotodiodeCalib.fromTable ( cls,
tableList )
Construct calibration from a list of tables.

This method uses the `fromDict` method to create the
calibration after constructing an appropriate dictionary from
the input tables.

Parameters
----------
tableList : `list` [`astropy.table.Table`]
    List of tables to use to construct the crosstalk
    calibration.

Returns
-------
calib : `lsst.ip.isr.PhotodiodeCalib`
    The calibration defined in the tables.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 152 of file photodiode.py.

152 def fromTable(cls, tableList):
153 """Construct calibration from a list of tables.
154
155 This method uses the `fromDict` method to create the
156 calibration after constructing an appropriate dictionary from
157 the input tables.
158
159 Parameters
160 ----------
161 tableList : `list` [`astropy.table.Table`]
162 List of tables to use to construct the crosstalk
163 calibration.
164
165 Returns
166 -------
167 calib : `lsst.ip.isr.PhotodiodeCalib`
168 The calibration defined in the tables.
169 """
170 dataTable = tableList[0]
171
172 metadata = dataTable.meta
173 inDict = {}
174 inDict['metadata'] = metadata
175 inDict['integrationMethod'] = metadata.pop('INTEGRATION_METHOD', 'DIRECT_SUM')
176
177 inDict['timeSamples'] = dataTable['TIME']
178 inDict['currentSamples'] = dataTable['CURRENT']
179
180 return cls().fromDict(inDict)
181

◆ integrate()

lsst.ip.isr.photodiode.PhotodiodeCalib.integrate ( self)
Integrate the current.

Raises
------
RuntimeError
    Raised if the integration method is not known.

Definition at line 231 of file photodiode.py.

231 def integrate(self):
232 """Integrate the current.
233
234 Raises
235 ------
236 RuntimeError
237 Raised if the integration method is not known.
238 """
239 if self.integrationMethod == 'DIRECT_SUM':
240 return self.integrateDirectSum()
241 elif self.integrationMethod == 'TRIMMED_SUM':
242 return self.integrateTrimmedSum()
243 elif self.integrationMethod == 'CHARGE_SUM':
244 return self.integrateChargeSum()
245 else:
246 raise RuntimeError(f"Unknown integration method {self.integrationMethod}")
247

◆ integrateChargeSum()

lsst.ip.isr.photodiode.PhotodiodeCalib.integrateChargeSum ( self)
For this method, the values in .currentSamples are actually the
integrated charge values as measured by the ammeter for each
sampling interval.  We need to do a baseline subtraction,
based on the charge values when the LED is off, then sum up
the corrected signals.

Returns
-------
sum : `float`
    Total charge measured.

Definition at line 280 of file photodiode.py.

280 def integrateChargeSum(self):
281 """For this method, the values in .currentSamples are actually the
282 integrated charge values as measured by the ammeter for each
283 sampling interval. We need to do a baseline subtraction,
284 based on the charge values when the LED is off, then sum up
285 the corrected signals.
286
287 Returns
288 -------
289 sum : `float`
290 Total charge measured.
291 """
292 dt = self.timeSamples[1:] - self.timeSamples[:-1]
293 # The .currentSamples values are the current integrals over
294 # the interval preceding the current time stamp, so omit the
295 # first value.
296 charge = self.currentScale*self.currentSamples[1:]
297 # The current per interval to use for baseline subtraction
298 # without assuming all of the dt values are the same:
299 current = charge/dt
300 # To determine the baseline current level, exclude points with
301 # signal levels > 5% of the maximum (measured relative to the
302 # overall minimum), and extend that selection 2 entries on
303 # either side to avoid otherwise low-valued points that sample
304 # the signal ramp and which should not be included in the
305 # baseline estimate.
306 dy = np.max(current) - np.min(current)
307 signal, = np.where(current > dy/20. + np.min(current))
308 imin = signal[0] - 2
309 imax = signal[-1] + 2
310 bg = np.concatenate([np.arange(0, imin), np.arange(imax, len(current))])
311 bg_current = np.sum(charge[bg])/np.sum(dt[bg])
312 # Return the background-subtracted total charge.
313 return np.sum(charge - bg_current*dt)

◆ integrateDirectSum()

lsst.ip.isr.photodiode.PhotodiodeCalib.integrateDirectSum ( self)
Integrate points.

This uses numpy's trapezoidal integrator.

Returns
-------
sum : `float`
    Total charge measured.

Definition at line 248 of file photodiode.py.

248 def integrateDirectSum(self):
249 """Integrate points.
250
251 This uses numpy's trapezoidal integrator.
252
253 Returns
254 -------
255 sum : `float`
256 Total charge measured.
257 """
258 return np.trapz(self.currentSamples, x=self.timeSamples)
259

◆ integrateTrimmedSum()

lsst.ip.isr.photodiode.PhotodiodeCalib.integrateTrimmedSum ( self)
Integrate points with a baseline level subtracted.

This uses numpy's trapezoidal integrator.

Returns
-------
sum : `float`
    Total charge measured.

See Also
--------
lsst.eotask.gen3.eoPtc

Definition at line 260 of file photodiode.py.

260 def integrateTrimmedSum(self):
261 """Integrate points with a baseline level subtracted.
262
263 This uses numpy's trapezoidal integrator.
264
265 Returns
266 -------
267 sum : `float`
268 Total charge measured.
269
270 See Also
271 --------
272 lsst.eotask.gen3.eoPtc
273 """
274 currentThreshold = ((max(self.currentSamples) - min(self.currentSamples))/5.0
275 + min(self.currentSamples))
276 lowValueIndices = np.where(self.currentSamples < currentThreshold)
277 baseline = np.median(self.currentSamples[lowValueIndices])
278 return np.trapz(self.currentSamples - baseline, self.timeSamples)
279
int min
int max

◆ readTwoColumnPhotodiodeData()

lsst.ip.isr.photodiode.PhotodiodeCalib.readTwoColumnPhotodiodeData ( cls,
filename )
Construct a PhotodiodeCalib by reading the simple column format.

Parameters
----------
filename : `str`
    File to read samples from.

Returns
-------
calib : `lsst.ip.isr.PhotodiodeCalib`
    The calibration defined in the file.

Definition at line 207 of file photodiode.py.

207 def readTwoColumnPhotodiodeData(cls, filename):
208 """Construct a PhotodiodeCalib by reading the simple column format.
209
210 Parameters
211 ----------
212 filename : `str`
213 File to read samples from.
214
215 Returns
216 -------
217 calib : `lsst.ip.isr.PhotodiodeCalib`
218 The calibration defined in the file.
219 """
220 import os.path
221
222 rawData = np.loadtxt(filename, dtype=[('time', 'float'), ('current', 'float')])
223
224 basename = os.path.basename(filename)
225 cleaned = os.path.splitext(basename)[0]
226 _, _, day_obs, seq_num = cleaned.split("_")
227
228 return cls(timeSamples=rawData['time'], currentSamples=rawData['current'],
229 day_obs=int(day_obs), seq_num=int(seq_num))
230

◆ toDict()

lsst.ip.isr.photodiode.PhotodiodeCalib.toDict ( self)
Return a dictionary containing the photodiode properties.

The dictionary should be able to be round-tripped through.
`fromDict`.

Returns
-------
dictionary : `dict`
    Dictionary of properties.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 128 of file photodiode.py.

128 def toDict(self):
129 """Return a dictionary containing the photodiode properties.
130
131 The dictionary should be able to be round-tripped through.
132 `fromDict`.
133
134 Returns
135 -------
136 dictionary : `dict`
137 Dictionary of properties.
138 """
139 self.updateMetadata()
140
141 outDict = {}
142 outDict['metadata'] = self.getMetadata()
143
144 outDict['timeSamples'] = self.timeSamples.tolist()
145 outDict['currentSamples'] = self.currentSamples.tolist()
146
147 outDict['integrationMethod'] = self.integrationMethod
148
149 return outDict
150

◆ toTable()

lsst.ip.isr.photodiode.PhotodiodeCalib.toTable ( self)
Construct a list of tables containing the information in this
calibration.

The list of tables should create an identical calibration
after being passed to this class's fromTable method.

Returns
-------
tableList : `list` [`astropy.table.Table`]
    List of tables containing the photodiode calibration
    information.

Reimplemented from lsst.ip.isr.calibType.IsrCalib.

Definition at line 182 of file photodiode.py.

182 def toTable(self):
183 """Construct a list of tables containing the information in this
184 calibration.
185
186 The list of tables should create an identical calibration
187 after being passed to this class's fromTable method.
188
189 Returns
190 -------
191 tableList : `list` [`astropy.table.Table`]
192 List of tables containing the photodiode calibration
193 information.
194 """
195 self.updateMetadata()
196 catalog = Table([{'TIME': self.timeSamples,
197 'CURRENT': self.currentSamples}])
198 inMeta = self.getMetadata().toDict()
199 outMeta = {k: v for k, v in inMeta.items() if v is not None}
200 outMeta.update({k: "" for k, v in inMeta.items() if v is None})
201 outMeta['INTEGRATION_METHOD'] = self.integrationMethod
202 catalog.meta = outMeta
203
204 return [catalog]
205

Member Data Documentation

◆ _OBSTYPE

str lsst.ip.isr.photodiode.PhotodiodeCalib._OBSTYPE = 'PHOTODIODE'
staticprotected

Definition at line 59 of file photodiode.py.

◆ _SCHEMA

str lsst.ip.isr.photodiode.PhotodiodeCalib._SCHEMA = 'Photodiode'
staticprotected

Definition at line 60 of file photodiode.py.

◆ _VERSION

float lsst.ip.isr.photodiode.PhotodiodeCalib._VERSION = 1.0
staticprotected

Definition at line 61 of file photodiode.py.

◆ currentSamples

lsst.ip.isr.photodiode.PhotodiodeCalib.currentSamples

Definition at line 69 of file photodiode.py.

◆ currentScale

lsst.ip.isr.photodiode.PhotodiodeCalib.currentScale

Definition at line 82 of file photodiode.py.

◆ integrationMethod

lsst.ip.isr.photodiode.PhotodiodeCalib.integrationMethod

Definition at line 77 of file photodiode.py.

◆ timeSamples

lsst.ip.isr.photodiode.PhotodiodeCalib.timeSamples

Definition at line 68 of file photodiode.py.


The documentation for this class was generated from the following file: