22Flat gradient fit storage class.
25__all__ = [
"FlatGradient"]
27from astropy.table
import Table
29from scipy.interpolate
import Akima1DInterpolator
35 """Flat gradient measurements.
39 log : `logging.Logger`, optional
40 Log to write messages to. If `None` a default logger will be used.
42 Additional parameters.
45 _OBSTYPE =
"flatGradient"
46 _SCHEMA =
"FlatGradient"
75 "normalizationFactor",
93 normalizationFactor=1.0,
95 """Set the parameters for the gradient model.
99 radialSplineNodes : `np.ndarray`
100 Array of spline nodes.
101 radialSplineValues : `np.ndarray`
102 Array of spline values (same length as ``radialSplineNodes``).
103 itlRatio : `float`, optional
104 Ratio of flat for ITL detectors to E2V detectors.
105 centroidX : `float`, optional
106 X centroid of the focal plane (mm). This will be used as the
107 pivot for the gradient plane.
108 centroidY : `float`, optional
109 Y centroid of the focal plane (mm). This will be used as the
110 pivot for the gradient plane.
111 centroidDeltaX : `float`, optional
112 Centroid offset (mm). This is used in the radial function to
113 allow for mis-centering in the illumination gradient.
114 centroidDeltaY : `float`, optional
115 Centroid offset (mm). This is used in the radial function to
116 allow for mis-centering in the illumination gradient.
117 gradientX : `float`, optional
118 Slope of gradient in x direction (throughput/mm).
119 gradientY : `float`, optional
120 Slope of gradient in y direction (throughput/mm).
121 normalizationFactor : `float`, optional
122 Overall normalization factor (used to, e.g. make the
123 center of the focal plane equal to 1.0 vs. a focal-plane
126 if len(radialSplineNodes) != len(radialSplineValues):
127 raise ValueError(
"The number of spline nodes and values must be equal.")
141 """Compute the radial spline model values from x/y.
143 The spline model is a 1D Akima spline. When computed, the values
144 from the model describe the radial function of the full focal
145 plane flat-field. Dividing by this model will yield a radially
146 flattened flat-field.
151 Array of focal plane x values (mm).
153 Array of focal plane y values (mm).
157 splineModel : `np.ndarray`
158 Spline model values at the x/y positions.
163 radius = np.sqrt((x - centroidX)**2. + (y - centroidY)**2.)
168 """Compute the radial spline model values from radii.
170 The spline model is a 1D Akima spline. When computed, the values
171 from the model describe the radial function of the full focal
172 plane flat-field. Dividing by this model will yield a radially
173 flattened flat-field.
177 radius : `np.ndarray`
178 Array of focal plane radii (mm).
182 splineModel : `np.ndarray`
183 Spline model values at the radius positions.
190 """Compute the gradient model values.
192 The gradient model is a plane constrained to be 1.0 at the
193 ``centroidX``, ``centroidY`` values. Dividing by this model will
194 remove the planar gradient in a flat field. Note that the planar
195 gradient pivot is always at the same position, and does not
196 move with the radial gradient centroid so as to keep the
197 model fit more stable.
202 Array of focal plane x values (mm).
204 Array of focal plane y values (mm).
208 gradientModel : `np.ndarray`
209 Gradient model values at the x/y positions.
216 """Compute the full gradient model given x/y and itl booleans.
218 This returns the full model that can be applied directly
219 to data that was used in a fit.
224 Array of focal plane x values (mm).
226 Array of focal plane y values (mm).
227 is_itl : `np.ndarray`
228 Boolean array of whether each point is from an ITL detector.
233 Model values at each position.
242 """Construct a FlatGradient from a dictionary of properties.
247 Dictionary of properties.
251 calib : `lsst.ip.isr.FlatGradient`
252 Constructed calibration.
256 calib.setMetadata(dictionary[
"metadata"])
258 calib.radialSplineNodes = np.asarray(dictionary[
"radialSplineNodes"])
259 calib.radialSplineValues = np.asarray(dictionary[
"radialSplineValues"])
260 calib.itlRatio = dictionary[
"itlRatio"]
261 calib.centroidX = dictionary[
"centroidX"]
262 calib.centroidY = dictionary[
"centroidY"]
263 calib.centroidDeltaX = dictionary[
"centroidDeltaX"]
264 calib.centroidDeltaY = dictionary[
"centroidDeltaY"]
265 calib.gradientX = dictionary[
"gradientX"]
266 calib.gradientY = dictionary[
"gradientY"]
267 calib.normalizationFactor = dictionary[
"normalizationFactor"]
269 calib.updateMetadata()
273 """Return a dictionary containing the calibration properties.
278 Dictionary of properties.
284 outDict[
"metadata"] = metadata
288 outDict[
"itlRatio"] = float(self.
itlRatio)
289 outDict[
"centroidX"] = float(self.
centroidX)
290 outDict[
"centroidY"] = float(self.
centroidY)
293 outDict[
"gradientX"] = float(self.
gradientX)
294 outDict[
"gradientY"] = float(self.
gradientY)
301 """Construct a calibration from a list of tables.
305 tableList : `list` [`astropy.table.Table`]
306 List of table(s) to use to construct the FlatGradient.
310 calib : `lsst.ip.isr.FlatGradient`
311 The calibration defined in the table(s).
313 gradientTable = tableList[0]
315 metadata = gradientTable.meta
317 inDict[
"metadata"] = metadata
318 inDict[
"radialSplineNodes"] = np.array(gradientTable[0][
"RADIAL_SPLINE_NODES"], dtype=np.float64)
319 inDict[
"radialSplineValues"] = np.array(gradientTable[0][
"RADIAL_SPLINE_VALUES"], dtype=np.float64)
320 inDict[
"itlRatio"] = float(gradientTable[0][
"ITL_RATIO"][0])
321 inDict[
"centroidX"] = float(gradientTable[0][
"CENTROID_X"][0])
322 inDict[
"centroidY"] = float(gradientTable[0][
"CENTROID_Y"][0])
323 inDict[
"centroidDeltaX"] = float(gradientTable[0][
"CENTROID_DELTA_X"][0])
324 inDict[
"centroidDeltaY"] = float(gradientTable[0][
"CENTROID_DELTA_Y"][0])
325 inDict[
"gradientX"] = float(gradientTable[0][
"GRADIENT_X"][0])
326 inDict[
"gradientY"] = float(gradientTable[0][
"GRADIENT_Y"][0])
327 inDict[
"normalizationFactor"] = float(gradientTable[0][
"NORMALIZATION_FACTOR"][0])
332 """Construct a list of table(s) containing the FlatGradient data.
336 tableList : `list` [`astropy.table.Table`]
337 List of tables containing the FlatGradient information.
346 "ITL_RATIO": np.array([self.
itlRatio]),
347 "CENTROID_X": np.array([self.
centroidX]),
348 "CENTROID_Y": np.array([self.
centroidY]),
351 "GRADIENT_X": np.array([self.
gradientX]),
352 "GRADIENT_Y": np.array([self.
gradientY]),
358 outMeta = {k: v
for k, v
in inMeta.items()
if v
is not None}
359 outMeta.update({k:
"" for k, v
in inMeta.items()
if v
is None})
360 catalog.meta = outMeta
361 tableList.append(catalog)
updateMetadata(self, camera=None, detector=None, filterName=None, setCalibId=False, setCalibInfo=False, setDate=False, **kwargs)
float normalizationFactor
fromTable(cls, tableList)
computeRadialSplineModelXY(self, x, y)
fromDict(cls, dictionary)
computeFullModel(self, x, y, is_itl)
setParameters(self, *, radialSplineNodes, radialSplineValues, itlRatio=1.0, centroidX=0.0, centroidY=0.0, centroidDeltaX=0.0, centroidDeltaY=0.0, gradientX=0.0, gradientY=0.0, normalizationFactor=1.0)
computeGradientModel(self, x, y)
computeRadialSplineModel(self, radius)