def _xyzRov(self, obs): """ calculates the heliocentric position of a roving observer at UTC JD in equatorial cartesian coordinates. Payne: This does *NOT* have an equivalent in MPCU.Observatory. """ key = ('247', obs.jdutc) try: return self.cache[key] except KeyError: pass leaps = self.leapsec.getLeapSeconds(obs.jdutc) delta_t = 32.184 + leaps jd_tt = obs.jdutc + delta_t / (24.0 * 60 * 60) e = MPCU.getEarthPosition(jd_tt) # Might need to switch to tdb observer = novas.make_observer_on_surface(obs.lat, obs.lon, obs.alt, 5, 990) # posvel returns GCRS o, _ = novas.geo_posvel(jd_tt, delta_t, observer) # add ICRS and GCRS? hc = (e[0] + o[0], e[1] + o[1], e[2] + o[2]) self.cache[key] = hc return hc
def V_LSR(RA, dec, dss, timedate): """ Computes the velocity of the local standard of rest w.r.t. the observer @param ra : J2000 right ascension as a float or as "12h34m56.78s" @type ra : float or str @param dec : J2000 declination as a float or as "-12d34m56.78s" @type dec : float or str @param observer : DSN station @type observer : int @param timedate : date/time of the observation @type timedate : datetime object """ logger.debug("V_LSR: entered with coord types %s and %s", type(RA), type(dec)) if type(RA) == str and type(dec) == str: skypos = coord.SkyCoord(RA, dec, unit=(u.hourangle, u.deg)) elif type(RA) == float and type(dec) == float: skypos = coord.SkyCoord(RA * u.hour, dec * u.degree) else: raise RuntimeError(RA, dec, "cannot be parsed") logger.debug("V_LSR: sky pos: %s", skypos) ra2000, dec2000 = skypos.ra.hour, skypos.dec.deg logger.debug("V_LSR: J2000 coordinates are %f, %f", ra2000, dec2000) sourcename = "%5.2f%+5.2f" % (ra2000, dec2000) cat_entry = novas.make_cat_entry(sourcename, "", 0, ra2000, dec2000, 0, 0, 0, 0) source = novas.make_object(2, 0, sourcename, cat_entry) station = Astronomy.DSN_coordinates.DSS(dss) logger.debug("V_LSR: station lat=%f", station.lat * 180 / math.pi) logger.debug("V_LSR: station long=%f", station.lon * 180 / math.pi) if station.long > math.pi: longitude = station.long - 2 * math.pi elif station.long < math.pi: longitude = station.long + 2 * math.pi else: longitude = station.long observer = novas.make_observer_on_surface(station.lat * 180 / math.pi, longitude * 180 / math.pi, station.elev, 0, 0) jd = novas.julian_date(timedate.year, timedate.month, timedate.day, timedate.hour + timedate.minute / 60.) mjd = DatesTimes.MJD(timedate.year, timedate.month, timedate.day) earth = novas.make_object(0, 3, 'Earth', None) urthpos, urthvel = novas.ephemeris((jd, 0), earth, origin=0) (obspos, obsvel) = novas.geo_posvel(jd, 0, observer, 0) totvel = tuple(numpy.array(urthvel) + numpy.array(obsvel)) (srcpos, srcvel) = novas.starvectors(cat_entry) V = novas.rad_vel(source, srcpos, srcvel, totvel, 0, 0, 0) logger.debug("V_LSR: velocity of observer w.r.t. Sun= %.2f", V) return V + Astronomy.v_sun(mjd, ra2000 / 15., dec2000)
def test_geocentric_position_and_velocity(jd): observer = c.make_observer_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) posu, velu = c.geo_posvel(jd.tt, jd.delta_t, observer) topos = positionlib.Topos('45 N', '75 W', elevation=0.0, temperature=10.0, pressure=1010.0) posv, velv = earthlib.geocentric_position_and_velocity(topos, jd) epsilon = 1e-6 * meter # 13 to 14 digits of agreement eq(posu, posv, epsilon) eq(velu, velv, epsilon)
def test_geocentric_position_and_velocity(): epsilon = 1e-13 delta_t = 0.0 observer = c.make_observer_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) pos0, vel0 = c.geo_posvel(T0, delta_t, observer) posA, velA = c.geo_posvel(TA, delta_t, observer) topos = coordinates.Topos('75 W', '45 N', elevation=0.0, temperature=10.0, pressure=1010.0) jd = JulianDate(tt=[T0, TA], delta_t=delta_t) posv, velv = earthlib.geocentric_position_and_velocity(topos, jd) eq(posv.T, [pos0, posA], epsilon) eq(velv.T, [vel0, velA], epsilon)
def test_github_issue1_limb_angle(self): # https://github.com/brandon-rhodes/python-novas/pull/1 # The _limb_angle() function was always return zero. observer = novas.make_observer_on_surface( latitude, longitude, height, temperature, pressure) position_observer, velocity_observer = novas.geo_posvel( jd, delta_t, observer, accuracy) position_obj = (-10.0, -0.3, 0.0) limb, nadir = novas.limb_angle(position_obj, position_observer) self.assertAlmostEqual(limb, -21.7796002325, 12) self.assertAlmostEqual(nadir, 0.758004441861, 12)
def test_github_issue1_limb_angle(self): # https://github.com/brandon-rhodes/python-novas/pull/1 # The _limb_angle() function was always return zero. observer = novas.make_observer_on_surface(latitude, longitude, height, temperature, pressure) position_observer, velocity_observer = novas.geo_posvel( jd, delta_t, observer, accuracy) position_obj = (-10.0, -0.3, 0.0) limb, nadir = novas.limb_angle(position_obj, position_observer) self.assertAlmostEqual(limb, -21.7796002325, 12) self.assertAlmostEqual(nadir, 0.758004441861, 12)
delta_t = tt_tai + leap_second - ut1_utc #构造不同的儒略日时间变量 jd_utc = novas.julian_date(year, month, day, hour) #utc jd_ut1 = jd_utc + ut1_utc / 86400.0 #ut1 jd_tt = jd_utc + (leap_second + tt_tai) / 86400.0 #tt jd = (jd_tt, 0.0) jd0 = (jd_tt - ta / 86400, 0.0) #打开de历表 jd_s, jd_e, num = eph_manager.ephem_open() #太阳和地球构造 sun = novas.make_object(0, 10, 'sun', None) moon = novas.make_object(0, 11, 'moon', None) earth = novas.make_object(0, 3, 'earth', None) #位置构造 location1 = novas.make_on_surface(latitude, longitude, height, 25.0, 1013) location = novas.make_observer_on_surface(latitude, longitude, height, 25.0, 1013) #矢量和夹角初始化 O1_S1 = [0.0, 0.0, 0.0] #月球半影锥点到太阳质心矢量坐标 O2_S1 = [0.0, 0.0, 0.0] #月球全影锥点到太阳质心矢量坐标 O1_E = [0.0, 0.0, 0.0] #月球半影锥点到地心距离矢量坐标 O1_T = [0.0, 0.0, 0.0] #月球半影锥点到地球某一点距离矢量坐标 O2_E = [0.0, 0.0, 0.0] #月球全影锥点到地心距离矢量坐标 O2_T = [0.0, 0.0, 0.0] #月球全影锥点到地球某一点距离矢量坐标 O1_M = [0.0, 0.0, 0.0] #月球半影锥点到月心距离矢量坐标 O2_M = [0.0, 0.0, 0.0] #月球全影锥点到月心距离矢量坐标 E_O4 = [0.0, 0.0, 0.0] #经纬度转为ITRS下坐标 E_T=[re*math.cos(latitude*constants.DEG2RAD)*math.cos(longitude*constants.DEG2RAD),\ re*math.cos(latitude*constants.DEG2RAD)*math.sin(longitude*constants.DEG2RAD),\ re*math.sin(latitude*constants.DEG2RAD)\ ]