def longitude_radius_low(jd): """Return geometric longitude and radius vector. Low precision. The longitude is accurate to 0.01 degree. The latitude should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5 Arguments: - `jd` : Julian Day in dynamical time Returns: - longitude in radians - radius in au """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) L0 = polynomial(_kL0, T) M = polynomial(_kM, T) er = polynomial((0.016708634, -0.000042037, -0.0000001267), T) C = polynomial(_kC, T) * np.sin(M) \ + (_ck3 - _ck4 * T) * np.sin(2 * M) \ + _ck5 * np.sin(3 * M) L = modpi2(L0 + C) v = M + C R = 1.000001018 * (1 - er * er) / (1 + er * np.cos(v)) return L, R
def longitude_radius_low(jd): """Return geometric longitude and radius vector. Low precision. The longitude is accurate to 0.01 degree. The latitude should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5 Parameters: jd : Julian Day in dynamical time Returns: longitude in radians radius in au """ T = jd_to_jcent(jd) L0 = polynomial(_kL0, T) M = polynomial(_kM, T) e = polynomial((0.016708634, -0.000042037, -0.0000001267), T) C = polynomial(_kC, T) * sin(M) \ + (_ck3 - _ck4 * T) * sin(2 * M) \ + _ck5 * sin(3 * M) L = modpi2(L0 + C) v = M + C R = 1.000001018 * (1 - e * e) / (1 + e * cos(v)) return L, R
def _constants(T): """Return some values needed for both nut_in_lon() and nut_in_obl()""" D = modpi2(polynomial(_kD, T)) M = modpi2(polynomial(_kM, T)) M1 = modpi2(polynomial(_kM1, T)) F = modpi2(polynomial(_kF, T)) omega = modpi2(polynomial(_ko, T)) return D, M, M1, F, omega
def _constants(T): """Return some values needed for both nutation_in_longitude() and nutation_in_obliquity()""" D = modpi2(polynomial(kD, T)) M = modpi2(polynomial(kM, T)) M1 = modpi2(polynomial(kM1, T)) F = modpi2(polynomial(kF, T)) omega = modpi2(polynomial(ko, T)) return D, M, M1, F, omega
def equinox_approx(yr, season): """Returns the approximate time of a solstice or equinox event. The year must be in the range -1000...3000. Within that range the the error from the precise instant is at most 2.16 minutes. Parameters: yr : year season : one of ("spring", "summer", "autumn", "winter") Returns: Julian Day of the event in dynamical time """ if not (-1000 <= yr <= 3000): raise Error, "year is out of range" if season not in astronomia.globals.season_names: raise Error, "unknown season =" + season yr = int(yr) if -1000 <= yr <= 1000: Y = yr / 1000.0 tbl = _approx_1000 else: Y = (yr - 2000) / 1000.0 tbl = _approx_3000 jd = polynomial(tbl[season], Y) T = jd_to_jcent(jd) W = d_to_r(35999.373 * T - 2.47) delta_lambda = 1 + 0.0334 * cos(W) + 0.0007 * cos(2 * W) jd += 0.00001 * sum([A * cos(B + C * T) for A, B, C in _terms]) / delta_lambda return jd
def vsop_to_fk5(jd, L, B): """Convert VSOP to FK5 coordinates. This is required only when using the full precision of the VSOP model. [Meeus-1998: pg 219] Parameters: jd : Julian Day in dynamical time L : longitude in radians B : latitude in radians Returns: corrected longitude in radians corrected latitude in radians """ T = jd_to_jcent(jd) L1 = polynomial([L, _k0, _k1], T) cosL1 = cos(L1) sinL1 = sin(L1) deltaL = _k2 + _k3 * (cosL1 + sinL1) * tan(B) deltaB = _k3 * (cosL1 - sinL1) return modpi2(L + deltaL), B + deltaB
def mean_longitude(self, jd): """Return mean longitude. Arguments: - `jd` : Julian Day in dynamical time Returns: - Longitude in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) # From astrolabe #X = polynomial((d_to_r(100.466457), # d_to_r(36000.7698278), # d_to_r(0.00030322), # d_to_r(0.000000020)), T) # From AA, Naughter # Takes T/10.0 X = polynomial((d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028), d_to_r(1.0/49931), d_to_r(-1.0/15300), d_to_r(-1.0/2000000)), T/10.0) X = modpi2(X + np.pi) return _scalar_if_one(X)
def mean_longitude(self, jd): """Return mean longitude. Arguments: - `jd` : Julian Day in dynamical time Returns: - Longitude in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) # From astrolabe #X = polynomial((d_to_r(100.466457), # d_to_r(36000.7698278), # d_to_r(0.00030322), # d_to_r(0.000000020)), T) # From AA, Naughter # Takes T/10.0 X = polynomial( (d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028), d_to_r(1.0 / 49931), d_to_r(-1.0 / 15300), d_to_r( -1.0 / 2000000)), T / 10.0) X = modpi2(X + np.pi) return _scalar_if_one(X)
def vsop_to_fk5(jd, L, B): """Convert VSOP to FK5 coordinates. This is required only when using the full precision of the VSOP model. [Meeus-1998: pg 219] Parameters: jd : Julian Day in dynamical time L : longitude in radians B : latitude in radians Returns: corrected longitude in radians corrected latitude in radians """ T = jd_to_jcent(jd) L1 = polynomial([L, _k0, _k1], T) cosL1 = cos(L1) sinL1 = sin(L1) deltaL = _k2 + _k3*(cosL1 + sinL1)*tan(B) deltaB = _k3*(cosL1 - sinL1) return modpi2(L + deltaL), B + deltaB
def mean_longitude_perigee(self, jd): """Return mean longitude of lunar perigee """ T = jd_to_jcent(jd) X = polynomial( (d_to_r(83.3532465), d_to_r(4069.0137287), d_to_r(-0.0103200), d_to_r(-1. / 80053), d_to_r(1. / 18999000)), T) return modpi2(X)
def _constants(T): """Calculate values required by several other functions""" L1 = modpi2(polynomial(_kL1, T)) D = modpi2(polynomial(_kD, T)) M = modpi2(polynomial(_kM, T)) M1 = modpi2(polynomial(_kM1, T)) F = modpi2(polynomial(_kF, T)) A1 = modpi2(polynomial(_kA1, T)) A2 = modpi2(polynomial(_kA2, T)) A3 = modpi2(polynomial(_kA3, T)) E = polynomial([1.0, -0.002516, -0.0000074], T) E2 = E * E return L1, D, M, M1, F, A1, A2, A3, E, E2
def _constants(T): """Calculate values required by several other functions""" L1 = modpi2(polynomial(kL1, T)) D = modpi2(polynomial(kD, T)) M = modpi2(polynomial(kM, T)) M1 = modpi2(polynomial(kM1, T)) F = modpi2(polynomial(kF, T)) A1 = modpi2(polynomial(_kA1, T)) A2 = modpi2(polynomial(_kA2, T)) A3 = modpi2(polynomial(_kA3, T)) E = polynomial([1.0, -0.002516, -0.0000074], T) E2 = E*E return L1, D, M, M1, F, A1, A2, A3, E, E2
def deltaT_seconds(jd): """Return deltaT as seconds of time. For a historical range from 1620 to a recent year, we interpolate from a table of observed values. Outside that range we use formulae. Parameters: jd : Julian Day number Returns: deltaT in seconds """ yr, mo, day = jd_to_cal(jd) # # 1620 - 20xx # if _tbl_start < yr < _tbl_end: idx = bisect(_tbl, (jd, 0)) jd1, secs1 = _tbl[idx] jd0, secs0 = _tbl[idx-1] # simple linear interpolation between two values return ((jd - jd0) * (secs1 - secs0) / (jd1 - jd0)) + secs0 t = (yr - 2000) / 100.0 # # before 948 [Meeus-1998: equation 10.1] # if yr < 948: return polynomial([2177, 497, 44.1], t) # # 948 - 1620 and after 2000 [Meeus-1998: equation 10.2) # result = polynomial([102, 102, 25.3], t) # # correction for 2000-2100 [Meeus-1998: pg 78] # if _tbl_end < yr < 2100: result += 0.37 * (yr - 2100) return result
def deltaT_seconds(jd): """Return deltaT as seconds of time. For a historical range from 1620 to a recent year, we interpolate from a table of observed values. Outside that range we use formulae. Parameters: jd : Julian Day number Returns: deltaT in seconds """ yr, mo, day = jd_to_cal(jd) # # 1620 - 20xx # if _tbl_start < yr < _tbl_end: idx = bisect(_tbl, (jd, 0)) jd1, secs1 = _tbl[idx] jd0, secs0 = _tbl[idx - 1] # simple linear interpolation between two values return ((jd - jd0) * (secs1 - secs0) / (jd1 - jd0)) + secs0 t = (yr - 2000) / 100.0 # # before 948 [Meeus-1998: equation 10.1] # if yr < 948: return polynomial([2177, 497, 44.1], t) # # 948 - 1620 and after 2000 [Meeus-1998: equation 10.2) # result = polynomial([102, 102, 25.3], t) # # correction for 2000-2100 [Meeus-1998: pg 78] # if _tbl_end < yr < 2100: result += 0.37 * (yr - 2100) return result
def argument_of_latitude(self, jd): """Return geocentric mean longitude. Arguments: - `jd` : Julian Day in dynamical time Returns: - argument of latitude in radians """ T = jd_to_jcent(jd) return modpi2(polynomial(kF, T))
def mean_anomaly(self, jd): """Return geocentric mean anomaly. Arguments: - `jd` : Julian Day in dynamical time Returns: - mean anomaly in radians """ T = jd_to_jcent(jd) return modpi2(polynomial(kM1, T))
def mean_elongation(self, jd): """Return geocentric mean elongation. Arguments: - `jd` : Julian Day in dynamical time Returns: - mean elongation in radians """ T = jd_to_jcent(jd) return modpi2(polynomial(kD, T))
def mean_longitude(self, jd): """Return geocentric mean longitude. Parameters: jd : Julian Day in dynamical time Returns: longitude in radians """ T = jd_to_jcent(jd) L1 = modpi2(polynomial(_kL1, T)) return L1
def mean_longitude_perigee(self, jd): """Return mean longitude of lunar perigee """ T = jd_to_jcent(jd) X = polynomial( (d_to_r(83.3532465), d_to_r(4069.0137287), d_to_r(-0.0103200), d_to_r(-1./80053), d_to_r(1./18999000) ), T) return modpi2(X)
def obliquity(jd): """Return the mean obliquity of the ecliptic. Low precision, but good enough for most uses. [Meeus-1998: equation 22.2]. Accuracy is 1" over 2000 years and 10" over 4000 years. Arguments: - `jd` : Julian Day in dynamical time Returns: - obliquity, in radians """ T = jd_to_jcent(jd) return polynomial(_el0, T)
def mean_longitude_perigee(self, jd): """Return mean longitude of solar perigee. Parameters: jd : Julian Day in dynamical time Returns: Longitude of solar perigee in radians """ T = jd_to_jcent(jd) X = polynomial((1012395.0, 6189.03, 1.63, 0.012), (T + 1)) / 3600.0 X = d_to_r(X) X = modpi2(X) return X
def obliquity_hi(jd): """Return the mean obliquity of the ecliptic. High precision [Meeus-1998: equation 22.3]. Accuracy is 0.01" between 1000 and 3000, and "a few arc-seconds after 10,000 years". Parameters: jd : Julian Day in dynamical time Returns: obliquity, in radians """ U = jd_to_jcent(jd) / 100 return polynomial(_el1, U)
def obliquity_hi(jd): """Return the mean obliquity of the ecliptic. High precision [Meeus-1998: equation 22.3]. Accuracy is 0.01" between 1000 and 3000, and "a few arc-seconds after 10,000 years". Arguments: - `jd` : Julian Day in dynamical time Returns: - obliquity, in radians """ U = jd_to_jcent(jd) / 100 return polynomial(_el1, U)
def mean_longitude_perigee(self, jd): """Return mean longitude of solar perigee. Arguments: - `jd` : Julian Day in dynamical time Returns: - Longitude of solar perigee in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) X = polynomial((1012395.0, 6189.03, 1.63, 0.012), (T + 1)) / 3600.0 X = d_to_r(X) X = modpi2(X) return _scalar_if_one(X)
def mean_longitude_ascending_node(self, jd): """Return mean longitude of ascending node Another equation from: * This routine is part of the International Astronomical Union's * SOFA (Standards of Fundamental Astronomy) software collection. * Fundamental (Delaunay) arguments from Simon et al. (1994) * Arcseconds to radians DOUBLE PRECISION DAS2R PARAMETER ( DAS2R = 4.848136811095359935899141D-6 ) * Milliarcseconds to radians DOUBLE PRECISION DMAS2R PARAMETER ( DMAS2R = DAS2R / 1D3 ) * Arc seconds in a full circle DOUBLE PRECISION TURNAS PARAMETER ( TURNAS = 1296000D0 ) * Mean longitude of the ascending node of the Moon. OM = MOD ( 450160.398036D0 -6962890.5431D0*T, TURNAS ) * DAS2R Current implemention in astronomia is from: PJ Naughter (Web: www.naughter.com, Email: [email protected]) Look in nutation.py for calculation of omega _ko = (d_to_r(125.04452), d_to_r( -1934.136261), d_to_r( 0.0020708), d_to_r( 1.0/450000)) Though the last term was left off... Will have to incorporate better... """ T = jd_to_jcent(jd) X = polynomial( (d_to_r(125.0445479), d_to_r(-1934.1362891), d_to_r(0.0020754), d_to_r(1.0/467441.0), d_to_r(1.0/60616000.0) ), T) return modpi2(X)
def mean_longitude(self, jd): """Return mean longitude. Parameters: jd : Julian Day in dynamical time Returns: Longitude in radians """ T = jd_to_jcent(jd) # From astrolabe #X = polynomial((d_to_r(100.466457), d_to_r(36000.7698278), d_to_r(0.00030322), d_to_r(0.000000020)), T) # From AA, Naughter # Takes T/10.0 X = polynomial((d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028), d_to_r(1.0/49931), d_to_r(-1.0/15300), d_to_r(-1.0/2000000)), T/10.0) X = modpi2(X + pi) return X
def mean_longitude_perigee(self, jd): """Return mean longitude of solar perigee. Arguments: - `jd` : Julian Day in dynamical time Returns: - Longitude of solar perigee in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) X = polynomial((1012395.0, 6189.03, 1.63, 0.012), (T + 1))/3600.0 X = d_to_r(X) X = modpi2(X) return _scalar_if_one(X)
def mean_longitude_perigee(self, jd): """Return mean longitude of solar perigee. Parameters: jd : Julian Day in dynamical time Returns: Longitude of solar perigee in radians """ T = jd_to_jcent(jd) X = polynomial((1012395.0, 6189.03 , 1.63 , 0.012 ), (T + 1))/3600.0 X = d_to_r(X) X = modpi2(X) return X
def vsop_to_fk5(jd, L, B): """Convert VSOP to FK5 coordinates. This is required only when using the full precision of the VSOP model. [Meeus-1998: pg 219] Arguments: - `jd` : Julian Day in dynamical time - `L` : longitude in radians - `B` : latitude in radians Returns: - corrected longitude in radians - corrected latitude in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) L1 = polynomial([L, _k0, _k1], T) cosL1 = np.cos(L1) sinL1 = np.sin(L1) deltaL = _k2 + _k3 * (cosL1 + sinL1) * np.tan(B) deltaB = _k3 * (cosL1 - sinL1) return _scalar_if_one(modpi2(L + deltaL)), _scalar_if_one(B + deltaB)
def mean_longitude_ascending_node(self, jd): """Return mean longitude of ascending node Another equation from: * This routine is part of the International Astronomical Union's * SOFA (Standards of Fundamental Astronomy) software collection. * Fundamental (Delaunay) arguments from Simon et al. (1994) * Arcseconds to radians DOUBLE PRECISION DAS2R PARAMETER ( DAS2R = 4.848136811095359935899141D-6 ) * Milliarcseconds to radians DOUBLE PRECISION DMAS2R PARAMETER ( DMAS2R = DAS2R / 1D3 ) * Arc seconds in a full circle DOUBLE PRECISION TURNAS PARAMETER ( TURNAS = 1296000D0 ) * Mean longitude of the ascending node of the Moon. OM = MOD ( 450160.398036D0 -6962890.5431D0*T, TURNAS ) * DAS2R Current implemention in astronomia is from: PJ Naughter (Web: www.naughter.com, Email: [email protected]) Look in nutation.py for calculation of omega _ko = (d_to_r(125.04452), d_to_r( -1934.136261), d_to_r( 0.0020708), d_to_r( 1.0/450000)) Though the last term was left off... Will have to incorporate better... """ T = jd_to_jcent(jd) X = polynomial( (d_to_r(125.0445479), d_to_r(-1934.1362891), d_to_r(0.0020754), d_to_r(1.0 / 467441.0), d_to_r(1.0 / 60616000.0)), T) return modpi2(X)
def mean_longitude_ascending_node(self, jd): """Return mean longitude of ascending node Another equation from: This routine is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Fundamental (Delaunay) arguments from Simon et al. (1994) * Arcseconds to radians DOUBLE PRECISION DAS2R PARAMETER ( DAS2R = 4.848136811095359935899141D-6 ) * Milliarcseconds to radians DOUBLE PRECISION DMAS2R PARAMETER ( DMAS2R = DAS2R / 1D3 ) * Arc seconds in a full circle DOUBLE PRECISION TURNAS PARAMETER ( TURNAS = 1296000D0 ) * Mean longitude of the ascending node of the Moon. OM = MOD ( 450160.398036D0 -6962890.5431D0*T, TURNAS ) * DAS2R Keeping above for documentation, but... Current implemention in astronomia is from: PJ Naughter (Web: www.naughter.com, Email: [email protected]) Arguments: - `jd` : julian Day Returns: - mean longitude of ascending node """ T = jd_to_jcent(jd) return modpi2(polynomial(ko, T))
def mean_longitude(self, jd): """Return mean longitude. Parameters: jd : Julian Day in dynamical time Returns: Longitude in radians """ T = jd_to_jcent(jd) # From astrolabe #X = polynomial((d_to_r(100.466457), d_to_r(36000.7698278), d_to_r(0.00030322), d_to_r(0.000000020)), T) # From AA, Naughter # Takes T/10.0 X = polynomial( (d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028), d_to_r(1.0 / 49931), d_to_r(-1.0 / 15300), d_to_r( -1.0 / 2000000)), T / 10.0) X = modpi2(X + pi) return X
def vsop_to_fk5(jd, L, B): """Convert VSOP to FK5 coordinates. This is required only when using the full precision of the VSOP model. [Meeus-1998: pg 219] Arguments: - `jd` : Julian Day in dynamical time - `L` : longitude in radians - `B` : latitude in radians Returns: - corrected longitude in radians - corrected latitude in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) L1 = polynomial([L, _k0, _k1], T) cosL1 = np.cos(L1) sinL1 = np.sin(L1) deltaL = _k2 + _k3*(cosL1 + sinL1)*np.tan(B) deltaB = _k3*(cosL1 - sinL1) return _scalar_if_one(modpi2(L + deltaL)), _scalar_if_one(B + deltaB)