Classes for celestial mechanics¶
This section is the documentation for developpers of classes related to celestial mechanics.
This page is generated according the docstrings of the python code. It displays only public methods of classes.
Module celme¶
celme.dates¶
-
class
celme.dates.
Date
(date='')[source]¶ Class to convert dates for astronomy
Date formats are:
now = Now. e.g. “now”jd = Julian day. e.g. 24504527.45678iso = ISO 8601. e.g. 2018-02-28T12:34:55.23sql = ISO 8601. e.g. 2018-02-28 12:34:55.23ymdhms = Calendar. e.g. 2018 2 28 12 34 55.23equinox = Equinox. e.g. J2000,0digits = Pure digits e.g. 20180228123455.23Usage:
First, instanciate an object from the class:
- ::
date = Date()
Second, assign a date in any date format:
- ::
date.date(“2018-02-28T12:34:55”)
Third, get the converted date:
- ::
jd = date.jd() date = date.date() iso = date.iso() ymdhms = date.ymdhms() equinox = date.equinox()
Informations:
All dates are in UTC. Some other useful methods:
- ::
help(Date) Date().infos(“doctest”) Date().infos(“doc_methods”)
-
__add__
(duration)[source]¶ Add a duration to a date
- Parameters
duration (string) – Duration in dhms format (e.g 3d20h5m3s).
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") ; date = objdate + "12m45s" ; date.iso() '2018-02-28T12:34:55.234' '2018-02-28T12:47:40.234'
-
__eq__
(date)[source]¶ Comparaison of dates. Return True if dates are defined and equals.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 28"); objdate2 = Date("2018 02 28"); objdate == objdate2 '2018 02 28' True
-
__ge__
(date)[source]¶ Comparaison of dates: date1 >= date 2. Return True if dates are defined and date1 >= date 2.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 28"); objdate2 = Date("2018 02 27"); objdate >= objdate2 '2018 02 28' True
-
__gt__
(date)[source]¶ Comparaison of dates: date1 > date 2. Return True if dates are defined and date1 > date 2.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 28"); objdate2 = Date("2018 02 27"); objdate > objdate2 '2018 02 28' True
-
__isub__
(duration)[source]¶ Subtract a duration to a date
- Parameters
duration (str) – Duration in dhms format (e.g 3d20h5m3s)
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") ; objdate -= "12m45s" ; objdate.iso() '2018-02-28T12:34:55.234' '2018-02-28T12:22:10.234'
-
__le__
(date)[source]¶ Comparaison of dates: date1 <= date 2. Return True if dates are defined and date1 <= date 2.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 26"); objdate2 = Date("2018 02 27"); objdate <= objdate2 '2018 02 26' True
-
__lt__
(date)[source]¶ Comparaison of dates: date1 < date 2. Return True if dates are defined and date1 < date 2.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 26"); objdate2 = Date("2018 02 27"); objdate < objdate2 '2018 02 26' True
-
__ne__
(date)[source]¶ Comparaison of dates. Return True if dates are defined and not equals.
- Parameters
date (Date) – An object instancied on Date
- Example
>>> objdate = Date() >>> objdate.date("2018 02 28"); objdate2 = Date("2018 02 28"); objdate != objdate2 '2018 02 28' False
-
__sub__
(object_or_duration)[source]¶ Subtract a duration to a date (returns an object date) or Compute the duration between two date objects.
- Parameters
object_or_duration (Date object) – Duration in dhms format (e.g 3d20h5m3s)
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") ; date = objdate - "12m45s" ; date.iso() '2018-02-28T12:34:55.234' '2018-02-28T12:22:10.234' >>> objdate.date("2018-02-28T12:34:55.234") ; objdate2 = Date("2018-02-25T12:34:55.234") ; days = objdate - objdate2 ; print(days) '2018-02-28T12:34:55.234' 3.0
-
date
(date='')[source]¶ Set the input date in any format
- Parameters
date (any) – date is a date in any supported format (cf. help(Date))
- Returns
The input date.
- Return type
string
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") '2018-02-28T12:34:55.234'
Note
After using objdate.date() get conversions with methods as objdate.jd() or objdate.iso().
-
date_date2jd
(date) → Tuple[int, float][source]¶ Compute a julian day from any date format
- Parameters
date (string) – A string formated as “2d7h23m12.5s”
- Returns
A tuple of init_dateformat, julian day. init_dateformat: The identified format of the input: * 0 = Error, format not known * 1 = Now * 2 = Equinox * 3 = Sql * 4 = Calendar * 5 = ISO 8601 * 6 = Julian day * 7 = Modified Julian day * 8 = Digits
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_date2jd("2018-02-28T12:34:55.234") (5, 2458178.0242503937)
Note
Prefer using objdate.date() followed by objdate.jd().
-
date_digits2jd
(string)[source]¶ Compute a julian day from a date with only digits
- Parameters
string (string) – A string formated in digits
- Returns
A tuple of error, julian day. error = 0 means no error
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_iso2jd("2018-02-28T12:34:55.234") (0, 2458178.0242503937)
First integer is an error code. 0 = no problem.
Note
Prefer using objdate.date() followed by objdate.digits().
-
date_equinox2jd
(string)[source]¶ Compute a julian day from a equinoxal date
- Parameters
string (string) – date string is a string in Equinox format (cf. help(Date))
- Returns
A tuple of error, julian day. error = 0 means no error
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_equinox2jd("J2025,0") (0, 2460676.25)
Note
Prefer using objdate.date() followed by objdate.jd()
-
date_iso2jd
(string) → tuple[source]¶ Compute a julian day from a ISO8601 date
- Parameters
string (string) – A string formated in ISO 8601
- Returns
A tuple of error, julian day. error = 0 means no error
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_iso2jd("2018-02-28T12:34:55.234") (0, 2458178.0242503937)
First integer is an error code. 0 = no problem.
Note
Prefer using objdate.date() followed by objdate.jd().
-
date_jd2digits
(jd, nb_subdigit=3)[source]¶ Compute a date only with digits from a julian day
- Parameters
jd (float) – A julian day
nb_subdigit (int) – The number of digits returned after the seconds.
- Returns
A tuple of error, string of a date formatted into ISO8601. error = 0 means no error.
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_jd2iso(2458178.0242503937) (0, '2018-02-28T12:34:55.234')
Note
Prefer using objdate.date() followed by objdate.digits()
-
date_jd2equinox
(jd, year_type='', nb_subdigit=1)[source]¶ Compute an equinoxal date from a julian day
- Parameters
jd (float) – A julian day
year_type (string) – “B” (Bessel) or “J” (Julian) or “” for automatic choice
nb_subdigit (int) – The number of digits returned after the year.
- Returns
A tuple of error, string of a date formatted into ISO8601. error = 0 means no error.
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_jd2equinox(2458178.0242503937) (0, 'J2018.2')
Note
Prefer using objdate.date() followed by objdate.equinox()
-
date_jd2iso
(jd, nb_subdigit=3, letter='T') → tuple[source]¶ Compute a ISO8601 date from a julian day
- Parameters
jd (float) – A julian day
nb_subdigit (int) – The number of digits returned after the seconds.
letter (int) – The letter to separe date end time. If letter is “” then the output format sticks all digits without any characters :-T. So the format is no longer ISO but useful for a pure digit code.
- Returns
A tuple of error, string of a date formatted into ISO8601. error = 0 means no error.
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_jd2iso(2458178.0242503937) (0, '2018-02-28T12:34:55.234')
Note
Prefer using objdate.date() followed by objdate.iso()
-
date_jd2ymd
(jd)[source]¶ Compute a calendar date from a julian day
- Parameters
jd (float) – Julian day
- Example
>>> objdate = Date() >>> objdate.date_jd2ymd(2457825.14232) (0, 2017, 3, 12.64232000010088)
First integer is an error code. 0 = no problem. Following items are:
year = year
month = month
day = day and fraction of day
- Related topics
Prefer using objdate.date() followed by objdate.ymdhms()
-
date_jd2ymdhms
(jd)[source]¶ Compute a calendar date from a julian day
- Parameters
jd (float) – Julian day
- Example
>>> objdate = Date() >>> objdate.date_jd2ymdhms(2457824.516115046) (0, 2017, 3, 12, 0, 23, 12.339983582496643)
First integer is an error code. 0 = no problem. Following items are:
y = year
m = month
d = day
hh = hour
mm = minutes
ss = seconds
- Related topics
Prefer using objdate.date() followed by objdate.ymdhms()
-
date_ymd2jd
(year, month, day)[source]¶ Compute a julian day from a calendar date
- Parameters
year (int) – Year
month (int) – Month
day (float) – Day and fraction of the day
- Example
>>> objdate = Date() >>> objdate.date_ymd2jd(2017,3,12.64232) (0, 2457825.14232)
First integer is an error code. 0 = no problem.
- Related topics
Prefer using objdate.date() followed by objdate.jd()
-
date_ymdhms2jd
(y: int, m: int, d: int, hh: int = 0, mm: int = 0, ss: float = 0) → tuple[source]¶ Compute a julian day from a calendar date
- Parameters
y (int) – Year
m (int) – Month
d (int) – Day
hh (int) – Hour
mm (int) – Minutes
ss (float) – Seconds
- Returns
A tuple of error, float corresponding to the julian day. error = 0 means no error.
- Return type
tuple(int, float)
- Example
>>> objdate = Date() >>> objdate.date_ymdhms2jd(2017,3,12,0,23,12.34) (0, 2457824.516115046)
First integer is an error code. 0 = no problem.
- Related topics
Prefer using objdate.date() followed by objdate.jd()
-
digits
(nb_subdigit=3)[source]¶ Get the date in digits format
- Parameters
nb_subdigit (int) – The number of digits returned after the seconds.
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") '2018-02-28T12:34:55.234' >>> objdate.iso(2) '2018-02-28T12:34:55.23'
- Related topics
Before use objdate.date() to set the input date.
-
equinox
(year_type='J', nb_subdigit=1)[source]¶ Get the date in equinox format
- Parameters
year_type (string) – “B” (Bessel) or “J” (Julian) or “” for automatic choice
nb_subdigit (int) – The number of digits returned after the year.
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") '2018-02-28T12:34:55.234' >>> objdate.equinox() 'J2018.2'
- Related topics
Before use objdate.date() to set the input date.
-
infos
(action)[source]¶ To get informations about this class
- Parameters
action (string) – A command to run a debug action (see examples).
- Example
Date().infos("doctest") Date().infos("doc_methods") Date().infos("internal_attributes") Date().infos("public_methods")
-
iso
(nb_subdigit=3, letter='T')[source]¶ Get the date in ISO 8601 format
- Parameters
nb_subdigit (int) – The number of digits returned after the seconds.
letter (int) – The letter to separe date end time. If letter is “” then the output format sticks all digits without any characters :-T. So the format is no longer ISO but useful for a pure digit code.
- Example
>>> objdate = Date() >>> objdate.date("2018-02-28T12:34:55.234") '2018-02-28T12:34:55.234' >>> objdate.iso(2) '2018-02-28T12:34:55.23'
- Related topics
Before use objdate.date() to set the input date.
celme.durations¶
-
class
celme.durations.
Duration
(duration='')[source]¶ Class to convert dates for astronomy
Date formats are:
day = days. e.g. 12.3457
dhms = day, hour, minutes seconds. e.g. 2d12h34m55.23s
-
__add__
(duration)[source]¶ Add a duration to a duration.
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The result of the addition
- Return type
Duration()
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.25) ; objduration2.duration("56d28m") ; objduration = objduration1 + objduration2 ; objduration.dhms("+0.3") 12.25 '56d28m' '+68d06h28m00.000s'
-
__eq__
(duration)[source]¶ Comparaison of durations. Return True if durations are defined and equals.
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 == objduration2 12.345 '56d28m' False
-
__ge__
(duration)[source]¶ Comparaison of durations. Return True if self >= duration
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 >= objduration2 12.345 '56d28m' False
-
__gt__
(duration)[source]¶ Comparaison of durations. Return True if self > duration
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 > objduration2 12.345 '56d28m' False
-
__isub__
(duration)[source]¶ Subtract a duration to a duration.
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The result of the addition
- Return type
Duration()
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.25) ; objduration2.duration("56d28m") ; objduration1 -= objduration2 ; objduration1.dhms("+0.3") 12.25 '56d28m' '-43d18h28m00.000s'
-
__le__
(duration)[source]¶ Comparaison of durations. Return True if self <= duration
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 <= objduration2 12.345 '56d28m' True
-
__lt__
(duration)[source]¶ Comparaison of durations. Return True if self < duration
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 < objduration2 12.345 '56d28m' True
-
__mul__
(multiplier)[source]¶ multiplication of duration by a float or int. Return a duration
- Parameters
multiplier (float) – A real number
- Returns
A duration
- Return type
Duration()
- Example
>>> objduration = Duration() >>> objduration.duration(30.43) ; (objduration*2).day() 30.43 60.86
-
__ne__
(duration)[source]¶ Comparaison of durations. Return True if durations are defined and not equals.
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The logic result of the comparison.
- Return type
bool
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.345) ; objduration2.duration("56d28m") ; objduration1 != objduration2 12.345 '56d28m' True
-
__sub__
(duration)[source]¶ Subtract a duration to a duration.
- Parameters
duration (Duration()) – A duration in any supported format (cf. help(Duration))
- Returns
The result of the addition
- Return type
Duration()
- Example
>>> objduration1 = Duration() >>> objduration2 = Duration() >>> objduration1.duration(12.25) ; objduration2.duration("56d28m") ; objduration = objduration1 - objduration2 ; objduration.dhms("+0.3") 12.25 '56d28m' '-43d18h28m00.000s'
-
__truediv__
(divisor)[source]¶ division of an angle by a float or int. Return a duration
- Parameters
divisor (float) – A real number
- Returns
A duration
- Return type
Duration()
- Example
>>> objduration = Duration() >>> objduration.duration(30.43) ; (objduration/2).day() 30.43 15.215
-
day
()[source]¶ Get the date in julian day format
- Returns
The julian day.
- Return type
float
- Example
>>> objduration = Duration() >>> objduration.duration("2d7h23m12.5s") '2d7h23m12.5s' >>> objduration.day() 2.3077835648148146
Note
After using objdate.duration() get conversion with objdate.day().
-
dhms
(dhms_format)[source]¶ Get the date in dhms format
- Parameters
dhms_format (string) – dhms format (cf. help(Duration))
- Returns
The formated string.
- Return type
string
- Example
>>> objduration = Duration() >>> objduration.duration("2d7h3m12.5s") '2d7h3m12.5s' >>> objduration.dhms("0") '2d07h03m12.50s'
Note
After using objdate.duration() get conversion with objdate.dhms().
-
duration
(duration='')[source]¶ Set the input duration in any format
- Parameters
duration (any) – duration is a duration in any supported format (cf. help(Duration))
- Returns
The input duration.
- Return type
string
- Example
>>> objduration = Duration() >>> objduration.duration("2d7h23m12.5s") '2d7h23m12.5s'
Note
After using objdate.duration() get conversions with methods as objdate.day() or objdate.dhms().
-
duration_duration2day
(duration) → Tuple[int, float][source]¶ Compute day number from any duration format
- Parameters
date (string) – A string formated as “2d7h23m12.5s” or “2 7 23 12.5”
- Returns
A tuple of decode, julian day. decode : (sign, da, ho, mi, se)
- Return type
tuple(tuple, float)
- Example
>>> objduration = Duration() >>> objduration.duration_duration2day("2d7h23m12.5s") ((1, 2.0, 7.0, 23.0, 12.5), 2.3077835648148146)
Note
Prefer using objduration.duration() followed by objduration.day().
celme.angles¶
-
class
celme.angles.
Angle
(angle='')[source]¶ Class to convert angles for astronomy
Angle formats are:
deg = degrees. e.g.
rad = radian. e.g.
- Usage
First, instanciate an object from the class:
angle = Angle()
Second, assign a date in any angle format:
angle.angle("-0d3m28.56s")
Third, get the converted angle:
rad = angle.rad() deg = angle.deg() arcmin = angle.arcmin() arcsec = angle.arcsec() dms = angle.dms() uspzad = angle.sexagesimal(sexagesimal_format)
- Informations
help(Angle) Angle().infos("doctest") Angle().infos("doc_methods")
-
__add__
(angle)[source]¶ Add an angle to an angle.
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The result of the addition :rtype: Angle()
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle = objangle1 + objangle2 ; objangle.sexagesimal("D") 12.345 '56d28m' '68d48m42.00s'
-
__eq__
(angle)[source]¶ Comparaison of angles. Return True if angles are defined and equals.
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 == objangle2 12.345 '56d28m' False
Note
Does not account for the modulo.
-
__ge__
(angle)[source]¶ Comparaison of angles. Return True if self >= angle
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 >= objangle2 12.345 '56d28m' False
Note
Does not account for the modulo.
-
__gt__
(angle)[source]¶ Comparaison of angles. Return True if self > angle
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 > objangle2 12.345 '56d28m' False
Note
Does not account for the modulo.
-
__isub__
(angle)[source]¶ Subtract an angle to an angle.
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The result of the subtraction :rtype: Angle()
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 -= objangle2 ; objangle1.sexagesimal("D") 12.345 '56d28m' '315d52m42.00s'
-
__le__
(angle)[source]¶ Comparaison of angles. Return True if self <= angle
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 <= objangle2 12.345 '56d28m' True
Note
Does not account for the modulo.
-
__lt__
(angle)[source]¶ Comparaison of angles. Return True if self < angle
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 < objangle2 12.345 '56d28m' True
Note
Does not account for the modulo.
-
__mod__
(angle)[source]¶ Modulo of an angle by another angle. Return an angle
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: An angle :rtype: Angle()
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(30.56) ; objangle2.angle(2.34) ; (objangle1 % objangle2).deg() 30.56 2.34 0.14000000000000412
-
__mul__
(multiplier)[source]¶ multiplication of an angle by a float or int. Return an angle
- Parameters
multiplier (float) – A real number
- Returns
An angle
- Return type
Angle()
- Example
>>> objangle = Angle() >>> objangle.angle(30.43) ; (objangle*2).deg() 30.43 60.86000000000001
-
__ne__
(angle)[source]¶ Comparaison of angles. Return True if angles are defined and not equals.
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The logic result of the comparison. :rtype: bool
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle1 != objangle2 12.345 '56d28m' True
Note
Does not account for the modulo.
-
__sub__
(angle)[source]¶ Subtract an angle to an angle.
:param angle : An angle in any supported format (cf. help(Angle)) :type angle : Angle() :returns: The result of the subtraction :rtype: Angle()
- Example
>>> objangle1 = Angle() >>> objangle2 = Angle() >>> objangle1.angle(12.345) ; objangle2.angle("56d28m") ; objangle = objangle1 - objangle2 ; objangle.sexagesimal("D") 12.345 '56d28m' '315d52m42.00s'
-
__truediv__
(divisor)[source]¶ division of an angle by a float or int. Return an angle
- Parameters
divisor (float) – A real number
- Returns
An angle
- Return type
Angle()
- Example
>>> objangle = Angle() >>> objangle.angle(30.43) ; (objangle/2).deg() 30.43 15.215000000000002
-
angle
(angle='')[source]¶ Set the input angle in any format
- Parameters
angle (str) – angle is an angle in any supported format (cf. help(Angle))
- Example
>>> objangle = Angle() >>> objangle.angle("23d 27m") '23d 27m'
- Related topics
After using objangle.angle() get conversions with methods as objangle.deg() or objdate.rad().
-
angle_angle2rad
(angle)[source]¶ Compute radian from any angle format
- Parameters
angle (str) – angle is an angle in any supported format (cf. help(Angle))
- Usage
>>> objangle = Angle() >>> objangle.angle_angle2rad("-57d45m34s") ([('-57', 'D'), ('45', 'M'), ('34', 'S')], -1.0080924796783026)
First integer is used to check the recognized input date format: 0 = Error, format not known
- Related topics
Prefer using objangle.angle() followed by objangle.rad()
-
angle_rad2deg
(rad)[source]¶ Compute a angle in degrees from a angle in radian
- Parameters
rad (float) – rad is an angle in radian.
- Usage
>>> objangle = Angle() >>> objangle.angle_rad2deg(1) (0, 57.29577951308232)
First integer is an error code. 0 = no problem.
- Related topics
Prefer using objangle.angle() followed by objangle.deg()
-
angle_rad2sexagesimal
(rad, sexagesimal_format)[source]¶ Compute a sexagesimal format string from radian
- Parameters
rad (float) – rad is an angle in radian
sexagesimal_format (str) – The uspzad format (see details below)
- Sexagesimal format:
u (unit) = h,H,d,D (default=D). Capital mean module [0:360[, lower case means module [-180:180[
s (separator) = ” “,:,”” (default=”” means letters hms or dms)
p (plus/minus) = +,”” (default=”“)
z (zeros) = 0,”” (default=”“)
a (angle_limits) = “”,90, (+/-limit if unit D,H, default=”” means 360)
d (sec_digits) = “”,”.1”,”.2”,… (default=”“)
- Style 1:
To Display a R.A.: “H0.2” => 23h07m42.49s
To Display a Decl.: “d+090.1” => +00d34m22.6s
To Display a H.A.: “h0.2” => -08h43m16.05s
- Style 2:
To Display a R.A.: “H 0.2” => 23 07 42.49
To Display a Decl.: “d +090.1” => -00 34 22.6
To Display a H.A.: “h 0.2” => -08 43 16.05
- Style 3:
To Display a R.A.: “H:0.2” => 23:07:42.49
To Display a Decl.: “d:+090.1” => -00:34:22.6
To Display a H.A.: “h:0.2” => -08:43:16.05
- Example
>>> objangle = Angle() >>> objangle.angle_rad2sexagesimal(-0.01,"d:-090.1") (0, '-00:34:22.6')
First integer is used to check the recognized input date format: 0 = Error, format not known
- Related topics
Prefer using objangle.angle() followed by objangle.sexagesimal()
-
arcmin
()[source]¶ Get the angle in arcmin
- Example
>>> objangle = Angle() >>> objangle.angle("-23 d 56'") "-23 d 56'" >>> objangle.arcmin() -1436.0
- Related topics
Before use objdate.angle() to set the input angle.
-
arcsec
()[source]¶ Get the angle in arcsec
- Example
>>> objangle = Angle() >>> objangle.angle("-23 d 56'") "-23 d 56'" >>> objangle.arcsec() -86160.0
- Related topics
Before use objdate.angle() to set the input angle.
-
deg
()[source]¶ Get the angle in degrees
- Example
>>> objangle = Angle() >>> objangle.angle("-23 d 56'") "-23 d 56'" >>> objangle.deg() -23.933333333333334
- Related topics
Before use objdate.angle() to set the input angle.
-
infos
(action) → None[source]¶ To get informations about this class
- Parameters
action (string) – A command to run a debug action (see examples).
- Example
Angle().infos(“doctest”) Angle().infos(“doc_methods”) Angle().infos(“internal_attributes”) Angle().infos(“public_methods”)
-
rad
()[source]¶ Get the angle in radian
- Example
>>> objangle = Angle() >>> objangle.angle("-23 d 56'") "-23 d 56'" >>> objangle.rad() -0.4177154676439762
- Related topics
Before use objdate.angle() to set the input angle.
-
sexagesimal
(sexagesimal_format)[source]¶ Get the angle in sexagesimal
- Parameters
rad (float) – rad is an angle in radian
sexagesimal_format (str) – The uspzad format (see details below)
- Sexagesimal format:
u (unit) = h,H,d,D (default=D). Capital mean module [0:360[, lower case means module [-180:180[
s (separator) = ” “,:,”” (default=”” means letters hms or dms)
p (plus/minus) = +,”” (default=”“)
z (zeros) = 0,”” (default=”“)
a (angle_limits) = “”,90, (+/-limit if unit D,H, default=”” means 360)
d (sec_digits) = “”,”.1”,”.2”,… (default=”“)
- Style 1:
To Display a R.A.: “H0.2” => 23h07m42.49s
To Display a Decl.: “d+090.1” => +00d34m22.6s
To Display a H.A.: “h0.2” => -08h43m16.05s
- Style 2:
To Display a R.A.: “H 0.2” => 23 07 42.49
To Display a Decl.: “d +090.1” => -00 34 22.6
To Display a H.A.: “h 0.2” => -08 43 16.05
- Style 3:
To Display a R.A.: “H:0.2” => 23:07:42.49
To Display a Decl.: “d:+090.1” => -00:34:22.6
To Display a H.A.: “h:0.2” => -08:43:16.05
- Example
>>> objangle = Angle() >>> objangle.angle(-0.57) -0.57 >>> objangle.sexagesimal("d:-090.1") '-00:34:12.0'
- Related topics
Before use objdate.angle() to set the input angle.
celme.coords¶
-
class
celme.coords.
Coords
(cart_or_sphe=(0, 0, 0))[source]¶ Class to convert coordinates for astronomy
Coordinate formats are:
cart = tuple of x, xy, xyz
sphe = tuple of r, rp, rpt
- Usage
First, instanciate an object from the class:
coord = Coords()
Second, assign a coordinate in any format:
xyz = (x, y, z) coord.coords(xyz)
or
phi = Angle(45) theta = Angle(120) rpt = (r, phi, theta) coord.coords(rpt)
Third, get the converted angles:
r, phi, theta = coord.sphe() x,y,y = coord.cart()
Fourth, some tools
coord.separation(coord2) coord.pole(coord2) coord.scalar_product(coord2) coord.vectorial_product(coord2)
- Informations
help(Coords) Coords().infos("doctest") Coords().infos("doc_methods")
-
cart
()[source]¶ Get the cartesian coordinates
- Returns
The tuple (x,y,z)
- Return type
tuple(float, float, float)
- Example
>>> objcoord = Coords() >>> objcoord.coords((1,3,6)) (1, 3, 6) >>> objcoord.cart() (1, 3, 6)
Note
Before use objcoord.cart() to set the input coords with objcoord.coords().
-
coords
(cart_or_sphe)[source]¶ Set the input cart_or_sphe in any format
- Parameters
cart_or_sphe (tuple) – Cartesian or spherical coordinates. If the tupple contains two elements it is spherical coordinates. If the tupple contains three elements it is cartesian coordinates.
Angles are in any supported format (cf. help(Coords))
- Example
>>> objcoord = Coords() >>> objcoord.coords((1,3,6)) (1, 3, 6)
- Related topics
After using objcoord.coords() get conversions with methods as objcoord.cart() or objcoord.sphe().
-
infos
(action) → None[source]¶ To get informations about this class
- Parameters
action (string) – A command to run a debug action (see examples).
- Example
Coords().infos(“doctest”) Coords().infos(“doc_methods”) Coords().infos(“internal_attributes”) Coords().infos(“public_methods”)
-
sphe
(format_phi='deg', format_theta='deg')[source]¶ Get the spherical coordinates
- Parameters
format_phi (str) – Angle format unit.
format_theta (str) – Angle format unit.
- Returns
The tuple (x,y,z)
- Return type
tuple(float, float, float)
- Example
>>> objcoord = Coords() >>> objcoord.coords((1,3,6)) (1, 3, 6) >>> objcoord.sphe("H","d") (6.782329983125268, '4h46m15.61s', '62d12m31.30s')
Note
Before use objcoord.sphe() to set the input coords with objcoord.coords().
celme.home¶
celme.site¶
-
class
celme.site.
Site
(home)[source]¶ Class to describe an Site
-
infos
(action) → None[source]¶ To get informations about this class
- Parameters
action (string) – A command to run a debug action (see examples).
- Example
Site(‘GPS 0 E 0 0’).infos(“doctest”) Site(‘GPS 0 E 0 0’).infos(“doc_methods”) Site(‘GPS 0 E 0 0’).infos(“internal_attributes”) Site(‘GPS 0 E 0 0’).infos(“public_methods”)
-