casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATMSpectralGrid.h
Go to the documentation of this file.
1 #ifndef _ATM_SPECTRALGRID_H
2 #define _ATM_SPECTRALGRID_H
3 /*******************************************************************************
4  * ALMA - Atacama Large Millimiter Array
5  * (c) Instituto de Estructura de la Materia, 2009
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * "@(#) $Id: ATMSpectralGrid.h Exp $"
22  *
23  * who when what
24  * -------- -------- ----------------------------------------------
25  * pardo 24/03/09 created
26  */
27 
28 #ifndef __cplusplus
29 #error "This is a C++ include file and cannot be used from plain C"
30 #endif
31 
32 #include "ATMCommon.h"
33 #include "ATMEnumerations.h"
34 #include "ATMFrequency.h"
35 #include <string>
36 #include <vector>
37 
70 {
71 public:
72  SpectralGrid(const Frequency &oneFreq);
73 
86  SpectralGrid(unsigned int numChan,
87  unsigned int refChan,
88  const Frequency &refFreq,
89  const Frequency &chanSep);
90 
104  SpectralGrid(unsigned int numChan,
105  double refFreq,
106  double* chanFreq,
107  const std::string &freqUnits);
108  SpectralGrid(double refFreq, const std::vector<double> &chanFreq, const std::string &freqUnits);
109  SpectralGrid(const std::vector<double> &chanFreq, const std::string &freqUnits);
110  SpectralGrid(const std::vector<Frequency> &chanFreq);
111 
129  SpectralGrid(unsigned int numChan,
130  unsigned int refChan,
131  const Frequency &refFreq,
132  const Frequency &chanSep,
133  const Frequency &intermediateFreq,
134  const SidebandSide &sbSide,
135  const SidebandType &sbType);
136 
152  SpectralGrid(unsigned int numChan,
153  unsigned int refChan,
154  double* chanFreq,
155  const std::string &freqUnits);
156 
157  SpectralGrid();
158 
159  SpectralGrid(const SpectralGrid &);
160 
161  ~SpectralGrid();
162 
173  unsigned int add(unsigned int numChan,
174  unsigned int refChan,
175  const Frequency &refFreq,
176  const Frequency &chanSep);
177 
188  unsigned int add(unsigned int numChan,
189  unsigned int refChan,
190  double* chanFreq,
191  const std::string &freqUnits);
192 
203  unsigned int add(unsigned int numChan,
204  double refFreq,
205  double* chanFreq,
206  const std::string &freqUnits);
207  unsigned int add(unsigned int numChan,
208  double refFreq,
209  const std::vector<double> &chanFreq,
210  const std::string &freqUnits);
211  unsigned int add(const std::vector<Frequency> &chanFreq)
212  {
213  unsigned int spwid;
214  std::vector<double> v;
215  for(unsigned int i = 0; i < chanFreq.size(); i++) {
216  v.push_back(chanFreq[i].get("GHz"));
217  }
218  spwid = add(chanFreq.size(), chanFreq[0].get("GHz"), v, "GHz");
219  return spwid;
220  }
235  void add(unsigned int numChan,
236  unsigned int refChan,
237  const Frequency &refFreq,
238  const Frequency &chanSep,
239  const Frequency &intermediateFreq,
240  const SidebandSide &sbSide,
241  const SidebandType &sbType);
242 
244 
247  unsigned int getNumSpectralWindow() const;
248 
252  unsigned int getNumChan() const;
257  unsigned int getNumChan(unsigned int spwId) const;
258 
265  unsigned int getRefChan() const;
270  unsigned int getRefChan(unsigned int spwId) const;
271 
272  // Frequency getRefFreq();
276  Frequency getRefFreq() const;
277 
282  Frequency getRefFreq(unsigned int spwId) const;
283 
287  Frequency getChanSep() const;
288 
293  Frequency getChanSep(unsigned int spwId) const;
294 
299  Frequency getChanFreq(unsigned int chanNum) const;
300  Frequency getChanWidth(unsigned int chanNum) const;
301 
307  Frequency getChanFreq(unsigned int spwId, unsigned int chanNum) const;
308  Frequency getChanWidth(unsigned int spwId, unsigned int chanNum) const;
309 
310 
319  std::vector<double> getSbChanFreq(unsigned int spwId,
320  unsigned int chanNum,
321  const std::string &freqUnits) const;
322 
327  std::vector<double> getSpectralWindow(unsigned int spwId) const;
328 
332  double getChanNum(double freq) const;
338  double getChanNum(unsigned int spwId, double freq) const;
339 
346  Frequency getBandwidth() const;
347 
355  Frequency getBandwidth(unsigned int spwId) const;
356 
360  Frequency getMinFreq() const;
361 
367  Frequency getMinFreq(unsigned int spwId) const;
368 
372  Frequency getMaxFreq() const;
378  Frequency getMaxFreq(unsigned int spwId) const;
379 
383  bool isRegular() const;
388  bool isRegular(unsigned int spwId) const;
389 
395  std::string getSidebandSide(unsigned int spwId) const;
396 
403  std::vector<std::string> getAssocNature(unsigned int spwId) const;
404 
411  std::vector<unsigned int> getAssocSpwId(unsigned int spwId) const;
412 
413  std::vector<unsigned int> getAssocSpwIds(const std::vector<unsigned int> &spwIds) const;
414 
423  std::string getSidebandType(unsigned int spwId) const;
424 
431  std::string getSideband(unsigned int spwId) const;
432 
433  double getLoFrequency() const;
434  double getLoFrequency(unsigned int spwId) const;
435 
437 
438  bool operator ==(const SpectralGrid&) const;
439 
440 protected:
441  std::string freqUnits_;
442  std::vector<double> v_chanFreq_;
443 
444  std::vector<unsigned int> v_numChan_;
445  std::vector<unsigned int> v_refChan_;
446  std::vector<double> v_refFreq_;
447  std::vector<double> v_chanSep_;
448  std::vector<double> v_maxFreq_;
449  std::vector<double> v_minFreq_;
450  std::vector<double> v_intermediateFrequency_; //<! intermediate frequency of the band for every spectral window
451  std::vector<double> v_loFreq_; //<! LO frequency
452 
453  std::vector<SidebandSide> v_sidebandSide_; //<! NOSB=0, LSB=1, USB=2
454  std::vector<SidebandType> v_sidebandType_; //<! DSB=0, SSB=1, TWOSB=2
455  std::vector<std::vector<unsigned int> > vv_assocSpwId_; //<! associated spectral window Id(s)
456  std::vector<std::vector<std::string> > vv_assocNature_; //<! corresponding associated nature
457 
458  std::vector<unsigned int> v_transfertId_;
459 
460 private:
461 
462  void appendChanFreq(unsigned int numChan, double* chanFreq);
463  void appendChanFreq(unsigned int numChan, const std::vector<double> &chanFreq);
464  bool wrongSpwId(unsigned int spwId) const;
465 };
466 
467 inline bool SpectralGrid::operator ==(const SpectralGrid & a) const
468 {
469  bool equals = false;
470 
471  if(freqUnits_ != a.freqUnits_) return equals;
472  if(v_refChan_ != a.v_refChan_) return equals;
473  if(v_chanSep_ != a.v_chanSep_) return equals;
474  if(v_numChan_ != a.v_numChan_) return equals;
475  if(v_maxFreq_ != a.v_maxFreq_) return equals;
476  if(v_minFreq_ != a.v_minFreq_) return equals;
477  if(!equals)
478 
479  if(v_chanFreq_ != a.v_chanFreq_) return equals;
480 
481  equals = true;
482  return equals;
483 }; // class SpectralGrid
484 
486 
487 #endif
#define ATM_NAMESPACE_END
Definition: ATMCommon.h:38
std::vector< unsigned int > getAssocSpwId(unsigned int spwId) const
Accessor to the identifier of the associated spectral window(s)
std::vector< unsigned int > v_transfertId_
Spectral grid defined as a list of frequencies with basic complementary informations.
std::vector< double > v_loFreq_
bool isRegular() const
Method to know if the spectral grid is regular or not (the first spectral window) ...
double getChanNum(double freq) const
Method to get the grid position for a given frequency specified in Hz (the first spectral window) ...
Global enumeration objects.
std::vector< double > v_intermediateFrequency_
SidebandType
Defines the kind of sideband separations.
std::vector< double > getSpectralWindow(unsigned int spwId) const
Accessor to retrieve the spectral grid of a spectral window.
unsigned int getNumChan() const
Accessor to the number of frequency points for the first spectral window.
Frequency getBandwidth() const
Method to get the frequency range encompassing the list of frequency grid points (for the first spect...
std::vector< SidebandSide > v_sidebandSide_
std::vector< std::string > getAssocNature(unsigned int spwId) const
Accessor to the nature(s) of the associated spectral window(s)
Frequency getMaxFreq() const
Method to get the frequency (Hz) for the point at the largest frequency (for the first spectral windo...
std::string getSidebandType(unsigned int spwId) const
Accessor for the type of sideband.
bool wrongSpwId(unsigned int spwId) const
SidebandSide
Defines the side of a sideband.
#define ATM_NAMESPACE_BEGIN
Definition: ATMCommon.h:37
std::vector< double > v_refFreq_
frequency at reference channel for every spectral window
Frequency getChanFreq(unsigned int chanNum) const
Accessor to the frequency (Hz) for a given grid point (for the first spectral window) ...
std::vector< double > getSbChanFreq(unsigned int spwId, unsigned int chanNum, const std::string &freqUnits) const
Accessor to the frequencies in the specified units for a given channel index (0-based) for the the sp...
std::vector< double > v_minFreq_
frequency minimum for every spectral window
bool operator==(const SpectralGrid &) const
unsigned int add(unsigned int numChan, unsigned int refChan, const Frequency &refFreq, const Frequency &chanSep)
Add a new spectral window, uniformly sampled, this spectral window having no sideband.
std::string getSidebandSide(unsigned int spwId) const
Accessor for the side of the sideband.
std::vector< double > v_maxFreq_
frequency maximum for every spectral window
Frequency getChanSep() const
Accessor to the channel separation for regularily spaced grids (for the first spectral window) ...
std::vector< double > v_chanFreq_
Channel frequencies of ALL the channels (i.e. all spectral window appended)
std::vector< double > v_chanSep_
channel separation for every spectral window
Frequency getMinFreq() const
Method to get the frequency (Hz) for the point at the lowest frequency (for the first spectral window...
unsigned int add(const std::vector< Frequency > &chanFreq)
std::vector< SidebandType > v_sidebandType_
std::string getSideband(unsigned int spwId) const
Accessor for the side of the sideband and its type.
Defines a frequency value with units.
Definition: ATMFrequency.h:48
std::vector< std::vector< std::string > > vv_assocNature_
std::vector< std::vector< unsigned int > > vv_assocSpwId_
Frequency getChanWidth(unsigned int chanNum) const
std::vector< unsigned int > v_refChan_
reference channel for every spectral window
double getLoFrequency() const
void appendChanFreq(unsigned int numChan, double *chanFreq)
std::vector< unsigned int > v_numChan_
number of channels for every spectral window
unsigned int getRefChan() const
Accessor to the reference channel of the first spectral window.
std::string freqUnits_
The frequency inits (always Hz)
std::vector< unsigned int > getAssocSpwIds(const std::vector< unsigned int > &spwIds) const
Frequency getRefFreq() const
Frequency getRefFreq();.
unsigned int getNumSpectralWindow() const
Accessor to the number of spectral wondows.