casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Measures.h
Go to the documentation of this file.
00001 //# Measures.h:  a module for coordinates
00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: Measures.h 20675 2009-07-10 05:54:49Z Malte.Marquarding $
00027 
00028 #ifndef MEASURES_MEASURES_H
00029 #define MEASURES_MEASURES_H
00030 
00031 //# Includes
00032 #include <casa/Quanta.h>
00033 #include <measures/Measures/Measure.h>
00034 #include <measures/Measures/MeasBase.h>
00035 #include <casa/Quanta/MeasValue.h>
00036 #include <measures/Measures/MeasRef.h>
00037 #include <measures/Measures/MeasConvert.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 // <module>
00042 // 
00043 
00044 // <summary> a module for coordinates </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasMath tMeasure"
00049 //       demos="dMeasure">
00050 
00051 // <prerequisite>
00052 //   <li> <linkto module=Quanta>Quanta</linkto> module for units and quantities.
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // The name Measure derives from physical measurements, i.e. values with
00057 // units and possibly a reference frame attached.
00058 // </etymology>
00059 //
00060 // <synopsis> 
00061 // The Measure model deals with measures (i.e. quantities with a
00062 // reference frame).
00063 // Measures are handled in the <a href="#Measure">Measure</a> section
00064 // (see <linkto class="Measure">Measure.h</linkto>).
00065 //
00066 // <h3> Includes</h3>
00067 // Including the <src>measures/Measures.h</src> will take care of all
00068 // includes necessary for the handling of Units and Quantities, and the
00069 // general Measure interface. For the use of individual Measures, the
00070 // appropiate include files should be added. E.g. to be able to handle
00071 // Directions, the following includes could be given:
00072 // <srcblock>
00073 //      #include <measures/Measures.h>
00074 //      #include <measures/Measures/MDirection.h>
00075 // </srcblock>
00076 // An inclusion of the appropiate measure file, will also take care of the
00077 // connected measure value (in this case <src>MVDirection</src>). However,
00078 // if only the value suffices, it can be included on its own (from the
00079 // Quanta directory).<br>
00080 // When doing actual conversions (see MeasConvert later on), by using the
00081 // explicit Measure::Convert types, the description of the actual
00082 // conversions (called MCmeasure, e.g. MCEpoch.h) should be included as well;
00083 // in adition to general MeasConvert.h. 
00084 //
00085 //  <anchor name="Measure"><h3> Measures</h3></anchor>
00086 //
00087 // Measures are physical quantities within a certain reference frame. Examples
00088 // are the Hour-angle and Declination of a source at a certain time and 
00089 // observatory; an Ra/Dec for a certain mean epoch; an apparent frequency at
00090 // a certain time given in eV; a local sidereal time at an observatory.<br>
00091 // Measures can be converted from one reference frame to another (and this
00092 // possibility is its main reason for existence). A simple B1950-J2000
00093 // coordinate conversion example:
00094 // <srcblock>
00095 //  cout <<                     // output
00096 //                              // the conversion of a B1950 direction
00097 //      MDirection::Convert( MDirection( Quantity( 20, "deg"),
00098 //                                       Quantity(-10, "deg"),
00099 //                                       MDirection::Ref( MDirection::B1950)),
00100 //                              // to J2000
00101 //                           MDirection::Ref( MDirection::J2000)) () 
00102 //                              // where the constructor sets up a conversion
00103 //                              // engine, and the operator() converts
00104 //              << endl;
00105 // </srcblock>
00106 // or converting an UTC to a local apparent sidereal time:
00107 // <srcblock>
00108 //  // Set up the model for the input (default reference is UTC)
00109 //      MEpoch model (  Quantity(0., "d"));
00110 //  // Set up the frame with the observatory position
00111 //      MPosition obs(  MVPosition(     Quantity( 10, "m"),
00112 //                                      Quantity( -6, "deg"),
00113 //                                      Quantity( 50, "deg")),
00114 //                      MPosition::Ref(MPosition::WGS84));
00115 //      Measframe frame( obs);
00116 //  // Set up the output reference
00117 //      MEpoch::Ref outref(     MEpoch::LAST,
00118 //                              frame);
00119 //  // Set up conversion
00120 //      MEpoch::Convert toLST(  model,
00121 //                              outref);
00122 //  // Output a series of sidereal times (formatted in ddd::hh:mm:ss)
00123 //      for (Double d = 12345; d<12346; d += 0.1) {
00124 //        cout << "Converted from UTC to LAST: " <<
00125 //              d <<  " : " <<
00126 //              toLST(d).getValue() << endl;
00127 //      };
00128 // </srcblock>
00129 //
00130 // The examples show the use of the 5 major classes involved in Measures:
00131 // <srcblock>
00132 //   Base         Example               Description
00133 //  ------       ---------             -------------
00134 //  Measure      MEpoch          has a value and a  reference
00135 //  MeasValue    MVEpoch         value
00136 //  MeasRef      MEpoch::Ref     contains type, frame, offset
00137 //  MeasFrame    MeasFrame       contains Measures describing frame
00138 //  MeasConvert  MEpoch::Convert contains conversion information and engine
00139 // </srcblock>
00140 //
00141 // Each type of Measure has its own distinct class. Each
00142 // is (weakly) derived from the <linkto class="Measure">Measure</linkto> base
00143 // class, and its name starts with an <em>M</em>. Examples are:
00144 // <ul>
00145 //   <li> <linkto class="MEpoch">MEpoch</linkto>: an instance in time
00146 //   <li> <linkto class="MDirection">MDirection</linkto>: a direction in space
00147 //   <li> <linkto class="MPosition">MPosition</linkto>: a position on Earth
00148 //   <li> <linkto class="MFrequency">MFrequency</linkto>: the characteristics
00149 //              of a wave
00150 //   <li> <linkto class="MDoppler">MDoppler</linkto>: a Doppler shift
00151 //   <li> <linkto class="MRadialVelocity">MRadialVelocity</linkto>: a 
00152 //              radial velocity
00153 //   <li> <linkto class="MBaseline">MBaseline</linkto>: a baseline
00154 //   <li> <linkto class="Muvw">Muvw</linkto>: a uvw value
00155 //   <li> <linkto class="MEarthMagnetic">MEarthMagnetic</linkto>: an
00156 //               earth' magnetic field value
00157 // </ul>
00158 // Others are being, or could be, considered.<br>
00159 // <note role=tip>The current set can be deduced from the class list at the end of
00160 // the html version of this module description.</note><br>
00161 // <p>
00162 // The main role of the Measure (and related) classes is to be able to convert
00163 // an observed (or to be calculated) physical entity from one reference frame
00164 // to another, e.g. a J2000 coordinate to galactic coordinates, or an TAI
00165 // time to a local sidereal time (LAST).
00166 // Simple unit conversions (e.g. an angle from mrad to deg), or calculations
00167 // with values with attached units, are sufficiently catered for by the
00168 // <linkto module="Quanta">Quanta</linkto> module classes.
00169 // <p>
00170 // Each measure has a <em>value</em> (<linkto class=MeasValue>MeasValue</linkto>) and
00171 // a <em>reference</em> (<linkto class=MeasRef>MeasRef</linkto>).<br>
00172 // The values are in general measure specific, weakly derived from MeasValue,
00173 // and named with an initial <em>MV</em>. Examples are:
00174 // <ul>  
00175 // <li> <linkto class=MVEpoch>MVEpoch</linkto> (a high precision single value), 
00176 // <li> <linkto class=MVDirection>MVDirection</linkto> (direction cosines), 
00177 // <li> <linkto class=MVPosition>MVPosition</linkto> (3-vector positions),
00178 // <li> <linkto class=MVFrequency>MVFrequency</linkto> (single, unit depended
00179 // value).<br>
00180 // <li> <linkto class=MVDoppler>MVDoppler</linkto> (single, unit depended value)
00181 // <li> <linkto class=MVRadialVelocity>MVRadialVelocity</linkto> (single value)
00182 // </ul>
00183 // MeasValue and the MV classes can be found in the
00184 // <linkto module=Quanta>Quanta</linkto> module.
00185 // In addition some other value classes, not directly used in measures, are
00186 // available. Examples:
00187 // <ul>
00188 //  <li> <linkto class=MVAngle>MVAngle</linkto> (to normalise
00189 // and have specific I/O formatting for angle-like values)
00190 // <li> <linkto class=MVTime>MVTime</linkto> (same for time-like values)
00191 // </ul>
00192 // <em>References</em> are measure specific. Each specific reference class is
00193 // called <em>Measure</em>::Ref (e.g. <src>MEpoch::Ref</src>). It specifies
00194 // the full reference frame of the specific measure, i.e. its type, an optional
00195 // frame of measures (a MeasFrame, consisting of say a time and position), and
00196 // an optional offset.
00197 // It has at least a <em>reference code</em>
00198 // (e.g. MDirection::B1950, MEpoch::LAST), with defaults for each measure
00199 // (i.e. MDirection::J2000, MEpoch::UTC) if none specified. <br>
00200 // In addition the reference can contain a <em>reference frame</em> 
00201 // (<linkto class=MeasFrame>MeasFrame</linkto>) to specify from when and/or
00202 // where the measure was obtained or calculated.<br>
00203 // A third optional element of the reference is an <em>offset measure</em>, which
00204 // indicates the offset (e.g. a sidereal date) that has to be added to the
00205 // value referenced before it is used.<br>
00206 // Examples of some measures are:
00207 // <srcblock>
00208 //      // An instance of time expressed in days (MJD) in UTC
00209 //      MEpoch date(MVEpoch(Quantity(50237.29, "d")),
00210 //                  MEpoch::Ref(MEpoch::UTC));
00211 //      // which could also be expressed as:
00212 //      MEpoch date(Quantity(50237.29, "d"),
00213 //                  MEpoch::UTC);
00214 //      // or using the default reference type:
00215 //      MEpoch date(Quantity(50237.29, "d"));
00216 //      // or as a time with an offset to a specific date:
00217 //      MEpoch date(Quantity(12.3, "h"),                // time
00218 //                  MEpoch::Ref(MEpoch::UTC,            // reference with
00219 //                              MEpoch(Quantity(50237, "d"))));  // offset
00220 //      // A position of a telescope
00221 //      MPosition pos(MVPosition(Quantity(25, "m"),     // height
00222 //                               Quantity(20, "deg"),   // East longitude
00223 //                               Quantity(53, "deg")),  // lattitude
00224 //                    MPosition::WGS84);                // reference type
00225 //      // Use this position in a frame
00226 //      MeasFrame frame(pos);
00227 //      // Specify an LAST (in MGSD) observed at this position:
00228 //      MEpoch last(Quantity(51000.234, "d"),           // time and date
00229 //                  MEpoch::Ref(MEpoch::LAST,           // indicate LAST
00230 //                              frame));                // and where observed
00231 //      // Maybe we know the MJD of the observed sidereal time,
00232 //      // but not its sidereal date. We could then specify it as an
00233 //      // offset to the beginning of the sidereal day in progress at
00234 //      // specified UTC
00235 //      MEpoch last(Quantity(13.45, "h"),               // time
00236 //                  MEpoch::Ref(MEpoch::LAST,           // indicate LAST
00237 //                              frame,                  // where observed
00238 //                              MEpoch(51234,           // MJD of today
00239 //                                     MEpoch::Ref(MEpoch::TAI + MEpoch::RAZE)));
00240 //      // where the RAZE indicates that the value will be truncated after
00241 //      // conversion. In this case it will be converted to LAST to be able
00242 //      // to add it as an offset to the specified LAST
00243 //      //
00244 //      // A direction (in RA/Dec) could be:
00245 //      MDirection coord(MVDirection(Quantity(54, "deg"),       // RA
00246 //                                   Quantity(2034, "'")),      // DEC arcmin
00247 //                       MDirection::Ref(MDirection::J2000));   // J2000 type
00248 //      // If it were apparent coordinates, the time when observed should
00249 //      // have been known. We could just add it to the frame defined above,
00250 //      // and use it:
00251 //      frame.set(date);                                // add time to frame
00252 //      MDirection acoord(MVDirection(Quantity(54, "deg"),      // RA
00253 //                                    Quantity(2034, "'")),     // DEC
00254 //                        MDirection::Ref(MDirection::APP,      // apparent type
00255 //                                        frame));              // and when
00256 //      // If it was given in HA/Dec, the position should have been known
00257 //      // as well, but it is already in the frame, hence we could say:
00258 //      MDirection acoord(MVDirection(Quantity(54, "deg"),      // HA
00259 //                                    Quantity(2034, "'")),     // DEC
00260 //                        MDirection::Ref(MDirection::HADEC,    // type
00261 //                                        frame));              // when/where
00262 // </srcblock>
00263 // <note role=tip>In the above examples in general explicit <em>MV</em>
00264 // values have been used to specified the measure's value. In many
00265 // cases (depending on the actual measure) it can be omitted, and the data
00266 // can be given directly to the measure constructor. See the 
00267 // constructors for the individual measures for details.<br>
00268 // If the reference is simple (i.e. no frame and/or offset) the 
00269 // <em>Measure::Ref</em> can be omitted, and only the code has to be
00270 // specified. </note>
00271 // A <linkto class=MeasFrame>MeasFrame</linkto> is a container for specifying
00272 // Measures needed to describe the circumstances under which the measure was
00273 // observed (or for which it has to be calculated).
00274 // E.g. the position on Earth (an <em>MPosition</em>) is necessary for 
00275 // sidereal time and coordinates like HA/Dec and Az/El; the time 
00276 // (<em>MEpoch</em>)
00277 // is necessary for non-standard coordinates (apparent, mean, HA/Dec etc); 
00278 // the coordinates (<em>MDirection</em>) for radial velocities; etc.<br>
00279 // Although quite often the value has to be in a specific format (e.g. TBD for
00280 // precession calculations; astronomical longitude for the LAST), the
00281 // frame values can be given in any known reference format: conversion to the
00282 // appropiate type will be done automatically if and when necessary.<br>
00283 // Frames (and references) are never copied, but act always as containers
00284 // with shallow copying only (i.e. <em>copied</em> frames will point to
00285 // identical instances, and changes made in one copy will be visible in all
00286 // others. This
00287 // means, e.g., that in the following:
00288 // <srcblock>
00289 //      MeasFrame frame1(MEpoch(50236.12));
00290 //      MeasFrame frame2(frame1);
00291 // </srcblock>
00292 // the two frames will be identical, and a change to one means a change to 
00293 // the other. Furthermore, only the information needed for a specific 
00294 // calculation will be used (and calculated). This means that one frame can
00295 // be used specifying all of e.g. the position (which will probably stay the
00296 // same for a series of calculations) and time; with the time being <em>set()</em>
00297 // (if also the reference of the epoch changes) or <em>resetEpoch()</em> (if only
00298 // the value changes, but the reference and its frame stay the same).
00299 // A change in the frame will influence automatically any calculation (e.g.
00300 // conversion to LAST) of which it is part.<br>
00301 //
00302 // The value of a measure (in <em>MV</em> format) can be obtained with the
00303 // <em>getValue()</em> member function. The value in a variety of formats
00304 // and units can be obtained with a (specific Measure dependent) series of
00305 // <em>get()</em> members of both the <em>MV</em>-value and the Measure.<br>
00306 //
00307 // Measures in themselves are not really necessary for proper data reduction
00308 // and the like. Its real value is the ability to transform a Measure from
00309 // one reference type (and frame, offset) to another.<br>
00310 // Conversion of a measure of a certain kind from one reference to another
00311 // is done with the aid of special, measure specific,
00312 // <linkto class=MeasConvert>MeasConvert</linkto> classes. Each conversion
00313 // class is called <em>Measure</em>::Convert (e.g. MDirection::Convert).
00314 // A conversion generates from an input reference (or an input measure) and
00315 // an output reference a conversion functional, that can be used to convert
00316 // specific values.<br>
00317 // Example:
00318 // <srcblock>
00319 //  cout <<                     // output
00320 //                              // the conversion of a B1950 direction
00321 //      MDirection::Convert( MDirection( Quantity( 20, "deg"),
00322 //                                       Quantity(-10, "deg"),
00323 //                                       MDirection::Ref( MDirection::B1950)),
00324 //                              // to J2000
00325 //                           MDirection::Ref( MDirection::J2000)) () 
00326 //                              // where the constructor sets up a conversion
00327 //                              // engine, and the operator() converts
00328 //              << endl;
00329 //</srcblock>
00330 // The same could have been done by only setting up the conversion engine, and
00331 // not specifing the default value to be converted in the Convert constructor
00332 // by:
00333 // <srcblock>
00334 //  cout <<                     // output
00335 //                              // the conversion of a B1950 direction
00336 //      MDirection::Convert(MDirection::Ref( MDirection::B1950),
00337 //                              // to J2000
00338 //                          MDirection::Ref( MDirection::J2000))
00339 //                              // and use conversion on value
00340 //                               (MVDirection( Quantity( 20, "deg"),
00341 //                                             Quantity(-10, "deg")))
00342 //                              // where the operator() converts
00343 //              << endl;
00344 // </srcblock>
00345 // Specifying the conversion engine separately, it can be re-used for other
00346 // values:
00347 // <srcblock>
00348 //      MDirection::Convert conv(MDirection::Ref( MDirection::B1950),
00349 //                               MDirection::Ref( MDirection::J2000));
00350 //      // We have some coordinates from somewhere, say coord(0:N-1):
00351 //      for (Int i=0; i<N; i++) {
00352 //         cout << "B1950: " << coord(i) << "= J2000: " <<
00353 //                              conv(coord(i)) << endl;
00354 //      };
00355 // </srcblock>
00356 // A larger example. Say you have the J2000 coordinates for a source (RA=11
00357 // deg, DEC= -30 deg), and you want to observe it on May 17, 1996 (MJD=50220)
00358 // at 8:18 UTC in a place
00359 // with a Longitude of 150 deg (latitude of 20 deg) at 1000 m high,
00360 //  you could get the
00361 // apparent RA,DEC, and the LAST at that time (you could also go straight to
00362 // HA/DEC or so) with (I write the example longer than necessary to indicate
00363 // the steps, and with explicit reference to MV values):
00364 // <srcblock>
00365 // // The observatory position. Note that the reference is geodetic position 
00366 //      MPosition myobs(MVPosition ( Quantity(1, "km") ,
00367 //                                   Quantity(150, "deg"),
00368 //                                   Quantity(20, "deg")),
00369 //                                   MPosition::WGS84);
00370 // // The time I want to observe (note that it could be specified in many
00371 // // other ways)
00372 //      MEpoch obstime(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)), 
00373 //                     MEpoch::UTC);
00374 // // The frame specification for when and where to observe
00375 //      MeasFrame frame(myobs, obstime);
00376 // // The reference for a sidereal time (note the frame could be empty and 
00377 // // filled at the actual conversion time)
00378 //      MEpoch::Ref sidref( MEpoch::LAST, frame);
00379 // // The reference for apparent coordinates:
00380 //      MDirection::Ref appref( MDirection::APP, frame);
00381 // // The conversion engine for my time to LAST
00382 //      MEpoch::Convert tosid(obstime, sidref);
00383 // // The conversion to sidereal time of obstime
00384 //      MEpoch sidtime = tosid();
00385 // // Conversion of UTC 10.8 h 
00386 //      sidtime = tosid(MVEpoch(MVTime(1996, 5, 17, 10.8/24.))); 
00387 // // Show me some time
00388 //      cout << "LAST for UTC = 11:00: " <<
00389 //              tosid(MVEpoch( MVTime( 1996, 5, 17, 11, 0))) << endl;
00390 // // An offset reference (note the RAZE will keep only the integer part of
00391 // // the day for the conversion result)
00392 //      MEpoch::Ref offtime(obstime.getValue(), MEpoch::UTC+MEpoch::RAZE);
00393 // // The reference for a sidereal with respect to a specified offset (note
00394 // // that it is automatically calculated into correct units)
00395 //      MEpoch::Ref sidoffref(MEpoch::LAST, frame, offtime);
00396 // // Show the offset result
00397 //      cout << "LAST today: " <<
00398 //              MEpoch::Convert(11., sidoffref)() << endl;
00399 // // Coordinate conversion from J2000
00400 //      cout << "Apparent coordinates: " <<
00401 //              MDirection::Convert ( MDirection(Quantum(11,"deg"),
00402 //                                               Quantum(-30, "deg")),
00403 //                                    MDirection::Ref( MDirection::APP,
00404 //                                                     frame))() << endl;
00405 // // Handier to have the conversion engine available
00406 //      MDirection::Convert cvt( MDirection(Quantum(11,"deg"),
00407 //                                          Quantum(-30, "deg")),
00408 //                               MDirection::Ref( MDirection::APP,
00409 //                                                frame));
00410 // // Set another frame time (note it is now sidereal, not UTC. The
00411 // // frame will automatically convert it (using the frame again for
00412 // // position) to TDB for precession etc calculations).
00413 //      frame.set(sidtime);
00414 // // And look what same position is at this new time
00415 //      cout << "Next position: " << cvt() << endl;
00416 // </srcblock>
00417 // <p>
00418 // Some conversions need maybe some fine tuning (e.g. what is the acceptable
00419 // interval for Nutation linear interpolation: could be different from the
00420 // default interval; some time calculations will want to use the predicted
00421 // IERS values rather than the actual determined; some Nutation will maybe
00422 // use the IERS updates, some maybe the JPL DE databases).<br>
00423 // The <linkto class=AipsrcValue>AipsrcValue</linkto> class can be used to
00424 // specify very specific parameters that are used to steer
00425 // the conversion process beyond what is possible with just a list
00426 // of measure reference types (that list is already long for some cases).
00427 // Values, switches can be <src>set()</src> (and removed) to change the
00428 // default behaviour of the conversions. In general the user will only need
00429 // to use the details in very specific cases. The details that can be used
00430 // are described in the classes that provide calculations (e.g.
00431 // <linkto class=Nutation>Nutation</linkto>), and in the aipsrc-data reference
00432 // manual entry.<br>
00433 // <p>
00434 // Some details about the different classes follows. In the examples often
00435 // a specific measure value (e.g. MVEpoch, the MeasValue for MEpoch), or a
00436 // specific measure (e.g. MDirection, a direction in space) is used. This
00437 // is only to visualise the use, any other measure could have been used.
00438 // <p>
00439 // <h4> MeasValue</h4>
00440 // The MeasValue class derivatives are all named <em>MVmeasure</em>, e.g.
00441 // <em>MVFrequency</em>, and represent the internal representation of the
00442 // specific measure class.  Details
00443 // can be found in the <linkto module=Quanta>Quanta</linkto> module.
00444 // <p>
00445 // <h4> Measure</h4>
00446 // The Measure class derivatives are all called <em>MMeasure</em>.
00447 // <linkto class=MDirection>MDirection</linkto> (a celestial direction),
00448 // <linkto class=MPosition>MPosition</linkto> (a position on Earth),
00449 // <linkto class=MFrequency>MFrequency</linkto> (characteristics of 
00450 //      electro-magnetic wave),
00451 // <linkto class=MEpoch>MEpoch</linkto> (an instance in time),
00452 // <linkto class=MDoppler>MDoppler</linkto>,
00453 // <linkto class=MRadialVelocity>MRadialVelocity</linkto>
00454 // <linkto class=MBaseline>MBaseline</linkto>,
00455 // <linkto class=Muvw>Muvw</linkto>,
00456 // <linkto class=MEarthMagnetic>MEarthMagnetic</linkto>,
00457 //. <br>
00458 // A measure has a value (kept in internal units in <em>MVmeasure</em>
00459 // format) and a definition
00460 // of the reference frame (MeasRef) of the value. The reference is optional, and
00461 // will default to <em>Measure::DEFAULT</em>.<br>
00462 // All measures have a set of standard constructors:
00463 // <srcblock>
00464 //      M();                    // some default, e.g. pole directoon, time ==0)
00465 //      M(MV, MeasRef);
00466 //      M(Quantity, MeasRef);
00467 //      M(Quantum<Vector<Double> >, MeasRef);
00468 //      M(Vector<Quantity>, MeasRef);
00469 // </srcblock>
00470 // But also some special ones (e.g. two Quantities for MDirection to specify
00471 // two angles) depending on type. The MeasRef can be omitted (will then be
00472 // defaulted to Measure::DEFAULT, e.g. MEpoch::DEFAULT); can be specified as
00473 // a full reference as a <em>Measure::Ref</em> (e.g. <em>MDirection::Ref</em>)
00474 // type; or as a simple reference as <em>Measure::TYPE</em> (e.g. 
00475 // <em>MDirection::J2000</em>).<br>
00476 // The individual elements of a Measure (i.e the MV value and the reference)
00477 // can be overwritten (or set) with the <src>set()</src> methods.<br>
00478 // <src>get()</src> methods (in general <src>get(unit)</src> 
00479 // to return the internal value in some
00480 // specified unit as a Quantum; and methods like <src>getAngle()</src>
00481 // for e.g. MDirection)
00482 // enable the user to obtain the value of the measure.<br>
00483 // A <src>String tellMe()</src> will tell the type of Measure; a 
00484 // <src>void assured(String)</src> and <src>Bool areYou(String)</src> will
00485 // check the type; while a <src>String showType(Measure::TYPE)</src> will
00486 // return the string value of a reference type code (e.g. J2000).<br>
00487 // <p>
00488 // Recall that a Measure is a value with a reference specified. The MeasConvert
00489 // engines enable you to convert it into another Measure, with a different 
00490 // reference (e.g. from J2000 to AZEL). The different get() methods (either
00491 // directly, or indirectly using additional MV get() functions, or
00492 // Quantum conversion methods, can convert the internal value into a value
00493 // (or values) with user preferred units.<br>
00494 // For reasons of speed (and safety) the allowed reference types for each
00495 // Measure are enumerated in each measure class. The different reference 
00496 // types for MDirection are, for example:
00497 // <srcblock>
00498 //              MDirection::J2000,
00499 //              MDirection::JMEAN,
00500 //              MDirection::JTRUE,
00501 //              MDirection::APP,
00502 //              MDirection::B1950,
00503 //              MDirection::BMEAN,
00504 //              MDirection::BTRUE,
00505 //              MDirection::GALACTIC,
00506 //              MDirection::HADEC,
00507 //              MDirection::AZEL,
00508 //              MDirection::DEFAULT = MDirection::J2000
00509 // </srcblock>
00510 // The MEpoch has a special reference type (<src>MEpoch::RAZE</src>) that 
00511 // can only be used
00512 // in conjuncion with another reference type 
00513 // (e.g. <src> MEpoch::UT1+MEpoch::RAZE)</src>.
00514 // The meaning is: if a measure with such a reference type is converted to
00515 // another reference type (say <src>MEpoch::LAST</src>) the 
00516 // resultant (sidereal time)
00517 // instance will be <em>razed</em> to an integer number of days; hence providing
00518 // an easy way to specify sidereal times offset with the beginning of the
00519 // current sidereal day.<br>
00520 // To aid with external data, a <src>Bool giveMe(String, uInt)</src> will
00521 // give the correct reference type to be used given the String type.
00522 // Note that the
00523 // uInt, rather than the corresponding enum is used, due to templating
00524 // restrictions in some compilers.<br>
00525 // The correct reference (MeasRef) and conversion (MeasConvert) class for
00526 // each Measure (a frequency cannot be converted into an epoch) are templated,
00527 // and have specified (and to be used) typedefs: <em>Measure::Ref</em> and
00528 // <em>Measure::Convert</em> (e.g. <em>MEpoch::Ref, MEpoch::Convert</em>). In
00529 // addition, Measure::MVType and Measure::MCType are defined for all
00530 // measures.
00531 // <p>
00532 // <h4>Measure errors </h4>
00533 // In the current implementation, no errors are attached to a Measure. In the
00534 // original design errors were foreseen, but up till now they have been left
00535 // out.<br>
00536 // The addition of errors is in principle an easy process. They could be 
00537 // attached to either a Measure (as an additial MV value), or the MV's could
00538 // be expanded to include errors (my preferred option at the moment). An
00539 // MV being converted will then automatically have its error converted as
00540 // well.<br>
00541 // Before implementing, however, I think it would be worthwhile to look at
00542 // the whole area of error handling. The easiest way would be to introduce
00543 // for each of the defined aips++ standard values a corresponding E class
00544 // (EDouble, EInt, EComplex, EuInt etc), and have all mathematical and
00545 // logical operators that are defined for the standard classes be defined
00546 // for the E-classes as well. It would then be easy to introduce errors
00547 // everywhere.
00548 // <p>
00549 // <h4>MeasFrame</h4>
00550 // A MeasFrame is a container with the instance of time
00551 // (an MEpoch) and/or the position (an MPosition) for a measure reference.
00552 // (Other Measures, like MDirection and MRadialVelocity are sometimes needed
00553 // as well).
00554 // MeasFrames are never actually copied, but only referred to (<em>shallow copy</em>)
00555 // , so they can be used for all different types
00556 // of measure reference. They are only necessary, but then essential, if the
00557 // reference type does not fully specify the frame (like e.g. MDirection::J2000,
00558 // or MEpoch::TAI do). Examples are the position necessary to go to
00559 // MEpoch::LAST, the epoch necessary to go to MDirection::APP, the epoch and
00560 // position necessary to reference an MDirection::AZEL.<br>
00561 // A MeasFrame can be constructed empty (and used in references, as long as it
00562 // is filled properly at the time of an actual conversion), or with one or
00563 // Measures already defined with: <src>MeasFrame frame(a_Measure, ...)</src>.
00564 // It can be filled, or re-filled, with <src>set(a_measure,....)</src>.<br>
00565 // The conversion routines use different values of the frame values given (e.g.
00566 // the precession and nutation will need the epoch in TDB time, the hour-angle
00567 // constructor local apparent sidereal time, which needs the astronomical
00568 // longitude etc.). For that reason the specification of an epoch or position
00569 // in either the constructor or the set() will create conversion engines for
00570 // conversion of the input measure to all appropiate values that can be asked
00571 // by the conversion routines. Note that the actual conversion is only done
00572 // when that value is requested (and is then saved for later use). It is,
00573 // therefore, safe and probably good practice to have one frame in a certain
00574 // conversion environment, filled with as much info as is needed at that stage.<br>
00575 // To aid and speed up, <src>resetEpoch()</src> and <src>resetPosition()</src>
00576 // methods are available. As arguments they accept the corresponding
00577 // MV or a variety of Double and Quantum arguments to reset the <em>value</em>
00578 // of the corresponding frame measure only. In that case the conversion engine
00579 // won't be redesigned, leading to fast recalculation when necessary, since
00580 // e.g. nutation values could be re-used.<br>
00581 // In an observing environment you could hence setup a proper frame with the
00582 // Observatory position, and an observing day offset (see MeasRef) time; and
00583 // do resetEpoch() to update the time if and when necessary.<br>
00584 // <p>
00585 // <h4>MeasRef</h4>
00586 // A MeasRef is a measure specific container (and its class reference is
00587 // <src>Measure::Ref</src>, e.g. <src>MFrequency::Ref</src>) with the
00588 // measure reference type (e.g. <src>MEpoch::UTC</src>), an optional (but in
00589 // some cases necessary) MeasFrame (e.g. to specify where the sidereal time
00590 // was determined), and, just for convenience, an optional offset (e.g.
00591 // the MJD for which the time specified in the MEpoch referenced is valid).
00592 // Note that if no frame or offset is necessary, the <src>Measure::TYPE</src>
00593 // can be used everywhere where a <src>Measure::Ref</src> is needed.<br>
00594 // A MeasRef is never copied (all copying and so is done by referencing). This
00595 // means, for example, that if a specific MeasRef is part of the MEpoch
00596 // definition for an epoch that is part of a MeasFrame, and you chnage that
00597 // MeasRef, the change will automatically occur wherever that MeasRef is
00598 // used (as e.g. in the frame). In most cases that is the expected response,
00599 // but you should be aware of it, and not re-use a MeasRef for a completely
00600 // different purpose.<br>
00601 // A simple example:
00602 // <srcblock>
00603 //      MEpoch mytime(MVEpoch(50236.5), MEpoch::UTC);
00604 // // this will define a time in UTC on MJD 50236, 12 hours. The MVEpoch
00605 // // explicit conversion could be left out for most compilers, but some
00606 // // have trouble with automatic conversions.
00607 // // Another way of doing it would be to use Quantities, which have
00608 // // explicit constructors for all measures:
00609 //      MEpoch mytime(Quantity(50236.5, "d"));
00610 // </srcblock>
00611 // A slighty more involved example, written out a bit:
00612 // <srcblock>
00613 // // Specify the location of the observatory (10m high, at given longitude
00614 // // and latitude as geodetic position)
00615 //      MPosition obs(  MVPosition(     Quantity( 10, "m"),
00616 //                                      Quantity( -6, "deg"),
00617 //                                      Quantity( 52, "deg")),
00618 //                      MPosition::WGS84);
00619 // // If the current time is MJD50236, 12.3 h UTC, it could be specified as:
00620 //      MEpoch tim(     MVEpoch(        Quantity( 50236, "d"),
00621 //                                      Quantity( 12.3, "h")));
00622 // // Note the default reference
00623 // // For this example we will also specify it as:
00624 //      MEpoch offtim(tim); 
00625 //      offtim.set(MEpoch::DEFAULT+MEpoch::RAZE);
00626 // // These two could define a frame
00627 //      MeasFrame frame(tim, obs);
00628 // // Or maybe as (since observatory will stay put)
00629 //      MeasFrame frame1(obs);
00630 // // and later addition of some time and its reference frame
00631 //      frame1.set(tim);
00632 // // with a change to another time value at a later stage with
00633 //      frame1.resetEpoch(      MVEpoch(        Quantity( 50236, "d"),
00634 //                                      Quantity( 13, "h")));
00635 // // At this time we observe a sidereal time of 2.3 h. The actual instance
00636 // // of time needs a sidereal date to specify, but we are too lazy to
00637 // // look it up, hence we specify that this time has an offset, equal to
00638 // // the sidereal time at offtim (which with the RAZE addition will be
00639 // // converted to an integral number of days in whatever time it is
00640 // // converted to)
00641 //      MEpoch mylast(  MVEpoch(        Quantity( 2.3, "h")),
00642 //                      MEpoch::Ref(    MEpoch::LAST,
00643 //                                      frame,
00644 //                                      offtim));
00645 // // Which specifies that we have a Local apparent sidereal time of 2.3 h
00646 // // at the position specified by obs in the frame, at an offset offtim.
00647 // // Note that the offset is given in UTC (and RAZE). Any conversion of
00648 // // this mylast value to any other reference type, will always auto start
00649 // // with a conversion of the offset to the current type (i.e LAST (with
00650 // // the RAZE taking the integer part only)), and adding it to the value
00651 // // given. Note that if an output reference has an offset, the resulting
00652 // // value will be corrected for the specified offset as well.
00653 // </srcblock>
00654 // The reference type can be set with a set() function, and set() functions
00655 // for the offset and frame will be present as well.<br>
00656 // A <src>Bool empty()</src> checks if the reference is empty; <src>get()</src>
00657 // functions provide the information in the reference; and a 
00658 // <src>String showMe()</src> will return the type of measure (e.g. "Epoch") the
00659 // MeasRef can be used for.
00660 //<p>
00661 // <h4>MeasConvert</h4>
00662 // The MeasConvert class converts Measures from one reference type and frame
00663 // to another.
00664 // It gathers all relevant
00665 // information and analyses it to have fast multiple conversions.
00666 // The MeasConvert classes are Measure specific, and should be used with
00667 // the class names <src>Measure::Convert</src> (e.g. <src>MFrequency::Convert
00668 // </src>).
00669 // The () operator will do the actual conversion; constructors and set()
00670 // methods will only fill the information necessary to do the conversion.
00671 // MeasConvert is a non-copying container.<br>
00672 // To set up the conversion engine, the MeasConvert object has to know the
00673 // input data reference (remember the MeasRef contains information about the
00674 // type, the possible reference frame and a possible offset), and an output
00675 // reference. Using these references it will communicate with the appropiate
00676 // Measure class to set up a series of routines that have to be executed in
00677 // order to attain the goal. (Note that if the input and output reference
00678 // both define a frame, but different ones, e.g. because you want to convert
00679 // a  sidereal time at one place to a sidereal time at another place, the
00680 // conversion machinery will always first go to the proper default (UTC in this
00681 // case), and then go to the goal).<br>
00682 // The actual conversion need a value to be converted, and it also can use
00683 // a default Unit, so that if your frequencies are in nm, you can once
00684 // specify that they are nm, and then simply convert a Double.<br>
00685 // This means that the optimal constructor for a MeasConvert is:
00686 // <srcblock>
00687 // // The first argument will give the input reference, and, if a Quantum is
00688 // // used to make the Measure, the default units for inputs to the conversion.
00689 // // It acts as a 'model' for subsequent input to be converted.
00690 // // () operator
00691 //      Measure::Convert(       Measure(Quantum), 
00692 // // the second argument gives the output reference
00693 //                              Measure::Ref);
00694 // </srcblock>
00695 // The actual constructors present include ones with the first argument only
00696 // an input reference, rather than a full Measure.
00697 // However, in all cases an empty or partial one can be constructed, with set()
00698 // functions filling in the rest. The conversion engine is only
00699 // (re-)setup if at least an input and output reference can be found.<br>
00700 // After setting up the conversion engine, the () operator can be used with
00701 // a variety of values to return a converted Measure. Possibilities are:
00702 // <srcblock>
00703 //      ()              // convert the value as specified in the 'model'
00704 //      (Double)        // convert the value first to appropiate units (if they
00705 //                      // were implicit in 'model' or explicitly set), and
00706 //                      // then convert
00707 //      (Vector<Double>)// as Double
00708 //      (Quantity)      // convert the full value, including its own units
00709 //      (Quantum<Vector<Double> >) // as Quantity
00710 //      (MeasValue)     // convert the specified appropiate MV
00711 //      (Measure)       // set up a new conversion chain, using the value as
00712 //                      // 'model', and the old output reference,
00713 //                      //  and then convert
00714 //      (Measure, Measure::Ref) // set up a new conversion chain for the
00715 //                      // 'model' given and the output reference given
00716 //      (Measure::Ref)  // set up a new conversion chain using the old 'model'
00717 //                      // and the output reference given, and convert the
00718 //                      // existing model value
00719 // </srcblock>
00720 // A simple example to output the J2000 coordinates for a B1950 input (RA=20 deg,
00721 // DEC=-10 deg):
00722 // <srcblock>
00723 //  cout <<     
00724 //      MDirection::Convert( MDirection( Quantity( 20, "deg")
00725 //                                       Quantity(-10, "deg"),
00726 //                                       MDirection::Ref( MDirection::B1950)),
00727 //                           MDirection::Ref( MDirection::J2000)) () << endl;
00728 // </srcblock>
00729 // In this example everything is done in one go (the () at the end does the
00730 // conversion). Another example, to have a UTC to LAST converter:
00731 // <srcblock>
00732 // // Set up the model for the input (default reference is UTC)
00733 //      MEpoch model (  Quantity(0., "d"));
00734 // // Set up the frame with the observatory position
00735 //      MPosition obs(  MVPosition(     Quantity( 10, "m"),
00736 //                                      Quantity( -6, "deg"),
00737 //                                      Quantity( 50, "deg")),
00738 //                      MPosition::Ref(MPosition::WGS84));
00739 //      Measframe frame( obs);
00740 // // set up the output reference
00741 //      MEpoch::Ref outref(     MEpoch::LAST,
00742 //                              frame);
00743 // // Set up conversion
00744 //      MEpoch::Convert toLST(  model,
00745 //                              outref);
00746 // // Output a series of sidereal times (formatted in ddd::hh:mm:ss)
00747 //      for (Double d = 12345; d<12346; d += 0.1) {
00748 //        cout << "Converted from UTC to LAST: " <<
00749 //              d <<
00750 //              toLST(d).getValue() << endl;
00751 //      };
00752 // </srcblock>
00753 // <p>
00754 // For specific purposes it would be very easy to set up a series of simple
00755 // classes, that would do standard conversions. 
00756 // <p>
00757 // <h4> MeasData, MeasTable, MeasBase, other help classes</h4>
00758 // A series of help classes are present to aid in the conversion, especially
00759 // caching information. They are of no direct use for the end user (except
00760 // maybe a few constants in MeasData).<br>
00761 // The classes are:
00762 // <ul>
00763 //  <li> <linkto class=MeasBase>MeasBase</linkto>:
00764 //      base class (derived from Measure) for all real Measures
00765 //  <li> <linkto class=MeasData>MeasData</linkto>:
00766 //      all constants, polynomial factors, interface to IERS
00767 //      database etc. which are not stored in Tables. (MeasTable looks after 
00768 //      these). Mn short it provides all the actual data values necessary
00769 //      for the conversions (and the other help classes)
00770 //  <li> <linkto class=MeasTable>MeasTable</linkto>:
00771 //      interface for all data that comes from Tables rather than
00772 //      the program
00773 //  <li> <linkto class=MeasIERS>MeasIERS</linkto>:
00774 //      (static) class to converse with the IERS database(s)
00775 //  <li> <linkto class=MeasJPL>MeasJPL</linkto>:
00776 //      (static) class to converse with the JPL DE database(s)
00777 //  <li> <linkto class=Precession>Precession</linkto>:
00778 //       all precession related calculations
00779 //  <li> <linkto class=Nutation>Nutation</linkto>
00780 //  <li> <linkto class=Aberration>Aberration</linkto>
00781 //  <li> <linkto class=SolarPos>SolarPos</linkto>:
00782 //       all solarposition related calculations
00783 //  <li> <linkto class=Euler>Euler</linkto>:
00784 //       representation of Euler rotation angles
00785 //  <li> <linkto class=RotMatrix>RotMatrix</linkto>: a 3-D rotation matrix
00786 // </ul>
00787 // <p>
00788 
00789 // </synopsis> 
00790 //
00791 // <motivation>
00792 // The Measures module originated to be able to convert ccordinates between
00793 // different reference frames.
00794 // </motivation>
00795 //
00796 // <todo asof="1998/07/22">
00797 //   <li> inlining
00798 // </todo>
00799 //
00800 // <example>
00801 // See the individual measures for appropiate examples.
00802 // </example>
00803 // </module>
00804 
00805 //# Dummy class definition for extractor
00806 //# class Measures {};
00807 
00808 
00809 } //# NAMESPACE CASA - END
00810 
00811 #endif