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 Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
lsst.meas.algorithms.simple_curve.Curve Class Reference
Inheritance diagram for lsst.meas.algorithms.simple_curve.Curve:
lsst.meas.algorithms.simple_curve.AmpCurve lsst.meas.algorithms.simple_curve.DetectorCurve lsst.meas.algorithms.simple_curve.ImageCurve

Public Member Functions

 __init__ (self, wavelength, efficiency, metadata)
 
 fromTable (cls, table)
 
 toTable (self)
 
 evaluate (self, detector, position, wavelength, kind='linear', bounds_error=False, fill_value=0)
 
 __init_subclass__ (cls, **kwargs)
 
 __eq__ (self, other)
 
 compare_metadata (self, other, keys_to_compare=['MODE', 'TYPE', 'CALIBDATE', 'INSTRUME', 'OBSTYPE', 'DETECTOR'])
 
 interpolate (self, wavelengths, values, wavelength, kind, bounds_error, fill_value)
 
 getMetadata (self)
 
 readText (cls, filename)
 
 readFits (cls, filename)
 
 writeText (self, filename)
 
 writeFits (self, filename)
 

Public Attributes

 wavelength
 
 efficiency
 
 mode
 
 metadata
 

Static Public Attributes

str mode = ''
 
 subclasses = dict()
 

Protected Member Functions

 _to_table_with_meta (self)
 

Static Protected Member Functions

 _check_cols (cols, table)
 

Detailed Description

 An abstract class to represent an arbitrary curve with
interpolation.

Definition at line 38 of file simple_curve.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.algorithms.simple_curve.Curve.__init__ ( self,
wavelength,
efficiency,
metadata )

Reimplemented in lsst.meas.algorithms.simple_curve.AmpCurve.

Definition at line 45 of file simple_curve.py.

45 def __init__(self, wavelength, efficiency, metadata):
46 if not (isinstance(wavelength, u.Quantity) and wavelength.unit.physical_type == 'length'):
47 raise ValueError('The wavelength must be a quantity with a length sense.')
48 if not isinstance(efficiency, u.Quantity) or efficiency.unit != u.percent:
49 raise ValueError('The efficiency must be a quantity with units of percent.')
50 self.wavelength = wavelength
51 self.efficiency = efficiency
52 # make sure needed metadata is set if built directly from ctor.
53 metadata.update({'MODE': self.mode, 'TYPE': 'QE'})
54 self.metadata = metadata
55

Member Function Documentation

◆ __eq__()

lsst.meas.algorithms.simple_curve.Curve.__eq__ ( self,
other )
Define equality for this class

Reimplemented in lsst.meas.algorithms.simple_curve.DetectorCurve, and lsst.meas.algorithms.simple_curve.AmpCurve.

Definition at line 134 of file simple_curve.py.

134 def __eq__(self, other):
135 """Define equality for this class"""
136 pass
137

◆ __init_subclass__()

lsst.meas.algorithms.simple_curve.Curve.__init_subclass__ ( cls,
** kwargs )
Register subclasses with the abstract base class

Definition at line 126 of file simple_curve.py.

126 def __init_subclass__(cls, **kwargs):
127 """Register subclasses with the abstract base class"""
128 super().__init_subclass__(**kwargs)
129 if cls.mode in Curve.subclasses:
130 raise ValueError(f'Class for mode, {cls.mode}, already defined')
131 Curve.subclasses[cls.mode] = cls
132

◆ _check_cols()

lsst.meas.algorithms.simple_curve.Curve._check_cols ( cols,
table )
staticprotected
Check that the columns are in the table

Definition at line 237 of file simple_curve.py.

237 def _check_cols(cols, table):
238 """Check that the columns are in the table"""
239 for col in cols:
240 if col not in table.columns:
241 raise ValueError(f'The table must include a column named "{col}".')
242

◆ _to_table_with_meta()

lsst.meas.algorithms.simple_curve.Curve._to_table_with_meta ( self)
protected
Compute standard metadata before writing file out

Definition at line 243 of file simple_curve.py.

243 def _to_table_with_meta(self):
244 """Compute standard metadata before writing file out"""
245 now = datetime.datetime.utcnow()
246 table = self.toTable()
247 metadata = table.meta
248 metadata["DATE"] = now.isoformat()
249 metadata["CALIB_CREATION_DATE"] = now.strftime("%Y-%m-%d")
250 metadata["CALIB_CREATION_TIME"] = now.strftime("%T %Z").strip()
251 return table
252
bool strip
Definition fits.cc:930

