LCOV - code coverage report
Current view: top level - alma/ASDMBinaries - DataDescriptionsSet.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 399 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 44 0.0 %

          Line data    Source code
       1             : #include <set>
       2             : #include <stdio.h>
       3             : #include <iostream>
       4             : #include <stdlib.h> // for atoi()
       5             : #include <alma/ASDMBinaries/Error.h>
       6             : #include <alma/ASDMBinaries/DataDescriptionsSet.h>
       7             : 
       8             : #include <alma/Enumtcl/StokesParameter.h>
       9             : #include <alma/Enumtcl/PolarizationType.h>
      10             : 
      11             : using namespace asdm;
      12             : using namespace std;
      13             : 
      14             : using namespace AtmPhaseCorrectionMod;
      15             : using namespace BasebandNameMod;
      16             : using namespace CorrelationModeMod;
      17             : 
      18             : namespace sdmbin {
      19             : 
      20           0 :   DataDescriptionsSet::DataDescriptionsSet(){}
      21             : 
      22           0 :   DataDescriptionsSet::DataDescriptionsSet( ASDM* const datasetPtr, vector<Tag> v_switchCycleId,
      23             :                                             vector<Tag> v_dataDescriptionIdArray,
      24           0 :                                             CorrelationMode corrMode, vector<AtmPhaseCorrection> v_atmPhaseCorrection):
      25             :     SwitchCyclesList(datasetPtr, v_switchCycleId),
      26           0 :     v_dataDescriptionIdArray_(v_dataDescriptionIdArray),
      27           0 :     correlationMode_(corrMode),
      28           0 :     v_atmPhaseCorrection_(v_atmPhaseCorrection)
      29             :   {
      30             :     /*
      31             :      * Do v_switchCycleId and v_dataDescriptionIdArray have the same size ?
      32             :      */
      33           0 :     if ( v_switchCycleId.size() != v_dataDescriptionIdArray.size() )
      34           0 :       Error(FATAL, (char *) "It seems that the arrays 'switchCycleId' and 'dataDescriptionId' do not have the same size in one row of the ConfigDescription table !");
      35             : 
      36           0 :     bool coutest=false;
      37             : 
      38           0 :     e_cm_   = corrMode;
      39             : 
      40           0 :     numApc_ = v_atmPhaseCorrection_.size();
      41           0 :     es_apc_.reset();
      42             :     //for(unsigned int n=0; n<numApc_; n++)es_apc_.set(v_atmPhaseCorrection_[n]);
      43           0 :     es_apc_.set(v_atmPhaseCorrection_);
      44             : 
      45           0 :     map<BasebandName,vector<DataDescParams> >::iterator itbnddp, itbnddpb, itbnddpf, itbnddpe;
      46           0 :     numDataDescription_ = v_dataDescriptionIdArray.size();   
      47           0 :     sumAutoSize_        = 0;
      48           0 :     sumCrossSize_       = 0;
      49           0 :     vector<SpectralWindowRow*> v_spwr;
      50           0 :     DataDescriptionTable&      rddSet =  datasetPtr_->getDataDescription();
      51           0 :     SwitchCycleTable&          rscSet =  datasetPtr_->getSwitchCycle();
      52           0 :     for(unsigned int n=0; n<numDataDescription_; n++){
      53           0 :       Enum<BasebandName>  e_bbn;
      54           0 :       DataDescriptionRow* ddPtr=rddSet.getRowByKey(v_dataDescriptionIdArray[n]);
      55           0 :       SwitchCycleRow*     scPtr=rscSet.getRowByKey(v_switchCycleId[n]);
      56           0 :       v_spwr.push_back(ddPtr->getSpectralWindowUsingSpectralWindowId());
      57             :       //      if(v_spwr[n]->isBasebandNameExists()){    mandatory since ASDMv1
      58           0 :       BasebandName   bbn = ddPtr->getSpectralWindowUsingSpectralWindowId()->getBasebandName();
      59           0 :       DataDescParams ddp;
      60           0 :       ddp.ddIdx   = n;
      61           0 :       ddp.scId    = v_switchCycleId[n];
      62           0 :       ddp.polId   = ddPtr->getPolOrHoloId();
      63           0 :       ddp.spwId   = ddPtr->getSpectralWindowId();
      64           0 :       ddp.numChan = ddPtr->getSpectralWindowUsingSpectralWindowId()->getNumChan();
      65           0 :       ddp.numCorr = ddPtr->getPolarizationUsingPolOrHoloId()->getNumCorr();
      66           0 :       ddp.numBin  = scPtr->getNumStep();
      67           0 :       itbnddpf = m_bn_v_ddp_.find(bbn);
      68           0 :       itbnddpe = m_bn_v_ddp_.end();
      69             :       // a map view, the  DataDescriptions being grouped as a function of their parent babseband name
      70           0 :       if(itbnddpf==itbnddpe){
      71           0 :         vector<DataDescParams> v_ddp; v_ddp.push_back(ddp);
      72           0 :         m_bn_v_ddp_.insert(make_pair(bbn,v_ddp));
      73           0 :       }else{
      74           0 :         itbnddpf->second.push_back(ddp);
      75             :       }
      76             :       // also a flat description, the DataDescription view:
      77           0 :       v_basebandName_.push_back(bbn);
      78           0 :       v_spwId_.push_back(ddp.spwId);
      79           0 :       v_numChan_.push_back(ddp.numChan);
      80           0 :       v_numPol_.push_back(ddp.numCorr);
      81             :       //       }else{
      82             :       //        Error(SERIOUS,"BasebandName ASDM item missing when spectralWindowId=%d",
      83             :       //              atoi(ddPtr->getSpectralWindowId().toString().c_str()));
      84             :       //       }
      85             :       /*
      86             :         if(v_basebandNum_[n]<1||v_basebandNum_[n]>numBaseband_){
      87             :         cout << "ERROR: bbcNo must have a value in the range [1,"<<numBaseband_<<"]"<<endl;
      88             :         return;
      89             :         }
      90             :       */
      91           0 :       e_bbn=v_basebandName_[n];
      92           0 :       if(coutest){
      93           0 :         cout << "v_spwId_["<<n<<"]        = "<< v_spwId_[n].toString() << endl;
      94           0 :         cout << "v_numChan_["<<n<<"]      = "<< v_numChan_[n] << endl;
      95           0 :         cout << "v_numPol_["<<n<<"]       = "<< v_numPol_[n] << endl;
      96           0 :         cout << "v_basebandName_["<<n<<"] = "<< e_bbn.str() << endl;
      97             :       }
      98           0 :       mapScToBaseband();
      99           0 :     }
     100           0 :     unsigned int numBaseband = m_bn_v_ddp_.size();
     101           0 :     if(coutest)cout << "The list of dataDescription for configDescriptionId involves "
     102           0 :                     << numBaseband << " basebands" 
     103           0 :                     << endl;
     104             : 
     105             : 
     106             :     //     // check that the basebands are in the order constrained by the definition of the BasebandName enumeration:
     107             :     //     for(unsigned int n=1; n<v_basebandName_.size(); n++){
     108             :     //       if(v_basebandName_[n]<v_basebandName_)
     109             :     //  Error( SERIOUS,"The sequence of spectral windows does not correspond to an ascending\n sequence of basebands");
     110             :     //     }
     111             :       
     112             :     // sequence of basebands, nb of spw/bb for each member of this sequence and nb of spectral point within each of these spw
     113             :     bool                  newBaseband;
     114           0 :     EnumSet<BasebandName> es_bn;
     115             :     // sequence of basebands v_basebandSet_
     116           0 :     for(unsigned int ndd=0; ndd<v_dataDescriptionIdArray.size(); ndd++){
     117           0 :       newBaseband = true;
     118           0 :       if(es_bn[v_basebandName_[ndd]])newBaseband = false;
     119           0 :       es_bn.set(v_basebandName_[ndd],false);
     120           0 :       if(newBaseband){
     121           0 :         v_basebandSet_.push_back(v_basebandName_[ndd]);
     122             :       }
     123             :     }
     124           0 :     if(coutest)cout << "The list of dataDescriptions for configDescriptionId involves "
     125           0 :                     << numBaseband << " basebands following the sequence:" 
     126           0 :                     << endl;
     127             : 
     128           0 :     for(unsigned int nbb=0; nbb<numBaseband; nbb++)v_numSpwPerBb_.push_back(0);
     129           0 :     for(unsigned int nbb=0; nbb<numBaseband; nbb++){
     130           0 :       itbnddpf=m_bn_v_ddp_.find(v_basebandSet_[nbb]);    
     131             :       // nb of spw/bb for each member of this sequence
     132           0 :       v_numSpwPerBb_[nbb]=itbnddpf->second.size();
     133             :     
     134             : 
     135           0 :       Enum<BasebandName> e_bn=v_basebandSet_[nbb];
     136           0 :       if(coutest)cout << " - baseband " << e_bn.str()
     137           0 :                       << " has " << v_numSpwPerBb_[nbb] 
     138           0 :                       << " spectral windows "
     139           0 :                       << endl;
     140           0 :       vector<int> v_ndd;
     141             :       // nb of spectral point within each of these spw, baseband organized, following the sequence input order
     142           0 :       for(unsigned int ndd=0; ndd<itbnddpf->second.size(); ndd++)
     143           0 :         v_ndd.push_back(itbnddpf->second[ndd].numChan);
     144           0 :       vv_nsp_.push_back(v_ndd);
     145           0 :     }
     146             : 
     147             : 
     148             :     /* Determination of the dataDescription identifiers for the auto and cross-correlation.
     149             :        When both are stored the input list of identifiers is the one for the cross correlations.
     150             :        The method below searches for the implicit dataDescriptionId corresponding to the 
     151             :        auto-correlation coming with the data identifier of the cross-correlation dataDescriptionId.
     152             :        Note that in the case of DSB receivers with sideband separation using 90d phase switching
     153             :        to the two sideband spectral windows for the cross data correspond only one implicit DSB
     154             :        spectral window for the auto-correlation data. 
     155             :     */
     156           0 :     Enum<CorrelationMode> e_cm; e_cm=corrMode;
     157           0 :     if(e_cm[CROSS_ONLY]){                        // Case when there are only cross-correlations:
     158           0 :       if(coutest)cout << "Only cross-correlations use-case " << endl;
     159           0 :       for(unsigned int n=0; n<numDataDescription_; n++){
     160           0 :         v_crossDataDescriptionId_.push_back(v_dataDescriptionIdArray[n]);
     161           0 :         v_pairDataDescriptionId_.push_back(false);
     162             :       }
     163           0 :     }else if(e_cm[AUTO_ONLY]){                  // Case when there are only auto-correlations:
     164           0 :       if(coutest)cout << "Only auto-correlations use-case" << endl;
     165           0 :       for(unsigned int n=0; n<numDataDescription_; n++){
     166           0 :         v_autoDataDescriptionId_.push_back(v_dataDescriptionIdArray[n]);
     167           0 :         v_pairDataDescriptionId_.push_back(false);
     168             :       }
     169             :     }else{                                       // Case when there are both auto and cross-correlations
     170           0 :       for(unsigned int n=0; n<numDataDescription_; n++){
     171           0 :         v_crossDataDescriptionId_.push_back(v_dataDescriptionIdArray[n]);
     172           0 :         v_autoDataDescriptionId_.push_back(v_dataDescriptionIdArray[n]);
     173           0 :         v_pairDataDescriptionId_.push_back(true);
     174             :       }
     175             :     }
     176             :     // set the number of data and the sizes in number of primitive data type (PDT) values.
     177           0 :     size();
     178           0 :     if(coutest)cout << "Total size in correlated PDT data values (a complex being 2 PDT values):\n" 
     179           0 :                     << "   number of cross-correlations  " << sumCrossSize_
     180           0 :                     << "   number of auto-correlations   " << sumAutoSize_
     181           0 :                     << endl;
     182             : 
     183             :     // set the indices for the binary meta-data (timeCentroid and exposure)
     184           0 :     if(coutest)cout << "Build metadata index" << endl;
     185           0 :     metaDataIndex();
     186             : 
     187           0 :   }
     188             : 
     189           0 :   DataDescriptionsSet::DataDescriptionsSet(const DataDescriptionsSet & a) : SwitchCyclesList(a){
     190             :     //cout << "copy constructor DataDescriptionsSet" << endl;
     191             : 
     192             :     // attribute in the 'abstract' class SwitchCyclesList
     193           0 :     m_bn_v_scId_              = a.m_bn_v_scId_;
     194           0 :     m_bn_v_numBin_            = a.m_bn_v_numBin_;
     195           0 :     vv_numBin_                = a.vv_numBin_;
     196           0 :     v_numBin_                 = a.v_numBin_;
     197           0 :     datasetPtr_               = a.datasetPtr_;
     198           0 :     vv_switchCycleId_         = a.vv_switchCycleId_;
     199           0 :     v_switchCycleId_          = a.v_switchCycleId_;
     200             : 
     201             : 
     202             :     // attribute in the present DataDescriptionsSet class:
     203           0 :     v_numPol_                 = a.v_numPol_;
     204           0 :     v_spwId_                  = a.v_spwId_;
     205           0 :     v_numChan_                = a.v_numChan_;
     206           0 :     v_basebandName_           = a.v_basebandName_;
     207           0 :     vv_nsp_                   = a.vv_nsp_;
     208             : 
     209           0 :     m_bn_v_ddp_               = a.m_bn_v_ddp_;
     210           0 :     m_ddid_bbn_               = a.m_ddid_bbn_;
     211             :     //cout << "1" << endl;
     212           0 :     numApc_                   = a.numApc_;
     213           0 :     numDataDescription_       = a.numDataDescription_;
     214           0 :     e_cm_                     = a.e_cm_;
     215           0 :     correlationMode_          = a.correlationMode_;
     216           0 :     es_apc_                   = a.es_apc_;
     217           0 :     v_atmPhaseCorrection_     = a.v_atmPhaseCorrection_;
     218             :     //cout << "2" << endl;
     219           0 :     sumMetaDataIndex_         = a.sumMetaDataIndex_;
     220           0 :     sumAutoSize_              = a.sumAutoSize_;
     221           0 :     sumCrossSize_             = a.sumCrossSize_;
     222             :     //cout << "3" << endl;
     223           0 :     v_metaDataIndex_          = a.v_metaDataIndex_;
     224           0 :     v_cumulAutoSize_          = a.v_cumulAutoSize_; 
     225           0 :     v_cumulCrossSize_         = a.v_cumulCrossSize_;
     226           0 :     v_numAutoData_            = a.v_numAutoData_;
     227           0 :     v_numCrossData_           = a.v_numCrossData_;
     228           0 :     v_autoSize_               = a.v_autoSize_;
     229           0 :     v_crossSize_              = a.v_crossSize_;
     230             :     //cout << "4" << endl;
     231           0 :     v_dataDescriptionIdArray_ = a.v_dataDescriptionIdArray_;
     232           0 :     v_crossDataDescriptionId_ = a.v_crossDataDescriptionId_;
     233           0 :     v_autoDataDescriptionId_  = a.v_autoDataDescriptionId_;
     234           0 :     v_basebandSet_            = a.v_basebandSet_;
     235           0 :     v_numSpwPerBb_            = a.v_numSpwPerBb_;
     236             :     //cout << "deep copy done" << endl;
     237           0 :   }
     238             : 
     239           0 :   DataDescriptionsSet::~DataDescriptionsSet(){}
     240             :   
     241           0 :   void DataDescriptionsSet::mapScToBaseband(){
     242           0 :     map<BasebandName,vector<DataDescParams> >::iterator itbnddp, itbnddpb, itbnddpf, itbnddpe;
     243           0 :     itbnddpb = m_bn_v_ddp_.begin();
     244           0 :     itbnddpe = m_bn_v_ddp_.end();
     245           0 :     if(vv_numBin_.size()){
     246           0 :       if(vv_numBin_.size()!=m_bn_v_ddp_.size())
     247           0 :         Error(SERIOUS,(char *)"The input dataDescription and switchCycle identifiers are not defined with the same nb of basebands");
     248           0 :       int nbb=0;
     249           0 :       for(itbnddp=itbnddpb; itbnddp!=itbnddpe; ++itbnddp){
     250           0 :         if(itbnddp->second.size()!=vv_numBin_[nbb].size())
     251           0 :           Error(SERIOUS,(char *) "Nb of dataDescriptionId for baseband %d not equal to nb (%d) of switchCycleId for that baseband",
     252           0 :                 itbnddp->second.size(),vv_numBin_[nbb].size());
     253           0 :         m_bn_v_numBin_.insert( make_pair(itbnddp->first,vv_numBin_[nbb]) );
     254           0 :         m_bn_v_scId_.insert( make_pair(itbnddp->first,vv_switchCycleId_[nbb]) );
     255             :       }
     256             :     }else{
     257           0 :       for(itbnddp=itbnddpb; itbnddp!=itbnddpe; ++itbnddp){
     258           0 :         vector<int> vi;
     259           0 :         vector<Tag> vt;
     260           0 :         for(unsigned int n=0; n<itbnddp->second.size(); n++){
     261           0 :           vi.push_back(itbnddp->second[n].numBin);
     262           0 :           vt.push_back(itbnddp->second[n].scId);
     263             :         }
     264           0 :         m_bn_v_numBin_.insert( make_pair(itbnddp->first,vi) );
     265           0 :         m_bn_v_scId_.insert(   make_pair(itbnddp->first,vt) );
     266           0 :       }
     267             :     }
     268           0 :   }
     269             : 
     270             :   
     271           0 :   void DataDescriptionsSet::size(){
     272             :     /* Determine for every data description:
     273             :      *
     274             :      * v_numAutoData_, v_autoSize_,  v_cumulAutoSize, sumAutoSize_
     275             :      * v_numCrossData_,v_crossSize_, v_cumulCrossSize_, sumCrossSize_
     276             :      *
     277             :      * The two first vectors describe the leaf for the auto and cross use-cases in term of 
     278             :      * number of pixels (num) and number of values (a complex number counting for 2 values).
     279             :      * The third vector defines the cumulative distribution of sizes as a function of the 
     280             :      * dataDescrition index. The dimensionality of the leaf, 4, is set by the axes APC, 
     281             :      * BIN, SPP and POL
     282             :      * WARNING: The size of the APC axis is considered to be 1 for auto
     283             :      * sumAutoSize_ (sumCrossSize_) is the sum of the elements of v_autoSize_ (v_crossSize_) 
     284             :      * Note that the number of values and size of a leaf is null for auto when a cross 
     285             :      * dataDescrition has no associated auto  dataDescrition (use-case CROSS_AND_AUTO with 
     286             :      * DSB 90d phase switching, the auto having no sideband separation).
     287             :      */  
     288           0 :     bool coutest=false;
     289           0 :     sumAutoSize_  = 0;
     290           0 :     sumCrossSize_ = 0;
     291             :     unsigned long dataSize, numVis, numAuto, nv;
     292             :     unsigned long numAutoPol;
     293             :     // int k;   // set in old code, but never actually used, kept in the event I work out what it was originally for and need it
     294           0 :     for(unsigned int ndd=0; ndd<numDataDescription_; ndd++){
     295           0 :       nv = v_numChan_[ndd] * v_numBin_[ndd]; 
     296           0 :       if(correlationMode_!=CROSS_ONLY){   // case there are auto data
     297             :         // if(v_numPol_[n]==1)numAutoPol = 1;                    modif Feb 06
     298           0 :         if(e_cm_[AUTO_ONLY]){             // single dish case: the list of dd is the list of single-dish dd
     299           0 :           numAutoPol = numPol(ndd);
     300             :         }else{
     301           0 :           numAutoPol = numSdPol(ndd);     // both single dish and interfero: the dd list is the list of interfero dd
     302             :         }
     303           0 :         v_cumulAutoSize_.push_back(sumAutoSize_);
     304           0 :         if(coutest)cout << "numChan=    " << v_numChan_[ndd] << endl;
     305           0 :         if(coutest)cout << "numAutoPol= " << numAutoPol << endl;
     306           0 :         if(coutest)cout << "numBin=     " << v_numBin_[ndd] << endl;
     307           0 :         numAuto = nv*numAutoPol;                                      // number of autocorr
     308           0 :         if(e_cm_[CROSS_AND_AUTO])
     309           0 :           if(!v_pairDataDescriptionId_[ndd])numAuto=0;                // case of the image of a DSB sideband already registred
     310             : 
     311           0 :         v_numAutoData_.push_back(numAuto);                            // a re datum as well as a complex data counts for 1 num 
     312           0 :         if(coutest)cout << "numAuto/dd= " << v_numAutoData_[ndd] << endl;   
     313             : 
     314           0 :         if(numAutoPol==3)
     315           0 :           dataSize = nv*(numAutoPol+1);                               // because XY data have 1re + 1 im)
     316             :         else
     317           0 :           dataSize = numAuto;
     318             : 
     319           0 :         if(e_cm_[CROSS_AND_AUTO])
     320           0 :           if(!v_pairDataDescriptionId_[ndd])dataSize=0;               // case of the image of a DSB sideband already registred
     321             : 
     322             : 
     323           0 :         v_autoSize_.push_back(dataSize);                              // size in nb of PDT values 
     324           0 :         sumAutoSize_  = sumAutoSize_  + dataSize;                     // grand total size for auto
     325             :       }
     326           0 :       if(!e_cm_[AUTO_ONLY]){              // there are cross data
     327           0 :         if(coutest)cout << "numApc=     " << numApc_ << endl;
     328           0 :         if(coutest)cout << "numChan=    " << v_numChan_[ndd] << endl;
     329           0 :         if(coutest)cout << "numPol=     " << v_numPol_[ndd]  << endl;
     330           0 :         if(coutest)cout << "numBin=     " << v_numBin_[ndd]  << endl;
     331             :         // k = 1;   // see note above where it was originally declared, set but not used
     332             :         // if(e_cm_[CROSS_ONLY])k=0;                                     // case with only cross-correlations, set but not used
     333           0 :         v_cumulCrossSize_.push_back(sumCrossSize_);
     334           0 :         numVis = nv*v_numPol_[ndd]*numApc_;                 
     335           0 :         if(coutest) cout << "numVis=     " << numVis << endl;
     336           0 :         v_numCrossData_.push_back(numVis);                            // number of complex visibilities
     337           0 :         dataSize = numVis*2;                                          // a complex is composed of 2 primitive data type values
     338           0 :         v_crossSize_.push_back(dataSize);
     339           0 :         sumCrossSize_ = sumCrossSize_ + dataSize;                     // grand total size for cross 
     340             :       }
     341             :     }
     342           0 :     if(coutest)cout << "Total size in auto-correlation data per zero baseline: " << sumAutoSize_  << " PDT values" << endl;
     343           0 :     if(coutest)cout << "Total size in cross-correlation data per baseline:     " << sumCrossSize_ << " PDT values" << endl;
     344             : 
     345             :     // instantiate the vector of meta data (timeCentroid and exposure) indices
     346             : 
     347           0 :     return;
     348             :   }
     349             : 
     350           0 :   void DataDescriptionsSet::metaDataIndex(){
     351           0 :     sumMetaDataIndex_ = 0;
     352             : 
     353           0 :     for(unsigned int ndd=0; ndd<numDataDescription_; ndd++){
     354           0 :       v_metaDataIndex_.push_back(sumMetaDataIndex_);
     355           0 :       sumMetaDataIndex_  = sumMetaDataIndex_  + v_numBin_[ndd];
     356             :     }
     357           0 :     return;
     358             :   }
     359             : 
     360           0 :   unsigned int DataDescriptionsSet::sumMetaDataIndex(){
     361           0 :     return sumMetaDataIndex_;
     362             :   }
     363             : 
     364           0 :   unsigned int DataDescriptionsSet::metaDataIndex( unsigned int ndd) {
     365           0 :     if((unsigned int)ndd>=v_metaDataIndex_.size())
     366           0 :       Error(FATAL,(char *) "The dataDescription index index must be smaller than %d",
     367             :             v_metaDataIndex_.size());
     368           0 :     return v_metaDataIndex_[ndd];
     369             :   }
     370             : 
     371             : 
     372           0 :   unsigned long DataDescriptionsSet::getNumAutoData(Tag autoDataDescriptionId) { //throw (Error){
     373           0 :     bool coutest=false;
     374           0 :     int m=-1;
     375           0 :     for(unsigned int n=0; n<v_autoDataDescriptionId_.size(); n++){
     376           0 :       if(coutest)cout << autoDataDescriptionId.toString()
     377             :                       << " compared with" 
     378           0 :                       << v_autoDataDescriptionId_[n].toString()
     379           0 :                       << endl;
     380           0 :       if(autoDataDescriptionId==v_autoDataDescriptionId_[n])m=n;
     381             :     }
     382           0 :     if(m<0){
     383           0 :       Error(SERIOUS, (char *)"requested autoDataDescriptionId %s not present for the spectro-polarization setup", 
     384           0 :             autoDataDescriptionId.getTag().c_str());
     385           0 :       return 0;
     386             :     }
     387           0 :     return v_numAutoData_[m];
     388             :   }
     389             : 
     390           0 :   unsigned long DataDescriptionsSet::getNumAutoData(){
     391           0 :     unsigned long numData=0;
     392           0 :     for(unsigned int n=0; n<v_autoDataDescriptionId_.size(); n++)
     393           0 :       numData = numData+getNumAutoData(v_autoDataDescriptionId_[n]);
     394           0 :     return numData;
     395             :   }
     396             : 
     397           0 :   unsigned long DataDescriptionsSet::getNumCrossData(Tag crossDataDescriptionId)  {
     398           0 :     int m=-1;
     399           0 :     for(unsigned int n=0; n<v_crossDataDescriptionId_.size(); n++)
     400           0 :       if(crossDataDescriptionId==v_crossDataDescriptionId_[n])m=n;
     401           0 :     if(m<0){
     402           0 :       Error(SERIOUS,(char *) "requested crossDataDescriptionId %s not present in the spectro-polarization setup", 
     403           0 :             crossDataDescriptionId.getTag().c_str()); 
     404           0 :       return 0;
     405             :     }
     406           0 :     return v_numCrossData_[m];
     407             :   }
     408             : 
     409             : 
     410           0 :   unsigned long DataDescriptionsSet::getNumCrossData(){
     411           0 :     unsigned long numData=0;
     412           0 :     for(unsigned int n=0; n<v_crossDataDescriptionId_.size(); n++)
     413           0 :       numData = numData+getNumCrossData(v_crossDataDescriptionId_[n]);
     414           0 :     return numData;
     415             :   }
     416             : 
     417           0 :   Tag         DataDescriptionsSet::getAutoDataDescriptionId(Tag crossDataDescriptionId) {
     418             : 
     419           0 :     for(unsigned int ndd=0; ndd<v_crossDataDescriptionId_.size(); ndd++){
     420           0 :       if(crossDataDescriptionId==v_crossDataDescriptionId_[ndd])
     421           0 :         return v_autoDataDescriptionId_[ndd];
     422             :     }
     423           0 :     Error(SERIOUS,
     424             :           (char *) "The data description identifier %s does not exist in the spectro-polarization setup",
     425           0 :           crossDataDescriptionId.toString().c_str()); 
     426           0 :     return Tag((unsigned int)32767);
     427             :   }
     428             : 
     429             : 
     430           0 :   vector<Tag> DataDescriptionsSet::getAutoDataDescriptionId(){
     431           0 :     return v_autoDataDescriptionId_;
     432             :   }
     433             : 
     434             : 
     435             : 
     436           0 :   vector<Tag> DataDescriptionsSet::getCrossDataDescriptionId(){
     437           0 :     return v_crossDataDescriptionId_;
     438             :   }
     439             : 
     440           0 :   unsigned int DataDescriptionsSet::numBaseband(){
     441           0 :     return v_basebandSet_.size();
     442             :   }
     443             : 
     444           0 :   unsigned int DataDescriptionsSet::getNumChan(unsigned int ndd) {
     445           0 :     if((unsigned int)ndd>=v_numChan_.size())
     446           0 :       Error(SERIOUS,(char *) "The dataDescription number exceeds %d",
     447             :             v_numChan_.size());
     448           0 :     return v_numChan_[ndd];
     449             :   }
     450             : 
     451           0 :   unsigned int DataDescriptionsSet::getNumPol(unsigned int basebandIndex) {
     452           0 :     if(basebandIndex>=v_basebandSet_.size())Error(FATAL,(char *) "No baseband with this index");
     453             : 
     454           0 :     return getNumPol(v_basebandSet_[basebandIndex]);
     455             :   }
     456             : 
     457           0 :   unsigned int DataDescriptionsSet::getNumPol(BasebandName basebandName) {
     458             : 
     459             : 
     460           0 :     unsigned int numpp=0;
     461             :   
     462             :     map<BasebandName,vector<DataDescParams> >::iterator 
     463           0 :       itbbnddpf=m_bn_v_ddp_.find(basebandName),
     464           0 :       itbbnddpe=m_bn_v_ddp_.end();
     465           0 :     if(itbbnddpf==itbbnddpe)return numpp;
     466             : 
     467           0 :     numpp =itbbnddpf->second[0].numCorr;
     468           0 :     if(itbbnddpf->second.size()==1)return numpp;
     469             :     
     470           0 :     Enum<BasebandName> e_bn=itbbnddpf->first;
     471           0 :     for(unsigned int n=1; n<itbbnddpf->second.size(); n++)
     472           0 :       if(itbbnddpf->second[n].numCorr!=numpp)
     473           0 :         Error(FATAL,(char *) "The dataDescriptions in %s do not have a common nb of pol. cross product",
     474           0 :               e_bn.str().c_str());
     475           0 :     return numpp;
     476             :   }
     477             : 
     478           0 :   unsigned int DataDescriptionsSet::getNumSdPol(unsigned int basebandIndex) {
     479           0 :     if(basebandIndex>=v_basebandSet_.size())Error(FATAL, (char *) "No baseband with this index");
     480             : 
     481           0 :     return getNumSdPol(v_basebandSet_[basebandIndex]);
     482             :   }
     483             : 
     484           0 :   unsigned int DataDescriptionsSet::getNumSdPol(BasebandName basebandName) {
     485             : 
     486           0 :     int numpp=0;
     487             :   
     488             :     map<BasebandName,vector<DataDescParams> >::iterator 
     489           0 :       itbbnddpf=m_bn_v_ddp_.find(basebandName),
     490           0 :       itbbnddpe=m_bn_v_ddp_.end();
     491           0 :     if(itbbnddpf==itbbnddpe)return numpp;
     492             : 
     493           0 :     PolarizationTable& rpolSet =  datasetPtr_->getPolarization(); 
     494           0 :     numpp = rpolSet.getRowByKey(itbbnddpf->second[0].polId)->getNumCorr();
     495             : 
     496           0 :     if(itbbnddpf->second.size()==1)return numpp;
     497             :     
     498           0 :     Enum<BasebandName> e_bn=itbbnddpf->first;
     499             :     int                numCorr;
     500           0 :     for(unsigned int n=1; n<itbbnddpf->second.size(); n++){
     501           0 :       numCorr = rpolSet.getRowByKey(itbbnddpf->second[n].polId)->getNumCorr();
     502           0 :       if(numCorr!=numpp)
     503           0 :         Error(FATAL,(char *) "The dataDescriptions in %s do not have a common nb of sd pol. cross product",
     504           0 :               e_bn.str().c_str());
     505             :     }
     506           0 :     return numpp;
     507             :   }
     508             : 
     509           0 :   unsigned int DataDescriptionsSet::getNumSpw(unsigned int basebandIndex) {
     510           0 :     if(basebandIndex>=v_basebandSet_.size())Error(FATAL,(char *) "No baseband with this index");
     511           0 :     return v_basebandSet_.size() ;
     512             :   }
     513             : 
     514           0 :   unsigned int DataDescriptionsSet::getNumSpw(BasebandName basebandName){
     515             :     map<BasebandName,vector<DataDescParams> >::iterator 
     516           0 :       itbbnddpf=m_bn_v_ddp_.find(basebandName),
     517           0 :       itbbnddpe=m_bn_v_ddp_.end();
     518           0 :     if(itbbnddpf==itbbnddpe)return 0;
     519           0 :     return itbbnddpf->second.size();
     520             :   }
     521             : 
     522           0 :   unsigned int DataDescriptionsSet::getNdd(unsigned int basebandIndex, unsigned int i) {
     523           0 :     if(basebandIndex>=v_basebandSet_.size())Error(FATAL,(char *) "No baseband with this index");
     524             : 
     525           0 :     return getNdd(v_basebandSet_[basebandIndex],i);
     526             :   }
     527             : 
     528           0 :   unsigned int DataDescriptionsSet::getNdd(BasebandName basebandName, unsigned int i) {
     529             : 
     530             :     map<BasebandName,vector<DataDescParams> >::iterator 
     531           0 :       itbbnddpf=m_bn_v_ddp_.find(basebandName),
     532           0 :       itbbnddpe=m_bn_v_ddp_.end();
     533           0 :     Enum<BasebandName> e_bn; e_bn=basebandName;
     534           0 :     if(itbbnddpf==itbbnddpe)Error(FATAL,(char *) "No baseband with the name %s for this configuration",
     535           0 :                                   e_bn.str().c_str() );
     536             : 
     537           0 :     if(i>=itbbnddpf->second.size())
     538           0 :       Error(FATAL,(char *) "Index %d too large; it cannot exceed %d",i,itbbnddpf->second.size());
     539           0 :     Tag spwId = itbbnddpf->second[i].spwId;
     540           0 :     for(unsigned int ndd=0; ndd<v_spwId_.size(); ndd++)if(v_spwId_[ndd]==spwId)return ndd;
     541           0 :     Error(FATAL,(char *)"error in the algorithm");
     542           0 :     return 0;
     543           0 :   }
     544             : 
     545           0 :   unsigned long     DataDescriptionsSet::getAutoSize(){
     546           0 :     return sumAutoSize_; 
     547             :   }
     548             : 
     549           0 :   unsigned long     DataDescriptionsSet::getCrossSize(){
     550           0 :     return sumCrossSize_;
     551             :   }
     552             : 
     553           0 :   BasebandName      DataDescriptionsSet::getBasebandName(unsigned int ndd) {
     554           0 :     if(ndd>v_basebandName_.size()-1)
     555           0 :       Error(SERIOUS,(char *) "The dataDescription index index must be smaller than %d",
     556             :             v_basebandName_.size());
     557           0 :     return v_basebandName_[ndd];
     558             :   }
     559             : 
     560           0 :   unsigned int      DataDescriptionsSet::getBasebandIndex(unsigned int ndd) {
     561           0 :     if(ndd>v_basebandName_.size()-1)
     562           0 :       Error(SERIOUS,(char *) "The dataDescription index index must be smaller than %d",
     563             :             v_basebandName_.size());
     564           0 :     for(unsigned int nbb=0; nbb<v_basebandSet_.size(); nbb++)
     565           0 :       if(v_basebandName_[ndd]==v_basebandSet_[nbb])return nbb;
     566           0 :     Error(FATAL,(char *) "Problem in the algorithm");
     567           0 :     return 0; // should never happen
     568             :   }
     569             : 
     570           0 :   CorrelationMode   DataDescriptionsSet::getCorrelationMode(){
     571           0 :     return correlationMode_;
     572             :   }
     573             : 
     574           0 :   unsigned int    DataDescriptionsSet::getNumDataDescription(){
     575           0 :     return numDataDescription_;
     576             :   }
     577             : 
     578           0 :   unsigned int    DataDescriptionsSet::getDataDescriptionIndex( Tag dataDescriptionId) {
     579           0 :     int ndd = -1;
     580           0 :     for(unsigned int n=0; n<numDataDescription_; n++)
     581           0 :       if(dataDescriptionId==v_dataDescriptionIdArray_[n])ndd=n; // numbers are 1 based
     582           0 :     if(ndd==-1)Error(FATAL,
     583             :                      (char *) "The data description identifier %s is not in the spectro-polarization setup",
     584           0 :                      dataDescriptionId.toString().c_str());
     585           0 :     return ndd;
     586             :   }
     587             : 
     588           0 :   unsigned int    DataDescriptionsSet::numApc(){
     589           0 :     return es_apc_.count();
     590             :   }
     591             : 
     592             : 
     593           0 :   Enum<AtmPhaseCorrection> DataDescriptionsSet::atmPhaseCorrection(unsigned int atmPhaseCorrectionIndex){
     594           0 :     Enum<AtmPhaseCorrection> e_apc;
     595           0 :     e_apc=v_atmPhaseCorrection_[atmPhaseCorrectionIndex];
     596             :     //     for(unsigned int n=0; n<v_atmPhaseCorrection_.size(); n++)
     597             :     //       if(v_atmPhaseCorrection_[n]==atmPhaseCorrectionIndex)e_apc = v_atmPhaseCorrection_[n];
     598           0 :     return e_apc;
     599             :   }
     600             : 
     601           0 :   unsigned int             DataDescriptionsSet::atmPhaseCorrectionIndex(AtmPhaseCorrection apc) {
     602           0 :     for(unsigned int n=0; n<v_atmPhaseCorrection_.size(); n++)
     603           0 :       if(v_atmPhaseCorrection_[n]==apc)return n;
     604           0 :     Enum<AtmPhaseCorrection> e_apc=apc;
     605           0 :     Error(FATAL, (char *) "No %s along the APC axis",e_apc.str().c_str());
     606           0 :     return 0;
     607             :   }
     608             : 
     609           0 :   unsigned int    DataDescriptionsSet::numPol(unsigned int ndd) {
     610           0 :     if((unsigned int)ndd>=v_numPol_.size())
     611           0 :       Error(SERIOUS,(char *) "The dataDescription index index must be smaller than %d",
     612             :             v_numPol_.size());
     613           0 :     return v_numPol_[ndd];
     614             :   }
     615             : 
     616           0 :   unsigned int    DataDescriptionsSet::numSdPol(unsigned int ndd) {
     617           0 :     if(e_cm_[CROSS_ONLY])return 0;
     618           0 :     if(ndd>=v_numPol_.size())
     619           0 :       Error(SERIOUS,(char *) "The dataDescription index index must be smaller than %d",
     620             :             v_numPol_.size());
     621           0 :     if(e_cm_[AUTO_ONLY])return v_numPol_[ndd];  
     622           0 :     if(v_numPol_[ndd]<=2)return v_numPol_[ndd];
     623           0 :     return 3;                                        // could be 2 but dropping XY not supported yet!
     624             :   }
     625             : 
     626           0 :   unsigned int  DataDescriptionsSet::numChan(unsigned int ndd) {
     627             :     //if(ndd<0)Error(FATAL,(char *) "DataDescription index must be 0 based");
     628           0 :     return v_numChan_[ndd];
     629             :   }
     630             : 
     631           0 :   Tag DataDescriptionsSet::getSpwId(unsigned int ndd) {
     632             :     //if(ndd<0)Error(FATAL,(char *) "DataDescription index must be 0 based");
     633           0 :     return v_spwId_[ndd];
     634             :   }
     635             : 
     636           0 :   Frequency DataDescriptionsSet::totBandwidth(unsigned int ndd) {
     637             :     //if(ndd<0)Error(FATAL,(char *) "DataDescription index must be 0 based");
     638           0 :     if(ndd>=numDataDescription_){
     639           0 :       Error(SERIOUS,(char *) "The index for a DataDescriptions cannot exceed %d",
     640             :             numDataDescription_);
     641           0 :       return 0;
     642             :     }
     643           0 :     DataDescriptionTable&  rddSet =  datasetPtr_->getDataDescription();
     644           0 :     return rddSet.getRowByKey(v_dataDescriptionIdArray_[ndd])->getSpectralWindowUsingSpectralWindowId()->getTotBandwidth();
     645             :   }
     646             : 
     647             : 
     648           0 :   int               DataDescriptionsSet::numAutoData(unsigned int ndd) {
     649             :     //if( ndd <= 0)Error(FATAL, (char *) "DataDescription index must be 0 based");
     650           0 :     if(v_numAutoData_.size()==0){
     651           0 :       Error(WARNING, (char *) "no auto data expected");
     652           0 :       return 0;
     653           0 :     }else if((unsigned int)ndd>=v_numAutoData_.size()){
     654           0 :       Error(SERIOUS, (char *) "The index for a DataDescriptions cannot exceed %d",
     655             :             v_numAutoData_.size());
     656             :     }
     657           0 :     return v_numAutoData_[ndd];
     658             :   }
     659             : 
     660           0 :   unsigned int      DataDescriptionsSet::numCrossData(unsigned int ndd) {
     661           0 :     if(!v_numCrossData_.size()){
     662           0 :       Error(WARNING, (char *) "no cross data expected");
     663           0 :       return 0;
     664           0 :     }else if((unsigned int)ndd>=v_numCrossData_.size()){
     665           0 :       Error(SERIOUS, (char *) "The index for a DataDescriptions cannot exceed %d",
     666             :             v_numCrossData_.size());
     667             :     }
     668           0 :     return v_numCrossData_[ndd];
     669             :   }
     670             : 
     671             : }

Generated by: LCOV version 1.16