casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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
103  MVFrequency();
104  // Copy constructor
105  MVFrequency(const MVFrequency &other);
106  // Copy assignment
107  MVFrequency &operator=(const MVFrequency &other);
108  // Constructor from Double, assuming Hz
109  MVFrequency(Double d);
110  // Constructor from Quantum : value taken will be the canonical value
111  // <group>
112  MVFrequency(const Quantity &other);
113  MVFrequency(const Quantum<Vector<Double> > &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>
121  MVFrequency(const Vector<Double> &other);
122  MVFrequency(const Vector<Quantity> &other);
123  // </group>
124 
125  // Destructor
126  ~MVFrequency();
127 
128  //# Operators
129  // Conversion operator
130  operator Double() const;
131 
132  // Addition
133  // <group>
134  MVFrequency &operator+=(const MVFrequency &other);
135  MVFrequency &operator-=(const MVFrequency &other);
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  virtual uInt type() const;
150  static void assure(const MeasValue &in);
151  // </group>
152 
153  // Print data
154  virtual void print(ostream &os) const;
155  // Clone
156  virtual MeasValue *clone() const;
157  // Adjust value: taken from base class, a NOP.
158  // Get value in Hz
159  Double getValue() const;
160  // Get quantity in Hz
161  Quantity get() const;
162  // Get the wave characteristics in (recognised) specified units
163  Quantity get(const Unit &unit) const;
164  // Get the value in internal units
165  virtual Vector<Double> getVector() const;
166  // Set the value from internal units (set 0 for empty vector)
167  virtual void putVector(const Vector<Double> &in);
168  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
169  // records. The getXRecordValue() gets additional information for records.
170  // Note that the Vectors could be empty.
171  // <group>
172  virtual Vector<Quantum<Double> > getRecordValue() const;
173  // </group>
174  // Set the internal value if correct values and dimensions
175  virtual Bool putValue(const Vector<Quantum<Double> > &in);
176 
177 private:
178  //# Data
179  // Value
181 
182  //# Member functions
183  // Get correct data type conversion factor from input Quantum
184  Double makeF(Double v, const Unit &dt, Bool rev=False) const;
185 };
186 
187 
188 } //# NAMESPACE CASACORE - END
189 
190 #endif
Double makeF(Double v, const Unit &dt, Bool rev=False) const
Get correct data type conversion factor from input Quantum.
Double val
Value.
Definition: MVFrequency.h:180
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
Bool operator==(const MVFrequency &other) const
Comparisons.
Internal value for MFrequency.
Definition: MVFrequency.h:97
Bool near(const MVFrequency &other, Double tol=1e-13) const
Bool operator!=(const MVFrequency &other) const
Double getValue() const
Adjust value: taken from base class, a NOP.
virtual MeasValue * clone() const
Clone.
~MVFrequency()
Destructor.
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
MVFrequency & operator=(const MVFrequency &other)
Copy assignment.
MVFrequency()
Default constructor: generate a zero value.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
defines physical units
Definition: Unit.h:189
Base class for values in a Measure.
Definition: MeasValue.h:107
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void print(ostream &os) const
Print data.
static void assure(const MeasValue &in)
const Bool False
Definition: aipstype.h:44
MVFrequency & operator-=(const MVFrequency &other)
const Double e
e and functions thereof:
MVFrequency & operator+=(const MVFrequency &other)
Addition.
virtual Vector< Double > getVector() const
Get the value in internal units.
Bool nearAbs(const MVFrequency &other, Double tol=1e-13) const
virtual uInt type() const
Tell me your type.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42