Пример #1
0
    def test_equatorial_to_galactic(self):
        """
        start with a pulsar in equatorial coordinates
        convert to Galactic and make sure the positions are consistent

        then apply the space motion to the equatorial object & convert to Galactic
        compare that to the Galactic object w/ space motion
        
        """

        # make a test SkyCoord object
        # make sure it has obstime and distance supplied
        # to use it for conversions as well
        J0613_icrs = self.modelJ0613.coords_as_ICRS()
        J0613_icrs_now = utils.add_dummy_distance(J0613_icrs)

        J0613_galactic = self.modelJ0613.coords_as_GAL()
        J0613_galactic_now = utils.add_dummy_distance(J0613_galactic)

        newepoch = self.modelJ0613.POSEPOCH.quantity.mjd + 100

        # what I get converting within astropy
        J0613_galactic_comparison = J0613_icrs_now.transform_to(
            astropy.coordinates.Galactic)
        sep = J0613_galactic_now.separation(J0613_galactic_comparison)
        msg = (
            "Equatorial to Galactic conversion for now failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-5 * u.arcsec, msg

        print(J0613_icrs_now)
        print(J0613_galactic_now)

        J0613_icrs = self.modelJ0613.coords_as_ICRS(epoch=newepoch)
        # what I get converting within astropy
        J0613_galactic_comparison = J0613_icrs.transform_to(
            astropy.coordinates.Galactic)
        J0613_galactic_then = utils.remove_dummy_distance(
            J0613_galactic_now.apply_space_motion(
                new_obstime=astropy.time.Time(newepoch, format="mjd")))
        sep = J0613_galactic_then.separation(J0613_galactic_comparison)
        msg = (
            "Equatorial to Galactic conversion for +100d failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-6 * u.arcsec, msg
Пример #2
0
    def test_ecliptic_to_galactic(self):
        """
        start with a pulsar in ecliptic coordinates
        convert to Galactic and make sure the positions are consistent

        then apply the space motion to the ecliptic object & convert to Galactic
        compare that to the Galactic object w/ space motion

        """

        # make a test SkyCoord object
        # make sure it has obstime and distance supplied
        # to use it for conversions as well
        B1855_ECL = self.modelB1855.coords_as_ECL()
        B1855_ECL_now = utils.add_dummy_distance(B1855_ECL)

        B1855_galactic = self.modelB1855.coords_as_GAL()
        B1855_galactic_now = utils.add_dummy_distance(B1855_galactic)

        newepoch = self.modelB1855.POSEPOCH.quantity.mjd + 100

        # what I get converting within astropy
        B1855_galactic_comparison = B1855_ECL_now.transform_to(
            astropy.coordinates.Galactic)
        sep = B1855_galactic_now.separation(B1855_galactic_comparison)
        msg = (
            "Ecliptic to Galactic conversion for now failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-9 * u.arcsec, msg

        B1855_ECL = self.modelB1855.coords_as_ECL(epoch=newepoch)
        # what I get converting within astropy
        B1855_galactic_comparison = B1855_ECL.transform_to(
            astropy.coordinates.Galactic)
        B1855_galactic_then = utils.remove_dummy_distance(
            B1855_galactic_now.apply_space_motion(
                new_obstime=astropy.time.Time(
                    newepoch, scale="tdb", format="mjd")))
        sep = B1855_galactic_then.separation(B1855_galactic_comparison)
        msg = (
            "Ecliptic to Galactic conversion for +100d failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-9 * u.arcsec, msg
Пример #3
0
    def get_psr_coords(self, epoch=None):
        """Returns pulsar sky coordinates as an astropy ecliptic coordinate instance.

        Parameters
        ----------
        epoch: `astropy.time.Time` or Float, optional
            new epoch for position.  If Float, MJD(TDB) is assumed

        Returns
        -------
        position
            PulsarEcliptic SkyCoord object optionally with proper motion applied

        If epoch (MJD) is specified, proper motion is included to return
        the position at the given epoch.
        """
        try:
            obliquity = OBL[self.ECL.value]
        except KeyError:
            raise ValueError(
                "No obliquity " + str(self.ECL.value) + " provided. "
                "Check your pint/datafile/ecliptic.dat file."
            )
        if epoch is None or (self.PMELONG.value == 0.0 and self.PMELAT.value == 0.0):
            # Compute only once
            return coords.SkyCoord(
                obliquity=obliquity,
                lon=self.ELONG.quantity,
                lat=self.ELAT.quantity,
                pm_lon_coslat=self.PMELONG.quantity,
                pm_lat=self.PMELAT.quantity,
                obstime=self.POSEPOCH.quantity,
                frame=PulsarEcliptic,
            )
        else:
            # Compute for each time because there is proper motion
            if isinstance(epoch, Time):
                newepoch = epoch
            else:
                newepoch = Time(epoch, scale="tdb", format="mjd")
            position_now = add_dummy_distance(self.get_psr_coords())
            position_then = remove_dummy_distance(
                position_now.apply_space_motion(new_obstime=newepoch)
            )
            return position_then
Пример #4
0
    def get_psr_coords(self, epoch=None):
        """Returns pulsar sky coordinates as an astropy ICRS object instance.

        Parameters
        ----------
        epoch: `astropy.time.Time` or Float, optional
            new epoch for position.  If Float, MJD is assumed

        Returns
        -------
        position
        ICRS SkyCoord object optionally with proper motion applied

        If epoch (MJD) is specified, proper motion is included to return
        the position at the given epoch.

        """
        if epoch is None or (self.PMRA.value == 0.0
                             and self.PMDEC.value == 0.0):
            dRA = 0.0 * u.hourangle
            dDEC = 0.0 * u.deg
            broadcast = 1
            newepoch = self.POSEPOCH.quantity
            return coords.SkyCoord(
                ra=self.RAJ.quantity + dRA,
                dec=self.DECJ.quantity + dDEC,
                pm_ra_cosdec=self.PMRA.quantity * broadcast,
                pm_dec=self.PMDEC.quantity * broadcast,
                obstime=newepoch,
                frame=coords.ICRS,
            )
        else:
            if isinstance(epoch, Time):
                newepoch = epoch
            else:
                newepoch = Time(epoch, format="mjd")
            position_now = add_dummy_distance(self.get_psr_coords())
            position_then = remove_dummy_distance(
                position_now.apply_space_motion(new_obstime=newepoch))
            return position_then
Пример #5
0
    def test_proper_motion(self):
        """
        use the PINT and astropy proper motion calculations and compare
        """

        # make a test SkyCoord object
        # make sure it has obstime and distance supplied
        # to use it for conversions as well
        J0613_icrs = self.modelJ0613.coords_as_ICRS()
        J0613_icrs_now = utils.add_dummy_distance(J0613_icrs)
        newepoch = self.modelJ0613.POSEPOCH.quantity.mjd + 100
        # now do it for a future epoch
        J0613_icrs = self.modelJ0613.coords_as_ICRS(epoch=newepoch)
        # and use the coordinates now but use astropy's space motion
        print(
            J0613_icrs_now.apply_space_motion(new_obstime=astropy.time.Time(
                newepoch, scale="tdb", format="mjd")))
        J0613_icrs_now_to_then = utils.remove_dummy_distance(
            J0613_icrs_now.apply_space_motion(new_obstime=astropy.time.Time(
                newepoch, scale="tdb", format="mjd")))
        sep = J0613_icrs.separation(J0613_icrs_now_to_then)
        msg = (
            "Applying proper motion for +100d failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-9 * u.arcsec, msg

        # make sure it can support newepoch supplied as a Time object
        newepoch = astropy.time.Time(newepoch, format="mjd")
        J0613_icrs = self.modelJ0613.coords_as_ICRS(epoch=newepoch)
        J0613_icrs_now_to_then = utils.remove_dummy_distance(
            J0613_icrs_now.apply_space_motion(new_obstime=newepoch))
        sep = J0613_icrs.separation(J0613_icrs_now_to_then)
        msg = (
            "Applying proper motion for +100d failed with separation %.1e arcsec"
            % sep.arcsec)
        assert sep < 1e-9 * u.arcsec, msg