GyotoConverters.h File Reference

GYOTO converters. More...

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

Go to the source code of this file.

Classes

class  Gyoto::Units::Unit
 Wrapper around ut_unit from udunits. More...
class  Gyoto::Units::Converter
 Wrapper around ut_converter from udunits. More...

Namespaces

namespace  Gyoto
 

Namespace for the Gyoto library.


namespace  Gyoto::Metric
 

Access to metrics.


namespace  Gyoto::Units
 

Units-related classes and functions.


Functions

ut_system * Gyoto::Units::getSystem ()
 Retrieve the unit system used in all of Gyoto.
void Gyoto::Units::Init ()
 Load and initialize all (non-context-sensitive) units.
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.
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.
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.
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.
double Gyoto::Units::ToKilograms (double value, const std::string &unit)
 Convert from arbitrary mass unit to kilograms.
double Gyoto::Units::FromKilograms (double value, const std::string &unit)
 Convert to arbitrary mass unit from kilograms.
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.
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.
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.
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.
double Gyoto::Units::ToHerz (double value, const std::string &unit)
 Convert from arbitrary frequency unit to Herz.
double Gyoto::Units::FromHerz (double value, const std::string &unit)
 Convert to arbitrary frequency unit from Herz.
bool Gyoto::Units::areConvertible (const Unit &unit1, const Unit &unit2)
 Is it possible to convert between unit1 and unit2?

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>

Generated on 6 May 2017 for Gyoto by  doxygen 1.6.1