def coords_as_ICRS(self, epoch=None): """Returns pulsar sky coordinates as an astropy ICRS object instance. Pulsar coordinates will be transform from ecliptic coordinates to ICRS If epoch (MJD) is specified, proper motion is included to return the position at the given epoch. If the ecliptic coordinates are provided, """ if epoch is None or (self.PMELONG.value == 0.0 and self.PMELAT.value == 0.0): pos_ecl = PulsarEcliptic(lon=self.ELONG.quantity, lat=self.ELAT.quantity) else: dt = (epoch - self.POSEPOCH.quantity.mjd) * u.d dELONG = dt * self.PMELONG.quantity / numpy.cos( self.ELAT.quantity.radian) dELAT = dt * self.PMELAT.quantity try: PulsarEcliptic.obliquity = OBL[self.ECL.value] except KeyError: raise ValueError("No obliquity " + self.ECL.value + " provided. " "Check your pint/datafile/ecliptic.dat file.") pos_ecl = PulsarEcliptic(lon=self.ELONG.quantity + dELONG, lat=self.ELAT.quantity + dELAT) return pos_ecl.transform_to(coords.ICRS)
def get_params_as_ICRS(self): result = dict() # NOTE This feature below needs astropy version 2.0. dlon_coslat = self.PMELONG.quantity # * numpy.cos(self.ELAT.quantity.radian) # Astropy2 and astropy3 have different APIs if int(astropy_version.split(".")[0]) <= 2: pv_ECL = PulsarEcliptic( lon=self.ELONG.quantity, lat=self.ELAT.quantity, d_lon_coslat=dlon_coslat, d_lat=self.PMELAT.quantity, ) else: pv_ECL = PulsarEcliptic( lon=self.ELONG.quantity, lat=self.ELAT.quantity, pm_lon_coslat=dlon_coslat, pm_lat=self.PMELAT.quantity, ) pv_ICRS = pv_ECL.transform_to(coords.ICRS) result["RAJ"] = pv_ICRS.ra.to(u.hourangle) result["DECJ"] = pv_ICRS.dec result["PMRA"] = pv_ICRS.pm_ra_cosdec result["PMDEC"] = pv_ICRS.pm_dec return result
def get_params_as_ICRS(self): result = dict() # NOTE This feature below needs astropy version 2.0. dlon_coslat = self.PMELONG.quantity #* numpy.cos(self.ELAT.quantity.radian) pv_ECL = PulsarEcliptic(lon=self.ELONG.quantity, lat=self.ELAT.quantity, d_lon_coslat=dlon_coslat, d_lat=self.PMELAT.quantity) pv_ICRS = pv_ECL.transform_to(coords.ICRS) result['RAJ'] = pv_ICRS.ra.to(u.hourangle) result['DECJ'] = pv_ICRS.dec result['PMRA'] = pv_ICRS.pm_ra_cosdec result['PMDEC'] = pv_ICRS.pm_dec return result
def get_psr_coords(self, epoch=None): """Returns pulsar sky coordinates as an astropy ecliptic oordinates object. Pulsar coordinates will be computed at current coordinates. If epoch (MJD) is specified, proper motion is included to return the position at the given epoch. """ try: PulsarEcliptic.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): dELONG = 0.0 * self.ELONG.units dELAT = 0.0 * self.ELAT.units else: dt = (epoch - self.POSEPOCH.quantity.mjd) * u.d dELONG = dt * self.PMELONG.quantity / numpy.cos( self.ELAT.quantity.radian) dELAT = dt * self.PMELAT.quantity pos_ecl = PulsarEcliptic(lon=self.ELONG.quantity + dELONG, lat=self.ELAT.quantity + dELAT) return pos_ecl
def coords_as_ECL(self, epoch=None, ecl=None): """Return the pulsar's ecliptic coordinates as an astropy coordinate object. The value used for the obliquity of the ecliptic can be controlled with the `ecl` keyword, which should be one of the codes listed in `ecliptic.dat`. If `ecl` is left unspecified, the model's ECL parameter will be used. """ pos_ecl = self.get_psr_coords(epoch) if ecl is not None: pos_ecl = pos_ecl.transform_to(PulsarEcliptic(ecl=ecl)) return pos_ecl
def get_params_as_ICRS(self): result = dict() # NOTE This feature below needs astropy version 2.0. dlon_coslat = self.PMELONG.quantity #* numpy.cos(self.ELAT.quantity.radian) # Astropy2 and astropy3 have different APIs if int(astropy_version.split('.')[0]) <= 2: pv_ECL = PulsarEcliptic(lon=self.ELONG.quantity, lat=self.ELAT.quantity, d_lon_coslat=dlon_coslat, d_lat=self.PMELAT.quantity) else: pv_ECL = PulsarEcliptic(lon=self.ELONG.quantity, lat=self.ELAT.quantity, pm_lon_coslat=dlon_coslat, pm_lat=self.PMELAT.quantity) pv_ICRS = pv_ECL.transform_to(coords.ICRS) result['RAJ'] = pv_ICRS.ra.to(u.hourangle) result['DECJ'] = pv_ICRS.dec result['PMRA'] = pv_ICRS.pm_ra_cosdec result['PMDEC'] = pv_ICRS.pm_dec return result
def coords_as_ECL(self, epoch=None, ecl=None): """Return the pulsar's ecliptic coordinates as an astropy coordinate object. The value used for the obliquity of the ecliptic can be controlled with the `ecl` keyword, which should be one of the codes listed in `ecliptic.dat`. If `ecl` is left unspecified, the global default IERS2010 will be used. """ if ecl is None: log.info("ECL not specified; using IERS2010.") ecl = "IERS2010" pos_icrs = self.get_psr_coords(epoch=epoch) return pos_icrs.transform_to(PulsarEcliptic(ecl=ecl))
def coords_as_ICRS(self, epoch=None): """Returns pulsar sky coordinates as an astropy ICRS object instance. Pulsar coordinates will be transform from ecliptic coordinates to ICRS If epoch (MJD) is specified, proper motion is included to return the position at the given epoch. If the ecliptic coordinates are provided, """ if epoch is None or (self.PMELONG.value == 0.0 and self.PMELAT.value == 0.0): pos_ecl = PulsarEcliptic(lon=self.ELONG.quantity, lat=self.ELAT.quantity) else: dt = (epoch - self.POSEPOCH.quantity.mjd) * u.d dELONG = dt * self.PMELONG.quantity / numpy.cos(self.ELAT.quantity.radian) dELAT = dt * self.PMELAT.quantity try: PulsarEcliptic.obliquity = OBL[self.ECL.value] except KeyError: raise ValueError("No obliquity " + self.ECL.value + " provided. " "Check your pint/datafile/ecliptic.dat file.") pos_ecl = PulsarEcliptic(lon=self.ELONG.quantity+dELONG, lat=self.ELAT.quantity+dELAT) return pos_ecl.transform_to(coords.ICRS)
def get_d_delay_quantities_ecliptical(self, toas): """Calculate values needed for many d_delay_d_param functions """ # TODO: Move all these calculations in a separate class for elegance rd = dict() # From the earth_ra dec to earth_elong and elat try: obliquity = OBL[self.ECL.value] except KeyError: raise ValueError("No obliquity " + self.ECL.value + " provided. " "Check your pint/datafile/ecliptic.dat file.") rd = self.get_d_delay_quantities(toas) coords_icrs = coords.ICRS(ra=rd["earth_ra"], dec=rd["earth_dec"]) coords_elpt = coords_icrs.transform_to( PulsarEcliptic(obliquity=obliquity)) rd["earth_elong"] = coords_elpt.lon rd["earth_elat"] = coords_elpt.lat return rd
def as_ECL(self, epoch=None, ecl="IERS2010"): """Return pint.models.astrometry.Astrometry object in PulsarEcliptic frame. Parameters ---------- epoch : `astropy.time.Time` or Float, optional new epoch for position. If Float, MJD(TDB) is assumed. Note that uncertainties are not adjusted. ecl : str, optional Obliquity for PulsarEcliptic frame Returns ------- pint.models.astrometry.AstrometryEcliptic """ # change epoch only if ecl == self.ECL.value: m = copy.deepcopy(self) if epoch is not None: m.change_posepoch(epoch) return m m_ecl = AstrometryEcliptic() # transfer over parallax and POSEPOCH: don't need to change m_ecl.PX = self.PX m_ecl.POSEPOCH = self.POSEPOCH # get ELONG, ELAT, PM c = self.coords_as_ECL(epoch=epoch, ecl=ecl) m_ecl.ELONG.quantity = c.lon m_ecl.ELAT.quantity = c.lat m_ecl.PMELONG.quantity = c.pm_lon_coslat m_ecl.PMELAT.quantity = c.pm_lat m_ecl.ECL.value = ecl # use fake proper motions to convert uncertainties on ELONG, ELAT # assume that ELONG uncertainty does not include cos(ELAT) # and that the RA uncertainty does not include cos(DEC) # put it in here as pm_ra_cosdec since astropy complains otherwise dt = 1 * u.yr c = coords.SkyCoord( lon=self.ELONG.quantity, lat=self.ELAT.quantity, obliquity=OBL[self.ECL.value], obstime=self.POSEPOCH.quantity, pm_lon_coslat=self.ELONG.uncertainty * np.cos(self.ELAT.quantity) / dt, pm_lat=self.ELAT.uncertainty / dt, frame=PulsarEcliptic, ) c_ECL = c.transform_to(PulsarEcliptic(ecl=ecl)) m_ecl.ELONG.uncertainty = c_ECL.pm_lon_coslat * dt / np.cos(c_ECL.lat) m_ecl.ELAT.uncertainty = c_ECL.pm_lat * dt # use fake proper motions to convert uncertainties on proper motion # assume that PMELONG uncertainty includes cos(DEC) c = coords.SkyCoord( lon=self.ELONG.quantity, lat=self.ELAT.quantity, obliquity=OBL[self.ECL.value], obstime=self.POSEPOCH.quantity, pm_lon_coslat=self.PMELONG.uncertainty, pm_lat=self.PMELAT.uncertainty, frame=PulsarEcliptic, ) c_ECL = c.transform_to(PulsarEcliptic(ecl=ecl)) m_ecl.PMELONG.uncertainty = c_ECL.pm_lon_coslat m_ecl.PMELAT.uncertainty = c_ECL.pm_lat # freeze comparable parameters m_ecl.ELONG.frozen = self.ELONG.frozen m_ecl.ELAT.frozen = self.ELAT.frozen m_ecl.PMELONG.frozen = self.PMELONG.frozen m_ecl.PMELAT.frozen = self.PMELAT.frozen return m_ecl
def coords_as_ECL(self, epoch=None): obliquity = OBL[self.ECL.value] pos_icrs = self.get_psr_coords(epoch=epoch) return pos_icrs.transform_to(PulsarEcliptic(obliquity=obliquity))