astro_toolbox package

This module init all the public classes.

class astro_toolbox.AngleDMS(anglevalue: tuple | str)

Bases: object

AngleDMS define a dms angle with its conversions.

Attributes

anglevaluetuple

The angle values as floats in tuple.

dmstodeg()

DMS to degrees converting method. This method return angle in degrees from angle in DMS.

Returns

float

The angle value in degrees.

dmstorad()

DMS to Radians converting method. This method return angle in radians from angle in DMS.

Returns

float

The angle value in radians.

class astro_toolbox.AngleDeg(anglevalue: float)

Bases: object

AngleDeg define degrees angle with its conversions.

Attributes

anglevalue: float

The angle value in degrees.

degtodms()

Degrees to DMS converting method. This method returns angle in DMS from angle in degrees.

Returns

tuple

The angle values in DMS.

degtohms()

Degrees to HMS converting method. This method returns angle in HMS from angle in degrees.

Returns

tuple

The angle values in HMS.

degtorad()

Degrees to radians converting method. This method returns angle in radians from angle in degrees.

Returns

float

The angle value in radians.

class astro_toolbox.AngleHMS(anglevalue: tuple | str)

Bases: object

AngleHMS define a HMS angle with its conversions.

Attributes

anglevaluetuple

The angle value as floats in tuple.

hmstodeg()

HMS to Degrees converting method. This method return angle in degrees from angle in HMS.

Returns

float

The angle value in degrees

hmstorad()

HMS to Radians converting method. This method return angle in radians from angle in HMS.

Returns

float

The angle value in radians.

class astro_toolbox.AngleRad(anglevalue: float)

Bases: object

AngleRad define radians angle with its conversions.

Attributes

anglevaluefloat

The angle value in radians.

radtodeg()

Radians to Degrees converting method. This method returns angle in radians from angle in degrees.

Returns

float

The angle value in degrees.

radtodms()

Radians to DMS converting method. This method returns angle in DMS from angle in radians.

Returns

tuple

The angle values in DMS.

radtohms()

Radians to HMS converting method. This method returns angle in HMS from angle in radians.

Returns

tuple

The angle values in HMS.

class astro_toolbox.AstroDateTime(ut_time: tuple | str = None)

Bases: object

This module contains AngleRad class

Attributes

ut_timetuple | str

Date and time as tuple or string in format (2000/01/01/12:00:00)

get_day()

Get day.

Returns

int

Day.

get_gmst()

Get Greenwich mean sidereal time with USNO formula.

\[gmst=mod(18.697375+24.065709824279(JD-2451545), 24)\]

Returns

tuple

Greenwich mean sidereal time.

get_gregorian(delta: int = 0)

Get gregorian date with possibility of delta days from USNO formulas.

\[g_1 = julian_day + 68569\]
\[g_2 = <\frac{4g_1}{146097}>\]
\[g_1 = g_1 - <\frac{146087g_2 + 3}{4}>\]
\[g_3 = <\frac{4000(g_1 + 1)}{1461001}>\]
\[g_1 = g_1 - <\frac{1461g_3}{4}> + 31\]
\[g_4 = <\frac{80g_3}{2447}>\]
\[day = g_1 - <\frac{2447g_4}{80}>\]
\[g_1 = <\frac{g_4}{11}\]
\[month = g_4 + 2 - 12g_1\]
\[year = 100(g_2 - 49) + g_3 + g_1\]

Parameters

deltaint, optional

Delta days, by default 0.

Returns

tuple

Tuple of int containing year month and month day.

get_jd(delta: int = 0)

Get julian day with possibility of delta days from USNO formula.

\[JD=367year-\frac{7(year+\frac{month+9}{12})}{4}>+\frac{275month}{9}+ day+1721013.5+\frac{UT}{24}-\]
\[0.5sign(100year+month-190002.5)+0.5\]

Parameters

deltaint

Delta in days.

Returns

float

Julian day.

