def test_planets(self):
     for p in self.planets:
         for ep in self.ephem:
             a = objPosVel_wrt_SSB(p, self.tdb_time ,ephem = ep)
             assert a.obj == p
             assert a.pos.shape == (3, 10000)
             assert a.vel.shape == (3, 10000)
示例#2
0
    def posvel(self, t, ephem):
        """Return position and velocity vectors of satellite, wrt SSB.

        These positions and velocites are in inertial coordinates
        (i.e. aligned with ICRS)

        t is an astropy.Time or array of astropy.Times
        """
        # Compute vector from SSB to Earth
        geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)
        # Now add vector from Earth to satellite
        sat_pos_geo = (
            np.array([self.X(t.tt.mjd),
                      self.Y(t.tt.mjd),
                      self.Z(t.tt.mjd)]) * self.FT2["X"].unit)
        log.debug("[{0}] sat_pos_geo {1}".format(self.name, sat_pos_geo[:, 0]))
        sat_vel_geo = (
            np.array([self.Vx(t.tt.mjd),
                      self.Vy(t.tt.mjd),
                      self.Vz(t.tt.mjd)]) * self.FT2["Vx"].unit)
        sat_posvel = PosVel(sat_pos_geo,
                            sat_vel_geo,
                            origin="earth",
                            obj=self.name)
        # Vector add to geo_posvel to get full posvel vector.
        return geo_posvel + sat_posvel
示例#3
0
    def _get_TDB_ephem(self, t, ephem):
        """Read the ephem TDB-TT column.

        This column is provided by DE4XXt version of ephemeris. This function is only
        for the ground-based observatories

        """
        geo_tdb_tt = get_tdb_tt_ephem_geocenter(t.tt, ephem)
        # NOTE The earth velocity is need to compute the time correcion from
        # Topocenter to Geocenter
        # Since earth velocity is not going to change a lot in 3ms. The
        # differences between TT and TDB can be ignored.
        earth_pv = objPosVel_wrt_SSB("earth", t.tdb, ephem)
        obs_geocenter_pv = gcrs_posvel_from_itrf(
            self.earth_location_itrf(), t, obsname=self.name
        )
        # NOTE
        # Moyer (1981) and Murray (1983), with fundamental arguments adapted
        # from Simon et al. 1994.
        topo_time_corr = numpy.sum(
            earth_pv.vel / c.c * obs_geocenter_pv.pos / c.c, axis=0
        )
        topo_tdb_tt = geo_tdb_tt - topo_time_corr
        result = Time(
            t.tt.jd1 - JD_MJD,
            t.tt.jd2 - topo_tdb_tt.to(u.day).value,
            format="pulsar_mjd",
            scale="tdb",
            location=self.earth_location_itrf(),
        )
        return result
示例#4
0
 def test_planets(self):
     for p in self.planets:
         for ep in self.ephem:
             a = objPosVel_wrt_SSB(p, self.tdb_time, ephem=ep)
             assert a.obj == p
             assert a.pos.shape == (3, 10000)
             assert a.vel.shape == (3, 10000)
 def test_from_dir(self):
     path = datapath('de432s.bsp')
     a = objPosVel_wrt_SSB('earth', self.tdb_time , 'de432s', path=path)
     assert a.obj == 'earth'
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,path))
     assert solar_system_ephemeris._value == path
示例#6
0
 def test_from_dir(self):
     path = datapath('de432s.bsp')
     a = objPosVel_wrt_SSB('earth', self.tdb_time, 'de432s', path=path)
     assert a.obj == 'earth'
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,
                                        path))
示例#7
0
 def posvel(self, t, ephem, group=None):
     if t.isscalar:
         t = Time([t])
     earth_pv = objPosVel_wrt_SSB("earth", t, ephem)
     obs_geocenter_pv = gcrs_posvel_from_itrf(
         self.earth_location_itrf(), t, obsname=self.name
     )
     return obs_geocenter_pv + earth_pv
示例#8
0
 def test_from_dir(self):
     path = pint.config.runtimefile("de432s.bsp")
     a = objPosVel_wrt_SSB("earth", self.tdb_time, "de432s", path=path)
     assert a.obj == "earth"
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,
                                        path))
