LSST Applications g0265f82a02+093ff98f47,g02d81e74bb+10352d6f39,g1f3e9fa97e+40b0fc677d,g2079a07aa2+14824f138e,g2bbee38e9b+093ff98f47,g337abbeb29+093ff98f47,g3ddfee87b4+064c02c7ee,g487adcacf7+7e842ebf4b,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g568d43a26c+1d7ac31cb0,g591dd9f2cf+fb1f69e2ea,g858d7b2824+10352d6f39,g8a8a8dda67+a6fc98d2e7,g8cdfe0ae6a+66d966b544,g99cad8db69+7ce8a7c20a,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga2e4dd1c03+064c02c7ee,ga8c6da7877+04f6ba86dc,gae46bcf261+093ff98f47,gb0e22166c9+3863383f4c,gba4ed39666+9664299f35,gbb8dafda3b+db40f59a7d,gbeb006f7da+e6a448e96d,gbf5cecdb8a+10352d6f39,gc0f3af6251+10a3fd39cd,gc120e1dc64+5839e50a77,gc28159a63d+093ff98f47,gcf0d15dbbd+064c02c7ee,gd2a12a3803+0c2c227a2b,gdaeeff99f8+a38ce5ea23,ge79ae78c31+093ff98f47,gee10cc3b42+a6fc98d2e7,gf1cff7945b+10352d6f39,w.2024.15
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
lsst::meas::extensions::trailedSources::VeresModel Class Referencefinal