◆ compare_metadata()

lsst.meas.algorithms.simple_curve.Curve.compare_metadata ( self,
other,
keys_to_compare = ['MODE', 'TYPE', 'CALIBDATE', 'INSTRUME', 'OBSTYPE', 'DETECTOR'] )
Compare metadata in this object to another.

Parameters
----------
other : `Curve`
    The object with which to compare metadata.
keys_to_compare : `list`
    List of metadata keys to compare.

Returns
-------
same : `bool`
    Are the metadata the same?

Definition at line 138 of file simple_curve.py.

139 keys_to_compare=['MODE', 'TYPE', 'CALIBDATE', 'INSTRUME', 'OBSTYPE', 'DETECTOR']):
140 """Compare metadata in this object to another.
141
142 Parameters
143 ----------
144 other : `Curve`
145 The object with which to compare metadata.
146 keys_to_compare : `list`
147 List of metadata keys to compare.
148
149 Returns
150 -------
151 same : `bool`
152 Are the metadata the same?
153 """
154 for k in keys_to_compare:
155 if self.metadata[k] != other.metadata[k]:
156 return False
157 return True
158

◆ evaluate()

lsst.meas.algorithms.simple_curve.Curve.evaluate ( self,
detector,
position,
wavelength,
kind = 'linear',
bounds_error = False,
fill_value = 0 )
Interpolate the curve at the specified position and wavelength.

Parameters
----------
detector : `lsst.afw.cameraGeom.Detector`
    Is used to find the appropriate curve given the position for
    curves that vary over the detector.  Ignored in the case where
    there is only a single curve per detector.
position : `lsst.geom.Point2D`
    The position on the detector at which to evaluate the curve.
wavelength : `astropy.units.Quantity`
    The wavelength(s) at which to make the interpolation.
kind : `str`, optional
    The type of interpolation to do (default is 'linear').
    See documentation for `scipy.interpolate.interp1d` for
    accepted values.
bounds_error : `bool`, optional
    Raise error if interpolating outside the range of x?
    (default is False)
fill_value : `float`, optional
    Fill values outside the range of x with this value
    (default is 0).

Returns
-------
value : `astropy.units.Quantity`
    Interpolated value(s).  Number of values returned will match the
    length of `wavelength`.

Raises
------
ValueError
    If the ``bounds_error`` is changed from the default, it will raise
    a `ValueError` if evaluating outside the bounds of the curve.

Reimplemented in lsst.meas.algorithms.simple_curve.DetectorCurve, lsst.meas.algorithms.simple_curve.AmpCurve, and lsst.meas.algorithms.simple_curve.ImageCurve.

Definition at line 87 of file simple_curve.py.

87 def evaluate(self, detector, position, wavelength, kind='linear', bounds_error=False, fill_value=0):
88 """Interpolate the curve at the specified position and wavelength.
89
90 Parameters
91 ----------
92 detector : `lsst.afw.cameraGeom.Detector`
93 Is used to find the appropriate curve given the position for
94 curves that vary over the detector. Ignored in the case where
95 there is only a single curve per detector.
96 position : `lsst.geom.Point2D`
97 The position on the detector at which to evaluate the curve.
98 wavelength : `astropy.units.Quantity`
99 The wavelength(s) at which to make the interpolation.
100 kind : `str`, optional
101 The type of interpolation to do (default is 'linear').
102 See documentation for `scipy.interpolate.interp1d` for
103 accepted values.
104 bounds_error : `bool`, optional
105 Raise error if interpolating outside the range of x?
106 (default is False)
107 fill_value : `float`, optional
108 Fill values outside the range of x with this value
109 (default is 0).
110
111 Returns
112 -------
113 value : `astropy.units.Quantity`
114 Interpolated value(s). Number of values returned will match the
115 length of `wavelength`.
116
117 Raises
118 ------
119 ValueError
120 If the ``bounds_error`` is changed from the default, it will raise
121 a `ValueError` if evaluating outside the bounds of the curve.
122 """
123 pass
124

◆ fromTable()

lsst.meas.algorithms.simple_curve.Curve.fromTable ( cls,
table )
Class method for constructing a `Curve` object.