示例#9
0
    def _get_TDB_default(self, t, ephem):
        # Add in correction term to t.tdb equal to r.v / c^2
        vel = objPosVel_wrt_SSB("earth", t, ephem).vel
        pos = self.get_gcrs(t, ephem=ephem)
        dnom = const.c * const.c

        corr = ((pos[0] * vel[0] + pos[1] * vel[1] + pos[2] * vel[2]) / dnom).to(u.s)
        log.debug("\tTopocentric Correction:\t%s" % corr)

        return t.tdb + corr
示例#10
0
    def posvel(self, t, ephem, grp):

        # Compute vector from SSB to Earth
        geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)

        # Spacecraft posvel w.r.t. Earth
        stl_posvel = self.posvel_gcrs(t, grp)

        # Vector add to geo_posvel to get full posvel vector w.r.t. SSB.
        return geo_posvel + stl_posvel
示例#11
0
    def posvel(self, t, ephem, group=None):
        """Return position and velocity vectors of satellite, wrt SSB.

        These positions and velocites are in inertial coordinates
        (i.e. aligned with ICRS)

        t is an astropy.Time or array of astropy.Times
        """
        # Compute vector from SSB to Earth
        geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)
        # Now add vector from Earth to satellite
        sat_posvel = self.posvel_gcrs(t, ephem)
        return geo_posvel + sat_posvel
示例#12
0
    def posvel(self, t, ephem, group=None):

        if group is None:
            raise ValueError("TOA group table needed for SpacecraftObs posvel")

        # Compute vector from SSB to Earth
        geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)

        # Spacecraft posvel w.r.t. Earth
        stl_posvel = self.posvel_gcrs(t, group)

        # Vector add to geo_posvel to get full posvel vector w.r.t. SSB.
        return geo_posvel + stl_posvel
示例#13
0
    def _get_TDB_astropy_correction(self, t, ephem):
        """Uses astropy.Time location to add the topocentric correction term to
            the Time object. The topocentric correction is given as (r/c).(v/c),
            with r equal to the geocentric position of the observer, v being the 
            barycentric velocity of the earth, and c being the speed of light.

            The geocentric observer position can be obtained from Time object. 
            The barycentric velocity can be obtained using solar_system_ephemerides
            objPosVel_wrt_SSB
        """
        #Add in correction term to t.tdb equal to r.v / c^2
        vel = sse.objPosVel_wrt_SSB('earth', t, ephem).vel
        pos = self.get_gcrs(t)

        dnom = const.c * const.c
        corr = ((pos[0] * vel[0] + pos[1] * vel[1] + pos[2] * vel[2]) /
                dnom).to(u.s)
        log.info('\tTopocentric Correction:\t%s' % corr)

        return t.tdb + corr
示例#14
0
    def _get_TDB_PINT(self, t, ephem, grp=None):
        """Uses astropy.Time location to add the topocentric correction term to
            the Time object. The topocentric correction is given as (r/c).(v/c),
            with r equal to the geocentric position of the observer, v being the
            barycentric velocity of the earth, and c being the speed of light.

            The geocentric observer position can be obtained from Time object.
            The barycentric velocity can be obtained using solar_system_ephemerides
            objPosVel_wrt_SSB
        """

        #Add in correction term to t.tdb equal to r.v / c^2
        vel = sse.objPosVel_wrt_SSB('earth', t, ephem).vel
        pos = self.get_gcrs(t, ephem=ephem, grp=grp)
        dnom = const.c * const.c 

        corr = ((pos[0] * vel[0] + pos[1] * vel[1] + pos[2] * vel[2])/dnom).to(u.s)
        log.debug('\tTopocentric Correction:\t%s' % corr)

        return t.tdb + corr
