- N_Types
- DEFAULT = 0
Measures can in general be constructed from a MeasRef and a value. The value can be expressed in the internally used units (e.g. MVEpoch for MEpoch, MVDirection for MDirection), or as a Quantum, i.e. a value with a dimension (e.g. (20,"km/s")) (see Quantum class). The preferred way of construction is by using the constructor:
Measure(MVmeasure, Measure::Ref)where the reference can be omitted, defaulting to Measure::DEFAULT), or in simple cases (not needing additional frame information) be specified directly as a code (e.g. MEpoch::IAT).
The value of the Measure can be obtained by a variety of
get functions, returning in general internal or Quantum
values. The preferred way is a getValue(void), which returns
the specific MVmeasure value, which can then be further formatted
using the appropiate MVmeasure get() functions.
Special formatting (like hh:mm:ss.t, dd.mm.ss.t, yy/mm/dd etc)
are catered for in conversion-type classes like
MVAngle,
MVTime.
Conversion (within a Measure type) from one reference frame to another
is done by the MeasConvert class. The
class is templated, but has typedefs Measure::Convert (e.g.
MEpoch::Convert) for easy, and recommended, reference.
The basic constructors for a
Measure::Convert are:
// With a default Measure included Measure::Convert(Measure val, Measure::Ref outref); // With only input and output reference frames given Mesaure::Convert( Measure::Ref inref, Measure::Ref outref);The val is used as a model for subsequent input values into this conversion engine, including possible units; the outref specifies the output reference frame wanted. The constructor analyses the conversion wanted, and sets up a vector of routine calls to be called in sequence for the conversion. The actual conversion is done by the () operator.
In the member description a number of dummy routines are present. They are the only way I have found to get cxx2html to get the belonging text properly present.
#include <aips/Measures.h> #include <aips/Measure/MEpoch.h> // Example is only to show what can be done, not the easiest way // Set up a simple reference (no offset or secondary Measures). It // indicates that times are given in MJD TAI. MEpoch::Ref reftai(MEpoch::TAI); // Same, but indicating MJD UTC MEpoch::Ref refutc(MEpoch::UTC); // Set up an MEpoch (note that no reference is given. In that case a // default is assumed (for MEpoch UTC). MJD2000 is a provided constant // of the MJD at 2000.0 MEpoch UTCval(Quantity(MeasData::MJD2000, "d"), reftai); // Set up, just for fun, an epoch, UTC for B1950.0: MEpoch val1950(Quantity(MeasData::MJDB1950, "d")); // and use it as an offset in a reference MEpoch::Ref ref1950(MEpoch::TAI, val1950); // An epoch for J2000 with an offset of B1950.0 will than be MEpoch val20_50(Quantity(MeasData::MJD2000-MeasData::MJDB1950, "d"), ref1950); // Set up conversion from TAI(with values in days w.r.t. B1950.0) to UTC: MEpoch::Convert tai_to_utc(val20_50, refutc); // And convert a value (in this case the value in val20_50, the model) // from TAI(relative to B1950.0) to 'absolute' UTC MEpoch result = tai_to_utc(); // Show result cout << "Result 1: " << result << endl; // To convert 10 years since B1950.0 result = tai_to_utc(Quantity(10.,"a")); cout << "Result 2: " << result << endl; // To convert any value in years(the last used units of the model) since B1950.0 result = tai_to_utc(12.3); cout << "Result 3: " << result << endl;Which generates the output:
Result 1: Epoch: 51544::11:59:25.2154 Result 2: Epoch: 36934::10:09:42.1283 Result 3: Epoch: 37774::11:57:41.1085
enum Types { CODE1, CODE2, ..., N_Types, // Number of types SPEC1 = n, // Possible special manipulator code ....., SYNONYM1 = CODEn, // Probable synonyms ...., DEFAULT = CODEm};Dummy for cxx2html
friend class MeasConvert<a_Measure, its_MV, its_MC>;Output a Measure
Destructor
Each Measure should have the following set functions (with appropiate MVs and Ref):
void set(const MVmeasure &dt); void set(const Measure::Ref &rf); void set(const MVmeasure &dt, const Measure::Ref &rf);
Check the type of derived Measure entity (e.g. "Epoch")
Each Measure should have the following static methods to give its
name (e.g. Epoch) or reference type (e.g. UTC):
// Show the Measure type (e.g. "Direction") static const String &showMe(); // Cast an integer to the appropriate reference type. Avaialable to provide // a safe cast in cases where Measure type is not explicitly known. static Measure::Types castType(uInt tp); // Show the reference type (e.g. MEpoch::showType(MEpoch::IAT) == "TAI") static const String &showType(uInt tp); static const String &showType(Measure::Types tp);
Each derived class should have a string-to-code translation routine for the reference type. The routine returns False if unknown String (and a default mr), else an appropiate mr reference.
Bool giveMe(Measure::Ref &mr, const String &in); static Bool getType(Measure::Types &tp, const String &in);
Dummy for cxx2html
Set the reference type to the specified String. False if illegal string, reference set to DEFAULT.
static const String *const allMyTypes(Int &nall, Int &nextra, const uInt *&typ);
Check if all internal tables of types (both enum and String) are complete and correct. This function is called automatically if and when necessary.
static void checkMyTypes();
A general string checking routine to be used in derived measures. Its arguments are the string to be converted (in), an array of strings to check against (tname), and its length (N_name). The check is case insensitive and mini-max. A return value less than N_name indicates success.
Measure::Ref getRef() const;
Dummy for cxx2html
Each derived class should be able to get its internal value and have:
const MVmeasure &getValue() const;To get dimensioned data, each derived class should contain the appropiate one of:
Quantity get(const Unit &unit) const; Quantum<Vector<Double> > get(const Unit &unit) const;
Get unit (only available if Measure generated from a Quantum, else "")
Get data pointer (used by MeasConvert)
Get general reference pointer
Print a Measure
MVmeasure data;Reference frame data
MeasRef<Measure> ref;Possible input units
Unit unit;And maybe later (or somewhere else)
MeasErr error;
Clear the measure