AveragingVi2Factory.h

Go to the documentation of this file.
00001 /*
00002  * AveragingViFactory.h
00003  *
00004  *  Created on: Feb 25, 2013
00005  *      Author: jjacobs
00006  */
00007 
00008 #ifndef MSVIS_AVERAGINGVIFACTORY_H_
00009 #define MSVIS_AVERAGINGVIFACTORY_H_
00010 
00011 #include <msvis/MSVis/VisibilityIterator2.h>
00012 
00013 namespace casa {
00014 
00015 class MeasurementSet2;
00016 
00017 namespace vi {
00018 
00019 // AveragingOptions
00020 //
00021 // A container for the options that can be specified when creating
00022 // an AveragingTvi2 based VI.  The user can specify which of the
00023 // data cubes (observed, model and corrected) are to be averaged.
00024 // The source of the weights applied to each cube can also be specified.
00025 // See enum Options below for the symbols to use; the symbols are usually
00026 // combined using bitwise-and ("|") in the constructor.
00027 
00028 class AveragingOptions {
00029 
00030 public:
00031 
00032     enum Options {Nothing = 0,
00033                   AverageObserved = 1 << 0,  // Average the observed data
00034                   AverageModel = 1 << 1,     // Average the model data
00035                   AverageCorrected = 1 << 2, // Average the corrected data
00036                   AverageFloat = 1 << 3,         // Average float (single dish) data
00037                   ObservedPlainAvg = 1 << 4,
00038                   ObservedFlagAvg = 1 << 5,
00039                   ObservedWeightAvgFromSIGMA = 1 << 6,
00040                   ObservedFlagWeightAvgFromSIGMA = 1 << 7,
00041                   ModelPlainAvg = 1 << 8,
00042                   ModelFlagAvg = 1 << 9,
00043                   ModelWeightAvgFromWEIGHT = 1 << 10,
00044                   ModelWeightAvgFromSIGMA = 1 << 11,
00045                   ModelFlagWeightAvgFromWEIGHT = 1 << 12,
00046                   ModelFlagWeightAvgFromSIGMA = 1 << 13,
00047                   CorrectedPlainAvg = 1 << 14,
00048                   CorrectedFlagAvg = 1 << 15,
00049                   CorrectedWeightAvgFromWEIGHT = 1 << 16,
00050                   CorrectedFlagWeightAvgFromWEIGHT = 1 << 17,
00051                   BaselineDependentAveraging = 1 << 18, // Do averaging with lengths dependent on baselines
00052                                                         // Requires specifying a max uvw distance parameter
00053                   phaseShifting = 1 << 19,
00054                   MarksLast
00055     };
00056 
00057     AveragingOptions () : options_p (AverageObserved) {}
00058     AveragingOptions (Int options) : options_p ((Options) options) {}
00059     explicit AveragingOptions (Options o) : options_p (o) {}
00060 
00061     AveragingOptions operator& (const AveragingOptions & other) const
00062     {
00063         return AveragingOptions (other.options_p & options_p);
00064     }
00065 
00066     AveragingOptions operator| (const AveragingOptions & other) const
00067     {
00068         return AveragingOptions (other.options_p | options_p);
00069     }
00070 
00071     AveragingOptions & operator|= (const AveragingOptions & other)
00072     {
00073         * this = AveragingOptions (options_p | other.options_p);
00074 
00075         return * this;
00076     }
00077 
00078     AveragingOptions & operator|= (Options options)
00079     {
00080         * this = AveragingOptions (options_p | options);
00081 
00082         return * this;
00083     }
00084 
00085     AveragingOptions operator~ () const
00086     {
00087         return AveragingOptions (~ options_p);
00088     }
00089 
00090     Bool contains (Options o) const { return (o & options_p) != 0; }
00091 
00092     Int
00093     nSet (Int o) const
00094     {
00095         Int result = o & options_p;
00096         Int nSet = 0;
00097 
00098         for (Int mask = 1; mask < MarksLast; mask = mask << 1){
00099 
00100             nSet += (result & mask) != 0 ? 1 : 0;
00101 
00102         }
00103 
00104         return nSet;
00105     }
00106 
00107 private:
00108 
00109 
00110     Options options_p;
00111 };
00112 
00113 class AveragingParameters {
00114 
00115 public:
00116 
00117     AveragingParameters ();
00118 
00119     AveragingParameters (Double averagingInterval,
00120                          Double chunkInterval,
00121                          const SortColumns & sortColumns = SortColumns (),
00122                          const AveragingOptions & options = AveragingOptions (),
00123                          Double maxUvwDistance = 0,
00124                          WeightScaling * weightScalingForAveraging = 0,
00125                          Bool isWriteable = False,
00126                          Double dx = 0,
00127                          Double dy = 0);
00128 
00129     AveragingParameters (const AveragingParameters & other);
00130 
00131     AveragingParameters & operator= (const AveragingParameters & other);
00132 
00133     Double getAveragingInterval () const;
00134     Double getChunkInterval () const;
00135     Double getMaxUvwDistance () const;
00136     const AveragingOptions & getOptions() const;
00137     const SortColumns & getSortColumns () const;
00138     WeightScaling * getWeightScaling () const;
00139     Double getXpcOffset () const;
00140     Double getYpcOffset () const;
00141     Bool isWriteable () const;
00142 
00143     void setAveragingInterval (Double);
00144     void setChunkInterval (Double);
00145     void setSortColumns (const SortColumns &);
00146     void setOptions (const AveragingOptions &);
00147     void setMaxUvwDistance (Double);
00148     void setWeightScaling (WeightScaling *);
00149     void setWritable (Bool isWritable);
00150     void setPhaseShift (Double dx, Double dy);
00151 
00152 private:
00153 
00154     void validate ();
00155     void validateOptions ();
00156 
00157     Double averagingInterval_p;
00158     AveragingOptions averagingOptions_p;
00159     Double chunkInterval_p;
00160     Double maxUvwDistance_p;
00161     SortColumns sortColumns_p;
00162     WeightScaling * weightScaling_p;
00163     Bool isWritable_p;
00164     Double XpcOffset_p;
00165     Double YpcOffset_p;
00166 
00167     VisBufferComponents2 allDataColumns () const;
00168 
00169 };
00170 
00171 // The AveragingVi2Factory is used to initialize a VisibilityIterator2 so that
00172 // it performs time averaging.  The parameters are fairly straightforward:
00173 //
00174 // averagingInterval - the time period to average over
00175 // chunkInterval - the time interval of an averaged chunk
00176 // sortColumns - the usual set of sort columns.  The sort columns also determine
00177 //               the boundaries of a chunk.  If a column is present in the sort
00178 //               columns, then there will be no averaging across values with different
00179 //               values of that column (e.g., scan_number, array_id, etc.).  This is
00180 //               because a chunk is defined to be the set of records having the same
00181 //               values for all of the sort columns except for time.  The time column
00182 //               is used to select rows having the same sort-column values but within
00183 //               a specified interval of time.
00184 
00185 class AveragingVi2Factory : public ViFactory {
00186 
00187 public:
00188 
00189     AveragingVi2Factory (const AveragingParameters & parameters,
00190                          MeasurementSet * ms);
00191 
00192     AveragingVi2Factory (const AveragingParameters & parameters,
00193                          MeasurementSet * ms1,
00194                          MeasurementSet * ms2,
00195                          ...);
00196     // use 0 to mark end of MSs
00197 
00198     AveragingVi2Factory (const AveragingParameters & parameters,
00199                          const Block<const MeasurementSet *> & mss);
00200 
00201     ~AveragingVi2Factory ();
00202 
00203 protected:
00204 
00205     virtual ViImplementation2 * createVi () const;
00206 
00207 private:
00208 
00209     void initialize (const AveragingParameters & parameters,
00210                      const Block<const MeasurementSet *> & mss);
00211 
00212     Block<const MeasurementSet *> mss_p;
00213     AveragingParameters parameters_p;
00214 };
00215 
00216 
00217 class AveragingVi2LayerFactory : public ViiLayerFactory {
00218 
00219 public:
00220 
00221   AveragingVi2LayerFactory(const AveragingParameters& avepars);
00222 
00223   virtual ~AveragingVi2LayerFactory() {};
00224 
00225  protected:
00226 
00227   
00228   virtual ViImplementation2 * createInstance(ViImplementation2* vii0) const;
00229 
00230   const AveragingParameters avepars_p;
00231 
00232 };
00233 
00234 
00235 } // end namesapce vi
00236 } // end namespace casa
00237 
00238 
00239 #endif /* MSVIS_AVERAGINGVIFACTORY_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1