LCOV - code coverage report
Current view: top level - singledishfiller/Filler - SourceRecord.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 44 46 95.7 %
Date: 2024-12-11 20:54:31 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * SourceRecord.h
       3             :  *
       4             :  *  Created on: Jan 27, 2016
       5             :  *      Author: nakazato
       6             :  */
       7             : 
       8             : #ifndef SINGLEDISH_FILLER_SOURCERECORD_H_
       9             : #define SINGLEDISH_FILLER_SOURCERECORD_H_
      10             : 
      11             : #include <casacore/casa/Arrays/Matrix.h>
      12             : #include <casacore/casa/BasicSL/String.h>
      13             : #include <casacore/measures/Measures/MDirection.h>
      14             : #include <casacore/ms/MeasurementSets/MSSource.h>
      15             : #include <casacore/ms/MeasurementSets/MSSourceColumns.h>
      16             : 
      17             : namespace casa { //# NAMESPACE CASA - BEGIN
      18             : namespace sdfiller { //# NAMESPACE SDFILLER - BEGIN
      19             : 
      20             : struct SourceRecord {
      21             :   typedef casacore::MSSource AssociatingTable;
      22             :   typedef casacore::MSSourceColumns AssociatingColumns;
      23             : 
      24             :   // mandatory
      25             :   casacore::Int source_id;
      26             :   casacore::Int spw_id;
      27             :   casacore::String name;
      28             :   casacore::Double time;
      29             :   casacore::Double interval;
      30             :   casacore::MDirection direction;
      31             :   casacore::Int num_lines;
      32             : 
      33             :   // optional
      34             :   casacore::String code;
      35             :   casacore::Int calibration_group;
      36             :   casacore::Vector<casacore::String> transition;
      37             :   casacore::Vector<casacore::Double> rest_frequency;
      38             :   casacore::Vector<casacore::Double> sysvel;
      39             :   casacore::Vector<casacore::Double> proper_motion;
      40             : 
      41             :   // method
      42          36 :   void clear() {
      43          36 :     source_id = -1;
      44          36 :     spw_id = -1;
      45          36 :     name = "";
      46          36 :     time = -1.0;
      47          36 :     interval = -1.0;
      48          36 :     direction = casacore::MDirection();
      49          36 :     num_lines = 0;
      50          36 :     code = "";
      51          36 :     calibration_group = -1;
      52          36 :     transition.resize();
      53          36 :     rest_frequency.resize();
      54          36 :     sysvel.resize();
      55          36 :     proper_motion.resize();
      56          36 :   }
      57             : 
      58             :   SourceRecord &operator=(SourceRecord const &other) {
      59             :     source_id = other.source_id;
      60             :     spw_id = other.spw_id;
      61             :     name = other.name;
      62             :     time = other.time;
      63             :     interval = other.interval;
      64             :     direction = other.direction;
      65             :     num_lines = other.num_lines;
      66             :     code = other.code;
      67             :     calibration_group = other.calibration_group;
      68             :     transition = other.transition;
      69             :     rest_frequency = other.rest_frequency;
      70             :     sysvel = other.sysvel;
      71             :     proper_motion = other.proper_motion;
      72             :     return *this;
      73             :   }
      74             : 
      75          29 :   void add(AssociatingTable &table, AssociatingColumns &columns) {
      76          29 :     if (columns.nrow() == 0) {
      77             :       // set frame info
      78           7 :       casacore::TableRecord &record = columns.direction().rwKeywordSet();
      79           7 :       casacore::Record meas_info = record.asRecord("MEASINFO");
      80           7 :       meas_info.define("Ref", direction.getRefString());
      81           7 :       record.defineRecord("MEASINFO", meas_info);
      82           7 :     }
      83             : 
      84          29 :     table.addRow(1, true);
      85          29 :   }
      86             : 
      87          29 :   casacore::Bool fill(casacore::uInt irow, AssociatingColumns &columns) {
      88          29 :     if (columns.nrow() <= irow) {
      89           0 :       return false;
      90             :     }
      91             : 
      92          29 :     columns.sourceId().put(irow, source_id);
      93          29 :     columns.spectralWindowId().put(irow, spw_id);
      94          29 :     columns.name().put(irow, name);
      95          29 :     columns.time().put(irow, time);
      96          29 :     columns.interval().put(irow, interval);
      97          29 :     columns.directionMeas().put(irow, direction);
      98          29 :     columns.numLines().put(irow, num_lines);
      99          29 :     columns.calibrationGroup().put(irow, calibration_group);
     100          29 :     if (code.size() > 0) {
     101           0 :       columns.code().put(irow, code);
     102             :     }
     103          29 :     if (transition.size() > 0) {
     104          10 :       columns.transition().put(irow, transition);
     105             :     }
     106          29 :     if (rest_frequency.size() > 0) {
     107          14 :       columns.restFrequency().put(irow, rest_frequency);
     108             :     }
     109          29 :     if (sysvel.size() > 0) {
     110          14 :       columns.sysvel().put(irow, sysvel);
     111             :     }
     112          29 :     if (proper_motion.size() > 0) {
     113          25 :       columns.properMotion().put(irow, proper_motion);
     114             :     }
     115             : 
     116          29 :     return true;
     117             :   }
     118             : };
     119             : 
     120             : } //# NAMESPACE SDFILLER - END
     121             : } //# NAMESPACE CASA - END
     122             : 
     123             : #endif /* SINGLEDISH_FILLER_SOURCERECORD_H_ */

Generated by: LCOV version 1.16