LCOV - code coverage report
Current view: top level - singledishfiller/Filler - SourceRecord.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 46 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 3 0.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           0 :   void clear() {
      43           0 :     source_id = -1;
      44           0 :     spw_id = -1;
      45           0 :     name = "";
      46           0 :     time = -1.0;
      47           0 :     interval = -1.0;
      48           0 :     direction = casacore::MDirection();
      49           0 :     num_lines = 0;
      50           0 :     code = "";
      51           0 :     calibration_group = -1;
      52           0 :     transition.resize();
      53           0 :     rest_frequency.resize();
      54           0 :     sysvel.resize();
      55           0 :     proper_motion.resize();
      56           0 :   }
      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           0 :   void add(AssociatingTable &table, AssociatingColumns &columns) {
      76           0 :     if (columns.nrow() == 0) {
      77             :       // set frame info
      78           0 :       casacore::TableRecord &record = columns.direction().rwKeywordSet();
      79           0 :       casacore::Record meas_info = record.asRecord("MEASINFO");
      80           0 :       meas_info.define("Ref", direction.getRefString());
      81           0 :       record.defineRecord("MEASINFO", meas_info);
      82           0 :     }
      83             : 
      84           0 :     table.addRow(1, true);
      85           0 :   }
      86             : 
      87           0 :   casacore::Bool fill(casacore::uInt irow, AssociatingColumns &columns) {
      88           0 :     if (columns.nrow() <= irow) {
      89           0 :       return false;
      90             :     }
      91             : 
      92           0 :     columns.sourceId().put(irow, source_id);
      93           0 :     columns.spectralWindowId().put(irow, spw_id);
      94           0 :     columns.name().put(irow, name);
      95           0 :     columns.time().put(irow, time);
      96           0 :     columns.interval().put(irow, interval);
      97           0 :     columns.directionMeas().put(irow, direction);
      98           0 :     columns.numLines().put(irow, num_lines);
      99           0 :     columns.calibrationGroup().put(irow, calibration_group);
     100           0 :     if (code.size() > 0) {
     101           0 :       columns.code().put(irow, code);
     102             :     }
     103           0 :     if (transition.size() > 0) {
     104           0 :       columns.transition().put(irow, transition);
     105             :     }
     106           0 :     if (rest_frequency.size() > 0) {
     107           0 :       columns.restFrequency().put(irow, rest_frequency);
     108             :     }
     109           0 :     if (sysvel.size() > 0) {
     110           0 :       columns.sysvel().put(irow, sysvel);
     111             :     }
     112           0 :     if (proper_motion.size() > 0) {
     113           0 :       columns.properMotion().put(irow, proper_motion);
     114             :     }
     115             : 
     116           0 :     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