Gyoto
Namespaces | Functions
GyotoConverters.h File Reference

GYOTO converters. More...

#include <GyotoUtils.h>
#include <GyotoSmartPointer.h>
#include <string>
#include <sstream>

Go to the source code of this file.

Namespaces

namespace  Gyoto
 Namespace for the Gyoto library.
 
namespace  Gyoto::Metric
 Access to metrics.
 
namespace  Gyoto::Units
 Units-related classes and functions.
 

Functions

void Gyoto::Units::Init ()
 Load and initialize all (non-context-sensitive) units. More...
 
double Gyoto::Units::ToMeters (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL)
 Convert from arbitrary length unit to meters. More...
 
double Gyoto::Units::FromMeters (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL)
 Convert to arbitrary length unit from meters. More...
 
double Gyoto::Units::ToSeconds (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL)
 Convert from arbitrary time unit to seconds. More...
 
double Gyoto::Units::FromSeconds (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL)
 Convert to arbitrary time unit from seconds. More...
 
double Gyoto::Units::ToKilograms (double value, const std::string &unit)
 Convert from arbitrary mass unit to kilograms. More...
 
double Gyoto::Units::FromKilograms (double value, const std::string &unit)
 Convert to arbitrary mass unit from kilograms. More...
 
double Gyoto::Units::ToGeometrical (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
 Convert from arbitrary length unit to geometrical units. More...
 
double Gyoto::Units::FromGeometrical (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
 Convert to arbitrary length unit from geometrical units. More...
 
double Gyoto::Units::ToGeometricalTime (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
 Convert from arbitrary time unit to geometrical units. More...
 
double Gyoto::Units::FromGeometricalTime (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
 Convert to arbitrary time unit from geometrical units. More...
 
double Gyoto::Units::ToHerz (double value, const std::string &unit)
 Convert from arbitrary frequency unit to Herz. More...
 
double Gyoto::Units::FromHerz (double value, const std::string &unit)
 Convert to arbitrary frequency unit from Herz. More...
 

Detailed Description

GYOTO converters.

As a (recommended) option, Gyoto can use the libudunits2 library by UCAR/Unidata (http://www.unidata.ucar.edu/software/udunits/udunits-2/udunits2.html) to perform conversions to and from various units. Since udunits parses units, the following are equivalent for instance: "mJy.sr-1", "mJy/sr", "1e-3Jy/sr". Gyoto considers every string as UTF-8: either use UTF-8 or stay with ASCII. This means "µ" can be used for "micro" and powers can be noted as superscripts: m³, pix².

In addition to the stock units known by udunits2, Gyoto registers the following (which may be used in any context): Jansky (symbol Jy), symbol "pc" for parsec, "sunradius", "sunmass", symbol "as" for "arcsec".

Other units are context-sensitive: "geometrical" allows converting between geometrical units and other legnth units, but only when a Metric is defined, and may not be used (yet) in compound units. Likewise, "geometrical_time" can be used as duration unit whenever a Metric is defined, but not in a compound unit.

When a Screen is defined, "pix" can be used as an angle unit (you need to call Screen::mapPixUnit() and Screen::unmapScreenUnit(), which is done automatically in certain contexts).

Units can often be specified using the "unit" XML attribute:

<Meric kind="KerrBL">
<Mass unit="sunmass">
4e6
</Mass>
</Metric>
<Screen>
<Distance unit="kpc">
8
</Distance>
<FieldOfView unit="µas">
150
</FieldOfView>
</Metric>

Units for output quantities are specified after the name of the quantity, in squared brackets, e.g.:

<Quantities>
Spectrum[erg.s-1.cm-2.sr-1.Hz-1]
</Quantities>

or

<Quantities>
Spectrum[mJy/pix²]
</Quantities>