casacore
MVFrequency.h
Go to the documentation of this file.
1 //# MVFrequency.h: Internal value for MFrequency
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_MVFREQUENCY_H
29 #define CASA_MVFREQUENCY_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 #include <casacore/casa/Quanta/QC.h>
36 #include <casacore/casa/Quanta/Quantum.h>
37 #include <casacore/casa/Quanta/MeasValue.h>
38 #include <casacore/casa/iosfwd.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 
44 // <summary> Internal value for MFrequency </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="tcornwel" date="1996/02/23" tests="tMeasMath" demos="">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class=MeasValue>MeasValue</linkto>
53 // </prerequisite>
54 //
55 // <etymology>
56 // From Measure, Value and Frequency
57 // </etymology>
58 //
59 // <synopsis>
60 // An MVFrequency is a simple Double, to be used in the MFrequency measure.
61 // Requirements can be found in the
62 // <linkto class=MeasValue>MeasValue</linkto> base class.<br>
63 // The only reasonable constructor is (but all MeasValue constructors are
64 // present)
65 // <src>MVFrequency(Double)</src> (with assumed Hz units);
66 // and an <src>operator Double</src> takes
67 // care of all other possibilities. Its external use is for
68 // <linkto class=MeasConvert>MeasConvert</linkto>, to distinguish between
69 // input in internal Measure units, and values which have to have
70 // units applied.<br>
71 // The MVFrequency(Quantum) constructors recognise the type of wave
72 // characteristics presented from its units. Recognised are:
73 // <ul>
74 // <li> frequency (1/time)
75 // <li> time
76 // <li> angle/time
77 // <li> wavelength
78 // <li> 1/wavelength (in 2pi units)
79 // <li> energy (h.nu)
80 // <li> impulse
81 // </ul>
82 // <br> The frequency is returned in Hz with getValue(); or as a Quantity
83 // in Hz with get(); or in one of the above units with get(unit).
84 // </synopsis>
85 //
86 // <example>
87 // See <linkto class=MFrequency>MFrequency</linkto>
88 // </example>
89 //
90 // <motivation>
91 // To aid coordinate transformations possibilities
92 // </motivation>
93 //
94 // <todo asof="1996/04/15">
95 // </todo>
96 
97 class MVFrequency : public MeasValue {
98 
99 public:
100 
101  //# Constructors
102  // Default constructor: generate a zero value
104  // Copy constructor
105  MVFrequency(const MVFrequency &other);
106  // Copy assignment
108  // Constructor from Double, assuming Hz
110  // Constructor from Quantum : value taken will be the canonical value
111  // <group>
112  MVFrequency(const Quantity &other);
114  // </group>
115  // Constructor from Vector. A zero value will be taken for an empty vector,
116  // the canonical value for a quantum vector.
117  // <thrown>
118  // <li> AipsError if vector length > 1
119  // </thrown>
120  // <group>
123  // </group>
124 
125  // Destructor
127 
128  //# Operators
129  // Conversion operator
130  operator Double() const;
131 
132  // Addition
133  // <group>
136  // </group>
137  // Comparisons
138  // <group>
139  Bool operator==(const MVFrequency &other) const;
140  Bool operator!=(const MVFrequency &other) const;
141  Bool near(const MVFrequency &other, Double tol = 1e-13) const;
142  Bool nearAbs(const MVFrequency &other, Double tol = 1e-13) const;
143  // </group>
144 
145  //# General member functions
146 
147  // Tell me your type
148  // <group>
149  static void assure(const MeasValue &in);
150  // </group>
151 
152  // Print data
153  virtual void print(ostream &os) const;
154  // Clone
155  virtual MeasValue *clone() const;
156  // Adjust value: taken from base class, a NOP.
157  // Get value in Hz
158  Double getValue() const;
159  // Get quantity in Hz
160  Quantity get() const;
161  // Get the wave characteristics in (recognised) specified units
162  Quantity get(const Unit &unit) const;
163  // Get the value in internal units
164  virtual Vector<Double> getVector() const;
165  // Set the value from internal units (set 0 for empty vector)
166  virtual void putVector(const Vector<Double> &in);
167  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
168  // records. The getXRecordValue() gets additional information for records.
169  // Note that the Vectors could be empty.
170  // <group>
172  // </group>
173  // Set the internal value if correct values and dimensions
174  virtual Bool putValue(const Vector<Quantum<Double> > &in);
175 
176 private:
177  //# Data
178  // Value
180 
181  //# Member functions
182  // Get correct data type conversion factor from input Quantum
183  Double makeF(Double v, const Unit &dt, Bool rev=False) const;
184 };
185 
186 
187 } //# NAMESPACE CASACORE - END
188 
189 #endif
Double getValue() const
Adjust value: taken from base class, a NOP.
MVFrequency & operator+=(const MVFrequency &other)
Addition.
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
virtual Vector< Double > getVector() const
Get the value in internal units.
virtual MeasValue * clone() const
Clone.
MVFrequency & operator=(const MVFrequency &other)
Copy assignment.
Bool operator==(const MVFrequency &other) const
Comparisons.
Quantity get() const
Get quantity in Hz.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
MVFrequency & operator-=(const MVFrequency &other)
MVFrequency()
Default constructor: generate a zero value.
Bool operator!=(const MVFrequency &other) const
~MVFrequency()
Destructor.
MVFrequency(const MVFrequency &other)
Copy constructor.
MVFrequency(const Quantum< Vector< Double > > &other)
MVFrequency(const Quantity &other)
Constructor from Quantum : value taken will be the canonical value.
virtual void print(ostream &os) const
Print data.
static void assure(const MeasValue &in)
Tell me your type.
MVFrequency(const Vector< Quantity > &other)
Bool nearAbs(const MVFrequency &other, Double tol=1e-13) const
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector<Quantity>.
Bool near(const MVFrequency &other, Double tol=1e-13) const
MVFrequency(Double d)
Constructor from Double, assuming Hz.
Quantity get(const Unit &unit) const
Get the wave characteristics in (recognised) specified units.
MVFrequency(const Vector< Double > &other)
Constructor from Vector.
Double makeF(Double v, const Unit &dt, Bool rev=False) const
Get correct data type conversion factor from input Quantum.
const Double e
e and functions thereof:
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55