casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SDMBinData.h
Go to the documentation of this file.
1 #if !defined(_SDMBINDATA_H)
2 
3 #include <iostream>
4 #include <sstream>
5 #include <string>
6 
7 #include <alma/ASDM/ASDMEntities.h>
8 #include <alma/ASDM/Tag.h>
9 #include <alma/ASDM/ArrayTime.h>
11 
12 // Enumerations used to select data:
19 
21 
22 // Views:
24 
27 
28 
31 
32 // shared_ptr not needed by CASA, do not compile this for the WITHOUT_BOOST option
33 // It may be needed by ALMA code, so do not elimiate it yet.
34 #ifndef WITHOUT_BOOST
35 #include <boost/shared_ptr.hpp>
36 #endif
37 
38 // #include "Singleton.hpp"
39 // #include "ExecBlockDir.hpp"
40 
41 namespace sdmbin{
42 
44 class SDMBinData{
45  public:
46  /* SDMBinData(); */
62  SDMBinData( asdm::ASDM* const datasetPtr, std::string execBlockDir);
63 
64  ~SDMBinData();
65 
73  void select( EnumSet<ScanIntentMod::ScanIntent> es_si);
74 
82  void select( EnumSet<ProcessorTypeMod::ProcessorType> es_pt);
83 
91  void select( EnumSet<CorrelationModeMod::CorrelationMode> es_cm);
92 
100  void select( EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> es_srt);
101 
109  void select( EnumSet<TimeSamplingMod::TimeSampling> es_ts);
110 
111 
121  void select( EnumSet<CorrelationModeMod::CorrelationMode> es_cm,
122  EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> es_srt,
123  EnumSet<TimeSamplingMod::TimeSampling> es_ts);
124 
125 
134  void selectDataSubset( Enum<CorrelationModeMod::CorrelationMode> e_qcm,
135  EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc );
136 
142 
149  std::vector<std::pair<unsigned int,double> > timeSequence()const;
150 
154  bool dataDescriptionFirst()const;
155 
161  void applySysCal();
162 
166  bool sysCalApplied() const;
167 
174  ProcessorTypeMod::ProcessorType processorType(asdm::MainRow* const mainRowPtr) const;
175 
183  bool acceptMainRow( asdm::MainRow* const mainRowPtr);
184 
191  bool openMainRow(asdm::MainRow* const mainRowPtr);
192 
198  std::string reasonToReject(asdm::MainRow* const mainRowPtr);
199 
200 
216  bool isComplexData();
217 
218  std::vector<SDMData*> getData();
219 
225  std::vector<MSData*> getData( Enum<CorrelationModeMod::CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc);
226 
227  MSData* getData( unsigned int na, unsigned int nfe, unsigned int ndd, unsigned int nbin) throw (Error);
228 
229  MSData* getCalibratedData( unsigned int na, unsigned int nfe, unsigned int ndd, unsigned int nbin,
230  std::pair<bool,std::vector<std::vector<float> > > p_tsys) throw (Error);
231 
232  MSData* getData( unsigned int na1, unsigned int nfe1, unsigned int na2, unsigned int nfe2,
233  unsigned int ndd, unsigned int nbin, std::vector<unsigned int> v_napc,
234  float scleFactor);
235 
236  MSData* getCalibratedData( unsigned int na1, unsigned int nfe1, unsigned int na2, unsigned int nfe2,
237  unsigned int ndd, unsigned int nbin, std::vector<unsigned int> v_napc,
238  float scleFactor,
239  std::pair<bool,std::vector<std::vector<float> > > p_tsys);
240 
241  MSData* getData( asdm::Tag antId, int feedId,
242  asdm::Tag dataDescId,
243  AtmPhaseCorrectionMod::AtmPhaseCorrection apc,
244  unsigned int binNum);
245 
246  MSData* getData( asdm::Tag antId1, int feedId1,
247  asdm::Tag antId2, int feedId2,
248  asdm::Tag dataDescId,
249  std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection> v_apc,
250  unsigned int binNum);
251 
252  const VMSData* getDataCols();
253 
254  const VMSData* getDataCols( Enum<CorrelationModeMod::CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc );
255 
266  const VMSData* getNextMSMainCols(unsigned int n);
267  const VMSData* getNextMSMainCols(Enum<CorrelationModeMod::CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc, unsigned int n);
268 
269  // shared_ptr not needed by CASA, do not compile this for the WITHOUT_BOOST option
270  // It may be needed by ALMA code, so do not elimiate it yet.
271 #ifndef WITHOUT_BOOST
272  void getNextMSMainCols(unsigned int n, boost::shared_ptr<VMSDataWithSharedPtr>& vmsData_p_sp);
273  void getNextMSMainCols(Enum<CorrelationModeMod::CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc, unsigned int n, boost::shared_ptr<VMSDataWithSharedPtr>& vmsData_p_sp);
274 #endif
275 
276  std::vector<MSData*> getMSDataFromBDFData(Enum<CorrelationModeMod::CorrelationMode> e_qcm, EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc, unsigned int n);
277 
281  void getNextDataDumps(unsigned int n);
282 
290  static bool baselineReverse();
291 
297  static bool autoTrailing();
298 
300  static std::pair<bool,bool> dataOrder();
301 
302  protected:
303 
307  int attachDataObject(std::string dataOID);
308 
313  int attachStreamDataObject(const std::string& dataOID);
314 
325  int openStreamDataObject(const std::string& dataOID);
326 
329  void detachDataObject();
330 
343  MSState getMSState( unsigned int subscanNum,
344  std::vector<asdm::Tag> v_stateId,
345  std::vector<asdm::Tag> v_antennaId, std::vector<int> v_feedId, std::vector<asdm::Tag> v_ddId,
346  unsigned int na, unsigned int nfe, unsigned int nspw, asdm::ArrayTime timeOfDump);
347 
348  private:
350  static std::string execBlockDir_;
351  static bool canSelect_;
352  static bool forceComplex_; // true ==> autoData will be transformed into complex data
353  EnumSet<ScanIntentMod::ScanIntent> es_si_; // set of scan intents selected
354  EnumSet<ProcessorTypeMod::ProcessorType> es_pt_; // set of processor type selected
355  EnumSet<CorrelationModeMod::CorrelationMode> es_cm_; // set of correlation mode selected
356  EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> es_srt_; // set of spectral resolution types selected
357  EnumSet<TimeSamplingMod::TimeSampling> es_ts_; // set of time sampling selected
358 
359  Enum<CorrelationModeMod::CorrelationMode> e_qcm_; // query to select a subset of data in a BLOB
360  EnumSet<AtmPhaseCorrectionMod::AtmPhaseCorrection> es_qapc_; // query to select a subset of data in a BLOB
361 
362  bool ddfirst_; // true ==> output sequences of time for every dataDescription
363 
365  std::string dataOID_;
366  asdmbinaries::SDMDataObjectReader blob_r_; // current read-only BLOB
367  asdmbinaries::SDMDataObjectStreamReader sdmdosr ; // current SDMDataObjectStreamReader
368  bool bdfMemoryMapped; // will the BDF mapped in memory (true) or read sequentially (false) ?
369  std::vector<DataDump*> v_dataDump_;
370 
371  const float* floatDataPtr_; // mutable attribute; autocorrelation data of a single dump
372  const short* shortDataPtr_; // mutable attribute; visiblity data of a single dump
373  const int* longDataPtr_; // mutable attribute; visiblity data of a single dump
374  static MSData* msDataPtr_; // mutable attribute; one MS-MAIN row given
375  static SDMData* sdmDataPtr_; // mutable attribute; one SDM-Main (v2) row
376  static BaselinesSet* baselinesSet_; // mutable attribute
377  static std::vector<MSData*> v_msDataPtr_; // mutable attribute
379  static std::vector<SDMData*> v_sdmDataPtr_;
380  std::map<asdm::Tag,BaselinesSet*> m_cdId_baselinesSet_;
381  std::set<asdm::Tag> s_cdId_; // the keys present in m_cdId_baselinesSet_ (used for optimization)
383  static bool coutDeleteInfo_; // utility for debugging
384  static bool baselineReverse_; // order in which the data are in the returning VMSData structure.
385  static bool autoTrailing_; // position of the auto data relative cross data in the returning VMSData structure.
386  static bool syscal_; // true ==> apply system temperature calibration.
387 
388  const float* floatDataDumpPtr_;
389 
390  std::vector<std::pair<unsigned int,double> > v_tci_; // Indexed time centroid sequence
391 
392  void deleteMsData(MSData* msDataPtr);
393 
394  bool verbose_ ; // A variable to turn on/off the verbosity of the code, traditionnally based on the existence of env var "ASDM_DEBUG"
395 };
396 
397 }
398 
399 #define _SDMBINDATA_H
400 #endif
int openStreamDataObject(const std::string &dataOID)
Initialize the sequential reading of the SDMDataSubsets (i.e.
A structure containing a block of data for a single MS Main table row.
Definition: SDMDataViews.h:58
int attachStreamDataObject(const std::string &dataOID)
Do the actual binary data binding.
asdm::MainRow * mainRowPtr_
Definition: SDMBinData.h:364
void setPriorityDataDescription()
Method to set priority for DataDescription in the output order.
EnumSet< SpectralResolutionTypeMod::SpectralResolutionType > es_srt_
Definition: SDMBinData.h:356
The Error class represents a list of exceptions that may happen when errors occur.
Definition: ATMError.h:56
std::set< asdm::Tag > s_cdId_
Definition: SDMBinData.h:381
asdmbinaries::SDMDataObjectReader blob_r_
Definition: SDMBinData.h:366
static bool coutDeleteInfo_
Definition: SDMBinData.h:383
static asdm::ASDM * datasetPtr_
Definition: SDMBinData.h:349
std::vector< DataDump * > v_dataDump_
Definition: SDMBinData.h:369
static std::string execBlockDir_
Definition: SDMBinData.h:350
EnumSet< ProcessorTypeMod::ProcessorType > es_pt_
Definition: SDMBinData.h:354
EnumSet< ScanIntentMod::ScanIntent > es_si_
Definition: SDMBinData.h:353
void detachDataObject()
Unset the current data binding.
MSState getMSState(unsigned int subscanNum, std::vector< asdm::Tag > v_stateId, std::vector< asdm::Tag > v_antennaId, std::vector< int > v_feedId, std::vector< asdm::Tag > v_ddId, unsigned int na, unsigned int nfe, unsigned int nspw, asdm::ArrayTime timeOfDump)
Determine the view of a MS STATE.
EnumSet< CorrelationModeMod::CorrelationMode > es_cm_
Definition: SDMBinData.h:355
int attachDataObject(std::string dataOID)
Do the actual binary data binding.
static bool baselineReverse_
Definition: SDMBinData.h:384
static bool syscal_
Definition: SDMBinData.h:386
The ASDM class is the container for all tables.
Definition: ASDM.h:273
static MSData * msDataPtr_
Definition: SDMBinData.h:374
void getNextDataDumps(unsigned int n)
Populates the vector v_dataDump after having read at most n DataSubsets in the BDF.
Definition of the second level (the top level) in the tree hierarchy: include the antenna baseline co...
Definition: BaselinesSet.h:17
std::vector< std::pair< unsigned int, double > > v_tci_
Definition: SDMBinData.h:390
SDMBinData(asdm::ASDM *const datasetPtr, std::string execBlockDir)
Constructor:
bool openMainRow(asdm::MainRow *const mainRowPtr)
Accessor to one SDM Main table row.
void selectDataSubset(Enum< CorrelationModeMod::CorrelationMode > e_qcm, EnumSet< AtmPhaseCorrectionMod::AtmPhaseCorrection > es_qapc)
Method to constrain the getData methods to return a (sub)set of the data which are in the BLOBs...
const VMSData * getNextMSMainCols(unsigned int n)
Returns a pointer to a VMSData structure containing the values require to populate the MS Main table ...
std::vector< SDMData * > getData()
std::vector< std::pair< unsigned int, double > > timeSequence() const
Accessor to the sequence of time centroids.
bool sysCalApplied() const
Predicate to know if the system temperature calibration is applied when accessing data...
static std::vector< SDMData * > v_sdmDataPtr_
Definition: SDMBinData.h:379
bool dataDescriptionFirst() const
Predicate to tell if the dataDescriptionId has priority over time in the out sequence of MSData objec...
ProcessorTypeMod::ProcessorType processorType(asdm::MainRow *const mainRowPtr) const
A utility method which returns the type of the processor which produced the data referred to by a row...
const int * longDataPtr_
Definition: SDMBinData.h:373
static bool autoTrailing()
To know easily the position of the auto data and metadata relative to the cross data and metadata in ...
std::map< asdm::Tag, BaselinesSet * > m_cdId_baselinesSet_
Definition: SDMBinData.h:380
asdmbinaries::SDMDataObjectStreamReader sdmdosr
Definition: SDMBinData.h:367
Enum< CorrelationModeMod::CorrelationMode > e_qcm_
Definition: SDMBinData.h:359
The MainRow class is a row of a MainTable.
Definition: MainRow.h:132
bool acceptMainRow(asdm::MainRow *const mainRowPtr)
Accessor to the SDM Main table rows.
MSData * getCalibratedData(unsigned int na, unsigned int nfe, unsigned int ndd, unsigned int nbin, std::pair< bool, std::vector< std::vector< float > > > p_tsys)
EnumSet< TimeSamplingMod::TimeSampling > es_ts_
Definition: SDMBinData.h:357
A structure containing the data from a single SDM BLOB (origin: version for TP FBT, FV 12 Avril 2007) with the view of one row in the SDM Main table.
Definition: SDMDataViews.h:18
A structure containing state information following the MSv2.0 data model.
Definition: SDMDataViews.h:45
static VMSData * vmsDataPtr_
Definition: SDMBinData.h:378
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
std::string dataOID_
Definition: SDMBinData.h:365
static bool baselineReverse()
To know easily in which order the baselines are returned in a sequence of MSData objects or in a VMSD...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
static bool canSelect_
Definition: SDMBinData.h:351
void select(EnumSet< ScanIntentMod::ScanIntent > es_si)
Method to select the main table rows to retrieve data for a subset of scan intents.
bool isComplexData()
Method to know if the data to be retrieved will be of type complex or not.
const float * floatDataDumpPtr_
Definition: SDMBinData.h:388
void applySysCal()
Apply system temperature calibration.
A class to read a MIME message containing ALMA binary data and provide a view on these binary data th...
static BaselinesSet * baselinesSet_
Definition: SDMBinData.h:376
Accessor to the SDM binary data.
Definition: SDMBinData.h:44
void deleteMsData(MSData *msDataPtr)
const float * floatDataPtr_
Definition: SDMBinData.h:371
static std::pair< bool, bool > dataOrder()
The two parameters defining the order in the output sequences, baslineReverse and autoTrailing...
const VMSData * getDataCols()
std::vector< MSData * > getMSDataFromBDFData(Enum< CorrelationModeMod::CorrelationMode > e_qcm, EnumSet< AtmPhaseCorrectionMod::AtmPhaseCorrection > es_qapc, unsigned int n)
static std::vector< MSData * > v_msDataPtr_
Definition: SDMBinData.h:377
static bool forceComplex_
Definition: SDMBinData.h:352
EnumSet< AtmPhaseCorrectionMod::AtmPhaseCorrection > es_qapc_
Definition: SDMBinData.h:360
static SDMData * sdmDataPtr_
Definition: SDMBinData.h:375
std::string reasonToReject(asdm::MainRow *const mainRowPtr)
Filter: rejection of a Main table row if it does not satisfy the criterion of selection.
A structure containing the data from a single SDM BLOB.
Definition: SDMDataViews.h:95
const short * shortDataPtr_
Definition: SDMBinData.h:372
static bool autoTrailing_
Definition: SDMBinData.h:385