gastro  0.1.0
 All Classes Files Functions Variables Pages
measuredstar.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef MEASUREDSTAR__H
3 #define MEASUREDSTAR__H
4 
5 #include <basestar.h>
6 #include <iostream>
7 
8 
9 #include "fittedstar.h" // for FittedStarRef
10 #include "preferences.h"
11 
12 
13 class SEStar;
14 class CcdImage;
15 class ReducedImage;
16 class fastifstream;
17 
20 class MeasuredStar : public BaseStar
22 {
23  public :
24  double mag;
25  double wmag;
26  double eflux;
27  double aperrad;
28  double chi2;
29 
30 
31  const CcdImage *ccdImage;
32  std::vector<double> usrVals;
33 
34  private :
35  bool valid;
36 
37  FittedStarRef fittedStar;
38 
39  public :
40 
42  MeasuredStar()
43  : BaseStar(),
44  mag(0.), wmag(0.), eflux(0.), aperrad(0.),
45  ccdImage(0),
46  fittedStar((const FittedStar*)NULL),
47  valid(true) {}
48 
49  MeasuredStar(const BaseStar &B, const FittedStar *F = NULL) :
50  BaseStar(B),
51  mag(0.), wmag(0.), eflux(0.), aperrad(0.),
52  ccdImage(0),
53  fittedStar(F),
54  valid(true)
55 
56  {
57  // InitialStarRef = &B;
58  }
59 
60  MeasuredStar( const SEStar &S);
61 
62  void SetFittedStar(FittedStar *F)
63  { if (F) F->MeasurementCount()++; fittedStar = F;
64  }
65 
66  double FluxSig() const { return eflux;}
67 
68  double Mag() const { return mag;}
69  double AperRad() const { return aperrad; }
70 
72  double MagWeight() const { return (flux*flux/(eflux*eflux));}
73 
74  const FittedStar* GetFittedStar() const { return fittedStar;};
75 
76  FittedStar* GetFittedStar() { return fittedStar;};
77 
78  const CcdImage &GetCcdImage() const { return *ccdImage;};
79 
80  void SetCcdImage(const CcdImage *C) { ccdImage = C;};
81 
83  bool IsValid() const { return valid; }
85  void SetValid(bool v) { valid=v; }
86 
87  // No longer decrement counter of associated fitted star in destructor (P. El-Hage le 10/04/2012)
88  // ~MeasuredStar() { if (fittedStar) fittedStar->MeasurementCount()--;}
89 
90  std::string WriteHeader_(std::ostream & pr = std::cout, const char* i = NULL) const;
91  void writen(std::ostream& s) const;
92  static BaseStar* read(fastifstream& s, const char* format);
93 };
94 
95 
96 typedef CountedRef<MeasuredStar> MeasuredStarRef;
97 
98 
99 
100 
101 /****** MeasuredStarList */
102 #include "starlist.h"
103 
105 class MeasuredStarList : public StarList<MeasuredStar> {
106 
107  double zeroPoint;
108 
109  public :
110  MeasuredStarList() {};
111 
112 
113  void SetZeroPoint(const double &ZP);
114 
115  void SetCcdImage(const CcdImage *C);
116 };
117 
118 
119 
120 typedef MeasuredStarList::const_iterator MeasuredStarCIterator;
121 typedef MeasuredStarList::iterator MeasuredStarIterator;
122 typedef CountedRef<MeasuredStar> MeasuredStarRef;
123 
124 BaseStarList& Measured2Base(MeasuredStarList &This);
125 BaseStarList* Measured2Base(MeasuredStarList *This);
126 const BaseStarList& Measured2Base(const MeasuredStarList &This);
127 const BaseStarList* Measured2Base(const MeasuredStarList *This);
128 
129 
130 
131 
132 typedef bool (CatalogLoader_(const ReducedImage &R, const CcdImage &, MeasuredStarList &List));
133 
134 class CatalogLoader{
135  CatalogLoader_ * loader;
136 public:
137  CatalogLoader(CatalogLoader_ *l){
138  loader = l;
139  }
140  bool operator()(const ReducedImage & ri,
141  const CcdImage & ccdim,
142  MeasuredStarList & stl) const{
143  return load(ri, ccdim, stl);
144  }
145  virtual bool load(const ReducedImage & ri,
146  const CcdImage & ccdim,
147  MeasuredStarList & stl) const{
148  return (*loader)(ri, ccdim, stl);
149  }
150 
151  virtual ~CatalogLoader(){};
152 
153  static CatalogLoader * DefaultCatalogLoader;
154  static CatalogLoader * getDefaultCatalogLoader();
155 
156 protected:
157  CatalogLoader(){}
158 };
159 
161 bool KeepSEStar(const SEStar &S);
162 
164 extern const CatalogLoader &AperSELoader_Minimal_NormalizeFluxes;
165 extern const CatalogLoader &AperSELoader_SelectStars_NormalizeFluxes;
166 extern const CatalogLoader &SELoader_SelectStars_NormalizeFluxes;
167 extern const CatalogLoader &AperSELoader_NormalizeFluxes;
168 extern const CatalogLoader &AperSELoader_SelectStars_NormalizeFluxes_nosncut;
169 extern const CatalogLoader &CachedMeasuredStarLoader;
170 extern const CatalogLoader &MCMeasuredStarLoader;
171 
172 
173 void SelectFluxForFitCatalog(std::string const& filename);
174 //void ConvertCatalogFluxesToMagnitudes(bool convert /*, double zp=0. */);
175 
176 #endif /* MEASUREDSTAR__H */
177 
const CatalogLoader & AperSELoader_Minimal_NormalizeFluxes
select stars and normalizes fluxes (ADU/sec @ X=1)
bool KeepSEStar(const SEStar &S)
routine that checks the quality of SEStar measurements and applies the signal2noise cut from datacard...
Definition: measuredstar.cc:198
double MagWeight() const
the inverse of the mag variance
Definition: measuredstar.h:72
handler of an actual image from a single CCD
Definition: ccdimage.h:21
The objects which have been measured several times. The MeasuredStar s measuring the same object in d...
Definition: fittedstar.h:37
bool IsValid() const
Fits may use that to discard outliers.
Definition: measuredstar.h:83
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
StarList ascii IO's.
Definition: measuredstar.cc:73
A list of MeasuredStar. They are usually filled in Associations::AddImage.
Definition: measuredstar.h:105
void SetValid(bool v)
Fits may use that to discard outliers.
Definition: measuredstar.h:85