1 #ifndef DOUBLE_WITH_UNIT_H 2 #define DOUBLE_WITH_UNIT_H 14 boost::ordered_field_operators<DoubleWithUnit> {
30 { value *= D.
value; units *= D.
units;
return *
this;}
32 { value /= D.
value; units /= D.
units;
return *
this;}
58 return (1.0 / *
this).
convert(R);
64 void print(std::ostream& Os)
const 65 { Os << value <<
" " << units.
name(); }
DoubleWithUnit convert_wave(const Unit &R) const
We often need to handle conversion from wavenumber to/from wavelength.
FullPhysics::DoubleWithUnit min(const FullPhysics::DoubleWithUnit &x, const FullPhysics::DoubleWithUnit &y)
FullPhysics::DoubleWithUnit max(const FullPhysics::DoubleWithUnit &x, const FullPhysics::DoubleWithUnit &y)
DoubleWithUnit & operator-=(const DoubleWithUnit &D)
FullPhysics::DoubleWithUnit floor(const FullPhysics::DoubleWithUnit &x)
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
const Unit dimensionless("dimensionless", 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
double conversion(const Unit &Dunit_from, const Unit &Dunit_to)
Return conversion factor to go from one unit to another.
DoubleWithUnit & operator/=(const DoubleWithUnit &D)
DoubleWithUnit & operator+=(const DoubleWithUnit &D)
This is a Mixin for classes that can be printed.
void print(std::ostream &Os) const
const Unit A("A", 1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)
DoubleWithUnit & operator*=(const DoubleWithUnit &D)
Basic math operators for class.
We frequently have a double with units associated with it.
DoubleWithUnit convert(const Unit &R) const
Convert to the given units.
Libraries such as boost::units allow unit handling where we know the units at compile time...
DoubleWithUnit(double V, const std::string &U)
bool is_commensurate(const Unit &Units) const
Test if this set of units is commensurate with another set.
FullPhysics::DoubleWithUnit round(const FullPhysics::DoubleWithUnit &x)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
DoubleWithUnit(double V, const Unit &U)
bool operator<(const FullPhysics::DoubleWithUnit &A, const FullPhysics::DoubleWithUnit &B)
const std::string & name() const
Name of unit. May be an empty string if a name wasn't assigned.
FullPhysics::DoubleWithUnit ceil(const FullPhysics::DoubleWithUnit &x)
bool operator==(const FullPhysics::DoubleWithUnit &A, const FullPhysics::DoubleWithUnit &B)
We define != in terms of this operator.