casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointingDirectionCache.h
Go to the documentation of this file.
1 /*
2  * PointingDirectionCache.h
3  *
4  * Created on: Dec 1, 2016
5  * Author: jjacobs
6  */
7 
8 #ifndef MSVIS_MSVIS_POINTINGDIRECTIONCACHE_H_
9 #define MSVIS_MSVIS_POINTINGDIRECTIONCACHE_H_
10 
12 
13 #include <memory>
14 #include <vector>
15 
16 namespace casacore {
17  class MDirection;
18  class MeasurementSet;
19  class ROMSPointingColumns;
20 }
21 
22 namespace casa {
23 namespace vi {
24 
25 struct Pointing;
26 class PointingDirectionCache;
27 class PointingSource;
28 
29 namespace pd_cache {
30 
31 // The namespace pd_cache contains the internal classes to the features provided
32 // by PointingDirectionCache.
33 
34 enum class CacheAccessStatus : int {
35  Hit, // Found requested value in cache
36  MissPrior, // Desired value before earliest time in cache
37  MissInternal, // Desired value in between cache values
38  MissPost // Desired value is after last one in cache
39 };
40 
41 class AntennaLevelCache;
42 class TimeLevelCache;
43 
44 bool timeMatch (double time, double rowsTime, double rowsInterval);
45 
47 
48 public:
49 
50  TimeLevelEntry () = delete;
51  TimeLevelEntry (const Pointing &, const TimeLevelCache *);
53  ~TimeLevelEntry ();
54 
56 
57  const casacore::MDirection * getDirection () const;
58  double getInterval () const;
59  double getTime () const;
60 
61 private:
62 
63  mutable std::unique_ptr<casacore::MDirection> direction_p; // own
64  int row_p;
65  double timeCenter_p;
67  double interval_p;
68 
69  const PointingSource * getPointingSource () const;
70 };
71 
72 bool operator== (double t, const TimeLevelEntry &);
73 bool operator== (const TimeLevelEntry &, double t);
74 bool operator< (double t, const TimeLevelEntry &);
75 bool operator< (const TimeLevelEntry &, double t);
76 
78 
79 public:
80 
81  TimeLevelCache (int minTimes, int maxTimes, const AntennaLevelCache * );
82 
83  void addEntry (Pointing & pointing);
84  void flush ();
85  std::pair<CacheAccessStatus, const casacore::MDirection *> getPointingDirection (double time);
86  const PointingSource * getPointingSource () const;
87 
88 private:
89 
90  typedef std::vector<TimeLevelEntry> Cache;
95 
96 };
97 
98 
100 
101 public:
102 
103  AntennaLevelCache (int minTimes, int maxTimes, int nAntennas, const PointingDirectionCache *);
104  AntennaLevelCache (const AntennaLevelCache & other) = delete;
105 
106  AntennaLevelCache & operator= (const AntennaLevelCache & other) = delete;
107 
108  void addEntry (Pointing & pointing);
109  void flushTimes ();
110  std::pair<CacheAccessStatus, const casacore::MDirection *> getPointingDirection (int antenna, double time);
111  const PointingSource * getPointingSource () const;
112 
113 private:
114 
116  std::vector<TimeLevelCache> timeLevelCache_p;
117 };
118 
119 } // end namepsace pd_cache
120 
121 class PointingSource;
122 
123 struct Pointing {
124 
125  // The direction and interval components are only usable if
126  // "valid" is set to true.
127 
128  Pointing () : antennaId (0), direction (nullptr), interval (0), row (0), source (nullptr), time (0) {}
129  Pointing (const Pointing & other)
130  : antennaId (other.antennaId),
131  direction (std::move (other.direction)),
132  interval (other.interval),
133  row (other.row),
134  source (other.source),
135  time (other.time)
136  {}
137 
138 
140  mutable std::unique_ptr<casacore::MDirection> direction;
141  double interval;
142  int row;
144  double time;
145 };
146 
148 
149  // Generic interface to allow passing different pointing information
150  // sources into the PointingDirectionCache. The primary source
151  // will be a POINTING subtable; the other likely source will be a unit
152  // test source.
153 
154 public:
155 
156  virtual ~PointingSource () {}
157 
158  virtual Pointing getPointingRow (int row, double targetTime, bool asMeasure) const = 0;
159  virtual int nRows () const = 0;
160 
161 protected:
162 
163 private:
164 
165 };
166 
168 
169  // Wrapper class to provide pointing subtable information into
170  // the cache.
171 
172 public:
173 
175 
176  virtual Pointing getPointingRow (int row, double targetTime, bool asMeasure) const override;
177  virtual int nRows () const override;
178 
179 private:
180 
182 };
183 
184 
185 
187 
188 public:
189 
190  PointingDirectionCache (int nAntennas, const PointingSource & pointingSource);
192 
193  std::pair<bool, casacore::MDirection>
194  getPointingDirection (int antennaId, double time, const casacore::MDirection & phaseCenter) const;
195 
196 protected:
197 
198  friend class pd_cache::AntennaLevelCache; // allow access to getPointingSource
199 
200  void fillCache (int antenna, double time, bool flushAndRewind) const;
201  const PointingSource * getPointingSource () const;
202  bool noDataForAntenna (int antenna, double time) const;
203 
204 private:
205 
207  mutable std::vector<double> antennaEarliestTime_p;
208  mutable int lastRowRead_p;
209  mutable int nFallbacks_p;
210  mutable int nHits_p;
211  mutable bool pointingEofReached_p;
213 
214  // These constants control the cache sizing. The max value specifies how many entries
215  // can be cached. The min entry controls how many are kept when the cache size exceeds
216  // the max value.
217 
218  static const int MaxTimeEntries = 3000;
219  static const int MinTimeEntries = 1000;
220 
221 };
222 
223 
224 
225 } // end namespace vi
226 } // end namepsace casa
227 
228 #endif /* MSVIS_MSVIS_POINTINGDIRECTIONCACHE_H_ */
A Measure: astronomical direction.
Definition: MDirection.h:174
virtual ~PointingSource()
Generic interface to allow passing different pointing information sources into the PointingDirectionC...
std::pair< CacheAccessStatus, const casacore::MDirection * > getPointingDirection(double time)
bool timeMatch(double time, double rowsTime, double rowsInterval)
static const int MaxTimeEntries
These constants control the cache sizing.
const PointingSource * getPointingSource() const
const PointingSource * getPointingSource() const
TimeLevelCache(int minTimes, int maxTimes, const AntennaLevelCache *)
void addEntry(Pointing &pointing)
void fillCache(int antenna, double time, bool flushAndRewind) const
virtual void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
const PointingSource * getPointingSource() const
bool operator<(double t, const TimeLevelEntry &)
const casacore::ROMSPointingColumns & pointingColumns_p
void addEntry(Pointing &pointing)
PointingColumns(const casacore::ROMSPointingColumns &)
Wrapper class to provide pointing subtable information into the cache.
std::vector< TimeLevelCache > timeLevelCache_p
A class to provide easy read-only access to MSPointing columns.
std::unique_ptr< casacore::MDirection > direction
std::vector< TimeLevelEntry > Cache
std::unique_ptr< casacore::MDirection > direction_p
Pointing()
The direction and interval components are only usable if &quot;valid&quot; is set to true.
AntennaLevelCache & operator=(const AntennaLevelCache &other)=delete
virtual Pointing getPointingRow(int row, double targetTime, bool asMeasure) const override
bool operator==(double t, const TimeLevelEntry &)
AntennaLevelCache(int minTimes, int maxTimes, int nAntennas, const PointingDirectionCache *)
const PointingSource * getPointingSource() const
pd_cache::AntennaLevelCache antennaLevelCache_p
const casacore::MDirection * getDirection() const
std::pair< CacheAccessStatus, const casacore::MDirection * > getPointingDirection(int antenna, double time)
virtual int nRows() const override
std::pair< bool, casacore::MDirection > getPointingDirection(int antennaId, double time, const casacore::MDirection &phaseCenter) const
CacheAccessStatus
The namespace pd_cache contains the internal classes to the features provided by PointingDirectionCac...
const PointingSource * source
Pointing(const Pointing &other)
virtual Pointing getPointingRow(int row, double targetTime, bool asMeasure) const =0
TimeLevelEntry & operator=(const TimeLevelEntry &other)
virtual int nRows() const =0
bool noDataForAntenna(int antenna, double time) const
const AntennaLevelCache * antennaLevelCache_p
PointingDirectionCache(int nAntennas, const PointingSource &pointingSource)
const PointingDirectionCache * pointingDirectionCache_p
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42