Parameters
----------
table : `astropy.table.QTable`
    Table containing metadata and columns necessary
    for constructing a `Curve` object.

Returns
-------
curve : `Curve`
    A `Curve` subclass of the appropriate type according
    to the table metadata

Reimplemented in lsst.meas.algorithms.simple_curve.DetectorCurve, lsst.meas.algorithms.simple_curve.AmpCurve, and lsst.meas.algorithms.simple_curve.ImageCurve.

Definition at line 58 of file simple_curve.py.

58 def fromTable(cls, table):
59 """Class method for constructing a `Curve` object.
60
61 Parameters
62 ----------
63 table : `astropy.table.QTable`
64 Table containing metadata and columns necessary
65 for constructing a `Curve` object.
66
67 Returns
68 -------
69 curve : `Curve`
70 A `Curve` subclass of the appropriate type according
71 to the table metadata
72 """
73 pass
74

◆ getMetadata()

lsst.meas.algorithms.simple_curve.Curve.getMetadata ( self)
Return metadata

Returns
-------
metadata : `dict`
    Dictionary of metadata for this curve.

Definition at line 187 of file simple_curve.py.

187 def getMetadata(self):
188 """Return metadata
189
190 Returns
191 -------
192 metadata : `dict`
193 Dictionary of metadata for this curve.
194 """
195 # Needed to duck type as an object that can be ingested
196 return self.metadata
197

◆ interpolate()

lsst.meas.algorithms.simple_curve.Curve.interpolate ( self,
wavelengths,
values,
wavelength,
kind,
bounds_error,
fill_value )
Interplate the curve at the specified wavelength(s).

Parameters
----------
wavelengths : `astropy.units.Quantity`
    The wavelength values for the curve.
values : `astropy.units.Quantity`
    The y-values for the curve.
wavelength : `astropy.units.Quantity`
    The wavelength(s) at which to make the interpolation.
kind : `str`
    The type of interpolation to do.  See documentation for
    `scipy.interpolate.interp1d` for accepted values.

Returns
-------
value : `astropy.units.Quantity`
    Interpolated value(s)

Definition at line 159 of file simple_curve.py.

159 def interpolate(self, wavelengths, values, wavelength, kind, bounds_error, fill_value):
160 """Interplate the curve at the specified wavelength(s).
161
162 Parameters
163 ----------
164 wavelengths : `astropy.units.Quantity`
165 The wavelength values for the curve.
166 values : `astropy.units.Quantity`
167 The y-values for the curve.
168 wavelength : `astropy.units.Quantity`
169 The wavelength(s) at which to make the interpolation.
170 kind : `str`
171 The type of interpolation to do. See documentation for
172 `scipy.interpolate.interp1d` for accepted values.
173
174 Returns
175 -------
176 value : `astropy.units.Quantity`
177 Interpolated value(s)
178 """
179 if not isinstance(wavelength, u.Quantity):
180 raise ValueError("Wavelengths at which to interpolate must be astropy quantities")
181 if not (isinstance(wavelengths, u.Quantity) and isinstance(values, u.Quantity)):
182 raise ValueError("Model to be interpreted must be astropy quantities")
183 interp_wavelength = wavelength.to(wavelengths.unit)
184 f = interp1d(wavelengths, values, kind=kind, bounds_error=bounds_error, fill_value=fill_value)
185 return f(interp_wavelength.value)*values.unit
186

◆ readFits()

lsst.meas.algorithms.simple_curve.Curve.readFits ( cls,
filename )
Class method for constructing a `Curve` object from
the standardized FITS format.

Parameters
----------
filename : `str`
    Path to the FITS file to read.

Returns
-------
curve : `Curve`
    A `Curve` subclass of the appropriate type according
    to the table metadata

Definition at line 218 of file simple_curve.py.

218 def readFits(cls, filename):
219 """Class method for constructing a `Curve` object from
220 the standardized FITS format.
221
222 Parameters
223 ----------
224 filename : `str`
225 Path to the FITS file to read.
226
227 Returns
228 -------
229 curve : `Curve`
230 A `Curve` subclass of the appropriate type according
231 to the table metadata
232 """
233 table = QTable.read(filename, format='fits')
234 return cls.subclasses[table.meta['MODE']].fromTable(table)
235

