22PhotodiodeCorrection storage class.
25__all__ = [
"PhotodiodeCorrection"]
28from astropy.table
import Table
29from .calibType
import IsrCalib
33 """Parameter set for photodiode correction.
35 These parameters are included in cameraGeom.Amplifier, but
36 should be accessible externally to allow
for testing.
40 table : `numpy.array`, optional
41 Lookup table; a 2-dimensional array of floats:
43 - one row
for each row index (value of coef[0]
in the amplifier)
44 - one column
for each image value.
46 To avoid copying the table the last index should vary fastest
47 (numpy default
"C" order)
48 log : `logging.Logger`, optional
49 Logger to handle messages.
50 kwargs : `dict`, optional
51 Other keyword arguments to
pass to the parent init.
56 Raised
if the supplied table
is not 2D,
or if the table has fewer
57 columns than rows (indicating that the indices are swapped).
61 The photodiode correction attributes stored are:
62 abscissaCorrections : `dict` : [`str`, `float`]
63 Correction value indexed by exposure pair
65 _OBSTYPE = "PHOTODIODE_CORRECTION"
66 _SCHEMA =
'PhotodiodeCorrection'
73 if len(table.shape) != 2:
74 raise RuntimeError(
"table shape = %s; must have two dimensions" % (table.shape,))
75 if table.shape[1] < table.shape[0]:
76 raise RuntimeError(
"table shape = %s; indices are switched" % (table.shape,))
77 self.
tableData = np.array(table, order=
"C")
83 """Update metadata keywords with new values.
85 This calls the base class's method after ensuring the required
86 calibration keywords will be saved.
90 setDate : `bool`, optional
91 Update the CALIBDATE fields in the metadata to the current
92 time. Defaults to
False.
94 Other keyword parameters to set
in the metadata.
101 """Construct a PhotodiodeCorrection from a dictionary of properties.
106 Dictionary of properties.
111 Constructed photodiode data.
116 Raised if the supplied dictionary
is for a different
121 if calib._OBSTYPE != dictionary[
'metadata'][
'OBSTYPE']:
122 raise RuntimeError(f
"Incorrect photodiode correction supplied. Expected {calib._OBSTYPE}, "
123 f
"found {dictionary['metadata']['OBSTYPE']}")
125 calib.setMetadata(dictionary[
'metadata'])
126 for pair
in dictionary[
'pairs']:
127 correction = dictionary[
'pairs'][pair]
128 calib.abscissaCorrections[pair] = correction
130 calib.tableData = dictionary.get(
'tableData',
None)
132 calib.tableData = np.array(calib.tableData)
137 """Return a dictionary containing the photodiode correction properties.
139 The dictionary should be able to be round-tripped through.
145 Dictionary of properties.
150 outDict['pairs'] = dict()
156 outDict[
'tableData'] = self.
tableData.tolist()
162 """Construct calibration from a list of tables.
164 This method uses the `fromDict` method to create the
165 calibration after constructing an appropriate dictionary from
170 tableList : `list` [`astropy.table.Table`]
171 List of tables to use to construct the crosstalk
177 The calibration defined
in the tables.
179 dataTable = tableList[0]
181 metadata = dataTable.meta
183 inDict['metadata'] = metadata
184 inDict[
'pairs'] = dict()
186 for record
in dataTable:
187 pair = record[
'PAIR']
188 inDict[
'pairs'][pair] = record[
'PD_CORR']
190 if len(tableList) > 1:
191 tableData = tableList[1]
192 inDict[
'tableData'] = [record[
'LOOKUP_VALUES']
for record
in tableData]
197 """Construct a list of tables containing the information in this
200 The list of tables should create an identical calibration
201 after being passed to this class's fromTable method.
205 tableList : `list` [`astropy.table.Table`]
206 List of tables containing the photodiode correction
211 catalog = Table([{'PAIR': key,
215 tableList.append(catalog)
218 catalog = Table([{
'LOOKUP_VALUES': value}
for value
in self.
tableData])
219 tableList.append(catalog)
224 """Validate photodiode correction"""
requiredAttributes(self, value)
updateMetadata(self, camera=None, detector=None, filterName=None, setCalibId=False, setCalibInfo=False, setDate=False, **kwargs)
__init__(self, table=None, **kwargs)
fromDict(cls, dictionary)
updateMetadata(self, setDate=False, **kwargs)
fromTable(cls, tableList)