casacore
Loading...
Searching...
No Matches
measures
Measures.h
Go to the documentation of this file.
1
// # Measures.h: a module for coordinates
2
// # Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2002
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_MEASURES_H
27
#define MEASURES_MEASURES_H
28
29
// # Includes
30
#include <casacore/casa/aips.h>
31
#include <casacore/casa/Quanta.h>
32
#include <casacore/measures/Measures/Measure.h>
33
#include <casacore/measures/Measures/MeasBase.h>
34
#include <casacore/casa/Quanta/MeasValue.h>
35
#include <casacore/measures/Measures/MeasRef.h>
36
#include <casacore/measures/Measures/MeasConvert.h>
37
38
namespace
casacore
{
// # NAMESPACE CASACORE - BEGIN
39
40
// <module>
41
//
42
43
// <summary> a module for coordinates </summary>
44
45
// <use visibility=export>
46
47
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasMath tMeasure"
48
// demos="dMeasure">
49
50
// <prerequisite>
51
// <li> <linkto module=Quanta>Quanta</linkto> module for units and quantities.
52
// </prerequisite>
53
54
// <etymology>
55
// The name Measure derives from physical measurements, i.e. values with
56
// units and possibly a reference frame attached.
57
// </etymology>
58
//
59
// <synopsis>
60
// The Measure model deals with measures (i.e. quantities with a
61
// reference frame).
62
// Measures are handled in the <a href="#Measure">Measure</a> section
63
// (see <linkto class="Measure">Measure.h</linkto>).
64
//
65
// <h3> Includes</h3>
66
// Including the <src>measures/Measures.h</src> will take care of all
67
// includes necessary for the handling of Units and Quantities, and the
68
// general Measure interface. For the use of individual Measures, the
69
// appropiate include files should be added. E.g. to be able to handle
70
// Directions, the following includes could be given:
71
// <srcblock>
72
// #include <casacore/measures/Measures.h>
73
// #include <casacore/measures/Measures/MDirection.h>
74
// </srcblock>
75
// An inclusion of the appropiate measure file, will also take care of the
76
// connected measure value (in this case <src>MVDirection</src>). However,
77
// if only the value suffices, it can be included on its own (from the
78
// Quanta directory).<br>
79
// When doing actual conversions (see MeasConvert later on), by using the
80
// explicit Measure::Convert types, the description of the actual
81
// conversions (called MCmeasure, e.g. MCEpoch.h) should be included as well;
82
// in adition to general MeasConvert.h.
83
//
84
// <anchor name="Measure"><h3> Measures</h3></anchor>
85
//
86
// Measures are physical quantities within a certain reference frame. Examples
87
// are the Hour-angle and Declination of a source at a certain time and
88
// observatory; an Ra/Dec for a certain mean epoch; an apparent frequency at
89
// a certain time given in eV; a local sidereal time at an observatory.<br>
90
// Measures can be converted from one reference frame to another (and this
91
// possibility is its main reason for existence). A simple B1950-J2000
92
// coordinate conversion example:
93
// <srcblock>
94
// cout << // output
95
// // the conversion of a B1950 direction
96
// MDirection::Convert( MDirection( Quantity( 20, "deg"),
97
// Quantity(-10, "deg"),
98
// MDirection::Ref( MDirection::B1950)),
99
// // to J2000
100
// MDirection::Ref( MDirection::J2000)) ()
101
// // where the constructor sets up a conversion
102
// // engine, and the operator() converts
103
// << endl;
104
// </srcblock>
105
// or converting an UTC to a local apparent sidereal time:
106
// <srcblock>
107
// // Set up the model for the input (default reference is UTC)
108
// MEpoch model ( Quantity(0., "d"));
109
// // Set up the frame with the observatory position
110
// MPosition obs( MVPosition( Quantity( 10, "m"),
111
// Quantity( -6, "deg"),
112
// Quantity( 50, "deg")),
113
// MPosition::Ref(MPosition::WGS84));
114
// Measframe frame( obs);
115
// // Set up the output reference
116
// MEpoch::Ref outref( MEpoch::LAST,
117
// frame);
118
// // Set up conversion
119
// MEpoch::Convert toLST( model,
120
// outref);
121
// // Output a series of sidereal times (formatted in ddd::hh:mm:ss)
122
// for (Double d = 12345; d<12346; d += 0.1) {
123
// cout << "Converted from UTC to LAST: " <<
124
// d << " : " <<
125
// toLST(d).getValue() << endl;
126
// };
127
// </srcblock>
128
//
129
// The examples show the use of the 5 major classes involved in Measures:
130
// <srcblock>
131
// Base Example Description
132
// ------ --------- -------------
133
// Measure MEpoch has a value and a reference
134
// MeasValue MVEpoch value
135
// MeasRef MEpoch::Ref contains type, frame, offset
136
// MeasFrame MeasFrame contains Measures describing frame
137
// MeasConvert MEpoch::Convert contains conversion information and engine
138
// </srcblock>
139
//
140
// Each type of Measure has its own distinct class. Each
141
// is (weakly) derived from the <linkto class="Measure">Measure</linkto> base
142
// class, and its name starts with an <em>M</em>. Examples are:
143
// <ul>
144
// <li> <linkto class="MEpoch">MEpoch</linkto>: an instance in time
145
// <li> <linkto class="MDirection">MDirection</linkto>: a direction in space
146
// <li> <linkto class="MPosition">MPosition</linkto>: a position on Earth
147
// <li> <linkto class="MFrequency">MFrequency</linkto>: the characteristics
148
// of a wave
149
// <li> <linkto class="MDoppler">MDoppler</linkto>: a Doppler shift
150
// <li> <linkto class="MRadialVelocity">MRadialVelocity</linkto>: a
151
// radial velocity
152
// <li> <linkto class="MBaseline">MBaseline</linkto>: a baseline
153
// <li> <linkto class="Muvw">Muvw</linkto>: a uvw value
154
// <li> <linkto class="MEarthMagnetic">MEarthMagnetic</linkto>: an
155
// earth magnetic field value
156
// </ul>
157
// Others are being, or could be, considered.
158
// <note role=tip>The current set can be deduced from the class list at the end of
159
// the html version of this module description.</note>
160
// <p>
161
// The main role of the Measure (and related) classes is to be able to convert
162
// an observed (or to be calculated) physical entity from one reference frame
163
// to another, e.g. a J2000 coordinate to galactic coordinates, or an TAI
164
// time to a local sidereal time (LAST).
165
// Simple unit conversions (e.g. an angle from mrad to deg), or calculations
166
// with values with attached units, are sufficiently catered for by the
167
// <linkto module="Quanta">Quanta</linkto> module classes.
168
// <p>
169
// Each measure has a <em>value</em> (<linkto class=MeasValue>MeasValue</linkto>) and
170
// a <em>reference</em> (<linkto class=MeasRef>MeasRef</linkto>).
171
// The values are in general measure specific, weakly derived from MeasValue,
172
// and named with an initial <em>MV</em>. Examples are:
173
// <ul>
174
// <li> <linkto class=MVEpoch>MVEpoch</linkto> (a high precision single value),
175
// <li> <linkto class=MVDirection>MVDirection</linkto> (direction cosines),
176
// <li> <linkto class=MVPosition>MVPosition</linkto> (3-vector positions),
177
// <li> <linkto class=MVFrequency>MVFrequency</linkto> (single, unit depended
178
// value).
179
// <li> <linkto class=MVDoppler>MVDoppler</linkto> (single, unit depended value)
180
// <li> <linkto class=MVRadialVelocity>MVRadialVelocity</linkto> (single value)
181
// </ul>
182
// MeasValue and the MV classes can be found in the
183
// <linkto module=Quanta>Quanta</linkto> module.
184
// In addition some other value classes, not directly used in measures, are
185
// available. Examples:
186
// <ul>
187
// <li> <linkto class=MVAngle>MVAngle</linkto> (to normalise
188
// and have specific I/O formatting for angle-like values)
189
// <li> <linkto class=MVTime>MVTime</linkto> (same for time-like values)
190
// </ul>
191
// <em>References</em> are measure specific. Each specific reference class is
192
// called <em>Measure</em>\::Ref (e.g. <src>MEpoch::Ref</src>). It specifies
193
// the full reference frame of the specific measure, i.e. its type, an optional
194
// frame of measures (a MeasFrame, consisting of say a time and position), and
195
// an optional offset.
196
// It has at least a <em>reference code</em>
197
// (e.g. MDirection::B1950, MEpoch::LAST), with defaults for each measure
198
// (i.e. MDirection::J2000, MEpoch::UTC) if none specified. <br>
199
// In addition the reference can contain a <em>reference frame</em>
200
// (<linkto class=MeasFrame>MeasFrame</linkto>) to specify from when and/or
201
// where the measure was obtained or calculated.<br>
202
// A third optional element of the reference is an <em>offset measure</em>, which
203
// indicates the offset (e.g. a sidereal date) that has to be added to the
204
// value referenced before it is used.<br>
205
// Examples of some measures are:
206
// <srcblock>
207
// // An instance of time expressed in days (MJD) in UTC
208
// MEpoch date(MVEpoch(Quantity(50237.29, "d")),
209
// MEpoch::Ref(MEpoch::UTC));
210
// // which could also be expressed as:
211
// MEpoch date(Quantity(50237.29, "d"),
212
// MEpoch::UTC);
213
// // or using the default reference type:
214
// MEpoch date(Quantity(50237.29, "d"));
215
// // or as a time with an offset to a specific date:
216
// MEpoch date(Quantity(12.3, "h"), // time
217
// MEpoch::Ref(MEpoch::UTC, // reference with
218
// MEpoch(Quantity(50237, "d")))); // offset
219
// // A position of a telescope
220
// MPosition pos(MVPosition(Quantity(25, "m"), // height
221
// Quantity(20, "deg"), // East longitude
222
// Quantity(53, "deg")), // lattitude
223
// MPosition::WGS84); // reference type
224
// // Use this position in a frame
225
// MeasFrame frame(pos);
226
// // Specify an LAST (in MGSD) observed at this position:
227
// MEpoch last(Quantity(51000.234, "d"), // time and date
228
// MEpoch::Ref(MEpoch::LAST, // indicate LAST
229
// frame)); // and where observed
230
// // Maybe we know the MJD of the observed sidereal time,
231
// // but not its sidereal date. We could then specify it as an
232
// // offset to the beginning of the sidereal day in progress at
233
// // specified UTC
234
// MEpoch last(Quantity(13.45, "h"), // time
235
// MEpoch::Ref(MEpoch::LAST, // indicate LAST
236
// frame, // where observed
237
// MEpoch(51234, // MJD of today
238
// MEpoch::Ref(MEpoch::TAI + MEpoch::RAZE)));
239
// // where the RAZE indicates that the value will be truncated after
240
// // conversion. In this case it will be converted to LAST to be able
241
// // to add it as an offset to the specified LAST
242
// //
243
// // A direction (in RA/Dec) could be:
244
// MDirection coord(MVDirection(Quantity(54, "deg"), // RA
245
// Quantity(2034, "'")), // DEC arcmin
246
// MDirection::Ref(MDirection::J2000)); // J2000 type
247
// // If it were apparent coordinates, the time when observed should
248
// // have been known. We could just add it to the frame defined above,
249
// // and use it:
250
// frame.set(date); // add time to frame
251
// MDirection acoord(MVDirection(Quantity(54, "deg"), // RA
252
// Quantity(2034, "'")), // DEC
253
// MDirection::Ref(MDirection::APP, // apparent type
254
// frame)); // and when
255
// // If it was given in HA/Dec, the position should have been known
256
// // as well, but it is already in the frame, hence we could say:
257
// MDirection acoord(MVDirection(Quantity(54, "deg"), // HA
258
// Quantity(2034, "'")), // DEC
259
// MDirection::Ref(MDirection::HADEC, // type
260
// frame)); // when/where
261
// </srcblock>
262
// <note role=tip>In the above examples in general explicit <em>MV</em>
263
// values have been used to specified the measure's value. In many
264
// cases (depending on the actual measure) it can be omitted, and the data
265
// can be given directly to the measure constructor. See the
266
// constructors for the individual measures for details.<br>
267
// If the reference is simple (i.e. no frame and/or offset) the
268
// <em>Measure::Ref</em> can be omitted, and only the code has to be
269
// specified. </note>
270
// A <linkto class=MeasFrame>MeasFrame</linkto> is a container for specifying
271
// Measures needed to describe the circumstances under which the measure was
272
// observed (or for which it has to be calculated).
273
// E.g. the position on Earth (an <em>MPosition</em>) is necessary for
274
// sidereal time and coordinates like HA/Dec and Az/El; the time
275
// (<em>MEpoch</em>)
276
// is necessary for non-standard coordinates (apparent, mean, HA/Dec etc);
277
// the coordinates (<em>MDirection</em>) for radial velocities; etc.<br>
278
// Although quite often the value has to be in a specific format (e.g. TBD for
279
// precession calculations; astronomical longitude for the LAST), the
280
// frame values can be given in any known reference format: conversion to the
281
// appropiate type will be done automatically if and when necessary.<br>
282
// Frames (and references) are never copied, but act always as containers
283
// with shallow copying only (i.e. <em>copied</em> frames will point to
284
// identical instances, and changes made in one copy will be visible in all
285
// others. This
286
// means, e.g., that in the following:
287
// <srcblock>
288
// MeasFrame frame1(MEpoch(50236.12));
289
// MeasFrame frame2(frame1);
290
// </srcblock>
291
// the two frames will be identical, and a change to one means a change to
292
// the other. Furthermore, only the information needed for a specific
293
// calculation will be used (and calculated). This means that one frame can
294
// be used specifying all of e.g. the position (which will probably stay the
295
// same for a series of calculations) and time; with the time being <em>set()</em>
296
// (if also the reference of the epoch changes) or <em>resetEpoch()</em> (if only
297
// the value changes, but the reference and its frame stay the same).
298
// A change in the frame will influence automatically any calculation (e.g.
299
// conversion to LAST) of which it is part.<br>
300
//
301
// The value of a measure (in <em>MV</em> format) can be obtained with the
302
// <em>getValue()</em> member function. The value in a variety of formats
303
// and units can be obtained with a (specific Measure dependent) series of
304
// <em>get()</em> members of both the <em>MV</em>-value and the Measure.<br>
305
//
306
// Measures in themselves are not really necessary for proper data reduction
307
// and the like. Its real value is the ability to transform a Measure from
308
// one reference type (and frame, offset) to another.<br>
309
// Conversion of a measure of a certain kind from one reference to another
310
// is done with the aid of special, measure specific,
311
// <linkto class=MeasConvert>MeasConvert</linkto> classes. Each conversion
312
// class is called <em>Measure</em>\::Convert (e.g. MDirection::Convert).
313
// A conversion generates from an input reference (or an input measure) and
314
// an output reference a conversion functional, that can be used to convert
315
// specific values.<br>
316
// Example:
317
// <srcblock>
318
// cout << // output
319
// // the conversion of a B1950 direction
320
// MDirection::Convert( MDirection( Quantity( 20, "deg"),
321
// Quantity(-10, "deg"),
322
// MDirection::Ref( MDirection::B1950)),
323
// // to J2000
324
// MDirection::Ref( MDirection::J2000)) ()
325
// // where the constructor sets up a conversion
326
// // engine, and the operator() converts
327
// << endl;
328
//</srcblock>
329
// The same could have been done by only setting up the conversion engine, and
330
// not specifing the default value to be converted in the Convert constructor
331
// by:
332
// <srcblock>
333
// cout << // output
334
// // the conversion of a B1950 direction
335
// MDirection::Convert(MDirection::Ref( MDirection::B1950),
336
// // to J2000
337
// MDirection::Ref( MDirection::J2000))
338
// // and use conversion on value
339
// (MVDirection( Quantity( 20, "deg"),
340
// Quantity(-10, "deg")))
341
// // where the operator() converts
342
// << endl;
343
// </srcblock>
344
// Specifying the conversion engine separately, it can be re-used for other
345
// values:
346
// <srcblock>
347
// MDirection::Convert conv(MDirection::Ref( MDirection::B1950),
348
// MDirection::Ref( MDirection::J2000));
349
// // We have some coordinates from somewhere, say coord(0:N-1):
350
// for (Int i=0; i<N; i++) {
351
// cout << "B1950: " << coord(i) << "= J2000: " <<
352
// conv(coord(i)) << endl;
353
// };
354
// </srcblock>
355
// A larger example. Say you have the J2000 coordinates for a source (RA=11
356
// deg, DEC= -30 deg), and you want to observe it on May 17, 1996 (MJD=50220)
357
// at 8:18 UTC in a place
358
// with a Longitude of 150 deg (latitude of 20 deg) at 1000 m high,
359
// you could get the
360
// apparent RA,DEC, and the LAST at that time (you could also go straight to
361
// HA/DEC or so) with (I write the example longer than necessary to indicate
362
// the steps, and with explicit reference to MV values):
363
// <srcblock>
364
// // The observatory position. Note that the reference is geodetic position
365
// MPosition myobs(MVPosition ( Quantity(1, "km") ,
366
// Quantity(150, "deg"),
367
// Quantity(20, "deg")),
368
// MPosition::WGS84);
369
// // The time I want to observe (note that it could be specified in many
370
// // other ways)
371
// MEpoch obstime(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)),
372
// MEpoch::UTC);
373
// // The frame specification for when and where to observe
374
// MeasFrame frame(myobs, obstime);
375
// // The reference for a sidereal time (note the frame could be empty and
376
// // filled at the actual conversion time)
377
// MEpoch::Ref sidref( MEpoch::LAST, frame);
378
// // The reference for apparent coordinates:
379
// MDirection::Ref appref( MDirection::APP, frame);
380
// // The conversion engine for my time to LAST
381
// MEpoch::Convert tosid(obstime, sidref);
382
// // The conversion to sidereal time of obstime
383
// MEpoch sidtime = tosid();
384
// // Conversion of UTC 10.8 h
385
// sidtime = tosid(MVEpoch(MVTime(1996, 5, 17, 10.8/24.)));
386
// // Show me some time
387
// cout << "LAST for UTC = 11:00: " <<
388
// tosid(MVEpoch( MVTime( 1996, 5, 17, 11, 0))) << endl;
389
// // An offset reference (note the RAZE will keep only the integer part of
390
// // the day for the conversion result)
391
// MEpoch::Ref offtime(obstime.getValue(), MEpoch::UTC+MEpoch::RAZE);
392
// // The reference for a sidereal with respect to a specified offset (note
393
// // that it is automatically calculated into correct units)
394
// MEpoch::Ref sidoffref(MEpoch::LAST, frame, offtime);
395
// // Show the offset result
396
// cout << "LAST today: " <<
397
// MEpoch::Convert(11., sidoffref)() << endl;
398
// // Coordinate conversion from J2000
399
// cout << "Apparent coordinates: " <<
400
// MDirection::Convert ( MDirection(Quantum(11,"deg"),
401
// Quantum(-30, "deg")),
402
// MDirection::Ref( MDirection::APP,
403
// frame))() << endl;
404
// // Handier to have the conversion engine available
405
// MDirection::Convert cvt( MDirection(Quantum(11,"deg"),
406
// Quantum(-30, "deg")),
407
// MDirection::Ref( MDirection::APP,
408
// frame));
409
// // Set another frame time (note it is now sidereal, not UTC. The
410
// // frame will automatically convert it (using the frame again for
411
// // position) to TDB for precession etc calculations).
412
// frame.set(sidtime);
413
// // And look what same position is at this new time
414
// cout << "Next position: " << cvt() << endl;
415
// </srcblock>
416
// <p>
417
// Some conversions need maybe some fine tuning (e.g. what is the acceptable
418
// interval for Nutation linear interpolation: could be different from the
419
// default interval; some time calculations will want to use the predicted
420
// IERS values rather than the actual determined; some Nutation will maybe
421
// use the IERS updates, some maybe the JPL DE databases).<br>
422
// The <linkto class=AipsrcValue>AipsrcValue</linkto> class can be used to
423
// specify very specific parameters that are used to steer
424
// the conversion process beyond what is possible with just a list
425
// of measure reference types (that list is already long for some cases).
426
// Values, switches can be <src>set()</src> (and removed) to change the
427
// default behaviour of the conversions. In general the user will only need
428
// to use the details in very specific cases. The details that can be used
429
// are described in the classes that provide calculations (e.g.
430
// <linkto class=Nutation>Nutation</linkto>), and in the aipsrc-data reference
431
// manual entry.<br>
432
// <p>
433
// Some details about the different classes follows. In the examples often
434
// a specific measure value (e.g. MVEpoch, the MeasValue for MEpoch), or a
435
// specific measure (e.g. MDirection, a direction in space) is used. This
436
// is only to visualise the use, any other measure could have been used.
437
// <p>
438
// <h4> MeasValue</h4>
439
// The MeasValue class derivatives are all named <em>MVmeasure</em>, e.g.
440
// <em>MVFrequency</em>, and represent the internal representation of the
441
// specific measure class. Details
442
// can be found in the <linkto module=Quanta>Quanta</linkto> module.
443
// <p>
444
// <h4> Measure</h4>
445
// The Measure class derivatives are all called <em>MMeasure</em>.
446
// <linkto class=MDirection>MDirection</linkto> (a celestial direction),
447
// <linkto class=MPosition>MPosition</linkto> (a position on Earth),
448
// <linkto class=MFrequency>MFrequency</linkto> (characteristics of
449
// electro-magnetic wave),
450
// <linkto class=MEpoch>MEpoch</linkto> (an instance in time),
451
// <linkto class=MDoppler>MDoppler</linkto>,
452
// <linkto class=MRadialVelocity>MRadialVelocity</linkto>
453
// <linkto class=MBaseline>MBaseline</linkto>,
454
// <linkto class=Muvw>Muvw</linkto>,
455
// <linkto class=MEarthMagnetic>MEarthMagnetic</linkto>,
456
//. <br>
457
// A measure has a value (kept in internal units in <em>MVmeasure</em>
458
// format) and a definition
459
// of the reference frame (MeasRef) of the value. The reference is optional, and
460
// will default to <em>Measure::DEFAULT</em>.<br>
461
// All measures have a set of standard constructors:
462
// <srcblock>
463
// M(); // some default, e.g. pole directoon, time ==0)
464
// M(MV, MeasRef);
465
// M(Quantity, MeasRef);
466
// M(Quantum<Vector<Double> >, MeasRef);
467
// M(Vector<Quantity>, MeasRef);
468
// </srcblock>
469
// But also some special ones (e.g. two Quantities for MDirection to specify
470
// two angles) depending on type. The MeasRef can be omitted (will then be
471
// defaulted to Measure::DEFAULT, e.g. MEpoch::DEFAULT); can be specified as
472
// a full reference as a <em>Measure::Ref</em> (e.g. <em>MDirection::Ref</em>)
473
// type; or as a simple reference as <em>Measure::TYPE</em> (e.g.
474
// <em>MDirection::J2000</em>).<br>
475
// The individual elements of a Measure (i.e the MV value and the reference)
476
// can be overwritten (or set) with the <src>set()</src> methods.<br>
477
// <src>get()</src> methods (in general <src>get(unit)</src>
478
// to return the internal value in some
479
// specified unit as a Quantum; and methods like <src>getAngle()</src>
480
// for e.g. MDirection)
481
// enable the user to obtain the value of the measure.<br>
482
// A <src>String tellMe()</src> will tell the type of Measure; a
483
// <src>void assured(String)</src> and <src>Bool areYou(String)</src> will
484
// check the type; while a <src>String showType(Measure::TYPE)</src> will
485
// return the string value of a reference type code (e.g. J2000).<br>
486
// <p>
487
// Recall that a Measure is a value with a reference specified. The MeasConvert
488
// engines enable you to convert it into another Measure, with a different
489
// reference (e.g. from J2000 to AZEL). The different get() methods (either
490
// directly, or indirectly using additional MV get() functions, or
491
// Quantum conversion methods, can convert the internal value into a value
492
// (or values) with user preferred units.<br>
493
// For reasons of speed (and safety) the allowed reference types for each
494
// Measure are enumerated in each measure class. The different reference
495
// types for MDirection are, for example:
496
// <srcblock>
497
// MDirection::J2000,
498
// MDirection::JMEAN,
499
// MDirection::JTRUE,
500
// MDirection::APP,
501
// MDirection::B1950,
502
// MDirection::BMEAN,
503
// MDirection::BTRUE,
504
// MDirection::GALACTIC,
505
// MDirection::HADEC,
506
// MDirection::AZEL,
507
// MDirection::DEFAULT = MDirection::J2000
508
// </srcblock>
509
// The MEpoch has a special reference type (<src>MEpoch::RAZE</src>) that
510
// can only be used
511
// in conjuncion with another reference type
512
// (e.g. <src> MEpoch::UT1+MEpoch::RAZE)</src>.
513
// The meaning is: if a measure with such a reference type is converted to
514
// another reference type (say <src>MEpoch::LAST</src>) the
515
// resultant (sidereal time)
516
// instance will be <em>razed</em> to an integer number of days; hence providing
517
// an easy way to specify sidereal times offset with the beginning of the
518
// current sidereal day.<br>
519
// To aid with external data, a <src>Bool giveMe(String, uInt)</src> will
520
// give the correct reference type to be used given the String type.
521
// Note that the
522
// uInt, rather than the corresponding enum is used, due to templating
523
// restrictions in some compilers.<br>
524
// The correct reference (MeasRef) and conversion (MeasConvert) class for
525
// each Measure (a frequency cannot be converted into an epoch) are templated,
526
// and have specified (and to be used) typedefs: <em>Measure::Ref</em> and
527
// <em>Measure::Convert</em> (e.g. <em>MEpoch::Ref, MEpoch::Convert</em>). In
528
// addition, Measure::MVType and Measure::MCType are defined for all
529
// measures.
530
// <p>
531
// <h4>Measure errors </h4>
532
// In the current implementation, no errors are attached to a Measure. In the
533
// original design errors were foreseen, but up till now they have been left
534
// out.<br>
535
// The addition of errors is in principle an easy process. They could be
536
// attached to either a Measure (as an additial MV value), or the MV's could
537
// be expanded to include errors (my preferred option at the moment). An
538
// MV being converted will then automatically have its error converted as
539
// well.<br>
540
// Before implementing, however, I think it would be worthwhile to look at
541
// the whole area of error handling. The easiest way would be to introduce
542
// for each of the defined Casacore standard values a corresponding E class
543
// (EDouble, EInt, EComplex, EuInt etc), and have all mathematical and
544
// logical operators that are defined for the standard classes be defined
545
// for the E-classes as well. It would then be easy to introduce errors
546
// everywhere.
547
// <p>
548
// <h4>MeasFrame</h4>
549
// A MeasFrame is a container with the instance of time
550
// (an MEpoch) and/or the position (an MPosition) for a measure reference.
551
// (Other Measures, like MDirection and MRadialVelocity are sometimes needed
552
// as well).
553
// MeasFrames are never actually copied, but only referred to (<em>shallow copy</em>)
554
// , so they can be used for all different types
555
// of measure reference. They are only necessary, but then essential, if the
556
// reference type does not fully specify the frame (like e.g. MDirection::J2000,
557
// or MEpoch::TAI do). Examples are the position necessary to go to
558
// MEpoch::LAST, the epoch necessary to go to MDirection::APP, the epoch and
559
// position necessary to reference an MDirection::AZEL.<br>
560
// A MeasFrame can be constructed empty (and used in references, as long as it
561
// is filled properly at the time of an actual conversion), or with one or
562
// Measures already defined with: <src>MeasFrame frame(a_Measure, ...)</src>.
563
// It can be filled, or re-filled, with <src>set(a_measure,....)</src>.<br>
564
// The conversion routines use different values of the frame values given (e.g.
565
// the precession and nutation will need the epoch in TDB time, the hour-angle
566
// constructor local apparent sidereal time, which needs the astronomical
567
// longitude etc.). For that reason the specification of an epoch or position
568
// in either the constructor or the set() will create conversion engines for
569
// conversion of the input measure to all appropiate values that can be asked
570
// by the conversion routines. Note that the actual conversion is only done
571
// when that value is requested (and is then saved for later use). It is,
572
// therefore, safe and probably good practice to have one frame in a certain
573
// conversion environment, filled with as much info as is needed at that stage.<br>
574
// To aid and speed up, <src>resetEpoch()</src> and <src>resetPosition()</src>
575
// methods are available. As arguments they accept the corresponding
576
// MV or a variety of Double and Quantum arguments to reset the <em>value</em>
577
// of the corresponding frame measure only. In that case the conversion engine
578
// won't be redesigned, leading to fast recalculation when necessary, since
579
// e.g. nutation values could be re-used.<br>
580
// In an observing environment you could hence setup a proper frame with the
581
// Observatory position, and an observing day offset (see MeasRef) time; and
582
// do resetEpoch() to update the time if and when necessary.<br>
583
// <p>
584
// <h4>MeasRef</h4>
585
// A MeasRef is a measure specific container (and its class reference is
586
// <src>Measure::Ref</src>, e.g. <src>MFrequency::Ref</src>) with the
587
// measure reference type (e.g. <src>MEpoch::UTC</src>), an optional (but in
588
// some cases necessary) MeasFrame (e.g. to specify where the sidereal time
589
// was determined), and, just for convenience, an optional offset (e.g.
590
// the MJD for which the time specified in the MEpoch referenced is valid).
591
// Note that if no frame or offset is necessary, the <src>Measure::TYPE</src>
592
// can be used everywhere where a <src>Measure::Ref</src> is needed.<br>
593
// A MeasRef is never copied (all copying and so is done by referencing). This
594
// means, for example, that if a specific MeasRef is part of the MEpoch
595
// definition for an epoch that is part of a MeasFrame, and you chnage that
596
// MeasRef, the change will automatically occur wherever that MeasRef is
597
// used (as e.g. in the frame). In most cases that is the expected response,
598
// but you should be aware of it, and not re-use a MeasRef for a completely
599
// different purpose.<br>
600
// A simple example:
601
// <srcblock>
602
// MEpoch mytime(MVEpoch(50236.5), MEpoch::UTC);
603
// // this will define a time in UTC on MJD 50236, 12 hours. The MVEpoch
604
// // explicit conversion could be left out for most compilers, but some
605
// // have trouble with automatic conversions.
606
// // Another way of doing it would be to use Quantities, which have
607
// // explicit constructors for all measures:
608
// MEpoch mytime(Quantity(50236.5, "d"));
609
// </srcblock>
610
// A slighty more involved example, written out a bit:
611
// <srcblock>
612
// // Specify the location of the observatory (10m high, at given longitude
613
// // and latitude as geodetic position)
614
// MPosition obs( MVPosition( Quantity( 10, "m"),
615
// Quantity( -6, "deg"),
616
// Quantity( 52, "deg")),
617
// MPosition::WGS84);
618
// // If the current time is MJD50236, 12.3 h UTC, it could be specified as:
619
// MEpoch tim( MVEpoch( Quantity( 50236, "d"),
620
// Quantity( 12.3, "h")));
621
// // Note the default reference
622
// // For this example we will also specify it as:
623
// MEpoch offtim(tim);
624
// offtim.set(MEpoch::DEFAULT+MEpoch::RAZE);
625
// // These two could define a frame
626
// MeasFrame frame(tim, obs);
627
// // Or maybe as (since observatory will stay put)
628
// MeasFrame frame1(obs);
629
// // and later addition of some time and its reference frame
630
// frame1.set(tim);
631
// // with a change to another time value at a later stage with
632
// frame1.resetEpoch( MVEpoch( Quantity( 50236, "d"),
633
// Quantity( 13, "h")));
634
// // At this time we observe a sidereal time of 2.3 h. The actual instance
635
// // of time needs a sidereal date to specify, but we are too lazy to
636
// // look it up, hence we specify that this time has an offset, equal to
637
// // the sidereal time at offtim (which with the RAZE addition will be
638
// // converted to an integral number of days in whatever time it is
639
// // converted to)
640
// MEpoch mylast( MVEpoch( Quantity( 2.3, "h")),
641
// MEpoch::Ref( MEpoch::LAST,
642
// frame,
643
// offtim));
644
// // Which specifies that we have a Local apparent sidereal time of 2.3 h
645
// // at the position specified by obs in the frame, at an offset offtim.
646
// // Note that the offset is given in UTC (and RAZE). Any conversion of
647
// // this mylast value to any other reference type, will always auto start
648
// // with a conversion of the offset to the current type (i.e LAST (with
649
// // the RAZE taking the integer part only)), and adding it to the value
650
// // given. Note that if an output reference has an offset, the resulting
651
// // value will be corrected for the specified offset as well.
652
// </srcblock>
653
// The reference type can be set with a set() function, and set() functions
654
// for the offset and frame will be present as well.<br>
655
// A <src>Bool empty()</src> checks if the reference is empty; <src>get()</src>
656
// functions provide the information in the reference; and a
657
// <src>String showMe()</src> will return the type of measure (e.g. "Epoch") the
658
// MeasRef can be used for.
659
//<p>
660
// <h4>MeasConvert</h4>
661
// The MeasConvert class converts Measures from one reference type and frame
662
// to another.
663
// It gathers all relevant
664
// information and analyses it to have fast multiple conversions.
665
// The MeasConvert classes are Measure specific, and should be used with
666
// the class names <src>Measure::Convert</src> (e.g. <src>MFrequency::Convert
667
// </src>).
668
// The () operator will do the actual conversion; constructors and set()
669
// methods will only fill the information necessary to do the conversion.
670
// MeasConvert is a non-copying container.<br>
671
// To set up the conversion engine, the MeasConvert object has to know the
672
// input data reference (remember the MeasRef contains information about the
673
// type, the possible reference frame and a possible offset), and an output
674
// reference. Using these references it will communicate with the appropiate
675
// Measure class to set up a series of routines that have to be executed in
676
// order to attain the goal. (Note that if the input and output reference
677
// both define a frame, but different ones, e.g. because you want to convert
678
// a sidereal time at one place to a sidereal time at another place, the
679
// conversion machinery will always first go to the proper default (UTC in this
680
// case), and then go to the goal).<br>
681
// The actual conversion need a value to be converted, and it also can use
682
// a default Unit, so that if your frequencies are in nm, you can once
683
// specify that they are nm, and then simply convert a Double.<br>
684
// This means that the optimal constructor for a MeasConvert is:
685
// <srcblock>
686
// // The first argument will give the input reference, and, if a Quantum is
687
// // used to make the Measure, the default units for inputs to the conversion.
688
// // It acts as a 'model' for subsequent input to be converted.
689
// // () operator
690
// Measure::Convert( Measure(Quantum),
691
// // the second argument gives the output reference
692
// Measure::Ref);
693
// </srcblock>
694
// The actual constructors present include ones with the first argument only
695
// an input reference, rather than a full Measure.
696
// However, in all cases an empty or partial one can be constructed, with set()
697
// functions filling in the rest. The conversion engine is only
698
// (re-)setup if at least an input and output reference can be found.<br>
699
// After setting up the conversion engine, the () operator can be used with
700
// a variety of values to return a converted Measure. Possibilities are:
701
// <srcblock>
702
// () // convert the value as specified in the 'model'
703
// (Double) // convert the value first to appropiate units (if they
704
// // were implicit in 'model' or explicitly set), and
705
// // then convert
706
// (Vector<Double>)// as Double
707
// (Quantity) // convert the full value, including its own units
708
// (Quantum<Vector<Double> >) // as Quantity
709
// (MeasValue) // convert the specified appropiate MV
710
// (Measure) // set up a new conversion chain, using the value as
711
// // 'model', and the old output reference,
712
// // and then convert
713
// (Measure, Measure::Ref) // set up a new conversion chain for the
714
// // 'model' given and the output reference given
715
// (Measure::Ref) // set up a new conversion chain using the old 'model'
716
// // and the output reference given, and convert the
717
// // existing model value
718
// </srcblock>
719
// A simple example to output the J2000 coordinates for a B1950 input (RA=20 deg,
720
// DEC=-10 deg):
721
// <srcblock>
722
// cout <<
723
// MDirection::Convert( MDirection( Quantity( 20, "deg")
724
// Quantity(-10, "deg"),
725
// MDirection::Ref( MDirection::B1950)),
726
// MDirection::Ref( MDirection::J2000)) () << endl;
727
// </srcblock>
728
// In this example everything is done in one go (the () at the end does the
729
// conversion). Another example, to have a UTC to LAST converter:
730
// <srcblock>
731
// // Set up the model for the input (default reference is UTC)
732
// MEpoch model ( Quantity(0., "d"));
733
// // Set up the frame with the observatory position
734
// MPosition obs( MVPosition( Quantity( 10, "m"),
735
// Quantity( -6, "deg"),
736
// Quantity( 50, "deg")),
737
// MPosition::Ref(MPosition::WGS84));
738
// Measframe frame( obs);
739
// // set up the output reference
740
// MEpoch::Ref outref( MEpoch::LAST,
741
// frame);
742
// // Set up conversion
743
// MEpoch::Convert toLST( model,
744
// outref);
745
// // Output a series of sidereal times (formatted in ddd::hh:mm:ss)
746
// for (Double d = 12345; d<12346; d += 0.1) {
747
// cout << "Converted from UTC to LAST: " <<
748
// d <<
749
// toLST(d).getValue() << endl;
750
// };
751
// </srcblock>
752
// <p>
753
// For specific purposes it would be very easy to set up a series of simple
754
// classes, that would do standard conversions.
755
// <p>
756
// <h4> MeasData, MeasTable, MeasBase, other help classes</h4>
757
// A series of help classes are present to aid in the conversion, especially
758
// caching information. They are of no direct use for the end user (except
759
// maybe a few constants in MeasData).<br>
760
// The classes are:
761
// <ul>
762
// <li> <linkto class=MeasBase>MeasBase</linkto>:
763
// base class (derived from Measure) for all real Measures
764
// <li> <linkto class=MeasData>MeasData</linkto>:
765
// all constants, polynomial factors, interface to IERS
766
// database etc. which are not stored in Tables. (MeasTable looks after
767
// these). Mn short it provides all the actual data values necessary
768
// for the conversions (and the other help classes)
769
// <li> <linkto class=MeasTable>MeasTable</linkto>:
770
// interface for all data that comes from Tables rather than
771
// the program
772
// <li> <linkto class=MeasIERS>MeasIERS</linkto>:
773
// (static) class to converse with the IERS database(s)
774
// <li> <linkto class=MeasJPL>MeasJPL</linkto>:
775
// (static) class to converse with the JPL DE database(s)
776
// <li> <linkto class=Precession>Precession</linkto>:
777
// all precession related calculations
778
// <li> <linkto class=Nutation>Nutation</linkto>
779
// <li> <linkto class=Aberration>Aberration</linkto>
780
// <li> <linkto class=SolarPos>SolarPos</linkto>:
781
// all solarposition related calculations
782
// <li> <linkto class=Euler>Euler</linkto>:
783
// representation of Euler rotation angles
784
// <li> <linkto class=RotMatrix>RotMatrix</linkto>: a 3-D rotation matrix
785
// </ul>
786
// <p>
787
788
// </synopsis>
789
//
790
// <motivation>
791
// The Measures module originated to be able to convert ccordinates between
792
// different reference frames.
793
// </motivation>
794
//
795
// <todo asof="1998/07/22">
796
// <li> inlining
797
// </todo>
798
//
799
// <example>
800
// See the individual measures for appropiate examples.
801
// </example>
802
// </module>
803
804
// # Dummy class definition for extractor
805
// # class Measures {};
806
807
}
// namespace casacore
808
809
#endif
casacore
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition
mainpage.dox:28
Generated by
1.15.0