◆ readText()

lsst.meas.algorithms.simple_curve.Curve.readText ( cls,
filename )
Class method for constructing a `Curve` object from
the standardized text format.

Parameters
----------
filename : `str`
    Path to the text file to read.

Returns
-------
curve : `Curve`
    A `Curve` subclass of the appropriate type according
    to the table metadata

Definition at line 199 of file simple_curve.py.

199 def readText(cls, filename):
200 """Class method for constructing a `Curve` object from
201 the standardized text format.
202
203 Parameters
204 ----------
205 filename : `str`
206 Path to the text file to read.
207
208 Returns
209 -------
210 curve : `Curve`
211 A `Curve` subclass of the appropriate type according
212 to the table metadata
213 """
214 table = QTable.read(filename, format='ascii.ecsv')
215 return cls.subclasses[table.meta['MODE']].fromTable(table)
216

◆ toTable()

lsst.meas.algorithms.simple_curve.Curve.toTable ( self)
Convert this `Curve` object to an `astropy.table.QTable`.

Returns
-------
table : `astropy.table.QTable`
    A table object containing the data from this `Curve`.

Reimplemented in lsst.meas.algorithms.simple_curve.DetectorCurve, lsst.meas.algorithms.simple_curve.AmpCurve, and lsst.meas.algorithms.simple_curve.ImageCurve.

Definition at line 76 of file simple_curve.py.

76 def toTable(self):
77 """Convert this `Curve` object to an `astropy.table.QTable`.
78
79 Returns
80 -------
81 table : `astropy.table.QTable`
82 A table object containing the data from this `Curve`.
83 """
84 pass
85

◆ writeFits()

lsst.meas.algorithms.simple_curve.Curve.writeFits ( self,
filename )
 Write the `Curve` out to a FITS file.

Parameters
----------
filename : `str`
    Path to the FITS file to write.

Returns
-------
filename : `str`
    Because this method forces a particular extension return
    the name of the file actually written.

Definition at line 274 of file simple_curve.py.

274 def writeFits(self, filename):
275 """ Write the `Curve` out to a FITS file.
276
277 Parameters
278 ----------
279 filename : `str`
280 Path to the FITS file to write.
281
282 Returns
283 -------
284 filename : `str`
285 Because this method forces a particular extension return
286 the name of the file actually written.
287 """
288 table = self._to_table_with_meta()
289 # Force file extension to .ecsv
290 path, ext = os.path.splitext(filename)
291 filename = path + ".fits"
292 table.write(filename, format="fits")
293 return filename
294
295

◆ writeText()

lsst.meas.algorithms.simple_curve.Curve.writeText ( self,
filename )
 Write the `Curve` out to a text file.

Parameters
----------
filename : `str`
    Path to the text file to write.

Returns
-------
filename : `str`
    Because this method forces a particular extension return
    the name of the file actually written.

Definition at line 253 of file simple_curve.py.

253 def writeText(self, filename):
254 """ Write the `Curve` out to a text file.
255
256 Parameters
257 ----------
258 filename : `str`
259 Path to the text file to write.
260
261 Returns
262 -------
263 filename : `str`
264 Because this method forces a particular extension return
265 the name of the file actually written.
266 """
267 table = self._to_table_with_meta()
268 # Force file extension to .ecsv
269 path, ext = os.path.splitext(filename)
270 filename = path + ".ecsv"
271 table.write(filename, format="ascii.ecsv")
272 return filename
273

Member Data Documentation

◆ efficiency

lsst.meas.algorithms.simple_curve.Curve.efficiency

Definition at line 51 of file simple_curve.py.

◆ metadata

lsst.meas.algorithms.simple_curve.Curve.metadata

Definition at line 54 of file simple_curve.py.

◆ mode [1/2]

str lsst.meas.algorithms.simple_curve.Curve.mode = ''
static

Definition at line 42 of file simple_curve.py.

◆ mode [2/2]

lsst.meas.algorithms.simple_curve.Curve.mode

Definition at line 53 of file simple_curve.py.

◆ subclasses

lsst.meas.algorithms.simple_curve.Curve.subclasses = dict()
static

Definition at line 43 of file simple_curve.py.

◆ wavelength

lsst.meas.algorithms.simple_curve.Curve.wavelength

Definition at line 50 of file simple_curve.py.


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