Angle

class astropy.coordinates.angles.Angle(angle, unit=None, bounds=(-360, 360)) [edit on github][source]

Bases: object

An angle.

An angle can be specified either as a float, tuple (see below), or string. If A string, it must be in one of the following formats:

  • ‘1:2:3.4’
  • ‘1 2 3.4’
  • ‘1h2m3.4s’
  • ‘1d2m3.4s’
Parameters :

angle : float, int, str, tuple

The angle value. If a tuple, will be interpreted as (h, m s) or (d, m, s) depending on unit. If a string, it will be interpreted following the rules described above.

unit : UnitBase, str

The unit of the value specified for the angle. This may be any string that Unit understands, but it is better to give an actual unit object. Must be one of degree, radian, or hour.

bounds : tuple

A tuple indicating the upper and lower value that the new angle object may have.

Raises :

`~astropy.coordinates.errors.UnitsError` :

If a unit is not provided or it is not hour, radian, or degree.

Attributes Summary

hours The angle’s value in hours (read-only property).
hms The angle’s value in hours, and print as an (h,m,s) tuple (read-only property).
radians The angle’s value in radians (read-only property).
bounds ” The angle’s bounds, an immutable property.
degrees The angle’s value in degrees (read-only property).
dms The angle’s value in degrees, and print as an (d,m,s) tuple (read-only property).

Methods Summary

format([unit, decimal, sep, precision, ...]) A string representation of the angle.

Attributes Documentation

hours[source]

The angle’s value in hours (read-only property).

hms[source]

The angle’s value in hours, and print as an (h,m,s) tuple (read-only property).

radians[source]

The angle’s value in radians (read-only property).

bounds[source]

” The angle’s bounds, an immutable property.

degrees[source]

The angle’s value in degrees (read-only property).

dms[source]

The angle’s value in degrees, and print as an (d,m,s) tuple (read-only property).

Methods Documentation

format(unit=Unit("deg"), decimal=False, sep='fromunit', precision=5, alwayssign=False, pad=False) [edit on github][source]

A string representation of the angle.

Parameters :

units : UnitBase

Specifies the units, should be ‘degree’, ‘hour’, or ‘radian’

decimal : bool

If True, a decimal respresentation will be used, otherwise the returned string will be in sexagesimal form.

sep : str

The separator between numbers in a sexagesimal representation. E.g., if it is ‘:’, the result is “12:41:11.1241”. Also accepts 2 or 3 separators. E.g., sep='hms' would give the result “12h41m11.1241s”, or sep=’-:’ would yield “11-21:17.124”. Alternatively, the special string ‘fromunit’ means ‘dms’ if the unit is degrees, or ‘hms’ if the unit is hours.

precision : int

The level of decimal precision. if decimal is True, this is the raw precision, otherwise it gives the precision of the last place of the sexagesimal representation (seconds).

alwayssign : bool

If True, include the sign no matter what. If False, only include the sign if it is necessary (negative).

pad : bool

If True, include leading zeros when needed to ensure a fixed number of characters for sexagesimal representation.

Returns :

strrepr : str

A string representation of the angle.

Page Contents