to

AngularPosition.to(target_unit: str, inplace: bool = False) AngularPosition

It converts actual value to a new value computed using target_unit as the reference unit of measurement.

If inplace is True, it overrides actual value and unit, otherwise it returns a new instance with the converted value and the target_unit as unit.

Parameters

target_unitstr

Target unit to which convert the current value.

inplacebool, optional

Whether to override the current instance value. Default is False, so it does not override the current value.

Returns

AngularPosition

Converted angular position.

Raises

TypeError
  • If target_unit is not a str,

  • if inplace is not a bool.

KeyError

If the target_unit is not among available ones.

Examples

AngularPosition instantiation.

>>> from gearpy.units import AngularPosition
>>> p = AngularPosition(180, 'deg')
>>> p
180 deg

Conversion from degree to radian with inplace=False by default, so it does not override the current value.

>>> p.to('rad')
3.141592653589793 rad
>>> p
180 deg

Conversion from degree to minute of arc with inplace=True, in order to override the current value.

>>> p.to('arcmin', inplace=True)
10800.0 arcmin
>>> p
10800.0 arcmin