|
casacore
|
#include <MVAngle.h>
Classes | |
| class | Format |
| Format structure. More... | |
Public Types | |
| enum | formatTypes { ANGLE , TIME , CLEAN , NO_D , NO_DM , DIG2 , FITS , LOCAL , USE_SPACE , ALPHA , NO_H , NO_HM , ANGLE_CLEAN , ANGLE_NO_D , ANGLE_NO_DM , ANGLE_CLEAN_NO_D , ANGLE_CLEAN_NO_DM , TIME_CLEAN , TIME_NO_H , TIME_NO_HM , TIME_CLEAN_NO_H , TIME_CLEAN_NO_HM , MOD_MASK } |
| Format types. More... | |
Public Member Functions | |
| MVAngle () | |
| Default constructor: generate a zero value. | |
| MVAngle (const MVAngle &other) | |
| Copy constructor. | |
| MVAngle & | operator= (const MVAngle &other) |
| Copy assignment. | |
| MVAngle (Double d) | |
| Constructor from Double. | |
| MVAngle (const Quantity &other) | |
| Constructor from Quantum : value can be an angle or time. | |
| ~MVAngle () | |
| Destructor. | |
| operator Double () const | |
| Conversion operator. | |
| const MVAngle & | operator() () |
| Normalisation between -180 and +180 degrees (-pi and +pi). | |
| const MVAngle & | operator() (Double norm) |
| Normalisation between 2pi*norm and 2pi*norm + 2pi. | |
| const MVAngle & | operator() (const MVAngle &norm) |
| Normalisation between norm-pi and norm+pi. | |
| const MVAngle & | binorm (Double norm) |
| Normalisation between pi*norm and pi*norm + pi. | |
| MVAngle | coAngle () const |
| Make co-angle (e.g. | |
| Double | radian () const |
| Get value in given unit. | |
| Double | degree () const |
| Double | circle () const |
| Quantity | get () const |
| Quantity | get (const Unit &inunit) const |
| String | string () const |
| Output data Warning: The first function below is thread-unsafe because it uses the result of the setFormat function which changes a static class member; The other functions are thread-safe because the format is directly given; . | |
| String | string (MVAngle::formatTypes intyp, uInt inprec=0) const |
| String | string (uInt intyp, uInt inprec) const |
| String | string (uInt inprec) const |
| String | string (const MVAngle::Format &form) const |
| void | print (ostream &oss, const MVAngle::Format &form) const |
| void | print (ostream &oss, const MVAngle::Format &form, Bool loc) const |
Static Public Member Functions | |
| static Bool | unitString (UnitVal &uv, String &us, MUString &in) |
| Check if String unit. | |
| static Bool | read (Quantity &res, const String &in, Bool chk=True) |
| Make res angle Quantity from string in angle/time-like format. | |
| static Bool | read (Quantity &res, MUString &in, Bool chk=True) |
| static Bool | read (Quantity &res, const String &in, Bool chk, Bool throwExcp) |
| static Bool | read (Quantity &res, MUString &in, Bool chk, Bool throwExcp) |
| static Bool | handleReadError (MUString &in, Bool throwExcp) |
| Handle a read error. | |
| static Format | setFormat (MVAngle::formatTypes intyp, uInt inprec=0) |
| Set default format Warning: It is thread-unsafe to print using the setFormat functions because they change a static class member; The only thred-safe way to print a time is to use the print function above; . | |
| static Format | setFormat (uInt intyp, uInt inprec) |
| static Format | setFormat (uInt inprec=0) |
| static Format | setFormat (const Format &form) |
| static Format | getFormat () |
| Get default format. | |
| static MVAngle::formatTypes | giveMe (const String &in) |
| Get code belonging to string. | |
| static Double | timeZone () |
| Get time zone offset (in days). | |
Private Attributes | |
| Double | val |
| Value. | |
Static Private Attributes | |
| static MVAngle::Format | defaultFormat |
| Default format. | |
| static MVAngle::Format | interimFormat |
| Temporary format. | |
| static Bool | interimSet |
Friends | |
| ostream & | operator<< (ostream &os, const MVAngle &meas) |
| Output an angle. | |
| istream & | operator>> (istream &is, MVAngle &meas) |
| Input an angle. | |
| ostream & | operator<< (ostream &os, const MVAngle::Format &form) |
| Set a temporary format. | |
Class to handle angle type conversions and I/O
Public interface
From Measure, Value and Angle
An MVAngle is a simple Double, to be used for angle conversions and I/O. It can be constructed from a Double (in which case radians are assumed), or from a Quantity (Quantum<Double>). Quantities must be in either angle or time units.
It has an automatic conversion to Double, so all standard mathematical operations can operate on it.
The class has a number of special member operations:
Output formatting is done with the << statement, with the following rules:
output can be formatted by using either the setFormat() method for global angle format setting, or the output of MVAngle::Format() data for a once off change (see later). Formats have a first argument which determines the type (default, if not given, MVAngle::ANGLE, other possibility MVAngle::TIME (as hh:mm:ss.tt..), the second the number of digits wanted (default stream precision), with a value:
comparable for time;
Tip: The added periods are to enable input checking of the format; Look at the 'clean' types to bypass them;
The output format can be modified with modifiers (specify as MVAngle::ANGLE | MVAngle::MOD (or + MVAngle::MOD)).
Caution: For overloading/casting problems with some compilers, the use of modifiers necessitates either the presence of a precision (i;e; (A|B, prec)), or an explicit cast: ((MVAngle::formatTypes)(A|B)), or make use of the provided ANGLE[_CLEAN][_NO_D[M]] and TIME[_CLEAN][_NO_H[M]];
The modifiers can be:
Output in formats like 20' can be done via the standard Quantum output (e.g. stream << angle.get("'") ).
The default formatting can be overwritten by a MVAngle::setFormat(); statement; which returns an MVAngle::Format structure, that can be used in a subsequent one to reset to previous. The format set holds for all MVAngle output on all streams.
Temporary formats (i.e. for one MVAngle output only), can be set by outputting a format (i.e. stream << MVAngle::Format() <<... ).
Caution: A setFormat() will also reset any lingering temporary format; A setFormat(getFormat()) will reset without changing; Problems could arise in parallel processors;
Input can be read if the values are in any of the above (non-clean) output formats.
For other formatting practice, the output can be written to a String with the string() member function.
Note that using a temporary format is inherently thread-unsafe because the format is kept in a static variable. Another thread may overwrite the format just set. The only thread-safe way to format an MVTime is using a print or string that accepts a Format object.
Strings and input can be converted to an MVAngle (or Quantity) by Bool read(Quantity &out, const String &in) and istream >> MVAngle &. In the latter case the actual reading is done by the String read, which reads between white-spaces.
The following input formats (note no blanks allowed) are supported (+stands for an optional + or -; v for an unsigned integer; dv for a floating number. [] indicate optional values. Separating codes are case insensitive):
Examples of valid strings:
Caution: In general the input will be read as a Quantity; Reading of Quantities will always try to read special formats (like MVAngle, MVTime) first; In that case problems could arise converting strings like 5d, 5::, 5hm, 5dm; In 'angle' mode they could have meant to be 5d0m, 5:0:, 5h0m, 5d0m, but they could have meant: days, min, hectometre, decimetre; In the same vain 5d2 could have meant 5d2m or 5 d2; To try to guess the general use, the following interpretation is made:
To be able to format angle-like values in user-required ways.
| casacore::MVAngle::MVAngle | ( | ) |
Default constructor: generate a zero value.
Referenced by binorm(), coAngle(), MVAngle(), operator()(), operator()(), operator()(), operator<<, operator=(), and operator>>.
| casacore::MVAngle::MVAngle | ( | const MVAngle & | other | ) |
Copy constructor.
References MVAngle().
| casacore::MVAngle::MVAngle | ( | const Quantity & | other | ) |
| casacore::MVAngle::~MVAngle | ( | ) |
Destructor.
Normalisation between pi*norm and pi*norm + pi.
References MVAngle(), and casacore::norm().
| Double casacore::MVAngle::circle | ( | ) | const |
| MVAngle casacore::MVAngle::coAngle | ( | ) | const |
| Double casacore::MVAngle::degree | ( | ) | const |
| Quantity casacore::MVAngle::get | ( | ) | const |
|
static |
Get default format.
|
static |
Get code belonging to string.
0 if not known
Handle a read error.
An exception is thrown if indicated so. Otherwise in.pop() is called and False is returned.
| casacore::MVAngle::operator Double | ( | ) | const |
Conversion operator.
| const MVAngle & casacore::MVAngle::operator() | ( | ) |
Normalisation between -180 and +180 degrees (-pi and +pi).
References MVAngle().
Normalisation between norm-pi and norm+pi.
References MVAngle(), and casacore::norm().
Normalisation between 2pi*norm and 2pi*norm + 2pi.
References MVAngle(), and casacore::norm().
Copy assignment.
References MVAngle().
| void casacore::MVAngle::print | ( | ostream & | oss, |
| const MVAngle::Format & | form ) const |
| void casacore::MVAngle::print | ( | ostream & | oss, |
| const MVAngle::Format & | form, | ||
| Bool | loc ) const |
| Double casacore::MVAngle::radian | ( | ) | const |
Get value in given unit.
Make res angle Quantity from string in angle/time-like format.
In the case of String input, also quantities are recognised. chk=True means that the entire string should be consumed. throwExcp=True means that an exception is thrown in case of an error.
References casacore::True.
References casacore::True.
|
static |
Set default format
Warning: It is thread-unsafe to print using the setFormat functions because they change a static class member; The only thred-safe way to print a time is to use the print function above;
.
| String casacore::MVAngle::string | ( | ) | const |
Output data
Warning: The first function below is thread-unsafe because it uses the result of the setFormat function which changes a static class member; The other functions are thread-safe because the format is directly given;
.
| String casacore::MVAngle::string | ( | const MVAngle::Format & | form | ) | const |
| String casacore::MVAngle::string | ( | MVAngle::formatTypes | intyp, |
| uInt | inprec = 0 ) const |
|
static |
Get time zone offset (in days).
Check if String unit.
|
friend |
Output an angle.
References MVAngle().
|
friend |
Set a temporary format.
|
staticprivate |
|
staticprivate |