LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
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: