LCOV - code coverage report
Current view: top level - singledishfiller/Filler - SpectralWindowRecord.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 49 52 94.2 %
Date: 2025-07-23 00:22:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * SpectralWindowRecord.h
       3             :  *
       4             :  *  Created on: Jan 27, 2016
       5             :  *      Author: nakazato
       6             :  */
       7             : 
       8             : #ifndef SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_H_
       9             : #define SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_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/MSSpectralWindow.h>
      15             : #include <casacore/ms/MeasurementSets/MSSpWindowColumns.h>
      16             : 
      17             : namespace casa { //# NAMESPACE CASA - BEGIN
      18             : namespace sdfiller { //# NAMESPACE SDFILLER - BEGIN
      19             : 
      20             : struct SpectralWindowRecord {
      21             :   typedef casacore::MSSpectralWindow AssociatingTable;
      22             :   typedef casacore::MSSpWindowColumns AssociatingColumns;
      23             : 
      24             :   // meta
      25             :   casacore::Int spw_id;
      26             : 
      27             :   // mandatory
      28             :   casacore::Int num_chan;
      29             :   casacore::Int meas_freq_ref;
      30             :   casacore::Double refpix;
      31             :   casacore::Double refval;
      32             :   casacore::Double increment;
      33             : 
      34             :   // optional
      35             :   casacore::String name;
      36             : 
      37             :   // for dummy entry
      38             :   casacore::Int const d_num_chan = 1;
      39             :   casacore::Vector<casacore::Double> const d_array = casacore::Vector<casacore::Double>(1, 0.0);
      40             :   casacore::Int const d_freq = 0.0;
      41             : 
      42             :   // method
      43          24 :   void clear() {
      44          24 :     spw_id = -1;
      45          24 :     name = "";
      46          24 :     meas_freq_ref = -1;
      47          24 :     num_chan = 0;
      48          24 :     refpix = 0.0;
      49          24 :     refval = 0.0;
      50          24 :     increment = 0.0;
      51          24 :   }
      52             : 
      53             :   SpectralWindowRecord &operator=(SpectralWindowRecord const &other) {
      54             :     spw_id = other.spw_id;
      55             :     name = other.name;
      56             :     meas_freq_ref = other.meas_freq_ref;
      57             :     num_chan = other.num_chan;
      58             :     refpix = other.refpix;
      59             :     refval = other.refval;
      60             :     increment = other.increment;
      61             :     return *this;
      62             :   }
      63             : 
      64          20 :   void add(AssociatingTable &table, AssociatingColumns &columns) {
      65          20 :     casacore::uInt uspw_id = (casacore::uInt) spw_id;
      66          20 :     casacore::uInt nrow = table.nrow();
      67          20 :     if (nrow <= uspw_id) {
      68          20 :       table.addRow(uspw_id - nrow + 1);
      69          20 :       casacore::uInt new_nrow = table.nrow();
      70          76 :       for (casacore::uInt i = nrow; i < new_nrow - 1; ++i) {
      71          56 :         columns.numChan().put(i, d_num_chan);
      72          56 :         columns.refFrequency().put(i, d_freq);
      73          56 :         columns.totalBandwidth().put(i, d_freq);
      74          56 :         columns.chanFreq().put(i, d_array);
      75          56 :         columns.chanWidth().put(i, d_array);
      76          56 :         columns.effectiveBW().put(i, d_array);
      77          56 :         columns.resolution().put(i, d_array);
      78             :       }
      79             :     }
      80          20 :   }
      81             : 
      82          20 :   casacore::Bool fill(casacore::uInt /*irow*/, AssociatingColumns &columns) {
      83          20 :     if (spw_id < 0) {
      84           0 :       return false;
      85             :     }
      86             : 
      87          20 :     casacore::uInt nrow = columns.nrow();
      88             : 
      89          20 :     if (nrow <= (casacore::uInt) spw_id) {
      90           0 :       return false;
      91             :     }
      92             : 
      93          20 :     columns.numChan().put(spw_id, num_chan);
      94          20 :     columns.measFreqRef().put(spw_id, meas_freq_ref);
      95          20 :     casacore::Double tot_bw = num_chan * fabs(increment);
      96          20 :     columns.totalBandwidth().put(spw_id, tot_bw);
      97          20 :     casacore::Double ref_frequency = refval - refpix * increment;
      98          20 :     columns.refFrequency().put(spw_id, ref_frequency);
      99          20 :     casacore::Vector<casacore::Double> freq(num_chan);
     100          20 :     indgen(freq, ref_frequency, increment);
     101          20 :     columns.chanFreq().put(spw_id, freq);
     102          20 :     freq = increment;
     103          20 :     columns.chanWidth().put(spw_id, freq);
     104          20 :     freq = abs(freq);
     105          20 :     columns.effectiveBW().put(spw_id, freq);
     106          20 :     columns.resolution().put(spw_id, freq);
     107          20 :     casacore::Int net_sideband = 0; // USB
     108          20 :     if (increment < 0.0) {
     109          16 :       net_sideband = 1; // LSB
     110             :     }
     111          20 :     columns.netSideband().put(spw_id, net_sideband);
     112          20 :     if (name.size() > 0) {
     113           0 :       columns.name().put(spw_id, name);
     114             :     }
     115             : 
     116          20 :     return true;
     117          20 :   }
     118             : };
     119             : 
     120             : } //# NAMESPACE SDFILLER - END
     121             : } //# NAMESPACE CASA - END
     122             : 
     123             : #endif /* SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_H_ */

Generated by: LCOV version 1.16