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/CyclicPtr.h>
34#include <casacore/measures/Measures/Measure.h>
35#include <casacore/casa/iosfwd.h>
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39//# Forward Declarations
40class MVEpoch;
41class MVPosition;
42class MVDirection;
44class MeasComet;
45class FrameRep;
46class MCFrame;
47template <class Qtype> class Quantum;
48
49// <summary> Container for Measure frame </summary>
50
51// <use visibility=export>
52
53// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
54// </reviewed>
55
56// <prerequisite>
57// <li> <linkto class=Measure>Measure</linkto> class
58// <li> <linkto class=MeasRef>MeasRef</linkto> class
59// </prerequisite>
60//
61// <etymology>
62// From Measure and Frame
63// </etymology>
64//
65// <synopsis>
66// Measurements are made in a reference frame (epoch, position, direction,
67// ...).
68//
69// The class is a container for the reference frame Measures (MEpoch etc).
70// Since a frame will possibly be used by many different Measures, it behaves
71// as a smart pointer, with reference rather than copy characteristics.
72// Since it caches all its operations, it is advisable to have a 'global'
73// MeasFrame across an execution, resetting (or setting) its values
74// when appropriate. The frame can also contain other related information. At
75// the moment the orbit of a solar system body (MeasComet) can be set.
76// In future the planetary ephemeris used (e.g. DE205) and environmental
77// information like refraction data will be added.
78//
79// A MeasFrame is constructed by setting the appropriate Measures, either in
80// a constructor, or with a set(). The input to the constructors and set are
81// Measures.
82//
83// Inside the frames automatic conversion to the most appropriate usage of
84// its values is done (e.g. time to TBD time, position to astronomical
85// longitude). These conversions are done only if an explicit
86// Measure::Convert was used that needed information, e.g. the following
87// code:
88// <srcblock>
89// MeasFrame frame(obser); // obser is an MPosition
90// MEpoch::Convert conv(MEpoch(12345), MEpoch::Ref(MEpoch::LAST,obser));
91// MEpoch last = conv();
92// </srcblock>
93// will set-up a state machine to convert UTC(default) to LAST in conv; the
94// next call will do the actual conversion. During this conversion, the
95// astronomical longitude (among others) will be needed to convert to
96// local sidereal time. conv will ask (getLong()) this from the frame, which
97// will calculate it (including possible other conversions) from the
98// observatory's position specified in a frame. Any calculation done will be
99// cached (e.g. a Nutation calculation in this case for dpsi), and used in
100// subsequent conversions using the same frame.
101//
102// Furthermore, a frame will often be regularly updated (e.g. coordinate
103// conversion for a series of times). To make use of cached information, and
104// to speed up as much as possible, <src>reset...()</src> functions are
105// available. These reset functions accept the same range of input parameter
106// types as the <linkto class=MeasConvert>MeasConvert</linkto> () operator,
107// and will keep any determined conversion machines and related information
108// intact, only recalculating whatever is necessary.
109//
110// The actual frame calculations and interrogations are done in a separate
111// <linkto class=MCFrame>MCFrame</linkto> hidden class, which attaches itself
112// to MeasFrame when and if necessary (see there if you are really curious).
113//
114// get...() functions can return frame measures. Only when the frame has been
115// attached to a calculating machine *MCFrame) are these values available.
116// This attachment is done if the frame has been actively used by a
117// Measure::Convert engine, or if explicitly done by the
118// <src>MCFrame::make(MeasFrame &)</src> static method.
119//
120// Because MeasFrame uses a reference to its implementation, which can be shared
121// by multiple MeasFrame instances, it is by default not thread safe
122// when different MeasFrames are accessed from different threads. Moreover,
123// a MeasFrame contains links to other objects which may also be shared.
124// In Casacore 3.8, the referenced data entries in this class
125// have been changed so they are initialized in thread-safe ways, and thread-safe
126// conversions can be achieved by using the independentCopy() method. See
127// the help for that function for more info.
128//
129// <note role=caution> An explicit (or implicit) call to MCFrame::make will
130// load the whole conversion machinery (including Tables) into your
131// linked module).</note>
132//
133// <linkto class=Aipsrc>Aipsrc keywords</linkto> can be used for additional
134// (highly specialised) additional internal conversion parameters.
135// </synopsis>
136//
137// <example>
138// <srcblock>
139// MEpoch my_epoch(Quantity(MeasData::MJDB1950,"d")); // an epoch
140// MeasFrame frame(my_epoch); // used in a frame
141// </srcblock>
142// </example>
143//
144// <motivation>
145// To separate the frame definition from the measure type
146// </motivation>
147//
148// <todo asof="1997/04/16">
149// </todo>
150
152
153 public:
154
155 //# Friends
156 // Output a frame
157 friend ostream &operator<<(ostream &os, MeasFrame &mf);
158 // Machinery
159 // <group>
160 friend class MCFrame;
161 // </group>
162
163 //# Enumerations
164 // Enumeration for the different farme entries possible. This can be used
165 // to find out if a certain conversion needs the frame. It will be
166 // used in a registration/notify environment to enable bypassing of
167 // some new conversion settings.
174
175 //# Constructors
176 // Default constructor
178 // Construct frame with specified measures
179 // <thrown>
180 // <li> AipsError if a non-frame Measure
181 // </thrown>
182 // <group>
183 MeasFrame(const Measure &meas1);
184 MeasFrame(const Measure &meas1, const Measure &meas2);
185 MeasFrame(const Measure &meas1, const Measure &meas2,
186 const Measure &meas3);
187 // </group>
188 // Copy constructor (reference semantics)
189 MeasFrame(const MeasFrame &other);
191
192 // Copy assignment (reference semantics)
195 // Destructor
197
198 //# Operators
199 // Comparisons
200 // <group>
201 Bool operator==(const MeasFrame &other) const;
202 Bool operator!=(const MeasFrame &other) const;
203 // </group>
204
205 //# General member functions
206 // Test if empty (i.e. no measure filled in)
207 Bool empty() const;
208
209 // Set frame elements
210 // <thrown>
211 // <li> AipsError if a non-frame Measure
212 // <li> AipsError if illegal or non-existant MeasComet given
213 // </thrown>
214 // <group>
215 void set(const Measure &meas1);
216 void set(const Measure &meas1, const Measure &meas2);
217 void set(const Measure &meas1, const Measure &meas2,
218 const Measure &meas3);
219 void set(const MeasComet &meas);
220 // </group>
221 // Reset a frame element and its cached derived values.
222 // <thrown>
223 // <li> AipsError if the specific Measure not yet present in frame
224 // </thrown>
225 // <group>
227 void resetEpoch(const Vector<Double> &val);
228 void resetEpoch(const Quantum<Double> &val);
230 void resetEpoch(const MVEpoch &val);
231 void resetEpoch(const Measure &val);
234 void resetPosition(const MVPosition &val);
235 void resetPosition(const Measure &val);
238 void resetDirection(const MVDirection &val);
239 void resetDirection(const Measure &val);
243 void resetRadialVelocity(const Measure &val);
244 void resetComet(const MeasComet &val);
245 // </group>
246
247 // Get the epoch pointer (0 if not present)
248 const Measure* epoch() const;
249 // Get the position pointer (0 if not present)
250 const Measure* position() const;
251 // Get the direction pointer (0 if not present)
252 const Measure* direction() const;
253 // Get the radial velocity pointer (0 if not present)
254 const Measure* radialVelocity() const;
255 // Get the comet pointer (0 if not present)
256 const MeasComet* comet() const;
257 // Get data from frame. Only available if appropriate measures are set,
258 // and the frame is in a calculating state.
259 // <group>
260 // Get TDB in days
261 Bool getTDB(Double &tdb) const;
262 // Get UT1 in days
263 Bool getUT1(Double &tdb) const;
264 // Get TT in days
265 Bool getTT(Double &tdb) const;
266 // Get the ITRF longitude (in rad)
267 Bool getLong(Double &tdb) const;
268 // Get the ITRF latitude (in rad)
269 Bool getLat(Double &tdb) const;
270 // Get the position
272 // Get the geocentric position (in m)
273 Bool getRadius(Double &tdb) const;
274 // Get the geodetic latitude
275 Bool getLatGeo(Double &tdb) const;
276 // Get the LAST (in days)
277 Bool getLAST(Double &tdb) const;
278 // Get the LAST (in rad)
279 Bool getLASTr(Double &tdb) const;
280 // Get J2000 coordinates (direction cosines) and its longitude/latitude (rad)
281 // <group>
285 // </group>
286 // Get B1950 coordinates (direction cosines)
287 // <group>
291 // </group>
292 // Get apparent coordinates (direction cosines)
293 // <group>
295 Bool getAppLong(Double &tdb) const;
296 Bool getAppLat(Double &tdb) const;
297 // </group>
298 // Get LSR radial velocity (m/s)
299 Bool getLSR(Double &tdb) const;
300 // Get the comet table reference type
301 Bool getCometType(uInt &tdb) const;
302 // Get the comet coordinates
304 // </group>
305
306 // Make a value copy of this MeasFrame, such that it contains no reference
307 // to the old MeasFrame data. This is useful for ensuring thread safety in conversions.
308 //
309 // This function is available since casacore v3.8.0.
310 //
311 // The following is an example of how a thread-safe conversion can be performed:
312 // <srcblock>
313 // void convert_example(const MDirection& shared_direction, const MeasFrame& shared_frame) {
314 // const MeasFrame frame = shared_frame.independentCopy();
315 // MDirection::Convert converter(MDirection::J2000,
316 // MDirection::Ref(MDirection::ITRF, frame));
317 // MDirection result = converter(shared_direction);
318 // </srcblock>
319 // The convert_example() function can be called from multiple threads (as long as
320 // they don't write to shared_direction or shared_frame), and performs a direction conversion
321 // from J2000 to ITRF. Any information that is shared between the threads is read-only.
323
324private:
325
326 //# Data
327 // Representation of MeasFrame. See the CyclicPtr class documentation for motivation.
329
331 //# Member functions
332 // Create an instance of the MeasFrame class
333 void create();
334 // Fill a MeasFrame element
335 // <group>
336 void fill(const Measure *in);
337 void fill(const MeasComet *in);
338 // </group>
339 // Make full Epoch
340 void makeEpoch();
341 // Make full Position
343 // Make full Direction
345 // Make full RadialVelocity
347 // Make full Comet
348 void makeComet();
349 // Throw reset error
350 void errorReset(const String &txt);
351};
352
353//# Global functions
354// <summary> Global functions </summary>
355// <group name=Output>
356// Output a frame
357ostream &operator<<(ostream &os, MeasFrame &mf);
358// </group>
360
361} //# NAMESPACE CASACORE - END
362
363#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).
MeasFrame(MeasFrame &&other)
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).
friend class MCFrame
Machinery.
Definition MeasFrame.h:160
MeasFrame & operator=(MeasFrame &&other)
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).
MeasFrame(details::CyclicPtr< FrameRep > new_rep)
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:168
Bool getLatGeo(Double &tdb) const
Get the geodetic latitude.
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.
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).
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)
Bool getB1950Long(Double &tdb) const
Bool getAppLong(Double &tdb) const
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).
details::CyclicPtr< FrameRep > rep
Representation of MeasFrame.
Definition MeasFrame.h:328
MeasFrame independentCopy() const
Make a value copy of this MeasFrame, such that it contains no reference to the old MeasFrame data.
void resetDirection(const Quantum< Vector< Double > > &val)
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
A smart pointer class that allows to work with complex cycles without using weak_ptrs.
Definition CyclicPtr.h:78
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.