gastro  0.1.0
 All Classes Files Functions Variables Pages
fittedstar.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef FITTEDSTAR__H
3 #define FITTEDSTAR__H
4 
5 
6 
7 #include <basestar.h>
8 
9 class fastifstream;
10 
11 
12 class MeasuredStar;
13 class RefStar;
14 class Gtransfo;
15 
19 
21 struct PmBlock
22 {
23 // proper motion in x and y. Units depend on how you fit them
24  double pmx,pmy;
25  double epmx, epmy, epmxy;
26  double color; // OK it is unrelated, but associated in practice
27  bool mightMove;
28 
29 
30  PmBlock() : pmx(0), pmy(0), epmx(0), epmy(0), epmxy(0), color(0), mightMove(false) {};
31 
32 
33 
34 };
35 
37 class FittedStar : public BaseStar, public PmBlock {
38 
39  friend class PhotomFit;
40  friend class PhotomFit2;
41 
42 
43  private:
44 
45  double mag;
46  double emag;
47  double col;
48  int gen;
49  double wmag;
50  unsigned indexInMatrix;
51  int measurementCount;
52  const RefStar *refStar;
53 
54  double flux2;
55  double fluxErr;
56  double fluxErr2;
57 
58  public:
59  FittedStar() :
60  BaseStar(), mag(-1), emag(-1), col(0.), gen(-1), wmag(0),
61  indexInMatrix(-1), measurementCount(0), refStar(NULL),
62  flux2(-1),
63  fluxErr(-1),
64  fluxErr2(-1) {}
65 
66  FittedStar(const BaseStar &B) :
67  BaseStar(B), mag(-1), emag(-1), col(0.), gen(-1), wmag(0),
68  indexInMatrix(0), measurementCount(0), refStar(NULL),
69  flux2(-1),
70  fluxErr(-1),
71  fluxErr2(-1) {}
72 
73  // FittedStar(const FittedStar& F)
74  // : BaseStar(F), mag(F.mag), emag(F.emag), col(F.col), gen(F.gen), wmag(F.wmag),
75  // index(F.index), measurementCount(F.measurementCount), refStar(F.refStar),
76  // flux2(F.flux2), fluxErr(F.fluxErr), fluxErr2(F.fluxErr2) {}
77 
79  FittedStar(const MeasuredStar &M);
80 
81 
83  void ClearBeforeAssoc()
84  {
85  indexInMatrix = -1;
86  measurementCount = 0;
87  refStar = NULL;
88  wmag = 0;
89  }
90 
91 
93  void dump(std::ostream & stream = std::cout) const
94  { BaseStar::dumpn(stream);
95  stream << " mcount "
96  << measurementCount << std::endl;
97  }
98 
100  int MeasurementCount() const { return measurementCount;}
101 
103  int& MeasurementCount() { return measurementCount;}
104 
106  double Mag() const { return mag;}
107  double& Mag() { return mag; }
108  double EMag() const { return emag;}
109  double& EMag() { return emag; }
110  double Col() const { return col;}
111  double& Col() { return col; }
112  int Generation() const { return gen;}
113  int& Generation() { return gen; }
114 
116  void SetMag(double Value) { mag = Value;}
117 
119  void AddMagMeasurement(const double &MagValue,
120  const double &MagWeight);
121 
123  void SetIndexInMatrix(const unsigned &Index){ indexInMatrix = Index;};
124 
126  int IndexInMatrix() const { return indexInMatrix;}
127 
129  void SetRefStar(const RefStar &);
130 
132  const RefStar *GetRefStar() const { return refStar;};
133 
135  double Flux() const { return flux; }
136  double& Flux() { return flux; }
137  double FluxErr() const { return fluxErr; }
138  double& FluxErr() { return fluxErr; }
139 
140  double Flux2() const { return flux2; }
141  double& Flux2() { return flux2; }
142  double FluxErr2() const { return fluxErr2; }
143  double& FluxErr2() { return fluxErr2; }
144 
146  std::string WriteHeader_(std::ostream& pr=std::cout, const char* i=NULL) const;
147  virtual void writen(std::ostream& s) const;
148  virtual void read_it(fastifstream& s, const char* format);
149  static BaseStar* read(fastifstream& s, const char* format);
150 };
151 
152 
153 /****** FittedStarList */
154 #include "starlist.h"
155 
156 
158 class FittedStarList : public StarList<FittedStar>
159 {
160 
161  public :
162 
163  bool inTangentPlaneCoordinates;
164 
166  FittedStarList() {inTangentPlaneCoordinates=true;}
167 
169  FittedStarList(const std::string &FileName);
170 
175  void WriteTuple(const std::string &FileName,
176  const Gtransfo &TP2RaDec,
177  const bool OnlyGoodStars = true);
178 
179 
180 };
181 
182 typedef FittedStarList::const_iterator FittedStarCIterator;
183 typedef FittedStarList::iterator FittedStarIterator;
184 typedef CountedRef<FittedStar> FittedStarRef;
185 
186 BaseStarList& Fitted2Base(FittedStarList &This);
187 BaseStarList* Fitted2Base(FittedStarList *This);
188 const BaseStarList& Fitted2Base(const FittedStarList &This);
189 const BaseStarList* Fitted2Base(const FittedStarList *This);
190 
191 
192 #include <fstream>
193 
194 
195 class FittedStarTuple {
196  private :
197  std::ofstream stream;
198 
199  public :
200  FittedStarTuple( const std::string &FileName);
201 
203 
204  void AddEntry(const FittedStar &F, const Point &RaDec);
205 
206  ~FittedStarTuple() { stream.close();}
207 };
208 
209 
210 #endif /* FITTEDSTAR__H */
double Mag() const
derived using available zero points in input images. In the absence ofZP, ZP= 0.
Definition: fittedstar.h:106
void SetIndexInMatrix(const unsigned &Index)
index is a value that a fit can set and reread....
Definition: fittedstar.h:123
A list of FittedStar s. Such a list is typically constructed by Associations.
Definition: fittedstar.h:158
Objects used as position anchors, typically USNO stars. Coordinate system defined by user...
Definition: refstar.h:12
void WriteTuple(const std::string &FileName, const Gtransfo &TP2RaDec, const bool OnlyGoodStars=true)
Definition: fittedstar.cc:90
void AddMagMeasurement(const double &MagValue, const double &MagWeight)
this routine will hopefully soon disappear.
Definition: fittedstar.cc:35
The objects which have been measured several times. The MeasuredStar s measuring the same object in d...
Definition: fittedstar.h:37
objects whose position is going to be fitted. Coordinates in Common Tangent Plane.
Definition: fittedstar.h:21
double Flux() const
getters
Definition: fittedstar.h:135
objects measured on actual images. Coordinates and uncertainties are expressed in pixel image frame...
Definition: measuredstar.h:21
std::string WriteHeader_(std::ostream &pr=std::cout, const char *i=NULL) const
write stuff
Definition: fittedstar.cc:142