Implementation of an axisymmetric 2D Gaussian convolved with a line – a model for a fast-moving, trailed-source (Veres et al. More...

#include <VeresModel.h>

Public Types

using ImageF = afw::image::Image<float>
 
using ExposureF = afw::image::Exposure<float>
 

Public Member Functions

 VeresModel (ExposureF const &data)
 Constructor for VeresModel.
 
 VeresModel (VeresModel const &)=default
 
 VeresModel (VeresModel &&)=default
 
VeresModeloperator= (VeresModel const &)=default
 
VeresModeloperator= (VeresModel &&)=default
 
 ~VeresModel ()=default
 
double operator() (std::vector< double > const &params) const
 Compute chi-squared of the model given the data.
 
std::vector< double > gradient (std::vector< double > const &params) const
 Compute the gradient of chi-squared of the model given the data.
 
std::tuple< double, std::vector< double > > computeFluxWithGradient (std::vector< double > const &params) const
 Computes the flux and the gradient with respect to the other model parameters.
 
std::shared_ptr< ImageFcomputeModelImage (std::vector< double > const &params) const
 Compute an image for a trail generated from the Veres model.
 
double getSigma () const noexcept
 Return the PSF sigma.
 

Detailed Description

Implementation of an axisymmetric 2D Gaussian convolved with a line – a model for a fast-moving, trailed-source (Veres et al.

2012).

VeresModel is designed to compute the chi-squared of the model given an lsst::afw::image::Exposure.

Definition at line 47 of file VeresModel.h.

Member Typedef Documentation

◆ ExposureF

Definition at line 50 of file VeresModel.h.

◆ ImageF

Definition at line 49 of file VeresModel.h.

Constructor & Destructor Documentation

◆ VeresModel() [1/3]

lsst::meas::extensions::trailedSources::VeresModel::VeresModel ( ExposureF const & data)
explicit

Constructor for VeresModel.

Parameters
dataExposure passed from the measurement task.

Definition at line 39 of file VeresModel.cc.

41 : _sigma(data.getPsf()->computeShape(data.getPsf()->getAveragePosition()).getTraceRadius()),
42 _bbox(data.getBBox()),
43 _data(data.getMaskedImage().getImage()->getArray()),
44 _variance(data.getMaskedImage().getVariance()->getArray()) {}
char * data
Definition BaseRecord.cc:61

◆ VeresModel() [2/3]

lsst::meas::extensions::trailedSources::VeresModel::VeresModel ( VeresModel const & )
default

◆ VeresModel() [3/3]

lsst::meas::extensions::trailedSources::VeresModel::VeresModel ( VeresModel && )
default

◆ ~VeresModel()

lsst::meas::extensions::trailedSources::VeresModel::~VeresModel ( )
default

Member Function Documentation

◆ computeFluxWithGradient()

std::tuple< double, std::vector< double > > lsst::meas::extensions::trailedSources::VeresModel::computeFluxWithGradient ( std::vector< double > const & params) const

Computes the flux and the gradient with respect to the other model parameters.

We estimate the flux by solving the linear least-squares problem for the Veres et al. 2012 model. By keeping the length, angle, and centroid coordinates fixed, we analytically solve for the flux.

Parameters
paramsModel parameters.
Returns
The flux and the gradient with respect to the model parameters.
Note
The params vector contains the following model parameters:
  • Centroid x: X-coordinate of the centroid in given image [pixels].
  • Centroid y: Y-coordinate of the centroid in given image [pixels].
  • Flux: Total flux in the trail [count].
  • Length: Length of the trail [pixels].
  • Angle: Angle from the +x-axis [radians].

Definition at line 95 of file VeresModel.cc.

95 {
96
97 double xc = params[0]; // Centroid x
98 double yc = params[1]; // Centroid y
99 // double flux = params[2]; // Flux (in this case, always 1)
100 double length = params[3]; // Trail length
101 double theta = params[4]; // Angle from +x-axis
102
103 // Compute the flux and gradient wrt the other model parameters
104 double m2 = 0.0; // sum_i model_i*model_i
105 double md = 0.0; // sum_i model_i*data_i
106 std::vector<double> gradmd = {0.0, 0.0, 0.0, 0.0, 0.0}; // sum_i (gradModel_(i,k)*data_i)
107 std::vector<double> gradmm = {0.0, 0.0, 0.0, 0.0, 0.0}; // sum_i (gradModel_(i,k)*model_i)
108 for (int yIndex = 0, yp = _bbox.getBeginY(); yIndex < _bbox.getHeight(); ++yIndex, ++yp) {
109 ImageF::Array::Reference dataRow = _data[yIndex];
110 for (int xIndex = 0, xp = _bbox.getBeginX(); xIndex < _bbox.getWidth(); ++xIndex, ++xp) {
111 double data = dataRow[xIndex];
112 double model = _computeModel(xp, yp, xc, yc, 1.0, length, theta);
113 std::array<double, 5> gradModel = _computeGradient(xp, yp, xc, yc, 1.0, length, theta);
114 m2 += model*model;
115 md += model*dataRow[xIndex];
116 for (int k=0; k<5; ++k) {
117 gradmd[k] += gradModel[k] * data;
118 gradmm[k] += gradModel[k] * model;
119 }
120 }
121 }
122 double flux = md / m2;
123 std::vector<double> gradFlux = {0.0, 0.0, 0.0, 0.0, 0.0};
124 for (int k=0; k<5; ++k) {
125 gradFlux[k] = (gradmd[k] - 2.0*flux*gradmm[k]) / m2;
126 }
127 gradFlux[2] = 0.0; // Make dfluxdflux = 0
129 return results;
130}
int getBeginX() const noexcept
Definition Box.h:172
int getHeight() const noexcept
Definition Box.h:188
int getWidth() const noexcept
Definition Box.h:187
int getBeginY() const noexcept
Definition Box.h:173
T make_tuple(T... args)

◆ computeModelImage()

std::shared_ptr< ImageF > lsst::meas::extensions::trailedSources::VeresModel::computeModelImage ( std::vector< double > const & params) const

Compute an image for a trail generated from the Veres model.

Definition at line 132 of file VeresModel.cc.

132 {
133 double xc = params[0]; // Centroid x
134 double yc = params[1]; // Centroid y
135 double flux = params[2]; // Flux
136 double length = params[3]; // Trail length
137 double theta = params[4]; // Angle from +x-axis
138
139 // Loop is adapted from lsst::afw::detection::GaussianPsf::doComputeKernelImage()
141 ImageF::Array array = image->getArray();
142 for (int yIndex = 0, yp = _bbox.getBeginY(); yIndex < _bbox.getHeight(); ++yIndex, ++yp) {
143 ImageF::Array::Reference row = array[yIndex];
144 for (int xIndex = 0, xp = _bbox.getBeginX(); xIndex < _bbox.getWidth(); ++xIndex, ++xp) {
145 row[xIndex] = _computeModel(xp,yp,xc,yc,flux,length,theta);
146 }
147 }
148 return image;
149}
afw::table::Key< afw::table::Array< ImagePixelT > > image
typename ndarray::Array< PixelT, 2, 1 > Array
A mutable ndarray representation of the image.
Definition ImageBase.h:149
int row
Definition CR.cc:145

◆ getSigma()

double lsst::meas::extensions::trailedSources::VeresModel::getSigma ( ) const
inlinenoexcept

Return the PSF sigma.

Definition at line 122 of file VeresModel.h.

122{ return _sigma; }

◆ gradient()

std::vector< double > lsst::meas::extensions::trailedSources::VeresModel::gradient ( std::vector< double > const & params) const

Compute the gradient of chi-squared of the model given the data.

Parameters
paramsModel parameters.
Returns
The gradient of chi-squared of the model with respect to the model parameters.
Note
The params vector contains the following model parameters:
  • Centroid x: X-coordinate of the centroid in given image [pixels].
  • Centroid y: Y-coordinate of the centroid in given image [pixels].
  • Flux: Total flux in the trail [count].
  • Length: Length of the trail [pixels].
  • Angle: Angle from the +x-axis [radians].

Definition at line 70 of file VeresModel.cc.

70 {
71
72 double xc = params[0]; // Centroid x
73 double yc = params[1]; // Centroid y
74 double flux = params[2]; // Flux
75 double length = params[3]; // Trail length
76 double theta = params[4]; // Angle from +x-axis
77
78 // Compute gradients of the model and of chi-squared
79 std::vector<double> gradChiSq = {0.0,0.0,0.0,0.0,0.0};
80 for (int yIndex = 0, yp = _bbox.getBeginY(); yIndex < _bbox.getHeight(); ++yIndex, ++yp) {
81 ImageF::Array::Reference dataRow = _data[yIndex];
82 ImageF::Array::Reference varRow = _variance[yIndex];
83 for (int xIndex = 0, xp = _bbox.getBeginX(); xIndex < _bbox.getWidth(); ++xIndex, ++xp) {
84 double model = _computeModel(xp,yp,xc,yc,flux,length,theta);
85 double gradDiff = -2.0 * (dataRow[xIndex] - model) / varRow[xIndex];
86 std::array<double, 5> gradModel = _computeGradient(xp,yp,xc,yc,flux,length,theta);
87 for (int k=0; k<5; ++k) {
88 gradChiSq[k] += gradModel[k] * gradDiff;
89 }
90 }
91 }
92 return gradChiSq;
93}

◆ operator()()

double lsst::meas::extensions::trailedSources::VeresModel::operator() ( std::vector< double > const & params) const

Compute chi-squared of the model given the data.

Parameters
paramsModel parameters.
Returns
The chi-squared of the model.
Note
The params vector contains the following model parameters:
  • Centroid x: X-coordinate of the centroid in given image [pixels].
  • Centroid y: Y-coordinate of the centroid in given image [pixels].
  • Flux: Total flux in the trail [count].
  • Length: Length of the trail [pixels].
  • Angle: Angle from the +x-axis [radians].

Definition at line 46 of file VeresModel.cc.

46 {
47
48 double xc = params[0]; // Centroid x
49 double yc = params[1]; // Centroid y
50 double flux = params[2]; // Flux
51 double length = params[3]; // Trail length
52 double theta = params[4]; // Angle from +x-axis
53
54 // Compute model image and chi-squared
55 double chiSq = 0.0;
56 // Loop is adapted from lsst::afw::detection::Psf::computeKernelImage()
57 for (int yIndex = 0, yp = _bbox.getBeginY(); yIndex < _bbox.getHeight(); ++yIndex, ++yp) {
58 ImageF::Array::Reference dataRow = _data[yIndex];
59 ImageF::Array::Reference varRow = _variance[yIndex];
60 for (int xIndex = 0, xp = _bbox.getBeginX(); xIndex < _bbox.getWidth(); ++xIndex, ++xp) {
61 double model = _computeModel(xp,yp,xc,yc,flux,length,theta);
62 double diff = dataRow[xIndex] - model;
63 chiSq += diff*diff/varRow[xIndex];
64 }
65 }
66
67 return chiSq;
68}

◆ operator=() [1/2]

VeresModel & lsst::meas::extensions::trailedSources::VeresModel::operator= ( VeresModel && )
default

◆ operator=() [2/2]

VeresModel & lsst::meas::extensions::trailedSources::VeresModel::operator= ( VeresModel const & )
default

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