casacore
Loading...
Searching...
No Matches
MeasFrame.h
Go to the documentation of this file.
1//# MeasFrame.h: Container for Measure frame
2//# Copyright (C) 1996-2003,2007
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_MEASFRAME_H
27#define MEASURES_MEASFRAME_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/measures/Measures/Measure.h>
34#include <casacore/casa/iosfwd.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39class MVEpoch;
40class MVPosition;
41class MVDirection;
42class MVRadialVelocity;
43class MeasComet;
44class FrameRep;
45class MCFrame;
46template <class Qtype> class Quantum;
47
48// <summary> Container for Measure frame </summary>
49
50// <use visibility=export>
51
52// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
53// </reviewed>
54
55// <prerequisite>
56// <li> <linkto class=Measure>Measure</linkto> class
57// <li> <linkto class=MeasRef>MeasRef</linkto> class
58// </prerequisite>
59//
60// <etymology>
61// From Measure and Frame
62// </etymology>
63//
64// <synopsis>
65// Measurements are made in a reference frame (epoch, position, direction,
66// ...).<br>
67// The class is a container for the reference frame Measures (MEpoch etc).
68// Since a frame will possibly be used by many different Measures, it behaves
69// as a smart pointer, with reference rather than copy characteristics.
70// Since it caches all its operations, it is advisable to have a 'global'
71// MeasFrame across an execution, resetting (or setting) its values
72// when appropriate. The frame can also contain other related information. At
73// the moment the orbit of a solar system body (MeasComet) can be set.
74// In future the planetary ephemeris used (e.g. DE205) and environmental
75// information like refraction data will be added.
76//
77// A MeasFrame is constructed by setting the appropriate Measures, either in
78// a constructor, or with a set(). The input to the constructors and set are
79// Measures.<br>
80//
81// Inside the frames automatic conversion to the most appropriate usage of
82// its values is done (e.g. time to TBD time, position to astronomical
83// longitude). These conversions are done only if an explicit
84// Measure::Convert was used that needed information, e.g. the following
85// code:
86// <srcblock>
87// MeasFrame frame(obser); // obser is an MPosition
88// MEpoch::Convert conv(MEpoch(12345), MEpoch::Ref(MEpoch::LAST,obser));
89// MEpoch last = conv();
90// </srcblock>
91// will set-up a state machine to convert UTC(default) to LAST in conv; the
92// next call will do the actual conversion. During this conversion, the
93// astronomical longitude (among others) will be needed to convert to
94// local sidereal time. conv will ask (getLong()) this from the frame, which
95// will calculate it (including possible other conversions) from the
96// observatory's position specified in a frame. Any calculation done will be
97// cached (e.g. a Nutation calculation in this case for dpsi), and used in
98// subsequent conversions using the same frame.<br>
99// Furthermore, a frame will often be regularly updated (e.g. coordinate
100// conversion for a series of times). To make use of cached information, and
101// to speed up as much as possible, <src>reset...()</src> functions are
102// available. These reset functions accept the same range of input parameter
103// types as the <linkto class=MeasConvert>MeasConvert</linkto> () operator,
104// and will keep any determined conversion machines and related information
105// intact, only recalculating whatever is necessary.<br>
106// The actual frame calculations and interrogations are done in a separate
107// <linkto class=MCFrame>MCFrame</linkto> hidden class, which attaches itself
108// to MeasFrame when and if necessary (see there if you are really curious).<br>.
109// get...() functions can return frame measures. Only when the frame has been
110// attached to a calculating machine *MCFrame) are these values available.
111// This attachment is done if the frame has been actively used by a
112// Measure::Convert engine, or if explicitly done by the
113// <src>MCFrame::make(MeasFrame &)</src> static method.
114// <note role=caution> An explicit (or implicit) call to MCFrame::make will
115// load the whole conversion machinery (including Tables) into your
116// linked module).</note><br>
117// <linkto class=Aipsrc>Aipsrc keywords</linkto> can be used for additional
118// (highly specialised) additional internal conversion parameters.
119// </synopsis>
120//
121// <example>
122// <srcblock>
123// MEpoch my_epoch(Quantity(MeasData::MJDB1950,"d")); // an epoch
124// MeasFrame frame(my_epoch); // used in a frame
125// </srcblock>
126// </example>
127//
128// <motivation>
129// To separate the frame definition from the measure type
130// </motivation>
131//
132// <todo asof="1997/04/16">
133// </todo>
134
136
137 public:
138
139 //# Friends
140 // Output a frame
141 friend ostream &operator<<(ostream &os, MeasFrame &mf);
142 // Machinery
143 // <group>
144 friend class MCFrame;
145 friend Bool MCFrameGetdbl(void *dmf, uInt tp, Double &result);
146 friend Bool MCFrameGetmvdir(void *dmf, uInt tp, MVDirection &result);
147 friend Bool MCFrameGetmvpos(void *dmf, uInt tp, MVPosition &result);
148 friend Bool MCFrameGetuint(void *dmf, uInt tp, uInt &result);
149 // </group>
150
151 //# Enumerations
152 // Enumeration for the different farme entries possible. This can be used
153 // to find out if a certain conversion needs the frame. It will be
154 // used in a registration/notify environment to enable bypassing of
155 // some new conversion settings.
162
163 //# Constructors
164 // Default constructor
166 // Construct frame with specified measures
167 // <thrown>
168 // <li> AipsError if a non-frame Measure
169 // </thrown>
170 // <group>
171 MeasFrame(const Measure &meas1);
172 MeasFrame(const Measure &meas1, const Measure &meas2);
173 MeasFrame(const Measure &meas1, const Measure &meas2,
174 const Measure &meas3);
175 // </group>
176 // Copy constructor (reference semantics)
177 MeasFrame(const MeasFrame &other);
178 // Copy assignment (reference semantics)
180 // Destructor
182
183 //# Operators
184 // Comparisons
185 // <group>
186 Bool operator==(const MeasFrame &other) const;
187 Bool operator!=(const MeasFrame &other) const;
188 // </group>
189
190 //# General member functions
191 // Test if empty (i.e. no measure filled in)
192 Bool empty() const;
193
194 // Set frame elements
195 // <thrown>
196 // <li> AipsError if a non-frame Measure
197 // <li> AipsError if illegal or non-existant MeasComet given
198 // </thrown>
199 // <group>
200 void set(const Measure &meas1);
201 void set(const Measure &meas1, const Measure &meas2);
202 void set(const Measure &meas1, const Measure &meas2,
203 const Measure &meas3);
204 void set(const MeasComet &meas);
205 // </group>
206 // Reset a frame element and its cached derived values.
207 // <thrown>
208 // <li> AipsError if the specific Measure not yet present in frame
209 // </thrown>
210 // <group>
212 void resetEpoch(const Vector<Double> &val);
213 void resetEpoch(const Quantum<Double> &val);
215 void resetEpoch(const MVEpoch &val);
216 void resetEpoch(const Measure &val);
219 void resetPosition(const MVPosition &val);
220 void resetPosition(const Measure &val);
223 void resetDirection(const MVDirection &val);
224 void resetDirection(const Measure &val);
228 void resetRadialVelocity(const Measure &val);
229 void resetComet(const MeasComet &val);
230 // </group>
231
232 // Get the epoch pointer (0 if not present)
233 const Measure* epoch() const;
234 // Get the position pointer (0 if not present)
235 const Measure* position() const;
236 // Get the direction pointer (0 if not present)
237 const Measure* direction() const;
238 // Get the radial velocity pointer (0 if not present)
239 const Measure* radialVelocity() const;
240 // Get the comet pointer (0 if not present)
241 const MeasComet* comet() const;
242 // Get data from frame. Only available if appropriate measures are set,
243 // and the frame is in a calculating state.
244 // <group>
245 // Get TDB in days
246 Bool getTDB(Double &tdb) const;
247 // Get UT1 in days
248 Bool getUT1(Double &tdb) const;
249 // Get TT in days
250 Bool getTT(Double &tdb) const;
251 // Get the ITRF longitude (in rad)
252 Bool getLong(Double &tdb) const;
253 // Get the ITRF latitude (in rad)
254 Bool getLat(Double &tdb) const;
255 // Get the position
257 // Get the geocentric position (in m)
258 Bool getRadius(Double &tdb) const;
259 // Get the geodetic latitude
260 Bool getLatGeo(Double &tdb) const;
261 // Get the LAST (in days)
262 Bool getLAST(Double &tdb) const;
263 // Get the LAST (in rad)
264 Bool getLASTr(Double &tdb) const;
265 // Get J2000 coordinates (direction cosines) and its longitude/latitude (rad)
266 // <group>
270 // </group>
271 // Get B1950 coordinates (direction cosines)
272 // <group>
276 // </group>
277 // Get apparent coordinates (direction cosines)
278 // <group>
280 Bool getAppLong(Double &tdb) const;
281 Bool getAppLat(Double &tdb) const;
282 // </group>
283 // Get LSR radial velocity (m/s)
284 Bool getLSR(Double &tdb) const;
285 // Get the comet table reference type
286 Bool getCometType(uInt &tdb) const;
287 // Get the comet coordinates
289 // </group>
290
291private:
292
293 //# Data
294 // Representation of MeasFrame
295 FrameRep *rep;
296
297 //# Member functions
298 // Create an instance of the MeasFrame class
299 void create();
300 // Fill a MeasFrame element
301 // <group>
302 void fill(const Measure *in);
303 void fill(const MeasComet *in);
304 // </group>
305 // Make full Epoch
306 void makeEpoch();
307 // Make full Position
309 // Make full Direction
311 // Make full RadialVelocity
313 // Make full Comet
314 void makeComet();
315 // Throw reset error
316 void errorReset(const String &txt);
317 // Lock the frame to make sure deletion occurs when needed
318 void lock(uInt &locker);
319 // Unlock the frame
320 void unlock(const uInt locker);
321};
322
323//# Global functions
324// <summary> Global functions </summary>
325// <group name=Output>
326// Output a frame
327ostream &operator<<(ostream &os, MeasFrame &mf);
328// </group>
330
331} //# NAMESPACE CASACORE - END
332
333#endif
const Measure * epoch() const
Get the epoch pointer (0 if not present)
Bool getCometType(uInt &tdb) const
Get the comet table reference type.
void resetEpoch(const MVEpoch &val)
Bool getTDB(Double &tdb) const
Get data from frame.
void resetPosition(const Quantum< Vector< Double > > &val)
void resetRadialVelocity(const Measure &val)
const Measure * position() const
Get the position pointer (0 if not present)
void resetEpoch(const Vector< Double > &val)
Bool getJ2000Long(Double &tdb) const
void resetDirection(const Measure &val)
void resetEpoch(const Quantum< Double > &val)
void resetDirection(const MVDirection &val)
Bool getLat(Double &tdb) const
Get the ITRF latitude (in rad)
MeasFrame(const Measure &meas1)
Construct frame with specified measures.
void set(const Measure &meas1, const Measure &meas2)
void makeEpoch()
Make full Epoch.
void resetEpoch(Double val)
Reset a frame element and its cached derived values.
void makeRadialVelocity()
Make full RadialVelocity.
Bool getUT1(Double &tdb) const
Get UT1 in days.
MeasFrame()
Default constructor.
void resetRadialVelocity(const MVRadialVelocity &val)
void resetEpoch(const Quantum< Vector< Double > > &val)
Bool getB1950(MVDirection &tdb) const
Get B1950 coordinates (direction cosines)
const Measure * direction() const
Get the direction pointer (0 if not present)
void resetDirection(const Vector< Double > &val)
void resetRadialVelocity(const Vector< Double > &val)
void resetRadialVelocity(const Quantum< Vector< Double > > &val)
MeasFrame(const Measure &meas1, const Measure &meas2)
Bool getTT(Double &tdb) const
Get TT in days.
void makeComet()
Make full Comet.
Bool getLAST(Double &tdb) const
Get the LAST (in days)
FrameTypes
Enumeration for the different farme entries possible.
Definition MeasFrame.h:156
Bool getLatGeo(Double &tdb) const
Get the geodetic latitude.
FrameRep * rep
Representation of MeasFrame.
Definition MeasFrame.h:295
void unlock(const uInt locker)
Unlock the frame.
Bool getLong(Double &tdb) const
Get the ITRF longitude (in rad)
Bool operator==(const MeasFrame &other) const
Comparisons.
void resetEpoch(const Measure &val)
void makeDirection()
Make full Direction.
void resetPosition(const Vector< Double > &val)
Bool getB1950Lat(Double &tdb) const
void errorReset(const String &txt)
Throw reset error.
friend Bool MCFrameGetmvpos(void *dmf, uInt tp, MVPosition &result)
MeasFrame(const Measure &meas1, const Measure &meas2, const Measure &meas3)
void fill(const Measure *in)
Fill a MeasFrame element.
void resetPosition(const MVPosition &val)
Bool getJ2000Lat(Double &tdb) const
void set(const Measure &meas1, const Measure &meas2, const Measure &meas3)
Bool getComet(MVPosition &tdb) const
Get the comet coordinates.
~MeasFrame()
Destructor.
friend ostream & operator<<(ostream &os, MeasFrame &mf)
Output a frame.
const Measure * radialVelocity() const
Get the radial velocity pointer (0 if not present)
const MeasComet * comet() const
Get the comet pointer (0 if not present)
void lock(uInt &locker)
Lock the frame to make sure deletion occurs when needed.
Bool empty() const
Test if empty (i.e.
Bool getAppLat(Double &tdb) const
void resetComet(const MeasComet &val)
void resetPosition(const Measure &val)
Bool getJ2000(MVDirection &tdb) const
Get J2000 coordinates (direction cosines) and its longitude/latitude (rad)
void set(const Measure &meas1)
Set frame elements.
void makePosition()
Make full Position.
Bool operator!=(const MeasFrame &other) const
MeasFrame(const MeasFrame &other)
Copy constructor (reference semantics)
Bool getRadius(Double &tdb) const
Get the geocentric position (in m)
void fill(const MeasComet *in)
friend Bool MCFrameGetmvdir(void *dmf, uInt tp, MVDirection &result)
Bool getB1950Long(Double &tdb) const
Bool getAppLong(Double &tdb) const
friend Bool MCFrameGetuint(void *dmf, uInt tp, uInt &result)
void set(const MeasComet &meas)
Bool getITRF(MVPosition &tdb) const
Get the position.
Bool getLSR(Double &tdb) const
Get LSR radial velocity (m/s)
MeasFrame & operator=(const MeasFrame &other)
Copy assignment (reference semantics)
void resetDirection(const Quantum< Vector< Double > > &val)
friend Bool MCFrameGetdbl(void *dmf, uInt tp, Double &result)
Bool getApp(MVDirection &tdb) const
Get apparent coordinates (direction cosines)
Bool getLASTr(Double &tdb) const
Get the LAST (in rad)
void create()
Create an instance of the MeasFrame class.
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
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53
ostream & operator<<(ostream &os, MeasFrame &mf)
Output a frame.