6 #include <casacore/ms/MeasurementSets/MeasurementSet.h> 8 #include <casacore/tables/Tables/ArrayColumn.h> 9 #include <casacore/tables/Tables/ScalarColumn.h> 18 typedef std::reverse_iterator<double*> reverse_iterator;
19 typedef std::reverse_iterator<const double*> const_reverse_iterator;
24 BandData() : _channelCount(0), _channelFrequencies(0), _frequencyStep(0.0)
35 if(spwTable.nrow() != 1)
throw std::runtime_error(
"Set should have exactly one spectral window");
37 initFromTable(spwTable, 0);
45 BandData(casacore::MSSpectralWindow& spwTable,
size_t bandIndex)
47 initFromTable(spwTable, bandIndex);
54 BandData(
const BandData& source) : _channelCount(source._channelCount), _frequencyStep(source._frequencyStep)
56 _channelFrequencies =
new double[_channelCount];
57 for(
size_t index = 0; index != _channelCount; ++index)
59 _channelFrequencies[index] = source._channelFrequencies[index];
70 _channelCount(endChannel - startChannel), _frequencyStep(source._frequencyStep)
72 if(_channelCount == 0)
throw std::runtime_error(
"No channels in set");
74 _channelFrequencies =
new double[_channelCount];
75 for(
size_t index = 0; index != _channelCount; ++index)
77 _channelFrequencies[index] = source._channelFrequencies[index + startChannel];
86 BandData(
size_t channelCount,
const double* frequencies) :
87 _channelCount(channelCount)
89 _channelFrequencies =
new double[channelCount];
90 memcpy(_channelFrequencies, frequencies,
sizeof(
double)*channelCount);
92 _frequencyStep = _channelFrequencies[1] - _channelFrequencies[0];
100 delete[] _channelFrequencies;
106 _channelCount = source._channelCount;
107 _frequencyStep = source._frequencyStep;
108 if(_channelCount != 0)
110 _channelFrequencies =
new double[_channelCount];
111 for(
size_t index = 0; index != _channelCount; ++index)
113 _channelFrequencies[index] = source._channelFrequencies[index];
117 _channelFrequencies = 0;
123 {
return _channelFrequencies; }
126 {
return _channelFrequencies+_channelCount; }
129 {
return _channelFrequencies; }
132 {
return _channelFrequencies+_channelCount; }
134 std::reverse_iterator<double*> rbegin()
135 {
return std::reverse_iterator<double*>(
end()); }
137 std::reverse_iterator<double*> rend()
138 {
return std::reverse_iterator<double*>(
begin()); }
140 std::reverse_iterator<const double*> rbegin()
const 141 {
return std::reverse_iterator<const double*>(
end()); }
143 std::reverse_iterator<const double*> rend()
const 144 {
return std::reverse_iterator<const double*>(
begin()); }
151 void Set(
size_t channelCount,
const double* frequencies)
153 _channelCount = channelCount;
154 delete[] _channelFrequencies;
155 _channelFrequencies =
new double[channelCount];
156 memcpy(_channelFrequencies, frequencies,
sizeof(
double)*channelCount);
169 return _channelFrequencies[channelIndex];
177 return 299792458.0L / _channelFrequencies[channelIndex];
185 return _channelFrequencies[_channelCount-1];
193 return _channelFrequencies[0];
210 return 299792458.0L / frequencyHz;
226 return _frequencyStep;
264 void initFromTable(casacore::MSSpectralWindow& spwTable,
size_t bandIndex)
266 casacore::ROScalarColumn<int> numChanCol(spwTable, casacore::MSSpectralWindow::columnName(casacore::MSSpectralWindowEnums::NUM_CHAN));
268 numChanCol.get(bandIndex, temp);
269 _channelCount = temp;
270 if(_channelCount == 0)
throw std::runtime_error(
"No channels in set");
272 casacore::ROArrayColumn<double> chanFreqCol(spwTable, casacore::MSSpectralWindow::columnName(casacore::MSSpectralWindowEnums::CHAN_FREQ));
273 casacore::Array<double> channelFrequencies;
274 chanFreqCol.get(bandIndex, channelFrequencies,
true);
276 _channelFrequencies =
new double[_channelCount];
278 for(casacore::Array<double>::const_iterator i=channelFrequencies.begin();
279 i != channelFrequencies.end(); ++i)
281 _channelFrequencies[index] = *i;
284 if(_channelCount > 1)
285 _frequencyStep = _channelFrequencies[1] - _channelFrequencies[0];
287 _frequencyStep = 0.0;
290 size_t _channelCount;
291 double *_channelFrequencies;
292 double _frequencyStep;
double CentreWavelength() const
Get the wavelength of the central channel.
Definition: banddata.h:216
double FrequencyStep() const
Get the distance between channels in Hz.
Definition: banddata.h:224
void Set(size_t channelCount, const double *frequencies)
Assign new frequencies to this instance.
Definition: banddata.h:151
BandData()
Construct an empty instance.
Definition: banddata.h:24
double LowestFrequency() const
Get the frequency of the first channel.
Definition: banddata.h:191
double CentreFrequency() const
Get the centre frequency.
Definition: banddata.h:199
BandData(const BandData &source, size_t startChannel, size_t endChannel)
Construct a new instance from a part of another band.
Definition: banddata.h:69
double BandStart() const
Get the start of the frequency range covered by this band.
Definition: banddata.h:245
const double * begin() const
Constant iterator over frequencies, pointing to first channel.
Definition: banddata.h:128
double HighestFrequency() const
Get the frequency of the last channel.
Definition: banddata.h:183
Contains information about a single band ("spectral window").
Definition: banddata.h:15
double BandEnd() const
Get the end of the frequency range covered by this band.
Definition: banddata.h:251
const double * end() const
Constant iterator over frequencies, pointing to last channel.
Definition: banddata.h:131
size_t ChannelCount() const
Retrieve number of channels in this band.
Definition: banddata.h:162
BandData(casacore::MSSpectralWindow &spwTable)
Construct an instance from a spectral window table.
Definition: banddata.h:33
double LongestWavelength() const
Get the wavelength of the first channel.
Definition: banddata.h:231
double * begin()
Iterator over frequencies, pointing to first channel.
Definition: banddata.h:122
double Bandwidth() const
Get the total bandwidth covered by this band.
Definition: banddata.h:258
~BandData()
Destructor.
Definition: banddata.h:98
double ChannelWavelength(size_t channelIndex) const
Get the wavelength in m of a specified channel.
Definition: banddata.h:175
BandData(size_t channelCount, const double *frequencies)
Construct a new BandData class and initialize it with an array of frequencies.
Definition: banddata.h:86
double * end()
Iterator over frequencies, pointing past last channel.
Definition: banddata.h:125
void operator=(const BandData &source)
Assignment operator.
Definition: banddata.h:104
double SmallestWavelength() const
Get the wavelength of the last channel.
Definition: banddata.h:238
BandData(casacore::MSSpectralWindow &spwTable, size_t bandIndex)
Construct an instance from a specified entry of a spectral window table.
Definition: banddata.h:45
BandData(const BandData &source)
Copy constructor.
Definition: banddata.h:54
static double FrequencyToLambda(double frequencyHz)
Convert a frequency to a wavelength.
Definition: banddata.h:208
double ChannelFrequency(size_t channelIndex) const
Get the frequency in Hz of a specified channel.
Definition: banddata.h:167