get_lst(location: Location)

Get local mean sidereal time with USNO formula.

\[lst=gmst+\frac{\lambda}{15}\]

Parameters

locationLocation

Observer location.

Returns

tuple

Local mean sidereal time.

get_month()

Get month

Returns

int

Month.

get_time()

Get time.

Returns

tuple

Time in format (hour,minute,second).

get_year()

Get year

Returns

int

Year.

get_year_day()

Get day of year.

\[N1 = floor(275 * month / 9)\]
\[N2 = floor((month + 9) / 12)\]
\[N3 = (1 + floor((year - 4 * floor(year / 4) + 2) / 3))\]
\[N = N1 - (N2 * N3) + day - 30\]

Returns

int

Day of year.

class astro_toolbox.Ephemeris(name: str, datetime: tuple | str)

Bases: object

Ephemeris class computing solar system objects positions in different referential. Orbital elements calculated by JPL.

Attributes

namestr

Planet name.

n_centuriesfloat

Number of centuries from J2000.

orbital_elementsdict

Dictionary which contains object orbital elements for current date.

calculate_ecliptic_obliquity()

Calculate on date ecliptic obliquity.

Returns

float

Ecliptic obliquity in degrees.

compute_earth_position()

Sun position from earth. Distance and true anomaly are computed by _compute_true_anomaly_distance method.

lonearth = v + w

\[xs = r * cos(lonsun)\]
\[ys = r * sin(lonsun)\]

Returns

tuple

Tuple containing sun position from earth

compute_ecliptic_position(**orbital_elements)

Compute the heliocentric ecliptic object position.

\[xh = r*(cos(\Omega)*cos(v+\omega)-sin(\Omega)*sin(v+\omega)*cos(I))\]
\[yh = r*(sin(\Omega)*cos(v+\omega)+cos(\Omega)*sin(v+\omega)*cos(I))\]
\[zh = r*(sin(v+\omega)*sin(I))\]

Returns

tuple

Tuple which contains object position around the sun.

compute_equatorial_position(**orbital_elements)

Compute equatorial object position.

For the sun:

\[xe = xs\]
\[ye = ys * cos(ecl)\]
\[ze = ys * sin(ecl)\]

For the moon:

\[xe = r*(cos(\Omega)*cos(v+\omega)-sin(\Omega)*sin(v+\omega)*cos(I))\]
\[ye = r*(sin(\Omega)*cos(v+\omega)+cos(\Omega)*sin(v+\omega)*cos(I))\]
\[ze = r*(sin(v+\omega)*sin(I))\]

For the planets:

\[xe = xg\]
\[ye = yg * cos(ecl) - zg * sin(ecl)\]
\[ze = yg * sin(ecl) + zg * cos(ecl)\]

Returns

tuple

Tuple which contains the geocentric position.

compute_geocentric_position(**orbital_elements)

Compute geocentric object position.

\[xg = xh + xs\]
\[yg = yh + ys\]
\[zg = zh\]

Where, xs and ys are the geocentric earth coordinates.

Returns

tuple

Tuple which contains the geocentric position.

compute_true_anomaly_distance(**orbital_elements)

Compute object distance and true anomaly.

\[xv = a(cos(E) - e)\]
\[yv = a\sqrt{1 - e^2} * sin(E)\]
\[v = atan2(yv, xv)\]
\[r = \sqrt{xv^2 + yv^2}\]

Returns

tuple

Tuple which contains true anomaly and distance.

get_equatorial_coord()

Calculate equatorial coordinates.

\[RA = atan2(ye, xe)\]
\[DEC = atan2(ze, \sqrt{xe^2 + ye^2})\]

Returns

tuple

Tuple which contains right-ascension as HMS tuple and declination as DMS tuple.

get_magnitude()

Get solar system objects magnitude.

Returns

float

Solar system object magnitude.

class astro_toolbox.Equatorial(alpha: tuple | str, delta: tuple | str, name: str = None, magnitude: float = None)

