39class AmpInfoBoxKey :
public table::FunctorKey<lsst::geom::Box2I> {
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 {
138 static RecordSchemaHelper
const & getMinimal() {
139 static RecordSchemaHelper
const instance;
143 RecordSchemaHelper(table::Schema
const & existing) :
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)),
206 "hasrawinfo",
"is raw amplifier information available (e.g. untrimmed bounding boxes)?")),
208 "entire amplifier bbox on raw image",
"pixel")),
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?")),
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());
311 auto setIfValid = [&record](
auto & member,
auto & key) {
313 member = record.
get(key);
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< std::string > name
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.
void setSaturation(double saturation)
Level in ADU above which pixels are considered saturated; use nan if no such level applies.
void setBBox(lsst::geom::Box2I const &bbox)
Bounding box of amplifier pixels in the trimmed, assembled image.
Builder & operator=(Builder const &)=default
Standard copy assignment.
void setRawFlipY(bool rawFlipY)
Is this amplifier (and the image to which it is attached) flipped in the Y direction,...
Builder()=default
Construct a Builder with default values for all fields.
void setReadNoise(double readNoise)
Amplifier read noise, in e-.
void setLinearityCoeffs(ndarray::Array< double const, 1, 1 > const &coeffs)
Vector of linearity coefficients.
static Builder fromRecord(table::BaseRecord const &record)
Construct a new Builder object from the fields in the given record.
void setRawHorizontalOverscanBBox(lsst::geom::Box2I const &bbox)
The bounding box of horizontal overscan pixels in the image to which it is attached,...
void setRawFlipX(bool rawFlipX)
Is this amplifier (and the image to which it is attached) flipped in the X direction,...
void setGain(double gain)
Amplifier gain in e-/ADU.
void setReadoutCorner(ReadoutCorner readoutCorner)
Readout corner in the trimmed, assembled image.
void setRawDataBBox(lsst::geom::Box2I const &bbox)
Bounding box of amplifier data pixels in the image to which it is attached, which is assumed to be un...
std::shared_ptr< Amplifier const > finish() const
Construct an immutable Amplifier with the same values as the Builder.
void setSuspectLevel(double suspectLevel)
Level in ADU above which pixels are considered suspicious, meaning they may be affected by unknown sy...
void setLinearityType(std::string const &type)
Name of linearity parameterization.
void setRawVerticalOverscanBBox(lsst::geom::Box2I const &bbox)
The bounding box of vertical overscan pixels in the image to which it is attached,...
void setRawXYOffset(lsst::geom::Extent2I const &xy)
Offset in transformation from this amplifier (and the image to which it is attached) to trimmed,...
void setRawPrescanBBox(lsst::geom::Box2I const &bbox)
The bounding box of (horizontal) prescan pixels in the image to which it is attached,...
void setName(std::string const &name)
Name of the amplifier.
void setRawBBox(lsst::geom::Box2I const &bbox)
Bounding box of the untrimmed amplifier in the image to which it is attached, which is assumed to be ...
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.
Point2I const getMin() const noexcept
Extent2I const getDimensions() const noexcept
daf::base::PropertySet * set
ReadoutCorner
Readout corner, in the frame of reference of the assembled image.
PointKey< int > Point2IKey
double linearityThreshold
std::string linearityUnits