casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDMBinData.h
Go to the documentation of this file.
00001 #if     !defined(_SDMBINDATA_H)
00002 
00003 #include <iostream>
00004 #include <sstream>
00005 #include <string>
00006 
00007 #include <ASDMEntities.h>  
00008 #include <Tag.h>
00009 #include <ArrayTime.h>
00010 #include <ArrayTimeInterval.h>
00011 
00012 // Enumerations used to select data:
00013 #include <AtmPhaseCorrection.h>
00014 #include <CorrelationMode.h>
00015 #include <ProcessorType.h>
00016 #include <ScanIntent.h>
00017 #include <SpectralResolutionType.h>
00018 #include <TimeSampling.h>
00019 
00020 #include <CorrelatorType.h>
00021 
00022 // Views:
00023 #include "SDMDataViews.h"
00024 
00025 #include "BaselinesSet.h"
00026 #include "Integration.h"
00027 
00028 
00029 #include "SDMDataObjectReader.h"
00030 #include "SDMDataObjectStreamReader.h"
00031 
00032 #include <boost/shared_ptr.hpp>
00033 
00034 using namespace asdmbinaries;
00035 
00036 // #include "Singleton.hpp"
00037 // #include "ExecBlockDir.hpp"
00038 
00039 
00040 using namespace std;
00041 using namespace asdm;
00042 
00043 namespace sdmbin{
00044 
00046 class SDMBinData{
00047  public:
00048   /*   SDMBinData(); */
00064   SDMBinData( ASDM* const datasetPtr, string execBlockDir);
00065 
00066   ~SDMBinData();
00067 
00075   void select( EnumSet<ScanIntent> es_si);
00076 
00084   void select( EnumSet<ProcessorType> es_pt);
00085 
00093   void select( EnumSet<CorrelationMode> es_cm);
00094   
00102   void select( EnumSet<SpectralResolutionType> es_srt);
00103 
00111   void select( EnumSet<TimeSampling> es_ts);
00112 
00113 
00123   void select( EnumSet<CorrelationMode>        es_cm,
00124                EnumSet<SpectralResolutionType> es_srt, 
00125                EnumSet<TimeSampling>           es_ts);  
00126 
00127 
00136   void selectDataSubset( Enum<CorrelationMode>       e_qcm,
00137                          EnumSet<AtmPhaseCorrection> es_qapc );
00138 
00143   void setPriorityDataDescription();
00144 
00151   vector<pair<unsigned int,double> > timeSequence()const;
00152 
00156   bool dataDescriptionFirst()const;
00157 
00163   void applySysCal();
00164 
00168   bool sysCalApplied() const;
00169 
00176   ProcessorType processorType(MainRow* const mainRowPtr) const; 
00177 
00185   bool acceptMainRow( MainRow* const mainRowPtr);
00186 
00193   bool openMainRow(MainRow* const mainRowPtr);
00194 
00200   string reasonToReject(MainRow* const mainRowPtr);
00201 
00202 
00218   bool isComplexData();
00219 
00220   vector<SDMData*> getData();
00221 
00227   vector<MSData*>  getData( Enum<CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrection> es_qapc); 
00228 
00229   MSData*          getData( unsigned int na, unsigned int nfe, unsigned int ndd, unsigned int nbin) throw (Error); 
00230 
00231   MSData*          getCalibratedData( unsigned int na, unsigned int nfe, unsigned int ndd, unsigned int nbin,
00232                                       pair<bool,vector<vector<float> > > p_tsys) throw (Error); 
00233 
00234   MSData*          getData( unsigned int na1, unsigned int nfe1, unsigned int na2, unsigned int nfe2, 
00235                             unsigned int ndd, unsigned int nbin, vector<unsigned int> v_napc,
00236                             float scleFactor);
00237 
00238   MSData*          getCalibratedData( unsigned int na1, unsigned int nfe1, unsigned int na2, unsigned int nfe2, 
00239                                       unsigned int ndd, unsigned int nbin, vector<unsigned int> v_napc,
00240                                       float scleFactor,
00241                                       pair<bool,vector<vector<float> > > p_tsys);
00242 
00243   MSData*          getData( Tag antId, int feedId,
00244                             Tag dataDescId, 
00245                             AtmPhaseCorrection apc, 
00246                             unsigned int  binNum); 
00247 
00248   MSData*          getData( Tag antId1, int feedId1,
00249                             Tag antId2, int feedId2,
00250                             Tag dataDescId, 
00251                             vector<AtmPhaseCorrection> v_apc, 
00252                             unsigned int  binNum); 
00253 
00254   const VMSData* getDataCols();
00255 
00256   const VMSData* getDataCols( Enum<CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrection> es_qapc );
00257 
00268   const VMSData* getNextMSMainCols(unsigned int n);
00269   void getNextMSMainCols(unsigned int n, boost::shared_ptr<VMSDataWithSharedPtr>& vmsData_p_sp);
00270 
00271   const VMSData* getNextMSMainCols(Enum<CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrection> es_qapc, unsigned int n);
00272   void getNextMSMainCols(Enum<CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrection> es_qapc, unsigned int n, boost::shared_ptr<VMSDataWithSharedPtr>& vmsData_p_sp);
00273 
00274   vector<MSData*> getMSDataFromBDFData(Enum<CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrection> es_qapc, unsigned int n);
00275 
00279   void getNextDataDumps(unsigned int n);
00280 
00288   static bool baselineReverse();
00289 
00295   static bool autoTrailing();
00296 
00298   static pair<bool,bool> dataOrder();
00299 
00300  protected:
00301 
00305   int  attachDataObject(string dataOID);
00306 
00311   int  attachStreamDataObject(const string& dataOID);
00312 
00323   int openStreamDataObject(const string& dataOID);
00324 
00327   void detachDataObject();
00328 
00341   MSState          getMSState( unsigned int subscanNum, 
00342                                vector<Tag>  v_stateId, 
00343                                vector<Tag>  v_antennaId, vector<int> v_feedId, vector<Tag> v_ddId,
00344                                unsigned int na, unsigned int nfe, unsigned int nspw, ArrayTime timeOfDump);
00345 
00346  private:
00347   static ASDM*                     datasetPtr_;
00348   static string                  execBlockDir_;
00349   static bool                       canSelect_;
00350   static bool                    forceComplex_;  // true ==> autoData will be transformed into complex data
00351   EnumSet<ScanIntent>                   es_si_;  // set of scan intents selected
00352   EnumSet<ProcessorType>                es_pt_;  // set of processor type selected
00353   EnumSet<CorrelationMode>              es_cm_;  // set of correlation mode selected
00354   EnumSet<SpectralResolutionType>      es_srt_;  // set of spectral resolution types selected
00355   EnumSet<TimeSampling>                 es_ts_;  // set of time sampling selected
00356 
00357   Enum<CorrelationMode>                 e_qcm_;  // query to select a subset of data in a BLOB
00358   EnumSet<AtmPhaseCorrection>         es_qapc_;  // query to select a subset of data in a BLOB
00359 
00360   bool                                ddfirst_;  // true ==> output sequences of time for every dataDescription
00361 
00362   MainRow*                         mainRowPtr_;
00363   string                              dataOID_;
00364   SDMDataObjectReader                  blob_r_;  // current read-only BLOB
00365   SDMDataObjectStreamReader           sdmdosr ;  // current SDMDataObjectStreamReader
00366   bool                         bdfMemoryMapped;  // will the BDF mapped in memory (true) or read sequentially (false) ?
00367   vector<DataDump*>                v_dataDump_;
00368 
00369   const  float*                  floatDataPtr_;  // mutable attribute; autocorrelation data of a single dump
00370   const  short*                  shortDataPtr_;  // mutable attribute; visiblity data of a single dump
00371   const  int*                     longDataPtr_;  // mutable attribute; visiblity data of a single dump
00372   const  unsigned int*               flagsPtr_;  // mutable attribute; flags data in a single dump
00373   const  int64_t*            actualTimesPtr_;  // mutable attribute; actualTimes in a single dump 
00374   const  int64_t*        actualDurationsPtr_;  // mutable attribute; actualDurations in a single dump
00375   const  float*                   zeroLagsPtr_;  // mutable attribute; zeroLags in a single dump
00376   static MSData*                    msDataPtr_;  // mutable attribute; one MS-MAIN row given
00377   static SDMData*                  sdmDataPtr_;  // mutable attribute; one SDM-Main (v2) row 
00378   static BaselinesSet*           baselinesSet_;  // mutable attribute
00379   static vector<MSData*>          v_msDataPtr_;  // mutable attribute
00380   static VMSData*                  vmsDataPtr_;
00381   static vector<SDMData*>        v_sdmDataPtr_;
00382   map<Tag,BaselinesSet*>  m_cdId_baselinesSet_;
00383   set<Tag>                             s_cdId_; // the keys present in  m_cdId_baselinesSet_ (used for optimization)
00384   bool                            complexData_;
00385   static bool                  coutDeleteInfo_; // utility for debugging
00386   static bool                 baselineReverse_; // order in which the data are in the returning VMSData structure.
00387   static bool                    autoTrailing_; // position of the auto data relative cross data in the returning VMSData structure.
00388   static bool                          syscal_; // true ==> apply system temperature calibration.
00389 
00390   const float*               floatDataDumpPtr_;
00391 
00392   vector<pair<unsigned int,double> >    v_tci_; // Indexed time centroid sequence
00393 
00394   void   deleteMsData(MSData* msDataPtr);
00395 
00396   bool verbose_ ;  // A variable to turn on/off the verbosity of the code, traditionnally based on the existence of env var "ASDM_DEBUG"
00397 };
00398 
00399 }
00400 
00401 #define _SDMBINDATA_H
00402 #endif