Bases: object

This class represents astronomical equatorial coordinate system.

Attributes

alphatuple

Object right-ascension.

deltatuple

Object declination.

namestr

Object name.

magnitudefloat

Object magnitude.

calculate_airmass(gamma: tuple | str, location: Location)

Airmass calculation method. The airmass is calculate with the Pickering (2002) formula from DIO, The International Journal of Scientific History vol. 12.

\[X = \frac{1}{sin(h+\frac{244}{165+47h^{1.1}})}\]

For altitude angle calculation c.f. to_horizontal method.

Parameters

gammatuple | str

Sidereal Time angle in hms.

locationLocation

observer location.

Returns

float

Airmass value of the object.

calculate_rise_time(location: Location, date: tuple | str, altitude_0: float = 0.0)

Rise time calculation method.

Parameters

locationLocation

Observer location as Location class.

datetuple | str

Date as tuple or str (yyyy-mm-dd or yyyy:mm:dd).

Returns

tuple

Tuple containing the rising time in HMS.

calculate_set_time(location: Location, date: tuple | str, altitude_0: float = 0.0)

Set time calculation method.

Parameters

locationLocation

Observer location as Location class.

datetuple | str

Date as tuple or str (yyyy-mm-dd or yyyy:mm:dd).

Returns

tuple

Tuple containing the setting time in HMS.

compute_on_date_coord(year: float)

On date Equatorial coordinates calculation method from J2000 Equatorial coordinate.

\[\Delta year = \frac{(year-2000)}{100}\]
\[M=1.2812323\Delta year+0.0003879\Delta year^2+0.0000101\Delta year^3\]
\[N=0.5567530\Delta year-0.0001185\Delta year^2+0.0000116\Delta year^3\]
\[\Delta \alpha=M+Nsin\alpha tan\delta\]
\[\Delta \delta=Ncos\alpha\]
\[\alpha=\alpha_{J2000}+\Delta \alpha\]
\[\delta=\delta_{J2000}+\Delta \delta\]

Parameters

yearfloat

Current year (months and days can be counted as year fraction).

get_hourangle(gamma: tuple | str)

Right-Ascension to Hour-Angle converting method.

\[HA = RA - \gamma\]

Parameters

gammatuple | str

Sidereal Time angle as tuple or string.

Returns

tuple

Hour-Angle tuple as tuple.

to_horizontal(gamma: tuple | str, location: Location)

Equatorial to Horizontal converting method.

\[h=sin^{-1}(cos\Phi cos H cos\delta+sin\Phi sin\delta)\]
\[A=sin^{-1}(\frac{-sin H cos \delta}{cosh})\]

Parameters

gammatuple | str

Sidereal Time angle as tuple or string.

locationLocation

observer location.

Returns

tuple

Tuple containing two tuple in DMS with (azimuth, altitude).

class astro_toolbox.Horizons(object_name: str | int, datetime: tuple | str, location: Location)

Bases: object

JPL Horizons ephemeris request and parsing.

Attributes

namestr | int

The object name or integer reference according to JPL Horizons.

datetimeAstroDateTime

Date and time as AstroDateTime class.

locationLocation

Observer location as Location class.

object_datalist

List which contains results from Horizons.

get_equatorial_coord()

Get equatorial coordinates from JPL Horizons.

Returns

tuple

Equatorial coordinates right_ascension as HMS tuple and declination as DMS tuple.

get_magnitude()

Get magnitude from JPL Horizons.

Returns

float

Magnitude.

get_name()

Get object name from JPL Horizons.

Returns

str

Object name.

class astro_toolbox.Horizontal(azimuth: tuple | str, altitude: tuple | str, name: str = None, magnitude: float = None)

Bases: object

This class represent horizontal coordinate system.

Attributes

azimuthAngleDMS

Object azimuth.

altitudeAngleDMS

Object altitude.

namestr

Object name.

magnitudefloat