示例#15
0
 def posvel(self, t, ephem):
     """Return position and velocity vectors of NuSTAR.
     t is an astropy.Time or array of astropy.Times
     """
     # Compute vector from SSB to Earth
     geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)
     # Now add vector from Earth to NuSTAR
     nustar_pos_geo = (
         np.array([self.X(t.tt.mjd),
                   self.Y(t.tt.mjd),
                   self.Z(t.tt.mjd)]) * self.FPorb["X"].unit)
     nustar_vel_geo = (
         np.array([self.Vx(t.tt.mjd),
                   self.Vy(t.tt.mjd),
                   self.Vz(t.tt.mjd)]) * self.FPorb["Vx"].unit)
     nustar_posvel = PosVel(nustar_pos_geo,
                            nustar_vel_geo,
                            origin="earth",
                            obj="nustar")
     # Vector add to geo_posvel to get full posvel vector.
     return geo_posvel + nustar_posvel
示例#16
0
    def posvel(self, t, ephem, maxextrap=2):
        """Return position and velocity vectors of NICER.

        t is an astropy.Time or array of astropy.Times
        maxextrap is the longest (in minutes) it is acceptable to
        extrapolate the S/C position
        """

        # this is a simple edge check mainly to prevent use of the wrong
        # orbit file or a single orbit file with a merged event file; if
        # needed, can check to make sure there is a spline anchor point
        # sufficiently close to all event times
        tmin = np.min(self.FPorb["MJD_TT"])
        tmax = np.max(self.FPorb["MJD_TT"])
        if tmin - np.min(t.tt.mjd) > float(maxextrap) / (60 * 24) or np.max(
            t.tt.mjd
        ) - tmax > float(maxextrap) / (60 * 24):
            log.error(
                "Extrapolating NICER position by more than %d minutes!" % maxextrap
            )
            log.error(
                "Orbit file goes {0} to {1}, Events go {2} to {3}".format(
                    tmin, tmax, np.min(t.tt.mjd), np.max(t.tt.mjd)
                )
            )
            raise ValueError("Bad extrapolation of S/C file.")
        # Compute vector from SSB to Earth
        geo_posvel = objPosVel_wrt_SSB("earth", t, ephem)
        # Now add vector from Earth to NICER
        nicer_pos_geo = (
            np.array([self.X(t.tt.mjd), self.Y(t.tt.mjd), self.Z(t.tt.mjd)])
            * self.FPorb["X"].unit
        )
        nicer_vel_geo = (
            np.array([self.Vx(t.tt.mjd), self.Vy(t.tt.mjd), self.Vz(t.tt.mjd)])
            * self.FPorb["Vx"].unit
        )
        nicer_posvel = PosVel(nicer_pos_geo, nicer_vel_geo, origin="earth", obj="nicer")
        # Vector add to geo_posvel to get full posvel vector.
        return geo_posvel + nicer_posvel
示例#17
0
 def posvel(self, t, ephem, group=None):
     return objPosVel_wrt_SSB("earth", t, ephem)
示例#18
0
 def get_gcrs(self, t, ephem=None):
     if ephem is None:
         raise ValueError("Ephemeris needed for BarycenterObs get_gcrs")
     ssb_pv = objPosVel_wrt_SSB("earth", t, ephem)
     return -1 * ssb_pv.pos
示例#19
0
 def test_sun(self):
     for ep in self.ephem:
         a = objPosVel_wrt_SSB('sun', self.tdb_time ,ephem = ep)
         assert a.obj == 'sun'
         assert a.pos.shape == (3, 10000)
         assert a.vel.shape == (3, 10000)
示例#20
0
 def posvel(self, t, ephem):
     return objPosVel_wrt_SSB("earth", t, ephem)
示例#21
0
 def test_sun(self):
     for ep in self.ephem:
         a = objPosVel_wrt_SSB('sun', self.tdb_time, ephem=ep)
         assert a.obj == 'sun'
         assert a.pos.shape == (3, 10000)
         assert a.vel.shape == (3, 10000)
示例#22
0
 def test_earth(self):
     for ep in self.ephem:
         a = objPosVel_wrt_SSB("earth", self.tdb_time, ephem=ep)
         assert a.obj == "earth"
         assert a.pos.shape == (3, 10000)
         assert a.vel.shape == (3, 10000)