AOFlagger
aoflagger.h
Go to the documentation of this file.
1 
6 #ifndef AOFLAGGER_INTERFACE_H
7 #define AOFLAGGER_INTERFACE_H
8 
9 #include <cstring>
10 #include <string>
11 
17 namespace aoflagger {
18 
25  enum TelescopeId {
44  };
45 
56  {
57  public:
59  static const unsigned NONE;
60 
65  static const unsigned LARGE_BANDWIDTH;
66 
68  static const unsigned SMALL_BANDWIDTH;
69 
78  static const unsigned TRANSIENTS;
79 
86  static const unsigned ROBUST;
87 
89  static const unsigned FAST;
90 
97  static const unsigned INSENSITIVE;
98 
106  static const unsigned SENSITIVE;
107 
112  static const unsigned USE_ORIGINAL_FLAGS;
113 
119  //static const unsigned CLEAR_FLAGS;
120 
122  static const unsigned AUTO_CORRELATION;
123 
130  static const unsigned HIGH_TIME_RESOLUTION;
131 
132  private:
133  StrategyFlags() = delete;
134  };
135 
156  class ImageSet
157  {
158  public:
159  friend class AOFlagger;
160 
162  ImageSet();
163 
165  ImageSet(const ImageSet& sourceImageSet);
166 
170  ImageSet(ImageSet&& sourceImageSet);
171 
173  ~ImageSet();
174 
176  ImageSet& operator=(const ImageSet& sourceImageSet);
177 
181  ImageSet& operator=(ImageSet&& sourceImageSet);
182 
187  float* ImageBuffer(size_t imageIndex);
188 
193  const float* ImageBuffer(size_t imageIndex) const;
194 
196  size_t Width() const;
197 
199  size_t Height() const;
200 
202  size_t ImageCount() const;
203 
217  size_t HorizontalStride() const;
218 
223  void Set(float newValue);
224 
236  void ResizeWithoutReallocation(size_t newWidth) const;
237 
238  private:
239  ImageSet(size_t width, size_t height, size_t count);
240 
241  ImageSet(size_t width, size_t height, size_t count, float initialValue);
242 
243  ImageSet(size_t width, size_t height, size_t count, size_t widthCapacity);
244 
245  ImageSet(size_t width, size_t height, size_t count, float initialValue, size_t widthCapacity);
246 
247  static void assertValidCount(size_t count);
248 
249  class ImageSetData* _data;
250  };
251 
273  class FlagMask
274  {
275  public:
276  friend class AOFlagger;
277 
281  FlagMask();
282 
284  FlagMask(const FlagMask& sourceMask);
285 
289  FlagMask(FlagMask&& sourceMask);
290 
294  FlagMask& operator=(const FlagMask& source);
295 
299  FlagMask& operator=(FlagMask&& source);
300 
302  ~FlagMask();
303 
305  size_t Width() const;
306 
308  size_t Height() const;
309 
323  size_t HorizontalStride() const;
324 
327  bool* Buffer();
328 
331  const bool* Buffer() const;
332 
333  private:
334  FlagMask(size_t width, size_t height);
335  FlagMask(size_t width, size_t height, bool initialValue);
336 
337  class FlagMaskData* _data;
338  };
339 
348  class Strategy
349  {
350  public:
351  friend class AOFlagger;
352 
354  Strategy(const Strategy& sourceStrategy);
355 
359  Strategy(Strategy&& sourceStrategy);
360 
362  ~Strategy();
363 
365  Strategy& operator=(const Strategy& sourceStrategy);
366 
370  Strategy& operator=(Strategy&& sourceStrategy);
371 
372  private:
373  Strategy(enum TelescopeId telescopeId, unsigned strategyFlags, double frequency=0.0, double timeRes=0.0, double frequencyRes=0.0);
374 
375  explicit Strategy(const std::string& filename);
376 
377  class StrategyData* _data;
378  };
379 
401  {
402  public:
403  friend class AOFlagger;
404 
411 
413  QualityStatistics(const QualityStatistics& sourceQS);
414 
419 
422 
425 
430 
441 
442  private:
443  QualityStatistics(const double* scanTimes, size_t nScans, const double* channelFrequencies, size_t nChannels, size_t nPolarizations, bool computeHistograms);
444 
445  class QualityStatisticsData* _data;
446  };
447 
455  {
456  public:
460  virtual ~StatusListener() { }
470  virtual void OnStartTask(size_t taskNo, size_t taskCount, const std::string& description)
471  { }
478  virtual void OnEndTask()
479  { }
487  virtual void OnProgress(size_t progress, size_t maxProgress)
488  { }
495  virtual void OnException(std::exception& thrownException) = 0;
496  };
497 
564  class AOFlagger
565  {
566  public:
568  AOFlagger() : _statusListener(nullptr) { }
569 
572 
582  ImageSet MakeImageSet(size_t width, size_t height, size_t count)
583  {
584  return ImageSet(width, height, count);
585  }
586 
598  ImageSet MakeImageSet(size_t width, size_t height, size_t count, size_t widthCapacity)
599  {
600  return ImageSet(width, height, count, widthCapacity);
601  }
602 
611  ImageSet MakeImageSet(size_t width, size_t height, size_t count, float initialValue)
612  {
613  return ImageSet(width, height, count, initialValue);
614  }
615 
626  ImageSet MakeImageSet(size_t width, size_t height, size_t count, float initialValue, size_t widthCapacity)
627  {
628  return ImageSet(width, height, count, initialValue, widthCapacity);
629  }
630 
636  FlagMask MakeFlagMask(size_t width, size_t height)
637  {
638  return FlagMask(width, height);
639  }
640 
647  FlagMask MakeFlagMask(size_t width, size_t height, bool initialValue)
648  {
649  return FlagMask(width, height, initialValue);
650  }
651 
671  Strategy MakeStrategy(enum TelescopeId telescopeId=GENERIC_TELESCOPE, unsigned strategyFlags=StrategyFlags::NONE, double frequency=0.0, double timeRes=0.0, double frequencyRes=0.0)
672  {
673  return Strategy(telescopeId, strategyFlags, frequency, timeRes, frequencyRes);
674  }
675 
684  Strategy LoadStrategy(const std::string& filename)
685  {
686  return Strategy(filename);
687  }
688 
699  FlagMask Run(Strategy& strategy, const ImageSet& input);
700 
715  FlagMask Run(Strategy& strategy, const ImageSet& input, const FlagMask& existingFlags);
716 
723  QualityStatistics MakeQualityStatistics(const double* scanTimes, size_t nScans, const double* channelFrequencies, size_t nChannels, size_t nPolarizations);
724 
732  QualityStatistics MakeQualityStatistics(const double* scanTimes, size_t nScans, const double* channelFrequencies, size_t nChannels, size_t nPolarizations, bool computeHistograms);
733 
751  void CollectStatistics(QualityStatistics& destination, const ImageSet& imageSet, const FlagMask& rfiFlags, const FlagMask& correlatorFlags, size_t antenna1, size_t antenna2);
752 
758  void WriteStatistics(const QualityStatistics& statistics, const std::string& measurementSetPath);
759 
764  static std::string GetVersionString();
765 
776  static void GetVersion(short& major, short& minor, short& subMinor);
777 
782  static std::string GetVersionDate();
783 
795  void SetStatusListener(StatusListener* statusListener)
796  {
797  _statusListener = statusListener;
798  }
799 
800  private:
803  AOFlagger(const AOFlagger&) = delete;
804 
807  void operator=(const AOFlagger&) = delete;
808 
809  FlagMask run(Strategy& strategy, const ImageSet& input, const FlagMask* existingFlags);
810 
811  StatusListener* _statusListener;
812  };
813 
814 }
815 
816 #endif
aoflagger::ImageSet::ImageCount
size_t ImageCount() const
Get number of images, see class description for details.
aoflagger::AOFlagger::MakeImageSet
ImageSet MakeImageSet(size_t width, size_t height, size_t count, float initialValue)
Create a new initialized ImageSet with specified specs.
Definition: aoflagger.h:611
aoflagger::StatusListener
A base class which callers can inherit from to be able to receive progress updates and error messages...
Definition: aoflagger.h:454
aoflagger::Strategy::~Strategy
~Strategy()
Destruct strategy.
aoflagger::WSRT_TELESCOPE
WSRT, the Westerbork Synthesis Radio Telescope in the Netherlands.
Definition: aoflagger.h:41
aoflagger::AOFlagger::AOFlagger
AOFlagger()
Create and initialize the flagger main class.
Definition: aoflagger.h:568
aoflagger::ImageSet::operator=
ImageSet & operator=(const ImageSet &sourceImageSet)
Assign to this image set. Only references to images are copied.
aoflagger::StrategyFlags::FAST
static const unsigned FAST
Optimize for speed at cost of accuracy and robustness.
Definition: aoflagger.h:89
aoflagger::AOFlagger::LoadStrategy
Strategy LoadStrategy(const std::string &filename)
Load a strategy from disk.
Definition: aoflagger.h:684
aoflagger::StrategyFlags::TRANSIENTS
static const unsigned TRANSIENTS
Make strategy insensitive for transient effect.
Definition: aoflagger.h:78
aoflagger::ImageSet::ImageBuffer
float * ImageBuffer(size_t imageIndex)
Get access to the data buffer of an image.
aoflagger::AOFlagger::CollectStatistics
void CollectStatistics(QualityStatistics &destination, const ImageSet &imageSet, const FlagMask &rfiFlags, const FlagMask &correlatorFlags, size_t antenna1, size_t antenna2)
Collect statistics from time-frequency images and masks.
aoflagger::StatusListener::~StatusListener
virtual ~StatusListener()
Virtual destructor.
Definition: aoflagger.h:460
aoflagger::PARKES_TELESCOPE
Parkes, the single dish telescope in New South Wales.
Definition: aoflagger.h:39
aoflagger::AOFlagger::MakeFlagMask
FlagMask MakeFlagMask(size_t width, size_t height, bool initialValue)
Create a new initialized FlagMask with specified dimensions.
Definition: aoflagger.h:647
aoflagger::JVLA_TELESCOPE
JVLA, the Jansky Very Large Array in New Mexico.
Definition: aoflagger.h:33
aoflagger::GENERIC_TELESCOPE
Most generic strategy.
Definition: aoflagger.h:27
aoflagger::StatusListener::OnEndTask
virtual void OnEndTask()
Called when at the end of the current task.
Definition: aoflagger.h:478
aoflagger::TelescopeId
TelescopeId
Strategy identifier for the supported telescopes.
Definition: aoflagger.h:25
aoflagger::AOFlagger::MakeStrategy
Strategy MakeStrategy(enum TelescopeId telescopeId=GENERIC_TELESCOPE, unsigned strategyFlags=StrategyFlags::NONE, double frequency=0.0, double timeRes=0.0, double frequencyRes=0.0)
Initialize a strategy for a specific telescope.
Definition: aoflagger.h:671
aoflagger::ImageSet::Height
size_t Height() const
Get height (number of frequency channels) of images.
aoflagger::Strategy
Holds a flagging strategy.
Definition: aoflagger.h:348
aoflagger::ImageSet::Set
void Set(float newValue)
Set all samples to the specified value.
aoflagger::Strategy::operator=
Strategy & operator=(const Strategy &sourceStrategy)
Assign to strategy.
aoflagger::StrategyFlags::SMALL_BANDWIDTH
static const unsigned SMALL_BANDWIDTH
Observation was made at smaller bandwidth than common.
Definition: aoflagger.h:68
aoflagger::ImageSet::HorizontalStride
size_t HorizontalStride() const
Get total number of floats in one row.
aoflagger::ImageSet::ImageSet
ImageSet()
Construct an empty ImageSet.
aoflagger::AOFlagger
Main class for access to the flagger functionality.
Definition: aoflagger.h:564
aoflagger::AOFlagger::SetStatusListener
void SetStatusListener(StatusListener *statusListener)
Set a handler for progress updates and exceptions.
Definition: aoflagger.h:795
aoflagger::AOFlagger::~AOFlagger
~AOFlagger()
Destructor.
Definition: aoflagger.h:571
aoflagger::AOFlagger::MakeImageSet
ImageSet MakeImageSet(size_t width, size_t height, size_t count)
Create a new uninitialized ImageSet with specified specs.
Definition: aoflagger.h:582
aoflagger::QualityStatistics::QualityStatistics
QualityStatistics()
aoflagger::AOFlagger::GetVersionString
static std::string GetVersionString()
Get the AOFlagger version number as a string.
aoflagger::QualityStatistics::operator+=
QualityStatistics & operator+=(const QualityStatistics &rhs)
Combine the statistics from the given object with the statistics in this object.
aoflagger::StrategyFlags::AUTO_CORRELATION
static const unsigned AUTO_CORRELATION
Erase any flags that are already set.
Definition: aoflagger.h:122
aoflagger::FlagMask::operator=
FlagMask & operator=(const FlagMask &source)
Copy assignment.
aoflagger::ImageSet::Width
size_t Width() const
Get width (number of time steps) of images.
aoflagger::FlagMask::Height
size_t Height() const
Get the height of the mask.
aoflagger::MWA_TELESCOPE
MWA, the Murchison Widefield Array in Western Australia.
Definition: aoflagger.h:37
aoflagger::LOFAR_TELESCOPE
LOFAR. the Low-Frequency Array in Europe.
Definition: aoflagger.h:35
aoflagger::FlagMask
A two-dimensional flag mask.
Definition: aoflagger.h:273
aoflagger::FlagMask::~FlagMask
~FlagMask()
Destroy a flag mask. Destroys mask data if no longer references.
aoflagger::AOFlagger::WriteStatistics
void WriteStatistics(const QualityStatistics &statistics, const std::string &measurementSetPath)
Write collected statistics in standard tables to a measurement set.
aoflagger::FlagMask::Width
size_t Width() const
Get the width of the mask.
aoflagger::StrategyFlags::HIGH_TIME_RESOLUTION
static const unsigned HIGH_TIME_RESOLUTION
Optimizes for observations with high time resolution.
Definition: aoflagger.h:130
aoflagger::StatusListener::OnProgress
virtual void OnProgress(size_t progress, size_t maxProgress)
Called while the current task is progressing.
Definition: aoflagger.h:487
aoflagger::StrategyFlags::ROBUST
static const unsigned ROBUST
Increase robustness by decreasing convergence speed.
Definition: aoflagger.h:86
aoflagger::FlagMask::HorizontalStride
size_t HorizontalStride() const
Get total number of bools in one row.
aoflagger::AOFlagger::MakeImageSet
ImageSet MakeImageSet(size_t width, size_t height, size_t count, float initialValue, size_t widthCapacity)
Create a new initialized ImageSet with specified specs.
Definition: aoflagger.h:626
aoflagger::QualityStatistics::~QualityStatistics
~QualityStatistics()
Destruct the object. Data is destroyed if no more references exist.
aoflagger::StatusListener::OnException
virtual void OnException(std::exception &thrownException)=0
Called when an exception occurs during execution of the strategy.
aoflagger::FlagMask::Buffer
bool * Buffer()
Get access to the data buffer.
aoflagger::StrategyFlags
Lists the flags that can be used to alter a default strategy.
Definition: aoflagger.h:55
aoflagger::AOFlagger::GetVersion
static void GetVersion(short &major, short &minor, short &subMinor)
Get the AOFlagger version number separated in major, minor and subminor fields.
aoflagger::StrategyFlags::INSENSITIVE
static const unsigned INSENSITIVE
Make the strategy less sensitive to RFI than the default telescope settings.
Definition: aoflagger.h:97
aoflagger::QualityStatistics
Statistics that can be collected online and saved to a measurement set.
Definition: aoflagger.h:400
aoflagger::AOFlagger::MakeImageSet
ImageSet MakeImageSet(size_t width, size_t height, size_t count, size_t widthCapacity)
Create a new uninitialized ImageSet with specified specs.
Definition: aoflagger.h:598
aoflagger::AOFlagger::MakeQualityStatistics
QualityStatistics MakeQualityStatistics(const double *scanTimes, size_t nScans, const double *channelFrequencies, size_t nChannels, size_t nPolarizations)
Create a new object for collecting statistics.
aoflagger::AARTFAAC_TELESCOPE
The AARTFAAC telescope, correlating the superterp antennas of LOFAR.
Definition: aoflagger.h:43
aoflagger::AOFlagger::MakeFlagMask
FlagMask MakeFlagMask(size_t width, size_t height)
Create a new uninitialized FlagMask with specified dimensions.
Definition: aoflagger.h:636
aoflagger::StatusListener::OnStartTask
virtual void OnStartTask(size_t taskNo, size_t taskCount, const std::string &description)
This virtual method is called when a new task is started.
Definition: aoflagger.h:470
aoflagger::StrategyFlags::LARGE_BANDWIDTH
static const unsigned LARGE_BANDWIDTH
Observation was made at larger bandwidth than common.
Definition: aoflagger.h:65
aoflagger::ImageSet::~ImageSet
~ImageSet()
Destruct image set. Destroys its images if no longer referenced.
aoflagger::AOFlagger::GetVersionDate
static std::string GetVersionDate()
Get the date this version was released as a string.
aoflagger::QualityStatistics::operator=
QualityStatistics & operator=(const QualityStatistics &sourceQS)
Assign to this object. This is fast; only references are copied.
aoflagger::StrategyFlags::SENSITIVE
static const unsigned SENSITIVE
Make the strategy more sensitive to RFI than the default telescope settings.
Definition: aoflagger.h:106
aoflagger::ImageSet::ResizeWithoutReallocation
void ResizeWithoutReallocation(size_t newWidth) const
Resize the image without reallocating new memory.
aoflagger::StrategyFlags::USE_ORIGINAL_FLAGS
static const unsigned USE_ORIGINAL_FLAGS
Will assume that the original flags that are already set in the observation denote bad data and shoul...
Definition: aoflagger.h:112
aoflagger::Strategy::Strategy
Strategy(const Strategy &sourceStrategy)
Create a copy of a strategy.
aoflagger::FlagMask::FlagMask
FlagMask()
Construct an empty FlagMask. The properties of empty FlagMask can not be accessed.
aoflagger::StrategyFlags::NONE
static const unsigned NONE
No flags: use the default strategy for the telescope.
Definition: aoflagger.h:59
aoflagger::BIGHORNS_TELESCOPE
Bighorns, instrument aimed at achieving an averaged all-sky measurement of the Epoch of Reionisation ...
Definition: aoflagger.h:31
aoflagger::ImageSet
A set of time-frequency 'images' which together contain data for one correlated baseline or dish.
Definition: aoflagger.h:156
aoflagger
Contains all the public types used by the AOFlagger.
Definition: aoflagger.h:17
aoflagger::ARECIBO_TELESCOPE
Arecibo radio telescope, the 305 m telescope in Puerto Rico.
Definition: aoflagger.h:29
aoflagger::AOFlagger::Run
FlagMask Run(Strategy &strategy, const ImageSet &input)
Run the flagging strategy on the given data.