Object magnitude.

calculate_airmass()

Airmass calculation method The airmass is calculate with the Pickering (2002) formula from DIO, The International Journal of Scientific History vol. 12.

\[X = \frac{1}{sin(h+\frac{244}{165+47h^{1.1}})}\]

Returns

float

Object airmass.

to_equatorial(gamma: tuple | str, location: Location)

Horizontal to equatorial converting method.

\[\delta=sin^{-1}(sin \Phi sin h-cos \Phi cos h cos A)\]
\[\alpha=sin^{-1}(\frac{-cosh cosA}{cos\delta})-\gamma\]

Parameters

gammaAngleHMS

Sidereal Time angle as tuple or string.

locationLocation

observer location.

Returns

Equatorial

Object equatorial coordinates.

class astro_toolbox.Location(name: str = None, latitude: tuple | str = None, longitude: tuple | str = None, elevation: float = None)

Bases: object

This class represents the observer location.

Attributes

namestr

Location name.

latitudetuple | str

Location latitude.

longitudetuple | str

Location longitude.

elevationfloat

Location elevation.

compute_pressure_level()

Pressure level computing method.

\[P = 1013.25(1 - \frac{h}{44307.694})^{5.25530}\]

Returns

float

Pressure level in hPa.

delete_site()

Method to delete current site from saved sites file.

Raises

KeyError

The first level key doesn’t exist.

save_site()

Method to save current site in sites file.

Raises

KeyError

The first level key already exist.

update_site()

Method to update current site in saved sites file.

Raises

KeyError

The first level key doesn’t exist.

class astro_toolbox.OpenMeteo(location: Location, model: str = 'best_match')

Bases: object

OpenMeteo service request and parsing.

Attributes

locationLocation

Observer location as Location class.

modelstr, optional

Weather model (https://open-meteo.com/en/docs), by default ‘best_match’

get_cloud_cover(datetime: str | tuple = None)

Get cloud coverage method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Cloud coverage

get_dewpoint(datetime: str | tuple = None)

Get dewpoint method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Dewpoint

get_humidity(datetime: str | tuple = None)

Get humidity method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Humidity

get_msl_pressure(datetime: str | tuple = None)

Get sea level pressure method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Sea level pressure

get_precipitation(datetime: str | tuple = None)

Get precipitation method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Precipitation

get_precipitation_probability(datetime: str | tuple = None)

Get precipitation probability method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Precipitation probability

get_temperature(datetime: str | tuple = None)

Get temperature method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Temperature

get_units()

Get units.

Returns

dict

Dict containing units.

get_wind_direction(datetime: str | tuple = None)

Get wind direction method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Wind direction

get_wind_speed(datetime: str | tuple = None)

Get wind speed method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

Wind speed

get_wmo(datetime: str | tuple = None)

Get World Meteorological Organization code method.

Parameters

datetimestr | tuple, optional

Date and Time as tuple (YYYY,MM,DD,hh,mm,ss or YYYY-MM-DDThh:mm:ss), by default None.

Returns

float

WMO cod

class astro_toolbox.Simbad(object_name: str)

Bases: object

This class allows to read astronomical catalogs over internet.

Attributes

object_name : str

get_equatorial_coord()

Get RA/DEC object coordinates.

Returns

Tuple

Tuple which contains two tuples RA/DEC coordinates.

get_magnitude()

Get visual magnitude.

Returns

float, None

The object magnitude if available.

get_name()

Get object name.

Returns

str

Object name from Simbad.

Subpackages

Submodules

astro_toolbox.command_line module

This module creates the console interface.

astro_toolbox.command_line.winddirectiontotext(wind_direction)

Funcion to convert wind direction to text.

Parameters

wind_directionfloat

Wind direction

Returns

Object

offset_image Object.

astro_toolbox.command_line.wmototext(code)

Function to convert WMO code to text.

Parameters

codestr

WMO code as str.

Returns

Object

offset_image Object.