casacore
Loading...
Searching...
No Matches
MFrequency.h
Go to the documentation of this file.
1//# MFrequency.h: A Measure: wave characteristics
2//# Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
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: casa-feedback@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#ifndef MEASURES_MFREQUENCY_H
27#define MEASURES_MFREQUENCY_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/measures/Measures/MeasBase.h>
32#include <casacore/measures/Measures/MeasRef.h>
33#include <casacore/casa/Quanta/MVFrequency.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38class MFrequency;
39class MCFrequency;
40class MDoppler;
41class MVDoppler;
42template <class M> class MeasConvert;
43template <class M> class ArrayMeasColumn;
44template <class M> class ScalarMeasColumn;
45
46//# Typedefs
47
48// <summary>
49// A Measure: wave characteristics
50// </summary>
51
52// <use visibility=export>
53
54// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
55// </reviewed>
56
57// <prerequisite>
58// <li> <linkto class=Measure>Measure</linkto> class
59// <li> <linkto class = MRadialVelocity>MRadialVelocity</linkto> class
60// for some other background.
61// </prerequisite>
62//
63// <etymology>
64// </etymology>
65//
66// <synopsis>
67// MFrequency is a derived Measure class for wave characteristics.<br>
68// An MFrequency can be generated from a simple value (or an
69// <linkto class=MVFrequency>MFrequency</linkto> object), which is then
70// interpreted as a frequency in Hz, and a reference, with an LSRK type
71// as default.<br>
72// It can also be generated from a Quantity, where the interpretation
73// depends on the dimensionality of the Quantity:
74// <ul>
75// <li> time (e.g. s): period
76// <li> frequency (e.g. Hz): frequency
77// <li> angular frequency (e.g. arcmin/s): angular frequency
78// <li> length (e.g. cm): wavelength
79// <li> inverse length (e.g. mm<sup>-1</sup>): wave number
80// <li> energy (e.g. J.s): energy (i.e. <em>h.nu</em>)
81// <li> momentum (e.g. kg.m): <em>m.c/h</em>
82// </ul>
83// The different reference types of a frequency are:
84// <ul>
85// <li> MFrequency::REST -- Rest frequency
86// <li> MFrequency::LSRD -- Local Standard of Rest (J2000) -- as the
87// dynamical definition (IAU, [9,12,7] km/s in galactic
88// coordinates)
89// <li> MFrequency::LSRK -- LSR as a kinematical (radio) definition --
90// 20.0 km/s in direction ra,dec = [270,+30] deg (B1900.0)
91// <li> MFrequency::BARY -- Barycentric (J2000)
92// <li> MFrequency::GEO --- Geocentric
93// <li> MFrequency::TOPO -- Topocentric
94// <li> MFrequency::GALACTO -- Galacto centric (with rotation of 220 km/s
95// in direction l,b = [90,0] deg.
96// <li> MFrequency::LGROUP -- Local group velocity -- 308km/s towards
97// l,b = [105,-7] deg (F. Ghigo)
98// <li> MFrequency::CMB -- CMB velocity -- 369.5km/s towards
99// l,b = [264.4, 48.4] deg (F. Ghigo)
100// <li> MFrequency::DEFAULT = LSRK
101// </ul>
102// <p>
103// Conversion between the different types is done with the standard
104// <linkto class=MeasConvert>MeasConvert</linkto> class
105// (<src>MFrequency::Convert</src> in this case).
106// Some of the conversions are only possible if frame information has been
107// filled in. The following frame information is necessary if a conversion
108// goes to or from the (different) specified types:
109// <ul>
110// <li><em>Radial Velocity</em>: REST
111// <li><em>Epoch</em>: TOPO, GEO
112// <li><em>Position</em>: TOPO
113// <li><em>Direction</em> all
114// </ul>
115// <br>
116// To accommodate unknown or invalid frames, the additional reference type
117// <ul>
118// <li> MFrequency::Undefined
119// </ul>
120// is available. Conversions to/from Undefined are not possible.
121// If attempted, an exception will be thrown.
122// The name was chosen to be Undefined and not UNDEFINED in order to
123// not collide with the (ugly) WCSLIB macro of the upper case name
124// and in concordance with Stokes::Undefined.
125// <br>
126// An MFrequency can be created from an
127// <linkto class=MDoppler>MDoppler</linkto> (and a rest frequency, (the
128// <linkto class=QC>QC</linkto> class contains at least <src>QC::HI</src>))
129// by the <src>fromDoppler()</src> member. It can be converted to an MDoppler
130// with the <src>toDoppler()</src>. Comparable methods will be available
131// for <linkto class=MFrequency>MFrequency</linkto> as
132// <src>toRadial()</src> and <src>fromRadial</src>.<br>
133// If the Doppler shift is known (e.g. from another spectral line), the
134// REST frequency can be determined with the <src>toREST()</src> member.
135// <note role=caution> Conversion between the different frequencies can,
136// due to relativistic effects, only be done approximately for very high
137// (order c) radial velocities (shifted frequencies). A better approach
138// would be to start from radial velocities and a rest frequency.
139// </note>
140// </synopsis>
141//
142// <example>
143// Get the Doppler shift for an oberved HI frequency of 1380 MHz
144// <srcblock>
145// cout << "Redshift for 1380 MHz: " <<
146// MDoppler::Convert( MFrequency( Quantity(1380., "MHz"),
147// MFrequency::TOPO).toDoppler(QC::HI),
148// MDoppler::Z)() << endl;
149// </srcblock>
150// </example>
151//
152// <motivation>
153// </motivation>
154//
155// <todo asof="2003/03/03">
156// </todo>
157
158class MFrequency : public MeasBase<MVFrequency, MeasRef<MFrequency> > {
159
160 public:
161 //# Friends
162 // Conversion of data
163 friend class MeasConvert<MFrequency>;
164
165 //# Enumerations
166 // Types of known MFrequencies
167 // <note role=warning> The order defines the order in the translation
168 // matrix FromTo
169 // in the getConvert routine. Do not change the order without
170 // changing the array. Additions should be made before N_types, and
171 // an additional row and column should be coded in FromTo, and
172 // in showType().</note>
173 enum Types {
186 // all extra bits
187 EXTRA = 64,
188 // Defaults
190 // Synonyms
192
193 //# Typedefs
194 // Measure value container for this class (i.e. MFrequency::MVType)
196 // Measure conversion routines for this class (i.e. MFrequency::MCType)
198 // Measure reference (i.e. MFrequency::Ref)
200 // Measure conversion use (i.e. MFrequency::Convert)
202 // Measure table Columns (e.g., MFrequency::ScalarColumn)
205
206 //# Constructors
207 // <note role=tip> In the following constructors and other functions, all
208 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
209 // where no offsets or frames are needed in the reference. </note>
210 // Default constructor; generates a zero rest frequency
212 // Create from data and reference
213 // <group>
218 MFrequency(const Quantity &dt, const MFrequency::Ref &rf);
220 MFrequency(const Measure *dt);
222 // </group>
223
224 //# Destructor
225 virtual ~MFrequency();
226
227 //# Operators
228
229 //# General Member Functions
230 // Tell me your type
231 // <group>
232 virtual const String &tellMe() const;
233 static const String &showMe();
234 static void assure(const Measure &in);
235 // </group>
236 // Translate reference code. The uInt version has a check for valid codes
237 // (i.e. it is a safe cast).
238 // <thrown>
239 // <li> AipsError in the uInt interface if illegal code given
240 // </thrown>
241 // <group>
244 static const String &showType(uInt tp);
245 // </group>
246 // Translate string to reference code
247 // <group>
248 static Bool getType(MFrequency::Types &tp, const String &in);
249
250 // Throws an exception if the type string is not recognized
252
253
255 // </group>
256 // Set the offset in the reference (False if non-matching Measure)
257 virtual Bool setOffset(const Measure &in);
258 // Set the reference type to the specified String. False if illegal
259 // string, reference set to DEFAULT.
260 virtual Bool setRefString(const String &in);
261 // Get the default reference type
262 virtual const String &getDefaultType() const;
263 // Get a list of all known reference codes. nall returns the number in list,
264 // nextra the number of specials (like planets) that should be at
265 // end of list). typ returns the list of corresponding types.
266 // <group>
267 virtual const String* allTypes(Int &nall, Int &nextra,
268 const uInt *&typ) const;
269 static const String* allMyTypes(Int &nall, Int &nextra,
270 const uInt *&typ);
271 // </group>
272 // Check if all internal tables of types (both enum and String) are
273 // complete and correct. This function is called automatically if and when
274 // necessary.
275 // <thrown>
276 // <li> AipsError if a (programming) error in the types.
277 // </thrown>
278 // <group>
279 virtual void checkTypes() const;
280 static void checkMyTypes();
281 // </group>
282 // Get the reference type (for records, including codes like R_)
283 virtual String getRefString() const;
284
285 // Get frequency in specified units
286 Quantity get(const Unit &un) const;
287
288 // Make a Doppler velocity from the frequency and the specified rest frequency
289 // <group>
291 MDoppler toDoppler(const MVFrequency &rest) const;
292 // </group>
293 // Local use only
294 static MDoppler toDoppler(const Measure &in, const MVFrequency &rest);
295 // Make a frequency from the Doppler velocity and the specified rest frequency
296 // (default reference type LSRK)
297 // <group>
298 static MFrequency fromDoppler(const MDoppler &dop,
299 const MVFrequency &rest);
300 static MFrequency fromDoppler(const MDoppler &dop,
301 const MVFrequency &rest,
302 MFrequency::Types type);
303 // For internal use only
304 static MFrequency fromDoppler(const Measure &dop,
305 const MVFrequency &rest,
306 MFrequency::Types type);
307 // </group>
308
309 // Make a rest frequency using a Doppler velocity
310 MFrequency toRest(const MDoppler &dop) const;
311 // For local use only
312 static MFrequency toRest(const Measure &in, const Measure &dop);
313
314 // Make a copy
315 // <group>
316 virtual Measure *clone() const;
317 // </group>
318
319 private:
320 //# Enumerations
321
322 //# Data
323
324 //# Member functions
325
326};
327
328
329} //# NAMESPACE CASACORE - END
330
331#endif
static Bool getType(MFrequency::Types &tp, const String &in)
Translate string to reference code.
MFrequency(const MVFrequency &dt, MFrequency::Types rf)
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
MDoppler toDoppler(const MVFrequency &rest)
Make a Doppler velocity from the frequency and the specified rest frequency.
static void checkMyTypes()
MeasConvert< MFrequency > Convert
Measure conversion use (i.e.
Definition MFrequency.h:201
MFrequency(const Quantity &dt, MFrequency::Types rf)
static void assure(const Measure &in)
static MFrequency toRest(const Measure &in, const Measure &dop)
For local use only.
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
MFrequency(const Quantity &dt)
MCFrequency MCType
Measure conversion routines for this class (i.e.
Definition MFrequency.h:197
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:173
@ EXTRA
all extra bits
Definition MFrequency.h:187
static MFrequency fromDoppler(const Measure &dop, const MVFrequency &rest, MFrequency::Types type)
For internal use only.
MeasRef< MFrequency > Ref
Measure reference (i.e.
Definition MFrequency.h:199
static const String & showType(uInt tp)
virtual const String & tellMe() const
Tell me your type.
MFrequency(const Measure *dt)
virtual const String & getDefaultType() const
Get the default reference type.
MFrequency(const MVFrequency &dt, const MFrequency::Ref &rf)
MFrequency()
Tip: In the following constructors and other functions, all MeasRef can be replaced with simple Measu...
static MFrequency fromDoppler(const MDoppler &dop, const MVFrequency &rest, MFrequency::Types type)
static const String & showType(MFrequency::Types tp)
ScalarMeasColumn< MFrequency > ScalarColumn
Measure table Columns (e.g., MFrequency::ScalarColumn)
Definition MFrequency.h:203
MVFrequency MVType
Measure value container for this class (i.e.
Definition MFrequency.h:195
MFrequency(const MeasValue *dt)
static MFrequency fromDoppler(const MDoppler &dop, const MVFrequency &rest)
Make a frequency from the Doppler velocity and the specified rest frequency (default reference type L...
ArrayMeasColumn< MFrequency > ArrayColumn
Definition MFrequency.h:204
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure)
MDoppler toDoppler(const MVFrequency &rest) const
static const String & showMe()
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
static MFrequency::Types typeFromString(const String &in)
Throws an exception if the type string is not recognized.
static MFrequency::Types castType(uInt tp)
Translate reference code.
Quantity get(const Unit &un) const
Get frequency in specified units.
Bool giveMe(MFrequency::Ref &mr, const String &in)
MFrequency(const MVFrequency &dt)
Create from data and reference.
virtual Measure * clone() const
Make a copy.
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
static MDoppler toDoppler(const Measure &in, const MVFrequency &rest)
Local use only.
MFrequency toRest(const MDoppler &dop) const
Make a rest frequency using a Doppler velocity.
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
MFrequency(const Quantity &dt, const MFrequency::Ref &rf)
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40