LCOV - code coverage report
Current view: top level - msvis/MSVis - MSCalEnums.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 93 103 90.3 %
Date: 2024-12-11 20:54:31 Functions: 2 4 50.0 %

          Line data    Source code
       1             : //# MSCalEnums.cc: Implementation of MSCalEnums.h
       2             : //# Copyright (C) 1996,1997,1998,2000,2001,2002
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id$
      27             : //----------------------------------------------------------------------------
      28             : 
      29             : #include <msvis/MSVis/MSCalEnums.h>
      30             : 
      31             : using namespace casacore;
      32             : namespace casa { //# NAMESPACE CASA - BEGIN
      33             : 
      34             : //----------------------------------------------------------------------------
      35             : 
      36             : // Static data initialization
      37             : std::map <Int, String> MSCalEnums::theirFieldMap;
      38             : std::map <Int, DataType> MSCalEnums::theirTypeMap;
      39             : 
      40             : //----------------------------------------------------------------------------
      41             : 
      42           1 : void MSCalEnums::initMaps ()
      43             : {
      44             : // Initialize the static map containing the field names.
      45             : // Skip this step if already initialized.
      46             : //
      47           1 :   if ( theirFieldMap.size( ) == 0 ) {
      48          83 :       theirFieldMap = {
      49           1 :           {ANTENNA1, "ANTENNA1"},
      50           1 :           {ANTENNA2, "ANTENNA2"},
      51           1 :           { FEED1, "FEED1" },
      52           1 :           { FEED2, "FEED2" },
      53           1 :           { PULSAR_BIN, "PULSAR_BIN" },
      54           1 :           { SCAN_NUMBER, "SCAN_NUMBER" },
      55           1 :           { TIME, "TIME" },
      56           1 :           { TIME_EXTRA_PREC, "TIME_EXTRA_PREC" },
      57           1 :           { INTERVAL, "INTERVAL" },
      58           1 :           { ARRAY_ID, "ARRAY_ID" },
      59           1 :           { PROCESSOR_ID, "PROCESSOR_ID" },
      60           1 :           { FIELD_ID, "FIELD_ID" },
      61           1 :           { OBSERVATION_ID, "OBSERVATION_ID" },
      62           1 :           { PULSAR_GATE_ID, "PULSAR_GATE_ID" },
      63           1 :           { SPECTRAL_WINDOW_ID, "SPECTRAL_WINDOW_ID" },
      64           1 :           { PHASE_ID, "PHASE_ID" },
      65           1 :           { STATE_ID, "STATE_ID" },
      66             : 
      67           1 :           { FREQ_GROUP, "FREQ_GROUP" },
      68           1 :           { FREQ_GROUP_NAME, "FREQ_GROUP_NAME" },
      69           1 :           { FIELD_NAME, "FIELD_NAME" },
      70           1 :           { FIELD_CODE, "FIELD_CODE" },
      71           1 :           { SOURCE_NAME, "SOURCE_NAME" },
      72           1 :           { SOURCE_CODE, "SOURCE_CODE" },
      73           1 :           { CALIBRATION_GROUP, "CALIBRATION_GROUP" },
      74             : 
      75           1 :           { GAIN, "GAIN" },
      76           1 :           { REF_ANT, "REF_ANT" },
      77           1 :           { REF_FEED, "REF_FEED" },
      78           1 :           { REF_RECEPTOR, "REF_RECEPTOR" },
      79           1 :           { REF_FREQUENCY, "REF_FREQUENCY" },
      80           1 :           { MEAS_FREQ_REF, "MEAS_FREQ_REF" },
      81           1 :           { REF_DIRECTION, "REF_DIRECTION" },
      82           1 :           { MEAS_DIR_REF, "MEAS_DIR_REF" },
      83           1 :           { POINTING_OFFSET, "POINTING_OFFSET" },
      84           1 :           { MEAS_POINTING, "MEAS_POINTING" },
      85           1 :           { CAL_DESC_ID, "CAL_DESC_ID" },
      86           1 :           { CAL_HISTORY_ID, "CAL_HISTORY_ID" },
      87             :     
      88           1 :           { TOTAL_SOLUTION_OK, "TOTAL_SOLUTION_OK" },
      89           1 :           { TOTAL_FIT, "TOTAL_FIT" },
      90           1 :           { TOTAL_FIT_WEIGHT, "TOTAL_FIT_WEIGHT" },
      91           1 :           { SOLUTION_OK, "SOLUTION_OK" },
      92           1 :           { FIT, "FIT" },
      93           1 :           { FIT_WEIGHT, "FIT_WEIGHT" },
      94           1 :           { FLAG, "FLAG" },
      95           1 :           { SNR, "SNR" },
      96             :     
      97           1 :           { NUM_SPW, "NUM_SPW" },
      98           1 :           { NUM_CHAN, "NUM_CHAN" },
      99           1 :           { NUM_RECEPTORS, "NUM_RECEPTORS" },
     100           1 :           { N_JONES, "N_JONES" },
     101           1 :           { CHAN_FREQ, "CHAN_FREQ" },
     102           1 :           { CHAN_WIDTH, "CHAN_WIDTH" },
     103           1 :           { CHAN_RANGE, "CHAN_RANGE" },
     104           1 :           { JONES_TYPE, "JONES_TYPE" },
     105           1 :           { POLARIZATION_TYPE, "POLARIZATION_TYPE" },
     106           1 :           { MS_NAME, "MS_NAME" },
     107             :     
     108           1 :           { CAL_PARMS, "CAL_PARMS" },
     109           1 :           { CAL_TABLES, "CAL_TABLES" },
     110           1 :           { CAL_SELECT, "CAL_SELECT" },
     111           1 :           { CAL_NOTES, "CAL_NOTES" },
     112             :     
     113           1 :           { CAL_DESC, "CAL_DESC" },
     114           1 :           { CAL_HISTORY, "CAL_HISTORY" },
     115           1 :           { OBSERVATION, "OBSERVATION" },
     116             :     
     117           1 :           { ROT_MEASURE, "ROT_MEASURE" },
     118           1 :           { ROT_MEASURE_ERROR, "ROT_MEASURE_ERROR" },
     119           1 :           { IONOSPH_TEC, "IONOSPH_TEC" },
     120           1 :           { IONOSPH_TEC_ERROR, "IONOSPH_TEC_ERROR" },
     121             : 
     122           1 :           { PHASE_OFFSET, "PHASE_OFFSET" },
     123           1 :           { SB_DELAY, "SB_DELAY" },
     124           1 :           { DELAY_RATE, "DELAY_RATE" },
     125             : 
     126           1 :           { POLY_TYPE, "POLY_TYPE" },
     127           1 :           { POLY_MODE, "POLY_MODE" },
     128           1 :           { SCALE_FACTOR, "SCALE_FACTOR" },
     129           1 :           { VALID_DOMAIN, "VALID_DOMAIN" },
     130           1 :           { N_POLY_AMP, "N_POLY_AMP" },
     131           1 :           { N_POLY_PHASE, "N_POLY_PHASE" },
     132           1 :           { POLY_COEFF_AMP, "POLY_COEFF_AMP" },
     133           1 :           { POLY_COEFF_PHASE, "POLY_COEFF_PHASE" },
     134           1 :           { PHASE_UNITS, "PHASE_UNITS" },
     135             : 
     136           1 :           { SIDEBAND_REF, "SIDEBAND_REF" },
     137             : 
     138           1 :           { N_KNOTS_AMP, "N_KNOTS_AMP" },
     139           1 :           { N_KNOTS_PHASE, "N_KNOTS_PHASE" },
     140           1 :           { SPLINE_KNOTS_AMP, "SPLINE_KNOTS_AMP" },
     141           2 :           { SPLINE_KNOTS_PHASE, "SPLINE_KNOTS_PHASE" }
     142          83 :       };
     143             :   }
     144             : 
     145             : // Initialize the static map containing the basic field data types
     146             : // Skip this step if already initialized.
     147             : //
     148           1 :   if ( theirTypeMap.size( ) == 0 ) {
     149           1 :       theirTypeMap = {
     150             :           { ANTENNA1, TpInt },
     151             :           { ANTENNA2, TpInt },
     152             :           { FEED1, TpInt },
     153             :           { FEED2, TpInt },
     154             :           { PULSAR_BIN, TpInt },
     155             :           { SCAN_NUMBER, TpInt },
     156             :           { TIME, TpDouble },
     157             :           { TIME_EXTRA_PREC, TpDouble },
     158             :           { INTERVAL, TpDouble },
     159             :           { ARRAY_ID, TpInt },
     160             :           { PROCESSOR_ID, TpInt },
     161             :           { FIELD_ID, TpInt },
     162             :           { OBSERVATION_ID, TpInt },
     163             :           { PULSAR_GATE_ID, TpInt },
     164             :           { SPECTRAL_WINDOW_ID, TpInt },
     165             :           { PHASE_ID, TpInt },
     166             :           { STATE_ID, TpInt },
     167             : 
     168             :           { FREQ_GROUP, TpInt },
     169             :           { FREQ_GROUP_NAME, TpString },
     170             :           { FIELD_NAME, TpString },
     171             :           { FIELD_CODE, TpString },
     172             :           { SOURCE_NAME, TpString },
     173             :           { SOURCE_CODE, TpString },
     174             :           { CALIBRATION_GROUP, TpInt },
     175             : 
     176             :           { GAIN, TpComplex },
     177             :           { REF_ANT, TpInt },
     178             :           { REF_FEED, TpInt },
     179             :           { REF_RECEPTOR, TpInt },
     180             :           { REF_FREQUENCY, TpDouble },
     181             :           { MEAS_FREQ_REF, TpInt },
     182             :           { REF_DIRECTION, TpDouble },
     183             :           { MEAS_DIR_REF, TpInt },
     184             :           { CAL_DESC_ID, TpInt },
     185             :           { CAL_HISTORY_ID, TpInt },
     186             :     
     187             :           { TOTAL_SOLUTION_OK, TpBool },
     188             :           { TOTAL_FIT, TpFloat },
     189             :           { TOTAL_FIT_WEIGHT, TpFloat },
     190             :           { SOLUTION_OK, TpBool },
     191             :           { FIT, TpFloat },
     192             :           { FIT_WEIGHT, TpFloat },
     193             :           { FLAG, TpBool },
     194             :           { SNR, TpFloat },
     195             :     
     196             :           { NUM_SPW, TpInt },
     197             :           { NUM_CHAN, TpInt },
     198             :           { NUM_RECEPTORS, TpInt },
     199             :           { N_JONES, TpInt },
     200             :           { CHAN_FREQ, TpDouble },
     201             :           { CHAN_WIDTH, TpDouble },
     202             :           { CHAN_RANGE, TpInt },
     203             :           { JONES_TYPE, TpString },
     204             :           { POLARIZATION_TYPE, TpString },
     205             :           { MS_NAME, TpString },
     206             :     
     207             :           { CAL_PARMS, TpString },
     208             :           { CAL_TABLES, TpString },
     209             :           { CAL_SELECT, TpString },
     210             :           { CAL_NOTES, TpString },
     211             :     
     212             :           { CAL_DESC, TpTable },
     213             :           { CAL_HISTORY, TpTable },
     214             :           { OBSERVATION, TpTable },
     215             :     
     216             :           { ROT_MEASURE, TpFloat },
     217             :           { ROT_MEASURE_ERROR, TpFloat },
     218             :           { IONOSPH_TEC, TpFloat },
     219             :           { IONOSPH_TEC_ERROR, TpFloat },
     220             : 
     221             :           { PHASE_OFFSET, TpFloat },
     222             :           { SB_DELAY, TpFloat },
     223             :           { DELAY_RATE, TpFloat },
     224             : 
     225             :           { POLY_TYPE, TpString },
     226             :           { POLY_MODE, TpString },
     227             :           { SCALE_FACTOR, TpComplex },
     228             :           { VALID_DOMAIN, TpDouble },
     229             :           { N_POLY_AMP, TpInt },
     230             :           { N_POLY_PHASE, TpInt },
     231             :           { POLY_COEFF_AMP, TpDouble },
     232             :           { POLY_COEFF_PHASE, TpDouble },
     233             :           { PHASE_UNITS, TpString },
     234             : 
     235             :           { SIDEBAND_REF, TpComplex },
     236             : 
     237             :           { N_KNOTS_AMP, TpInt },
     238             :           { N_KNOTS_PHASE, TpInt },
     239             :           { SPLINE_KNOTS_AMP, TpDouble },
     240             :           { SPLINE_KNOTS_PHASE, TpDouble }
     241           1 :       };
     242             :   }
     243             : 
     244           1 : }
     245             : 
     246             : //----------------------------------------------------------------------------
     247             : 
     248         649 : String MSCalEnums::fieldName (Int enumField)
     249             : {
     250             : // Static function to look up the field name:
     251             : // Inputs:
     252             : //    enumField   Int     Field enumeration.
     253             : // Outputs:
     254             : //    fieldName   String  Field name.
     255             : // Exceptions:
     256             : //    Exception if invalid field enumeration.
     257             : //
     258             :   // Initialize map if empty
     259         649 :   if ( theirFieldMap.size( ) == 0 ) initMaps();
     260             :   
     261             :   // Return the column name
     262         649 :   return theirFieldMap[enumField];
     263             : };
     264             : 
     265             : //----------------------------------------------------------------------------
     266             : 
     267           0 : Block<String> MSCalEnums::fieldNames (const Vector<Int>& enumFields)
     268             : {
     269             : // Static function to look up a set of field names:
     270             : // Inputs:
     271             : //    enumFields  const Vector<Int>&     Field enumerations.
     272             : // Outputs:
     273             : //    fieldNames  Block<String>          Field names.
     274             : // Exceptions:
     275             : //    Exception if invalid field enumeration.
     276             : //
     277             :   // Return the column names
     278           0 :   uInt nFields = enumFields.nelements();
     279           0 :   Block<String> names(nFields);
     280           0 :   for (uInt i=0; i < nFields; i++) {
     281           0 :     names[i] = fieldName (enumFields(i));
     282             :   };
     283           0 :   return names;
     284           0 : };
     285             : 
     286             : //----------------------------------------------------------------------------
     287             : 
     288           0 : DataType MSCalEnums::basicType (Int enumField)
     289             : {
     290             : // Static function to look up the basic field data type:
     291             : // Inputs:
     292             : //    enumField   Int        Field enumeration.
     293             : // Outputs:
     294             : //    basicType   DataType   Basic data type
     295             : // Exceptions:
     296             : //    Exception if invalid field enumeration.
     297             : //
     298             :   // Initialize map if empty
     299           0 :   if ( theirTypeMap.size( ) == 0 ) initMaps();
     300             :   
     301             :   // Return the column name
     302           0 :   return theirTypeMap[enumField];
     303             : };
     304             : 
     305             : //----------------------------------------------------------------------------
     306             : 
     307             : 
     308             : 
     309             : 
     310             : 
     311             : 
     312             : 
     313             : } //# NAMESPACE CASA - END
     314             : 

Generated by: LCOV version 1.16