39class AmpInfoBoxKey :
public table::FunctorKey<lsst::geom::Box2I> {
61 schema.join(name,
"min"),
67 schema.join(name,
"extent"),
75 AmpInfoBoxKey() noexcept = default;
85 AmpInfoBoxKey(table::SubSchema const& s) : _min(s["
min"]), _dimensions(s["extent"]) {}
87 AmpInfoBoxKey(AmpInfoBoxKey
const&)
noexcept =
default;
88 AmpInfoBoxKey(AmpInfoBoxKey&&) noexcept = default;
89 AmpInfoBoxKey& operator=(AmpInfoBoxKey const&) noexcept = default;
90 AmpInfoBoxKey& operator=(AmpInfoBoxKey&&) noexcept = default;
91 ~AmpInfoBoxKey() noexcept override = default;
94 lsst::
geom::Box2I get(table::BaseRecord const& record)
const override {
101 record.set(_min,
value.getMin());
106 bool isValid() const noexcept {
return _min.isValid() && _dimensions.isValid(); }
114struct RecordSchemaHelper {
115 table::Schema schema;
116 table::Key<std::string> name;
138 static RecordSchemaHelper
const & getMinimal() {
139 static RecordSchemaHelper
const instance;
143 RecordSchemaHelper(table::Schema
const & existing) :
145 name(schema[
"name"]),
146 bbox(schema[
"bbox"]),
147 gain(schema[
"gain"]),
164 auto setKeyIfPresent = [
this](
auto & key,
std::string const & name) {
167 }
catch (pex::exceptions::NotFoundError &) {}
175 setKeyIfPresent(linearityThreshold,
"linearityThreshold");
176 setKeyIfPresent(linearityMaximum,
"linearityMaximum");
177 setKeyIfPresent(linearityUnits,
"linearityUnits");
182 RecordSchemaHelper() :
184 name(schema.addField<
std::string>(
"name",
"name of amplifier location in camera",
"", 0)),
185 bbox(AmpInfoBoxKey::addFields(
186 schema,
"bbox",
"bbox of amplifier image data on assembled image",
"pixel")),
187 gain(schema.addField<double>(
"gain",
"amplifier gain",
"electron adu^-1")),
190 "level above which pixels are considered saturated; use `nan` if no such level applies",
194 "level above which pixels are considered suspicious, meaning they may be affected by unknown "
195 "systematics; for example if non-linearity corrections above a certain level are unstable "
196 "then that would be a useful value for suspectLevel; use `nan` if no such level applies",
198 readNoise(schema.addField<double>(
"readnoise",
"amplifier read noise",
"electron")),
200 schema.addField<
int>(
"readoutcorner",
"readout corner, in the frame of the assembled image")),
202 schema.addField<table::Array<double> >(
"linearity_coeffs",
203 "coefficients for linearity fit up to cubic",
"", 0)),
204 linearityType(schema.addField<
std::string>(
"linearity_type",
"type of linearity model",
"", 0)),
206 "hasrawinfo",
"is raw amplifier information available (e.g. untrimmed bounding boxes)?")),
207 rawBBox(AmpInfoBoxKey::addFields(schema,
"raw_bbox",
208 "entire amplifier bbox on raw image",
"pixel")),
209 rawDataBBox(AmpInfoBoxKey::addFields(schema,
"raw_databbox",
210 "image data bbox on raw image",
"pixel")),
211 rawFlipX(schema.addField<table::Flag>(
"raw_flip_x",
"flip row order to make assembled image?")),
212 rawFlipY(schema.addField<table::Flag>(
"raw_flip_y",
"flip column order to make an assembled image?")),
214 schema,
"raw_xyoffset",
215 "offset for assembling a raw CCD image: desired xy0 - raw xy0; 0,0 if raw data comes assembled",
218 AmpInfoBoxKey::addFields(schema,
"raw_horizontaloverscanbbox",
219 "usable horizontal overscan bbox on raw image",
"pixel")),
221 AmpInfoBoxKey::addFields(schema,
"raw_verticaloverscanbbox",
222 "usable vertical overscan region raw image",
"pixel")),
224 AmpInfoBoxKey::addFields(schema,
"raw_prescanbbox",
225 "usable (horizontal) prescan bbox on raw image",
"pixel")),
227 "Minimum ADU level to apply linearity.")),
229 "Maximum ADU level to apply linearity.")),
231 "Input units for linearity relation.",
"", 0))
239class FrozenAmplifier final :
public Amplifier {
242 explicit FrozenAmplifier(Fields
const & fields) : _fields(fields) {}
247 FrozenAmplifier(FrozenAmplifier
const &) =
delete;
248 FrozenAmplifier(FrozenAmplifier &&) =
delete;
250 FrozenAmplifier & operator=(FrozenAmplifier
const &) =
delete;
251 FrozenAmplifier & operator=(FrozenAmplifier &&) =
delete;
253 ~FrozenAmplifier() noexcept override = default;
257 Fields const & getFields()
const override {
return _fields; }
261 Fields
const _fields;
268 return RecordSchemaHelper::getMinimal().schema;
283 return std::make_shared<FrozenAmplifier>(_fields);
287 auto const helper = RecordSchemaHelper(record.
getSchema());
292 result.setReadNoise(record.
get(helper.readNoise));
293 result.setSaturation(record.
get(helper.saturation));
294 result.setSuspectLevel(record.
get(helper.suspectLevel));
296 result.setLinearityCoeffs(ndarray::copy(record.
get(helper.linearityCoeffs)));
297 result.setLinearityType(record.
get(helper.linearityType));
298 result.setRawBBox(record.
get(helper.rawBBox));
299 result.setRawDataBBox(record.
get(helper.rawDataBBox));
300 result.setRawFlipX(record.
get(helper.rawFlipX));
301 result.setRawFlipY(record.
get(helper.rawFlipY));
303 result.setRawHorizontalOverscanBBox(record.
get(helper.rawHorizontalOverscanBBox));
304 result.setRawVerticalOverscanBBox(record.
get(helper.rawVerticalOverscanBBox));
305 result.setRawHorizontalOverscanBBox(record.
get(helper.rawHorizontalOverscanBBox));
306 result.setRawPrescanBBox(record.
get(helper.rawPrescanBBox));
311 auto setIfValid = [&record](
auto & member,
auto & key) {
313 member = record.
get(key);
316 setIfValid(
result._fields.linearityThreshold, helper.linearityThreshold);
317 setIfValid(
result._fields.linearityMaximum, helper.linearityMaximum);
318 setIfValid(
result._fields.linearityUnits, helper.linearityUnits);
323 auto const helper = RecordSchemaHelper(record.
getSchema());
325 record.
set(helper.name, fields.name);
326 record.
set(helper.bbox, fields.bbox);
327 record.
set(helper.gain, fields.gain);
328 record.
set(helper.readNoise, fields.readNoise);
329 record.
set(helper.saturation, fields.saturation);
330 record.
set(helper.suspectLevel, fields.suspectLevel);
331 record.
set(helper.readoutCorner,
static_cast<int>(fields.readoutCorner));
332 ndarray::Array<double, 1, 1> coeffs = ndarray::copy(fields.linearityCoeffs);
333 record.
set(helper.linearityCoeffs, coeffs);
334 record.
set(helper.linearityType, fields.linearityType);
335 record.
set(helper.rawBBox, fields.rawBBox);
336 record.
set(helper.rawDataBBox, fields.rawDataBBox);
337 record.
set(helper.rawFlipX, fields.rawFlipX);
338 record.
set(helper.rawFlipY, fields.rawFlipY);
340 record.
set(helper.rawHorizontalOverscanBBox, fields.rawHorizontalOverscanBBox);
341 record.
set(helper.rawVerticalOverscanBBox, fields.rawVerticalOverscanBBox);
342 record.
set(helper.rawPrescanBBox, fields.rawPrescanBBox);
344 auto setIfValid = [&record](
auto value,
auto & key) {
346 record.
set(key, value);
349 setIfValid(fields.linearityThreshold, helper.linearityThreshold);
350 setIfValid(fields.linearityMaximum, helper.linearityMaximum);
351 setIfValid(fields.linearityUnits, helper.linearityUnits);
table::Key< double > linearityThreshold
table::Key< table::Flag > hasRawInfo
table::Key< std::string > linearityType
table::Key< double > gain
table::Key< table::Array< double > > linearityCoeffs
table::Key< std::string > linearityUnits
AmpInfoBoxKey rawVerticalOverscanBBox
AmpInfoBoxKey rawHorizontalOverscanBBox
table::Key< double > saturation
table::Key< double > readNoise
table::Key< table::Flag > rawFlipX
table::Key< int > readoutCorner
table::PointKey< int > rawXYOffset
table::Key< table::Flag > rawFlipY
table::Key< double > suspectLevel
AmpInfoBoxKey rawDataBBox
AmpInfoBoxKey rawPrescanBBox
table::Key< double > linearityMaximum
A mutable Amplifier subclass class that can be used to incrementally construct or modify Amplifiers.
Builder & operator=(Builder const &)=default
Standard copy assignment.
Builder()=default
Construct a Builder with default values for all fields.
static Builder fromRecord(table::BaseRecord const &record)
Construct a new Builder object from the fields in the given record.
std::shared_ptr< Amplifier const > finish() const
Construct an immutable Amplifier with the same values as the Builder.
void setName(std::string const &name)
Name of the amplifier.
Geometry and electronic information about raw amplifier images.
Builder rebuild() const
Return a Builder object initialized with the fields of this.
virtual Fields const & getFields() const =0
void toRecord(table::BaseRecord &record) const
Copy the Amplifier's fields into the given record.
static table::Schema getRecordSchema()
Return the schema used in the afw.table representation of amplifiers.
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Schema getSchema() const
Return the Schema that holds this record's fields and keys.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y fields to a Schema, and return a PointKey that points to them.
Defines the fields and offsets for a table.
An integer coordinate rectangle.
daf::base::PropertySet * set
ReadoutCorner
Readout corner, in the frame of reference of the assembled image.
void swap(CameraSys &a, CameraSys &b)
PointKey< int > Point2IKey