SpectralWindowRecord.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_H_
00009 #define SINGLEDISH_FILLER_SPECTRALWINDOWRECORD_H_
00010
00011 #include <casacore/casa/Arrays/Matrix.h>
00012 #include <casacore/casa/BasicSL/String.h>
00013 #include <casacore/measures/Measures/MDirection.h>
00014 #include <casacore/ms/MeasurementSets/MSSpectralWindow.h>
00015 #include <casacore/ms/MeasurementSets/MSSpWindowColumns.h>
00016
00017 namespace casa {
00018 namespace sdfiller {
00019
00020 struct SpectralWindowRecord {
00021 typedef MSSpectralWindow AssociatingTable;
00022 typedef MSSpWindowColumns AssociatingColumns;
00023
00024
00025 Int spw_id;
00026
00027
00028 Int num_chan;
00029 Int meas_freq_ref;
00030 Double refpix;
00031 Double refval;
00032 Double increment;
00033
00034
00035 String name;
00036
00037
00038 Int const d_num_chan = 1;
00039 Vector<Double> const d_array = Vector<Double>(1, 0.0);
00040 Int const d_freq = 0.0;
00041
00042
00043 void clear() {
00044 spw_id = -1;
00045 name = "";
00046 meas_freq_ref = -1;
00047 num_chan = 0;
00048 refpix = 0.0;
00049 refval = 0.0;
00050 increment = 0.0;
00051 }
00052
00053 SpectralWindowRecord &operator=(SpectralWindowRecord const &other) {
00054 spw_id = other.spw_id;
00055 name = other.name;
00056 meas_freq_ref = other.meas_freq_ref;
00057 num_chan = other.num_chan;
00058 refpix = other.refpix;
00059 refval = other.refval;
00060 increment = other.increment;
00061 return *this;
00062 }
00063
00064 void add(AssociatingTable &table, AssociatingColumns &columns) {
00065 uInt uspw_id = (uInt) spw_id;
00066 uInt nrow = table.nrow();
00067 if (nrow <= uspw_id) {
00068 table.addRow(uspw_id - nrow + 1);
00069 uInt new_nrow = table.nrow();
00070 for (uInt i = nrow; i < new_nrow - 1; ++i) {
00071 columns.numChan().put(i, d_num_chan);
00072 columns.refFrequency().put(i, d_freq);
00073 columns.totalBandwidth().put(i, d_freq);
00074 columns.chanFreq().put(i, d_array);
00075 columns.chanWidth().put(i, d_array);
00076 columns.effectiveBW().put(i, d_array);
00077 columns.resolution().put(i, d_array);
00078 }
00079 }
00080 }
00081
00082 Bool fill(uInt , AssociatingColumns &columns) {
00083 if (spw_id < 0) {
00084 return False;
00085 }
00086
00087 uInt nrow = columns.nrow();
00088
00089 if (nrow <= (uInt) spw_id) {
00090 return False;
00091 }
00092
00093 columns.numChan().put(spw_id, num_chan);
00094 columns.measFreqRef().put(spw_id, meas_freq_ref);
00095 Double tot_bw = num_chan * abs(increment);
00096 columns.totalBandwidth().put(spw_id, tot_bw);
00097 Double ref_frequency = refval - refpix * increment;
00098 columns.refFrequency().put(spw_id, ref_frequency);
00099 Vector<Double> freq(num_chan);
00100 indgen(freq, ref_frequency, increment);
00101 columns.chanFreq().put(spw_id, freq);
00102 freq = increment;
00103 columns.chanWidth().put(spw_id, freq);
00104 freq = abs(freq);
00105 columns.effectiveBW().put(spw_id, freq);
00106 columns.resolution().put(spw_id, freq);
00107 Int net_sideband = 0;
00108 if (increment < 0.0) {
00109 net_sideband = 1;
00110 }
00111 columns.netSideband().put(spw_id, net_sideband);
00112 if (name.size() > 0) {
00113 columns.name().put(spw_id, name);
00114 }
00115
00116 return True;
00117 }
00118 };
00119
00120 }
00121 }
00122
00123 #endif