AveragingTvi2.h

Go to the documentation of this file.
00001 #if ! defined (Msvis_AveragingTvi2_H_121211_1236)
00002 #define Msvis_AveragingTvi2_H_121211_1236
00003 
00004 #include <casa/aips.h>
00005 #include <msvis/MSVis/TransformingVi2.h>
00006 #include <msvis/MSVis/VisibilityIterator2.h>
00007 #include <msvis/MSVis/AveragingVi2Factory.h>
00008 
00009 namespace casa {
00010 
00011 namespace ms {
00012 
00013 class MsRow;
00014 
00015 };
00016 
00017 namespace vi {
00018 
00019 class AveragingOptions;
00020 
00021 namespace avg {
00022 
00023 class MsRowAvg;
00024 class VbAvg;
00025 
00026 }
00027 
00028 class AveragingTvi2 : public TransformingVi2 {
00029 
00030 public:
00031 
00032     AveragingTvi2 (ViImplementation2 * inputVii,
00033                    const AveragingParameters & averagingParameters);
00034     ~AveragingTvi2 ();
00035 
00036     // Report the the ViImplementation type
00037     virtual String ViiType() const { return String("TimeAve( ")+getVii()->ViiType()+" )"; };
00038 
00040     //
00041     // Chunk/Subchunk structure in the AveragingTvi2
00042     //
00043     // The averaging interval, in seconds, is specified at construction time.
00044     // The interval (i.e., the size of the chunk in time) is also specified
00045     // at creation time; the interval must be an integer multiple of the
00046     // averaging interval.
00047     //
00048     // The input VI's setting must be compatible with those of the
00049     // AveragingTvi2.  This means that the chunk size of the input VI must
00050     // have the same duration as the averaging VI.  Although the input VI
00051     // and the averaging VI have the same duration, the averaging VI will
00052     // have fewer subchunks since N input subchunks will be averaged down
00053     // to create a single output subchunk.
00054     //
00055     // The input VI will also define the averaging boundaries by its
00056     // definition of a chunk.  For example, if the input VI allows data with
00057     // different scans to be in the same chunk, then they will potentially
00058     // be averaged together.
00059     //
00060     // The input VI must use the data description ID as a sort column so that
00061     // a chunk will only contain data from a single DDID setting.
00062 
00063     void originChunks (Bool forceRewind = False);
00064     void nextChunk ();
00065     Bool moreChunks () const;
00066 
00067     void origin ();
00068     void next ();
00069     Bool more () const;
00070 
00071     void writeFlag (const Cube<Bool> & flag);
00072     void writeFlagRow (const Vector<Bool> & rowflags);
00073 
00074     static Float weightToSigma (Float weight);
00075     static inline Float sigmaToWeight (Float sigma)
00076     {
00077         return sigma > FLT_MIN ? 1.0 / (sigma * sigma) : 0.0; // bad sample
00078     }
00079 
00080 
00081     static Vector<Float> average (const Matrix<Float> &data, const Matrix<Bool> &flags);
00082     static Matrix<Float> average (const Cube<Float> &data, const Cube<Bool> &flags);
00083 
00084 protected:
00085 
00086     void advanceInputVii ();
00087     Int determineDdidToUse () const;
00088     Bool inputExceedsTimeDistance (ms::MsRow * rowInput, avg::MsRowAvg * rowAveraged);
00089     Bool inputExceedsUvwDistance (ms::MsRow * rowInput, avg::MsRowAvg * rowAveraged);
00090     void produceSubchunk ();
00091     void processInputSubchunk (const VisBuffer2 *);
00092     Bool reachedAveragingBoundary();
00093     void captureIterationInfo (const VisBuffer2 * vb2);
00094     bool subchunksReady () const;
00095     void validateInputVi (ViImplementation2 *);
00096 
00097 private:
00098 
00099     const Double averagingInterval_p; // averaging interval in seconds
00100     AveragingOptions averagingOptions_p;
00101     AveragingParameters averagingParameters_p;
00102     Int ddidLastUsed_p; // ddId last used to produce a subchunk.
00103     Bool inputViiAdvanced_p; // true if input VII was advanced but data not used
00104     Bool more_p;
00105     Subchunk subchunk_p;
00106     Bool subchunkExists_p;
00107     avg::VbAvg * vbAvg_p;
00108     WeightScaling * weightScaling_p;
00109     Int startBuffer_p;
00110     Int endBuffer_p;
00111 };
00112 
00113 } // end namespace vi
00114 
00115 } // end namespace casa
00116 
00117 #endif // ! defined (Msvis_AveragingTvi2_H_121211_1236)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1