LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
MeasuredStar.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * This file is part of jointcal.
4  *
5  * Developed for the LSST Data Management System.
6  * This product includes software developed by the LSST Project
7  * (https://www.lsst.org).
8  * See the COPYRIGHT file at the top-level directory of this distribution
9  * for details of code ownership.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef LSST_JOINTCAL_MEASURED_STAR_H
26 #define LSST_JOINTCAL_MEASURED_STAR_H
27 
28 #include <iostream>
29 
30 #include "lsst/afw/table/misc.h"
31 #include "lsst/jointcal/BaseStar.h"
33 #include "lsst/jointcal/StarList.h"
34 
35 namespace lsst {
36 namespace jointcal {
37 
38 namespace {
39 double instMagFromInstFlux(double instFlux) { return -2.5 * std::log10(instFlux); }
40 } // namespace
41 
42 class CcdImage;
43 
46 class MeasuredStar : public BaseStar {
47 public:
49  : BaseStar(),
50  _id(0),
51  _instFlux(0.),
52  _instFluxErr(0.),
53  _ccdImage(0),
54  _valid(true),
55  _xFocal(0.0),
56  _yFocal(0.0),
57  _instMag(0.),
58  _instMagErr(0.) {}
59 
60  MeasuredStar(BaseStar const &baseStar)
61  : BaseStar(baseStar),
62  _id(0),
63  _instFlux(0.),
64  _instFluxErr(0.),
65  _ccdImage(0),
66  _valid(true),
67  _xFocal(0.0),
68  _yFocal(0.0),
69  _instMag(0.),
70  _instMagErr(0.) {}
71 
74  MeasuredStar(MeasuredStar const &) = default;
75  MeasuredStar(MeasuredStar &&) = delete;
76  MeasuredStar &operator=(MeasuredStar const &) = delete;
77  MeasuredStar &operator=(MeasuredStar &&) = delete;
78 
80  if (fittedStar) fittedStar->getMeasurementCount()++;
81  _fittedStar = std::move(fittedStar);
82  }
83 
84  void dump(std::ostream &stream = std::cout) const {
86  stream << " instFlux: " << _instFlux << " instFluxErr: " << _instFluxErr << " id: " << _id
87  << " valid: " << _valid;
88  }
89 
90  void setInstFluxAndErr(double instFlux, double instFluxErr) {
91  _instFlux = instFlux;
92  _instMag = instMagFromInstFlux(instFlux);
93  _instFluxErr = instFluxErr;
94  _instMagErr = magErrFromFluxErr(instFlux, instFluxErr);
95  }
96 
97  double getInstFlux() const { return _instFlux; }
98  double getInstFluxErr() const { return _instFluxErr; }
99  double getInstMag() const { return _instMag; }
100  double getInstMagErr() const { return _instMagErr; }
101 
102  void setId(afw::table::RecordId id) { _id = id; }
103  afw::table::RecordId getId() { return _id; }
104 
106  double getMagWeight() const { return (_instFlux * _instFlux / (_instFluxErr * _instFluxErr)); }
107 
108  double getXFocal() const { return _xFocal; }
109  void setXFocal(double xFocal) { _xFocal = xFocal; }
110  double getYFocal() const { return _yFocal; }
111  void setYFocal(double yFocal) { _yFocal = yFocal; }
112 
113  std::shared_ptr<FittedStar> getFittedStar() const { return _fittedStar; };
114 
115  CcdImage const &getCcdImage() const { return *_ccdImage; };
116 
117  void setCcdImage(const CcdImage *ccdImage) { _ccdImage = ccdImage; };
118 
120  bool isValid() const { return _valid; }
122  void setValid(bool v) { _valid = v; }
123 
124 private:
125  afw::table::RecordId _id; // id in original catalog
126 
127  // on-chip flux, in ADU
128  double _instFlux;
129  double _instFluxErr;
130 
131  const CcdImage *_ccdImage;
132  // Note: _fittedStar is not const, but measuredStar won't modify it.
133  std::shared_ptr<FittedStar> _fittedStar;
134  bool _valid;
135 
136  double _xFocal, _yFocal;
137 
138  // on-sensor "magnitudes", used when fitting the MagnitudeModel.
139  double _instMag;
140  double _instMagErr;
141 };
142 
143 /****** MeasuredStarList */
144 
146 class MeasuredStarList : public StarList<MeasuredStar> {
147 public:
149 
150  void setCcdImage(const CcdImage *_ccdImage);
151 };
152 
153 typedef MeasuredStarList::const_iterator MeasuredStarCIterator;
154 typedef MeasuredStarList::iterator MeasuredStarIterator;
155 
158 const BaseStarList &Measured2Base(const MeasuredStarList &This);
159 const BaseStarList *Measured2Base(const MeasuredStarList *This);
160 } // namespace jointcal
161 } // namespace lsst
162 
163 #endif // LSST_JOINTCAL_MEASURED_STAR_H
void setXFocal(double xFocal)
Definition: MeasuredStar.h:109
virtual void dump(std::ostream &stream=std::cout) const
utility
Definition: BaseStar.h:82
MeasuredStarList::iterator MeasuredStarIterator
Definition: MeasuredStar.h:154
MeasuredStar(BaseStar const &baseStar)
Definition: MeasuredStar.h:60
CcdImage const & getCcdImage() const
Definition: MeasuredStar.h:115
MeasuredStar & operator=(MeasuredStar const &)=delete
void setCcdImage(const CcdImage *ccdImage)
Definition: MeasuredStar.h:117
table::Key< int > id
Definition: Detector.cc:162
T log10(T... args)
A list of MeasuredStar. They are usually filled in Associations::createCcdImage.
Definition: MeasuredStar.h:146
void setYFocal(double yFocal)
Definition: MeasuredStar.h:111
The base class for handling stars. Used by all matching routines.
Definition: BaseStar.h:50
afw::table::RecordId getId()
Definition: MeasuredStar.h:103
void dump(std::ostream &stream=std::cout) const
utility
Definition: MeasuredStar.h:84
std::lists of Stars.
Definition: StarList.h:58
void setFittedStar(std::shared_ptr< FittedStar > fittedStar)
Definition: MeasuredStar.h:79
A base class for image defects.
MeasuredStarList::const_iterator MeasuredStarCIterator
Definition: MeasuredStar.h:153
void setInstFluxAndErr(double instFlux, double instFluxErr)
Definition: MeasuredStar.h:90
double getInstFluxErr() const
Definition: MeasuredStar.h:98
objects measured on actual images.
Definition: MeasuredStar.h:46
double getMagWeight() const
the inverse of the mag variance
Definition: MeasuredStar.h:106
T move(T... args)
void setValid(bool v)
Fits may use that to discard outliers.
Definition: MeasuredStar.h:122
BaseStarList & Measured2Base(MeasuredStarList &This)
Definition: MeasuredStar.cc:58
Handler of an actual image from a single CCD.
Definition: CcdImage.h:64
void setId(afw::table::RecordId id)
Definition: MeasuredStar.h:102
bool isValid() const
Fits may use that to discard outliers.
Definition: MeasuredStar.h:120
std::shared_ptr< FittedStar > getFittedStar() const
Definition: MeasuredStar.h:113
STL class.