示例#1
0
def check_db_and_create_det(pulsar):
    """
    Checks to see if a pulsar is already on the database. If not, will create a new entry

    Parameters:
    -----------
    puslar: str
        The name of the pulsar

    Returns:
    --------
    new_pulsar: boolean
        If True, this is a new pulsar detection
    """
    web_address, auth = get_db_auth_addr()
    pul_list_dict = client.pulsar_list(web_address, auth)
    pul_list_str = ''
    for p in pul_list_dict:
        pul_list_str = pul_list_str + p[u'name']
    if pulsar in pul_list_str:
        logger.info('This pulsar is already on the database')
        #gets Ra and DEC from PSRCAT
        pulsar_ra_dec = fpio.get_psrcat_ra_dec(pulsar_list=[pulsar])
        pulsar_name, pul_ra, pul_dec = pulsar_ra_dec[0]
        new_pulsar = False
    else:
        logger.info('Congratulations you have detected ' + pulsar + ' for the first time with the MWA')
        #gets Ra and DEC from PSRCAT
        pulsar_ra_dec = fpio.get_psrcat_ra_dec(pulsar_list=[pulsar])
        pulsar_name, pul_ra, pul_dec = pulsar_ra_dec[0]
        #then adds it to the database
        client.pulsar_create(web_address, auth, name = pulsar, ra = pul_ra, dec = pul_dec)
        new_pulsar = True
    return new_pulsar
def test_get_psrcat_ra_dec():
    """Test the psrqpy query and the max DM of get_psrcat_ra_dec"""
    ans = fpio.get_psrcat_ra_dec(
        pulsar_list=['J0002+6216', 'J0006+1834', 'J1056-6258'], max_dm=300)
    # Removes J0002+6216 because it has no DM and J1056-6258 becausethe DM is over 300
    if ans != [['J0006+1834', '00:06:04.8', '+18:34:59']]:
        raise AssertionError()
示例#3
0
        ffa = 28.5
        ax.fill_between(np.array(map_ra_range)/180.*np.pi + -np.pi,
                        np.full(len(map_ra_range),np.radians((-16.5)/90.*ff+ffa)),
                        np.full(len(map_ra_range),np.radians((34.5)/90.*ff+ffa)),
                        facecolor='0.5', alpha=0.5, transform=trans)

        handles, labels = ax.get_legend_handles_labels()
        plt.legend(bbox_to_anchor=(0.84, 0.85,0.21,0.2), loc=3,numpoints=1,
                   ncol=1, mode="expand", borderaxespad=0., fontsize=6)


    if args.pulsar_all:
        #add some pulsars
        ra_PCAT = []
        dec_PCAT = []
        pulsar_list = get_psrcat_ra_dec()
        for pulsar in pulsar_list:
            ra_temp, dec_temp = sex2deg(pulsar[1], pulsar[2])
            if args.ra_offset:
                if ra_temp > 180:
                    ra_PCAT.append(-ra_temp/180.*np.pi+2*np.pi)
                else:
                    ra_PCAT.append(-ra_temp/180.*np.pi)
            else:
                ra_PCAT.append(-ra_temp/180.*np.pi+np.pi)
            dec_PCAT.append(dec_temp/180.*np.pi)
        ax.scatter(ra_PCAT, dec_PCAT, s=0.2, color ='b', zorder=90)


    if args.pulsar:
        #add some pulsars
示例#4
0
    elif args.ascii:
        if not args.stop or not args.start:
            logger.error(
                "Please supply both start and stop times of the detection for ascii files"
            )
            sys.exit(1)
        profile, num_bins = prof_utils.get_from_ascii(args.ascii)
        dm, period = get_pulsar_dm_p(args.pulsar)
        time_detection = args.stop - args.start
        bestprof_data = [
            args.obsid, args.pulsar, dm, period, None, args.start,
            time_detection, profile, num_bins
        ]

    if args.bestprof or args.ascii:
        _, pul_ra, pul_dec = fpio.get_psrcat_ra_dec(
            pulsar_list=[args.pulsar])[0]
        subbands = flux_cal_and_submit(time_obs,
                                       metadata,
                                       bestprof_data,
                                       pul_ra,
                                       pul_dec,
                                       coh,
                                       auth,
                                       pulsar=args.pulsar,
                                       trcvr=args.trcvr)

    if args.cal_dir_to_tar:
        if not args.srclist:
            logger.error(
                "You must use --srclist to define the srclist file location. Exiting"
            )
示例#5
0
    #calculate pointing
    if args.all_pointings:
        #calculating loop number
        fudge_factor = 2.
        tile_fwhm = np.degrees(fudge_factor * (3 * 10**8 /
                                               (centrefreq * 10**6)) / 6.56)
        #account for the "increase" in tile beam size due to drifting
        tile_fwhm += duration / 3600. * 15.
        args.loop = int(tile_fwhm / 2. / (args.deg_fwhm * args.fraction))

        #calculating pointing from metadata
        ra = np.radians(ra + duration / 3600. * 15. / 2)
        dec = np.radians(dec)
    elif args.pulsar:
        temp = fpio.get_psrcat_ra_dec(pulsar_list=args.pulsar)
        _, raj, decj = fpio.format_ra_dec(temp, ra_col=1, dec_col=2)[0]
        coord = SkyCoord(raj, decj, unit=(u.hourangle, u.deg))
        ra = coord.ra.radian  #in radians
        dec = coord.dec.radian
    elif args.pointing:
        coord = SkyCoord(args.pointing[0],
                         args.pointing[1],
                         unit=(u.hourangle, u.deg))
        ra = coord.ra.radian  #in radians
        dec = coord.dec.radian
    else:
        print(
            "Please use either --pointing, --pulsar or --all_pointings. Exiting."
        )
        quit()
示例#6
0
        obsid = args.obsid
    else:
        logger.error("Please us either (--obsid and --pulsar) or --bestprof")
        quit()

    if args.pulsar or args.bestprof or args.ascii:
        #Checks to see if the pulsar is already on the database
        pul_list_dict = client.pulsar_list(web_address, auth)
        pul_list_str = ''
        for p in pul_list_dict:
            pul_list_str = pul_list_str + p[u'name']
        if pulsar in pul_list_str:
            logger.info('This pulsar is already on the database')

            #gets Ra and DEC from PSRCAT
            pulsar_ra_dec = fpio.get_psrcat_ra_dec(pulsar_list=[pulsar])
            pulsar_name, pul_ra, pul_dec = pulsar_ra_dec[0]
        else:
            logger.info('Congratulations you have detected ' + pulsar + ' for the first time with the MWA')
            #gets Ra and DEC from PSRCAT
            pulsar_ra_dec = fpio.get_psrcat_ra_dec(pulsar_list=[pulsar])
            pulsar_name, pul_ra, pul_dec = pulsar_ra_dec[0]

            #then adds it to the database
            client.pulsar_create(web_address, auth, name = pulsar, ra = pul_ra, dec = pul_dec)





    #get meta data from obsid