Beispiel #1
0
names.remove(names[6])
names_cat.remove(names_cat[6])

print('Select Source', flush=True)
Test_source = 'J1643-1224'

print('Define Simulation Parameters', flush=True)
times_str = np.load('./binarytimestamps/times_%s.npy' %
                    Test_source).astype(str)
times = Time(times_str)

##Knowns
if not os.path.isfile('%s_params.npy' % Test_source):
    try:
        query = QueryATNF(psrs=names_cat)
        psrs = query.get_pulsars()
        cat = True
    except:
        print('psrqpy not available', flush=True)
        sys.exit()
    PSR = psrs[Test_source]
    dp = PSR.DIST_DM1 * u.kpc
    Om_peri = PSR.OM * u.deg
    Om_peri_dot = PSR.OMDOT * u.deg / u.year
    A1 = PSR.A1 * u.s * const.c
    Ecc = PSR.ECC
    Pb = PSR.PB * u.day
    if str(PSR.T0) == '--':
        TASC = Time(PSR.TASC, format='mjd')
        T0 = Time(brentq(orbfits.T0_find,
                         TASC.mjd, (TASC + Pb).mjd,
Beispiel #2
0
    def __init__(self, name, data=None, sigma=None):
        self.name = name

        if not os.path.isfile('%s_params.npy' % self.name):
            try:
                query = QueryATNF(psrs=[self.name])
                psrs = query.get_pulsars()
                cat = True
            except:
                print('psrqpy not available', flush=True)
                sys.exit()
            PSR = psrs[self.name]

            self.dp = parameter(PSR.DIST_DM1 * u.kpc)
            if not PSR.DIST_DM1_ERR == None:
                sig = PSR.DIST_DM1_ERR
                self.dp.lnprior = lambda x: np.exp(.5 * (
                    (x - self.dp.val.value) / sig)**2) / np.sqrt(2 * np.pi *
                                                                 err**2)
                self.dp.fixed = False

            self.Om_peri = parameter(PSR.OM * u.deg)
            if not PSR.OM_ERR == None:
                sig = PSR.OM_ERR
                self.Om_peri.lnprior = lambda x: np.exp(.5 * (
                    (x - self.Om_peri.val.value) / sig)**2) / np.sqrt(2 * np.pi
                                                                      * err**2)
                self.Om_peri.fixed = False

            self.Om_peri_dot = parameter(PSR.OMDOT * u.deg / u.year)
            if not PSR.OMDOT_ERR == None:
                sig = PSR.OMDOT_ERR
                self.Om_peri_dot.lnprior = lambda x: np.exp(.5 * (
                    (x - self.Om_peri_dot.val.value) / sig)**2) / np.sqrt(
                        2 * np.pi * err**2)
                self.Om_peri_dot.fixed = False

            self.A1 = parameter(PSR.A1 * u.s * const.c)
            if not PSR.A1_ERR == None:
                sig = PSR.A1_ERR * const.c.value
                self.A1.lnprior = lambda x: np.exp(.5 * (
                    (x - self.A1.val.value) / sig)**2) / np.sqrt(2 * np.pi *
                                                                 err**2)
                self.A1.fixed = False

            self.Ecc = parameter(PSR.ECC)
            if not PSR.ECC_ERR == None:
                sig = PSR.ECC_ERR
                self.Ecc.lnprior = lambda x: np.exp(.5 * (
                    (x - self.A1.val) / sig)**2) / np.sqrt(2 * np.pi * err**2)
                self.Ecc.fixed = False

            self.Pb = parameter(PSR.PB * u.day)
            if not PSR.PB_ERR == None:
                sig = PSR.PB_ERR
                self.Pb.lnprior = lambda x: np.exp(.5 * (
                    (x - self.Pb.val.value) / sig)**2) / np.sqrt(2 * np.pi *
                                                                 err**2)
                self.Pb.fixed = False
            if str(PSR.T0) == '--':
                TASC = Time(PSR.TASC, format='mjd')
                self.T0 = parameter(
                    Time(brentq(orbfits.T0_find,
                                TASC.mjd, (TASC + Pb).mjd,
                                args=(TASC, -Om_peri, Pb, Ecc)),
                         format='mjd'))
                if not PSR.TASC_ERR == None:
                    sig = PSR.TASC_ERR
                    self.T0.lnprior = lambda x: np.exp(.5 * (
                        (x - self.T0.val.mjd) / sig)**2) / np.sqrt(2 * np.pi *
                                                                   err**2)
                    self.T0.fixed = False
            else:
                self.T0 = parameter(Time(PSR.T0, format='mjd'))
                if not PSR.T0_ERR == None:
                    sig = PSR.PB_ERR
                    self.T0.lnprior = lambda x: np.exp(.5 * (
                        (x - self.T0.val.mjd) / sig)**2) / np.sqrt(2 * np.pi *
                                                                   err**2)
                    self.T0.fixed = False

            self.pm_ra = parameter(
                (PSR.PMRA * u.mas / u.year).to_value(u.rad / u.s) / u.s)
            if not PSR.PMRA_ERR == None:
                sig = (PSR.PMRA_ERR * u.mas / u.year).to_value(u.rad / u.s)
                self.pm_ra.lnprior = lambda x: np.exp(.5 * (
                    (x - self.pm_ra.val.value) / sig)**2) / np.sqrt(2 * np.pi *
                                                                    err**2)
                self.pm_ra.fixed = False

            self.pm_dec = parameter(
                (PSR.PMDec * u.mas / u.year).to_value(u.rad / u.s) / u.s)
            if not PSR.PMDec_ERR == None:
                sig = (PSR.PMDec_ERR * u.mas / u.year).to_value(u.rad / u.s)
                self.pm_dec.lnprior = lambda x: np.exp(.5 * (
                    (x - self.pm_dec.val.value) / sig)**2) / np.sqrt(2 * np.pi
                                                                     * err**2)
                self.pm_dec.fixed = False
            self.srce = SkyCoord.from_name('PSR %s' % Test_source)
            np.save(
                '%s_params.npy' % Test_source,
                np.array([
                    dp.value, Om_peri.value, Om_peri_dot.value, A1.value, Ecc,
                    Pb.value, T0.mjd, pm_ra.value, pm_dec.value,
                    self.srce.ra.to_value(u.deg),
                    self.srce.dec.to_value(u.deg)
                ]))

        self.Om_orb = parameter(180, lambda x: bound_prior(x, 0, 360))
        self.Om_scr = parameter(0,
                                lambda x: bound_prior(x, -90, 90),
                                fixed=False)
        self.inc = parameter(45, lambda x: bound_prior(x, 0, 1), fixed=False)
        self.s = parameter(.5, lambda x: bound_prior(x, 0, 1), fixed=False)
        self.data = data
        self.sigma = sigma