LCOV - code coverage report
Current view: top level - singledishfiller/Filler - SpectralWindowRecord.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 52 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 3 0.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           0 :   void clear() {
      44           0 :     spw_id = -1;
      45           0 :     name = "";
      46           0 :     meas_freq_ref = -1;
      47           0 :     num_chan = 0;
      48           0 :     refpix = 0.0;
      49           0 :     refval = 0.0;
      50           0 :     increment = 0.0;
      51           0 :   }
      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           0 :   void add(AssociatingTable &table, AssociatingColumns &columns) {
      65           0 :     casacore::uInt uspw_id = (casacore::uInt) spw_id;
      66           0 :     casacore::uInt nrow = table.nrow();
      67           0 :     if (nrow <= uspw_id) {
      68           0 :       table.addRow(uspw_id - nrow + 1);
      69           0 :       casacore::uInt new_nrow = table.nrow();
      70           0 :       for (casacore::uInt i = nrow; i < new_nrow - 1; ++i) {
      71           0 :         columns.numChan().put(i, d_num_chan);
      72           0 :         columns.refFrequency().put(i, d_freq);
      73           0 :         columns.totalBandwidth().put(i, d_freq);
      74           0 :         columns.chanFreq().put(i, d_array);
      75           0 :         columns.chanWidth().put(i, d_array);
      76           0 :         columns.effectiveBW().put(i, d_array);
      77           0 :         columns.resolution().put(i, d_array);
      78             :       }
      79             :     }
      80           0 :   }
      81             : 
      82           0 :   casacore::Bool fill(casacore::uInt /*irow*/, AssociatingColumns &columns) {
      83           0 :     if (spw_id < 0) {
      84           0 :       return false;
      85             :     }
      86             : 
      87           0 :     casacore::uInt nrow = columns.nrow();
      88             : 
      89           0 :     if (nrow <= (casacore::uInt) spw_id) {
      90           0 :       return false;
      91             :     }
      92             : 
      93           0 :     columns.numChan().put(spw_id, num_chan);
      94           0 :     columns.measFreqRef().put(spw_id, meas_freq_ref);
      95           0 :     casacore::Double tot_bw = num_chan * fabs(increment);
      96           0 :     columns.totalBandwidth().put(spw_id, tot_bw);
      97           0 :     casacore::Double ref_frequency = refval - refpix * increment;
      98           0 :     columns.refFrequency().put(spw_id, ref_frequency);
      99           0 :     casacore::Vector<casacore::Double> freq(num_chan);
     100           0 :     indgen(freq, ref_frequency, increment);
     101           0 :     columns.chanFreq().put(spw_id, freq);
     102           0 :     freq = increment;
     103           0 :     columns.chanWidth().put(spw_id, freq);
     104           0 :     freq = abs(freq);
     105           0 :     columns.effectiveBW().put(spw_id, freq);
     106           0 :     columns.resolution().put(spw_id, freq);
     107           0 :     casacore::Int net_sideband = 0; // USB
     108           0 :     if (increment < 0.0) {
     109           0 :       net_sideband = 1; // LSB
     110             :     }
     111           0 :     columns.netSideband().put(spw_id, net_sideband);
     112           0 :     if (name.size() > 0) {
     113           0 :       columns.name().put(spw_id, name);
     114             :     }
     115             : 
     116           0 :     return true;
     117           0 :   }
     118             : };
     119             : 
     120             : } //# NAMESPACE SDFILLER - END
     121             : } //# NAMESPACE CASA - END
     122             : 
     123             : #endif /* SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_H_ */

Generated by: LCOV version 1.16