22PhotodiodeCorrection storage class.
25from astropy.table
import Table
26from .calibType
import IsrCalib
28__all__ = [
"PhotodiodeCorrection"]
32 """Parameter set for photodiode correction.
34 These parameters are included in cameraGeom.Amplifier, but
35 should be accessible externally to allow
for testing.
39 table : `numpy.array`, optional
40 Lookup table; a 2-dimensional array of floats:
41 - one row
for each row index (value of coef[0]
in the amplifier)
42 - one column
for each image value
43 To avoid copying the table the last index should vary fastest
44 (numpy default
"C" order)
45 log : `logging.Logger`, optional
46 Logger to handle messages.
47 kwargs : `dict`, optional
48 Other keyword arguments to
pass to the parent init.
53 Raised
if the supplied table
is not 2D,
or if the table has fewer
54 columns than rows (indicating that the indices are swapped).
58 The photodiode correction attributes stored are:
59 abscissaCorrections : `dict` : [`str`, `float`]
60 Correction value indexed by exposure pair
62 _OBSTYPE = "PHOTODIODE_CORRECTION"
63 _SCHEMA =
'PhotodiodeCorrection'
70 if len(table.shape) != 2:
71 raise RuntimeError(
"table shape = %s; must have two dimensions" % (table.shape,))
72 if table.shape[1] < table.shape[0]:
73 raise RuntimeError(
"table shape = %s; indices are switched" % (table.shape,))
74 self.
tableData = np.array(table, order=
"C")
80 """Update metadata keywords with new values.
82 This calls the base class's method after ensuring the required
83 calibration keywords will be saved.
87 setDate : `bool`, optional
88 Update the CALIBDATE fields in the metadata to the current
89 time. Defaults to
False.
91 Other keyword parameters to set
in the metadata.
98 """Construct a PhotodiodeCorrection from a dictionary of properties.
103 Dictionary of properties.
108 Constructed photodiode data.
113 Raised if the supplied dictionary
is for a different
118 if calib._OBSTYPE != dictionary[
'metadata'][
'OBSTYPE']:
119 raise RuntimeError(f
"Incorrect photodiode correction supplied. Expected {calib._OBSTYPE}, "
120 f
"found {dictionary['metadata']['OBSTYPE']}")
122 calib.setMetadata(dictionary[
'metadata'])
123 for pair
in dictionary[
'pairs']:
124 correction = dictionary[
'pairs'][pair]
125 calib.abscissaCorrections[pair] = correction
127 calib.tableData = dictionary.get(
'tableData',
None)
129 calib.tableData = np.array(calib.tableData)
134 """Return a dictionary containing the photodiode correction properties.
136 The dictionary should be able to be round-tripped through.
142 Dictionary of properties.
147 outDict['pairs'] = dict()
153 outDict[
'tableData'] = self.
tableData.tolist()
159 """Construct calibration from a list of tables.
161 This method uses the `fromDict` method to create the
162 calibration after constructing an appropriate dictionary from
167 tableList : `list` [`astropy.table.Table`]
168 List of tables to use to construct the crosstalk
174 The calibration defined
in the tables.
176 dataTable = tableList[0]
178 metadata = dataTable.meta
180 inDict['metadata'] = metadata
181 inDict[
'pairs'] = dict()
183 for record
in dataTable:
184 pair = record[
'PAIR']
185 inDict[
'pairs'][pair] = record[
'PD_CORR']
187 if len(tableList) > 1:
188 tableData = tableList[1]
189 inDict[
'tableData'] = [record[
'LOOKUP_VALUES']
for record
in tableData]
194 """Construct a list of tables containing the information in this
197 The list of tables should create an identical calibration
198 after being passed to this class's fromTable method.
202 tableList : `list` [`astropy.table.Table`]
203 List of tables containing the photodiode correction
208 catalog = Table([{'PAIR': key,
212 tableList.append(catalog)
215 catalog = Table([{
'LOOKUP_VALUES': value}
for value
in self.
tableData])
216 tableList.append(catalog)
221 """Validate photodiode correction"""
def requiredAttributes(self, value)
def updateMetadata(self, camera=None, detector=None, filterName=None, setCalibId=False, setCalibInfo=False, setDate=False, **kwargs)
def requiredAttributes(self)
def fromDict(cls, dictionary)
def fromTable(cls, tableList)
def __init__(self, table=None, **kwargs)
def updateMetadata(self, setDate=False, **kwargs)