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 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 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 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 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 dimension(self, jd, planet, dim): """Return one of heliocentric ecliptic longitude, latitude and radius. [Meeus-1998: pg 218] Arguments: - `jd` : Julian Day in dynamical time - `planet` : must be one of ("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune") - `dim` : must be one of "L" (longitude) or "B" (latitude) or "R" (radius) Returns: - longitude in radians, or latitude in radians, or radius in au, depending on the value of `dim`. """ jd = np.atleast_1d(jd) X = 0.0 tauN = 1.0 tau = jd_to_jcent(jd) / 10.0 c = _planets[(planet, dim)] for s in c: X += np.sum([A * np.cos(B + C * tau) for A, B, C in s]) * tauN tauN = tauN * tau # last calculation is wasted if dim == "L": X = modpi2(X) return _scalar_if_one(X)
def dimension(self, jd, planet, dim): """Return one of heliocentric ecliptic longitude, latitude and radius. [Meeus-1998: pg 218] Arguments: - `jd` : Julian Day in dynamical time - `planet` : must be one of ("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune") - `dim` : must be one of "L" (longitude) or "B" (latitude) or "R" (radius) Returns: - longitude in radians, or latitude in radians, or radius in au, depending on the value of `dim`. """ jd = np.atleast_1d(jd) X = 0.0 tauN = 1.0 tau = jd_to_jcent(jd)/10.0 c = _planets[(planet, dim)] for s in c: X += np.sum([A*np.cos(B + C*tau) for A, B, C in s])*tauN tauN = tauN*tau # last calculation is wasted if dim == "L": X = modpi2(X) return _scalar_if_one(X)
def dimension(self, jd, planet, dim): """Return one of heliocentric ecliptic longitude, latitude and radius. [Meeus-1998: pg 218] Parameters: jd : Julian Day in dynamical time planet : must be one of ("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune") dim : must be one of "L" (longitude) or "B" (latitude) or "R" (radius) Returns: longitude in radians, or latitude in radians, or radius in au """ X = 0.0 tauN = 1.0 tau = jd_to_jcent(jd) / 10.0 c = _planets[(planet, dim)] for s in c: X += sum([A * cos(B + C * tau) for A, B, C in s]) * tauN tauN = tauN * tau # last calculation is wasted if dim == "L": 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] 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 dimension(self, jd, planet, dim): """Return one of heliocentric ecliptic longitude, latitude and radius. [Meeus-1998: pg 218] Parameters: jd : Julian Day in dynamical time planet : must be one of ("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune") dim : must be one of "L" (longitude) or "B" (latitude) or "R" (radius) Returns: longitude in radians, or latitude in radians, or radius in au """ X = 0.0 tauN = 1.0 tau = jd_to_jcent(jd)/10.0 c = _planets[(planet, dim)] for s in c: X += sum([A*cos(B + C*tau) for A, B, C in s])*tauN tauN = tauN*tau # last calculation is wasted if dim == "L": X = modpi2(X) return 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 rise(jd, raList, decList, h0, delta): """Return the Julian Day of the rise time of an object. Parameters: jd : Julian Day number of the day in question, at 0 hr UT raList : a sequence of three right accension values, in radians, for (jd-1, jd, jd+1) decList : a sequence of three right declination values, in radians, for (jd-1, jd, jd+1) h0 : the standard altitude in radians delta : desired accuracy in days. Times less than one minute are infeasible for rise times because of atmospheric refraction. Returns: Julian Day of the rise time """ longitude = astronomia.globals.longitude latitude = astronomia.globals.latitude THETA0 = sidereal_time_greenwich(jd) deltaT_days = deltaT_seconds(jd) / seconds_per_day cosH0 = (sin(h0) - sin(latitude) * sin(decList[1])) / (cos(latitude) * cos(decList[1])) # # future: return some indicator when the object is circumpolar or always # below the horizon. # if cosH0 < -1.0: # circumpolar return None if cosH0 > 1.0: # never rises return None H0 = acos(cosH0) m0 = (raList[1] + longitude - THETA0) / pi2 m = m0 - H0 / pi2 # this is the only difference between rise() and set() if m < 0: m += 1 elif m > 1: m -= 1 if not 0 <= m <= 1: raise Error, "m is out of range = " + str(m) for bailout in range(20): m0 = m theta0 = modpi2(THETA0 + _k1 * m) n = m + deltaT_days if not -1 < n < 1: return None # Bug: this is where we drop some events ra = interpolate_angle3(n, raList) dec = interpolate3(n, decList) H = theta0 - longitude - ra # if H > pi: # H = H - pi2 H = diff_angle(0.0, H) A, h = equ_to_horiz(H, dec) dm = (h - h0) / (pi2 * cos(dec) * cos(latitude) * sin(H)) m += dm if abs(m - m0) < delta: return jd + m raise Error, "bailout"
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 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 _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 _riseset(jd, raList, decList, h0, delta, mode, longitude=astronomia.globals.longitude, latitude=astronomia.globals.latitude): # Private function since rise/set so similar THETA0 = sidereal_time_greenwich(jd) deltaT_days = deltaT_seconds(jd) / seconds_per_day cosH0 = (np.sin(h0) - np.sin(latitude)*np.sin(decList[1])) / ( np.cos(latitude)*np.cos(decList[1])) # # future: return some indicator when the object is circumpolar or always # below the horizon. # if cosH0 < -1.0: # circumpolar return None if cosH0 > 1.0: # never rises return None H0 = np.arccos(cosH0) m0 = (raList[1] + longitude - THETA0) / pi2 if mode == 'rise': m = m0 - H0 / pi2 # the only difference between rise() and settime() elif mode == 'set': m = m0 + H0 / pi2 # the only difference between rise() and settime() if m < 0: m += 1 elif m > 1: m -= 1 if not 0 <= m <= 1: raise Error("m is out of range = " + str(m)) for bailout in range(20): m0 = m theta0 = modpi2(THETA0 + _k1 * m) n = m + deltaT_days if not -1 < n < 1: return None # Bug: this is where we drop some events ra = interpolate_angle3(n, raList) dec = interpolate3(n, decList) H = theta0 - longitude - ra # if H > pi: # H = H - pi2 H = diff_angle(0.0, H) A, h = equ_to_horiz(H, dec) dm = (h - h0) / (pi2 * np.cos(dec) * np.cos(latitude) * np.sin(H)) m += dm if abs(m - m0) < delta: return jd + m raise Error("bailout")
def equ_to_ecl(ra, dec, obliquity): """Convert equitorial to ecliptic coordinates. [Meeus-1998: equations 13.1, 13.2] Arguments: - `ra` : right accension in radians - `dec` : declination in radians - `obliquity` : obliquity of the ecliptic in radians Returns: - ecliptic longitude in radians - ecliptic latitude in radians """ cose = np.cos(obliquity) sine = np.sin(obliquity) sina = np.sin(ra) longitude = modpi2(np.arctan2(sina * cose + np.tan(dec) * sine, np.cos(ra))) latitude = modpi2(np.arcsin(np.sin(dec) * cose - np.cos(dec) * sine * sina)) return longitude, latitude
def equ_to_ecl(ra, dec, obliquity): """Convert equitorial to ecliptic coordinates. [Meeus-1998: equations 13.1, 13.2] Arguments: - `ra` : right accension in radians - `dec` : declination in radians - `obliquity` : obliquity of the ecliptic in radians Returns: - ecliptic longitude in radians - ecliptic latitude in radians """ cose = np.cos(obliquity) sine = np.sin(obliquity) sina = np.sin(ra) longitude = modpi2(np.arctan2(sina * cose + np.tan(dec) * sine, np.cos(ra))) latitude = modpi2( np.arcsin(np.sin(dec) * cose - np.cos(dec) * sine * sina)) return longitude, latitude
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 apparent_longitude_low(jd, L): """Correct the geometric longitude for nutation and aberration. Low precision. [Meeus-1998: pg 164] Parameters: jd : Julian Day in dynamical time L : longitude in radians Returns: corrected longitude in radians """ T = jd_to_jcent(jd) omega = _lk0 - _lk1 * T return modpi2(L - _lk2 - _lk3 * sin(omega))
def apparent_longitude_low(jd, L): """Correct the geometric longitude for nutation and aberration. Low precision. [Meeus-1998: pg 164] Arguments: - `jd` : Julian Day in dynamical time - `L` : longitude in radians Returns: - corrected longitude in radians """ jd = np.atleast_1d(jd) T = jd_to_jcent(jd) omega = _lk0 - _lk1 * T return _scalar_if_one(modpi2(L - _lk2 - _lk3 * np.sin(omega)))
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 transit(jd, raList, delta): """Return the Julian Day of the transit time of an object. Parameters: jd : Julian Day number of the day in question, at 0 hr UT raList : a sequence of three right accension values, in radians, for (jd-1, jd, jd+1) delta : desired accuracy in days. Returns: Julian Day of the transit time """ # # future: report both upper and lower culmination, and transits of objects below # the horizon # longitude = astronomia.globals.longitude THETA0 = sidereal_time_greenwich(jd) deltaT_days = deltaT_seconds(jd) / seconds_per_day m = (raList[1] + longitude - THETA0) / pi2 if m < 0: m += 1 elif m > 1: m -= 1 if not 0 <= m <= 1: raise Error, "m is out of range = " + str(m) for bailout in range(20): m0 = m theta0 = modpi2(THETA0 + _k1 * m) n = m + deltaT_days if not -1 < n < 1: return None # Bug: this is where we drop some events ra = interpolate_angle3(n, raList) H = theta0 - longitude - ra # if H > pi: # H = H - pi2 H = diff_angle(0.0, H) dm = -H / pi2 m += dm if abs(m - m0) < delta: return jd + m raise Error, "bailout"
def transit(jd, raList, delta): """Return the Julian Day of the transit time of an object. Arguments: - `jd` : Julian Day number of the day in question, at 0 hr UT - `raList` : a sequence of three right accension values, in radians, for (jd-1, jd, jd+1) - `delta` : desired accuracy in days. Returns: - Julian Day of the transit time """ # # future: report both upper and lower culmination, and transits of objects # below the horizon # longitude = astronomia.globals.longitude THETA0 = sidereal_time_greenwich(jd) deltaT_days = deltaT_seconds(jd) / seconds_per_day m = (raList[1] + longitude - THETA0) / pi2 if m < 0: m += 1 elif m > 1: m -= 1 if not 0 <= m <= 1: raise Error("m is out of range = " + str(m)) for bailout in range(20): m0 = m theta0 = modpi2(THETA0 + _k1 * m) n = m + deltaT_days if not -1 < n < 1: return None # Bug: this is where we drop some events ra = interpolate_angle3(n, raList) H = theta0 - longitude - ra # if H > pi: # H = H - pi2 H = diff_angle(0.0, H) dm = -H/pi2 m += dm if abs(m - m0) < delta: return jd + m raise Error("bailout")
def sidereal_time_greenwich(jd): """Return the mean sidereal time at Greenwich. The Julian Day number must represent Universal Time. Parameters: jd : Julian Day number Return: sidereal time in radians (2pi radians = 24 hrs) """ T = jd_to_jcent(jd) T2 = T * T T3 = T2 * T theta0 = 280.46061837 + 360.98564736629*(jd - 2451545.0) + 0.000387933*T2 - T3/38710000 result = d_to_r(theta0) return modpi2(result)
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 sidereal_time_greenwich(julian_day): """Return the mean sidereal time at Greenwich. The Julian Day number must represent Universal Time. Arguments: - `julian_day` : (int) Julian Day number Returns: - sidereal time in radians : (float) 2pi radians = 24 hours """ T = jd_to_jcent(julian_day) T2 = T * T T3 = T2 * T theta0 = 280.46061837 + 360.98564736629 * (julian_day - 2451545.0) + 0.000387933 * T2 - T3 / 38710000 result = d_to_r(theta0) return modpi2(result)
def sidereal_time_greenwich(jd): """Return the mean sidereal time at Greenwich. The Julian Day number must represent Universal Time. Parameters: jd : Julian Day number Return: sidereal time in radians (2pi radians = 24 hrs) """ T = jd_to_jcent(jd) T2 = T * T T3 = T2 * T theta0 = 280.46061837 + 360.98564736629 * ( jd - 2451545.0) + 0.000387933 * T2 - T3 / 38710000 result = d_to_r(theta0) return modpi2(result)
def dimension(self, jd, dim): """Return one of geocentric ecliptic longitude, latitude and radius. Parameters: jd : Julian Day in dynamical time dim : one of "L" (longitude) or "B" (latitude) or "R" (radius). Returns: Either longitude in radians, or latitude in radians, or radius in au. """ X = self.vsop.dimension(jd, "Earth", dim) if dim == "L": X = modpi2(X + pi) elif dim == "B": X = -X return X
def dimension(self, jd, dim): """Return one of geocentric ecliptic longitude, latitude and radius. Arguments: - jd : Julian Day in dynamical time - dim : one of "L" (longitude) or "B" (latitude) or "R" (radius). Returns: - Either longitude in radians, or latitude in radians, or radius in au, depending on value of `dim`. """ jd = np.atleast_1d(jd) X = self.vsop.dimension(jd, "Earth", dim) if dim == "L": X = modpi2(X + np.pi) elif dim == "B": X = -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_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 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 sidereal_time_greenwich(julian_day): """Return the mean sidereal time at Greenwich. The Julian Day number must represent Universal Time. Arguments: - `julian_day` : (int) Julian Day number Returns: - sidereal time in radians : (float) 2pi radians = 24 hours """ T = jd_to_jcent(julian_day) T2 = T * T T3 = T2 * T theta0 = 280.46061837 + \ 360.98564736629*(julian_day - 2451545.0) + \ 0.000387933*T2 - \ T3/38710000 result = d_to_r(theta0) return modpi2(result)
def ecl_to_equ(longitude, latitude, obliquity): """Convert ecliptic to equitorial coordinates. [Meeus-1998: equations 13.3, 13.4] Arguments: - `longitude` : ecliptic longitude in radians - `latitude` : ecliptic latitude in radians - `obliquity` : obliquity of the ecliptic in radians Returns: - Right accension in radians - Declination in radians """ cose = np.cos(obliquity) sine = np.sin(obliquity) sinl = np.sin(longitude) ra = modpi2(np.arctan2(sinl * cose - np.tan(latitude) * sine, np.cos(longitude))) dec = np.arcsin(np.sin(latitude) * cose + np.cos(latitude) * sine * sinl) return ra, dec
def ecl_to_equ(longitude, latitude, obliquity): """Convert ecliptic to equitorial coordinates. [Meeus-1998: equations 13.3, 13.4] Arguments: - `longitude` : ecliptic longitude in radians - `latitude` : ecliptic latitude in radians - `obliquity` : obliquity of the ecliptic in radians Returns: - Right accension in radians - Declination in radians """ cose = np.cos(obliquity) sine = np.sin(obliquity) sinl = np.sin(longitude) ra = modpi2( np.arctan2(sinl * cose - np.tan(latitude) * sine, np.cos(longitude))) dec = np.arcsin(np.sin(latitude) * cose + np.cos(latitude) * sine * sinl) return ra, dec
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 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(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_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)