LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
FittedPsf.h
Go to the documentation of this file.
1 #ifndef FitPsf_H
2 #define FitPsf_H
3 
4 #include <vector>
5 #include <iostream>
6 #include <memory>
7 
12 
13 namespace lsst {
14 namespace meas {
15 namespace algorithms {
16 namespace shapelet {
17 
18  class FittedPsfAtXY;
19 
20  class FittedPsf {
21 
22  public :
23 
24 #if 0
25  // Make from PsfCatalog
26  FittedPsf(PsfCatalog& psfcat, const ConfigFile& params, PsfLog& log);
27 #endif
28 
29  // Setup FittedPsf, but don't assign to the values yet.
30  // Should be followed by either read or calculate.
31  FittedPsf(const ConfigFile& params);
32 
33  int getPsfOrder() const { return _psfOrder; }
34  int getPsfSize() const { return (_psfOrder+1)*(_psfOrder+2)/2; }
35  int getFitOrder() const { return _fitOrder; }
36  int getFitSize() const { return _fitSize; }
37  int getNpca() const { return _nPca; }
38  double getSigma() const { return _sigma; }
39  void setSigma(double sigma) { _sigma = sigma; }
40 
41  double getXMin() const { return _bounds.getXMin(); }
42  double getXMax() const { return _bounds.getXMax(); }
43  double getYMin() const { return _bounds.getYMin(); }
44  double getYMax() const { return _bounds.getYMax(); }
45  const Bounds& getBounds() const { return _bounds; }
46 
47 #if 0
48  void write() const;
49  void writeAscii(std::string file) const;
50  void writeFits(std::string file) const;
51  void writeFitsOld(std::string file) const;
52 
53  void read();
54  void read(std::string file);
55  void readAscii(std::string file);
56  void readFits(std::string file);
57 #endif
58 
59  void calculate(
60  const std::vector<Position>& pos,
61  const std::vector<BVec>& psf,
62  const std::vector<double>& nu,
63  std::vector<long>& flags);
64 
65  void interpolate(Position pos, BVec& b) const
66  {
67  Assert(_avePsf.get());
68  //Assert(_mV.get());
69  Assert(b.getOrder() == _psfOrder);
70  Assert(static_cast<int>(b.size()) == _avePsf->size());
71  b.setSigma(_sigma);
73  }
74 
75  double interpolateSingleElement(Position pos, int i) const;
76 
77  // This next construct with FittedPsfAtXY allows you to write:
78  // b = psf(pos);
79  // instead of:
80  // psf.interpolate(pos,b);
81  // Both do the same thing. I just like the first notation better.
82  friend class FittedPsfAtXY;
83  inline FittedPsfAtXY operator()(Position pos) const; // below...
84 
85  BVec getMean() const;
86 
87  private :
88 
89  void interpolateVector(Position pos, DVectorView b) const;
90 
92 
93  int _psfOrder;
94  double _sigma;
95  int _fitOrder;
96  int _fitSize;
97  int _nPca;
99  std::auto_ptr<DVector> _avePsf;
100 #if USE_TMV
101  std::auto_ptr<tmv::Matrix<double,tmv::RowMajor> > _mV;
102 #else
103  std::auto_ptr<DMatrix> _mV_transpose;
104 #endif
105  std::auto_ptr<DMatrix> _f;
106  };
107 
109  {
110 
111  public :
112 
113  FittedPsfAtXY(const FittedPsf& psf, Position pos) :
114  _psf(psf), _pos(pos)
115  {}
116 
117  size_t size() const { return _psf._avePsf->size(); }
118  int getOrder() const { return _psf.getPsfOrder(); }
119  double getSigma() const { return _psf.getSigma(); }
120 
121  void assignTo(BVec& b) const
122  { _psf.interpolate(_pos,b); }
123 
124  private :
125 
126  const FittedPsf& _psf;
128  };
129 
131  { return FittedPsfAtXY(*this,pos); }
132 
133 }}}}
134 
135 #endif
Eigen::Block< DVector, Eigen::Dynamic, 1 > DVectorView
Definition: MyMatrix.h:130
#define TMV_vview(v)
Definition: MyMatrix.h:202
void calculate(const std::vector< Position > &pos, const std::vector< BVec > &psf, const std::vector< double > &nu, std::vector< long > &flags)
Definition: FittedPsf.cc:83
FittedPsf(const ConfigFile &params)
Definition: FittedPsf.cc:309
void interpolate(Position pos, BVec &b) const
Definition: FittedPsf.h:65
std::auto_ptr< DVector > _avePsf
Definition: FittedPsf.h:99
double interpolateSingleElement(Position pos, int i) const
Definition: FittedPsf.cc:315
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:43
FittedPsfAtXY operator()(Position pos) const
Definition: FittedPsf.h:130
def log
Definition: log.py:85
void setSigma(double sigma)
Definition: BVec.h:69
void interpolateVector(Position pos, DVectorView b) const
Definition: FittedPsf.cc:332
std::auto_ptr< DMatrix > _mV_transpose
Definition: FittedPsf.h:103
afw::table::Key< double > b
FittedPsfAtXY(const FittedPsf &psf, Position pos)
Definition: FittedPsf.h:113
#define Assert(x)
Definition: dbg.h:73