示例#1
0
def test_get_obs_array_phase():
    """Test FWHM calculation"""
    for obsid, expect_ans in [(1117101752, 'P1'), (1252177744, 'P2C'),
                              (1247832024, 'P2E'), (1188439520, 'OTH')]:
        ans = get_obs_array_phase(obsid)
        if ans != expect_ans:
            raise AssertionError()
示例#2
0
def find_pulsars_in_fov(obsid, psrbeg, psrend):
    """
    Find all pulsars in the field of view and return all the pointings sorted into vdif and normal lists:
    -----------
    obsid: int
        The observation ID
    psrbeg: int
        The begining of the observation you are processing in GPS time
    psrend: int
        The end of the observation you are processing in GPS time

    Returns:
    --------
    list of lists:
           [pulsar_name_list,
            pulsar_pointing_list,
            vdif_name_list,
            vdif_pointing_list,
            sp_name_list,
            sp_pointing_list]
    """

    #Find all pulsars in beam at at least 0.3 of zenith normlaized power
    names_ra_dec = np.array(fpio.grab_source_alog(max_dm=250))
    pow_dict, meta_data = find_pulsars_power(obsid,
                                             powers=[0.3, 0.1],
                                             names_ra_dec=names_ra_dec)
    channels = meta_data[-1][-1]
    obs_psrs = pow_dict[0.3][obsid]
    psrs_list_03 = [x[0] for x in obs_psrs]
    #Include all bright pulsars in beam at at least 0.1 of zenith normalized power
    psrs_01 = [x[0] for x in pow_dict[0.1][obsid]]
    sn_dict_01 = snfe.multi_psr_snfe(psrs_01,
                                     obsid,
                                     beg=psrbeg,
                                     end=psrend,
                                     min_z_power=0.1)
    for psr in pow_dict[0.1][obsid]:
        if psr[0] not in psrs_list_03:
            sn, sn_err = sn_dict_01[psr[0]]
            if sn is not None and sn_err is not None:
                if sn - sn_err >= 10.:
                    obs_psrs.append(psr)

    #get all the pulsars periods
    pulsar_list = []
    for o in obs_psrs:
        pulsar_list.append(o[0])
    periods = psrqpy.QueryATNF(params=["P0"],
                               psrs=pulsar_list,
                               loadfromdb=ATNF_LOC).pandas["P0"]

    oap = get_obs_array_phase(obsid)
    centrefreq = 1.28 * float(min(channels) + max(channels)) / 2.
    fwhm = calc_ta_fwhm(centrefreq, array_phase=oap)

    # Sort all the sources into 3 categories, pulsars which is for slow pulsars, vdif
    # for fast pulsars that require vdif and sp for singple pulse searches (FRBs,
    # RRATs and pulsars without ATNF periods)
    pulsar_pointing_list = []
    pulsar_name_list = []
    vdif_pointing_list = []
    vdif_name_list = []
    pulsar_search_pointing_list = []
    pulsar_search_name_list = []
    sp_pointing_list = []
    sp_name_list = []

    for pi, pulsar_line in enumerate(obs_psrs):
        vdif_check = False
        sp_check = False

        PSRJ = pulsar_line[0]
        #See if pulsar is in beam for times
        #enter, exit = snfe.pulsar_beam_coverage(obsid, PSRJ, beg=psrbeg, end=psrend)
        #if enter is None or exit is None:
        #    print("{0} is not in beam for time range. Not beamforming".format(PSRJ))
        #    continue
        #TODO: uncomment this section when sn_flux_est is pulled to vcstools master

        if not (len(PSRJ) < 11 or PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa'):
            continue

        for line in names_ra_dec:
            if PSRJ == line[0]:
                temp = [line]

        #temp = fpio.get_psrcat_ra_dec(pulsar_list=[PSRJ])
        temp = fpio.format_ra_dec(temp, ra_col=1, dec_col=2)
        jname, raj, decj = temp[0]
        #get pulsar period
        period = periods[pi]
        if math.isnan(period):
            print(
                "WARNING: Period not found in ephermeris for {0} so assuming "
                "it's an RRAT".format(jname))
            sp_check = True
            period = 0.
        elif float(period) < .05:
            vdif_check = True
        period = float(period) * 1000.
        print(
            "{0:12} RA: {1} Dec: {2} Period: {3:8.2f} (ms) Begin {4} End {5}".
            format(PSRJ, raj, decj, period, psrbeg, psrend))

        jname_temp_list = []
        if PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa':
            #Got to find all the pulsar J names with other letters
            vdif_check = True
            for pulsar_l in obs_psrs:
                pulsar_name = pulsar_l[0]
                if pulsar_name.startswith(PSRJ[:-2]):
                    jname_temp_list.append(pulsar_name)
        else:
            jname_temp_list.append(jname)

        # grid the pointings to fill 2 arcminute raduis to account for ionosphere shift
        pointing_list_list = get_pointings_required(raj, decj, fwhm, 2. / 60.)

        # sort the pointings into the right groups
        for prd in pointing_list_list:
            if vdif_check:
                vdif_name_list.append(jname_temp_list)
                vdif_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))
            elif sp_check:
                sp_name_list.append(jname_temp_list)
                sp_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))
            else:
                pulsar_name_list.append(jname_temp_list)
                pulsar_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))

    #Get the rest of the singple pulse search canidates
    #-----------------------------------------------------------------------------------------------------------
    temp = get_sources_in_fov(obsid, 'RRATs', fwhm)
    sp_name_list = sp_name_list + temp[0]
    sp_pointing_list = sp_pointing_list + temp[1]

    # Find all of the FRB candidates
    #-----------------------------------------------------------------------------------------------------------
    temp = get_sources_in_fov(obsid, 'FRB', fwhm)
    sp_name_list = sp_name_list + temp[0]
    sp_pointing_list = sp_pointing_list + temp[1]

    # Find all of the Fermi candidates
    #-----------------------------------------------------------------------------------------------------------
    fermi_list = get_sources_in_fov(obsid, 'Fermi', fwhm)
    pulsar_search_name_list = pulsar_search_name_list + fermi_list[0]
    pulsar_search_pointing_list = pulsar_search_pointing_list + fermi_list[1]

    # Find all of the points of interest candidates
    #-----------------------------------------------------------------------------------------------
    poi_list = get_sources_in_fov(obsid, 'POI', fwhm)
    pulsar_search_name_list = pulsar_search_name_list + poi_list[0]
    pulsar_search_pointing_list = pulsar_search_pointing_list + poi_list[1]

    # Sometimes we get redundant RRATs that are found in RRAT and ANTF catalogues so they need to be removed
    sp_name_list = list(dict.fromkeys([";".join(s) for s in sp_name_list]))
    sp_pointing_list = list(dict.fromkeys(sp_pointing_list))

    # Changing the format of the names list to make it easier to format
    return [[";".join(s) for s in pulsar_name_list], pulsar_pointing_list,
            [";".join(s) for s in vdif_name_list], vdif_pointing_list,
            [";".join(s) for s in pulsar_search_name_list],
            pulsar_search_pointing_list, sp_name_list, sp_pointing_list]
def write_output_obs_files(output_data,
                           obsid_meta,
                           beam='analytic',
                           min_power=0.3,
                           cal_check=False,
                           SN_est=False):
    """
    Writes an ouput file using the output of find_sources_in_obs when obs_for_source is false.
    """
    for on, obsid in enumerate(output_data):
        oap = get_obs_array_phase(obsid)
        out_name = "{0}_{1}_beam.txt".format(obsid, beam)
        with open(out_name, "w") as output_file:
            output_file.write(
                '#All of the sources that the {0} beam model calculated a power'
                'of {1} or greater for observation ID: {2}\n'.format(
                    beam, min_power, obsid))
            output_file.write(
                '#Observation data :RA(deg): {0} DEC(deg): {1} Duration(s): '
                '{2} Array Phase: {3}\n'.format(obsid_meta[on][1],
                                                obsid_meta[on][2],
                                                obsid_meta[on][3], oap))
            if cal_check:
                #checks the MWA Pulsar Database to see if the obsid has been
                #used or has been calibrated
                logger.info(
                    "Checking the MWA Pulsar Databse for the obsid: {0}".
                    format(obsid))
                cal_check_result = cal_on_database_check(obsid)
                output_file.write(
                    "#Calibrator Availability: {0}\n".format(cal_check_result))
            output_file.write('#Column headers:\n')
            output_file.write('#Source: Pulsar Jname\n')
            output_file.write('#Enter:  The fraction of the observation when '+\
                                        'the source entered the beam\n')
            output_file.write('#Exit:   The fraction of the observation when '+\
                                        'the source exits the beam\n')
            output_file.write(
                '#Power:  The maximum zenith normalised power of the source.\n'
            )
            if SN_est:
                output_file.write(
                    "#S/N Est: An estimate of the expected signal to noise using ANTF flux desnities\n"
                )
                output_file.write("#S/N Err: The uncertainty of S/N Est\n")

            output_file.write('#Source    |Enter|Exit |Power')
            if SN_est:
                output_file.write('| S/N Est | S/N Err \n')
            else:
                output_file.write('\n')

            for data in output_data[obsid]:
                pulsar, enter, exit, max_power = data
                output_file.write('{:11} {:1.3f} {:1.3f} {:1.3f} '.format(
                    pulsar, enter, exit, max_power))
                if SN_est:
                    beg = int(obsid) + 7
                    end = beg + int(obsid_meta[on][3])
                    pulsar_sn, pulsar_sn_err = sfe.est_pulsar_sn(pulsar, obsid, beg=beg, end=end,\
                      obs_metadata=obsid_meta[on], o_enter=enter, o_exit=exit)
                    if pulsar_sn is None:
                        output_file.write('   None    None\n')
                    else:
                        output_file.write('{:9.2f} {:9.2f}\n'.format(
                            pulsar_sn, pulsar_sn_err))
                else:
                    output_file.write('\n')

    return
def write_output_source_files(output_data,
                              beam='analytic',
                              min_power=0.3,
                              cal_check=False,
                              SN_est=False):
    """
    Writes an ouput file using the output of find_sources_in_obs when obs_for_source is true.
    """
    for source in output_data:
        out_name = "{0}_{1}_beam.txt".format(source, beam)
        with open(out_name, "w") as output_file:
            output_file.write(
                '#All of the observation IDs that the {0} beam model '
                'calculated a power of {1} or greater for the source: '
                '{2}\n'.format(beam, min_power, source))
            output_file.write('#Column headers:\n')
            output_file.write('#Obs ID: Observation ID\n')
            output_file.write(
                '#Dur:    The duration of the observation in seconds\n')
            output_file.write('#Enter:  The fraction of the observation when '
                              'the source entered the beam\n')
            output_file.write('#Exit:   The fraction of the observation when '
                              'the source exits the beam\n')
            output_file.write(
                '#Power:  The maximum zenith normalised power of the source.\n'
            )
            output_file.write(
                "#OAP:    The observation's array phase where P1 is the "
                "phase 1 array, P2C is the phase compact array "
                "and P2E is the phase 2 extended array.\n")

            if SN_est:
                output_file.write(
                    "#S/N Est: An estimate of the expected signal to noise using ANTF flux desnities\n"
                )
                output_file.write("#S/N Err: The uncertainty of S/N Est\n")
            if cal_check:
                output_file.write('#Cal ID: Observation ID of an available '+\
                                            'calibration solution\n')
            output_file.write('#Obs ID   |Dur |Enter|Exit |Power| OAP ')
            if SN_est:
                output_file.write("|S/N Est|S/N Err")

            if cal_check:
                output_file.write("|Cal ID\n")
            else:
                output_file.write('\n')
            for data in output_data[source]:
                obsid, duration, enter, exit, max_power = data
                oap = get_obs_array_phase(obsid)
                output_file.write(
                    '{} {:4d} {:1.3f} {:1.3f} {:1.3f}  {:.3}'.format(
                        obsid, duration, enter, exit, max_power, oap))
                if SN_est:
                    pulsar_sn, pulsar_sn_err = sfe.est_pulsar_sn(pulsar, obsid)
                    if pulsar_sn is None:
                        output_file.write('   None    None')
                    else:
                        output_file.write('{:9.2f} {:9.2f}'.format(
                            pulsar_sn, pulsar_sn_err))

                if cal_check:
                    #checks the MWA Pulsar Database to see if the obsid has been
                    #used or has been calibrated
                    logger.info(
                        "Checking the MWA Pulsar Databse for the obsid: {0}".
                        format(obsid))
                    cal_check_result = cal_on_database_check(obsid)
                    output_file.write("   {0}\n".format(cal_check_result))
                else:
                    output_file.write("\n")
    return
示例#5
0
        help=
        'Manualy give the declination FWHM in degrees instead of it estimating it from the array phase and frequency'
    )
    args = parser.parse_args()

    # Set up plots
    fig = plt.figure()
    plt.rc("font", size=8)
    fig.add_subplot(111)
    ax = plt.axes()
    ax.axis('equal')

    # Get the fwhm of the observation
    meta_data = get_common_obs_metadata(args.obsid)
    channels = meta_data[-1]
    oap = get_obs_array_phase(args.obsid)
    if oap == "OTH":
        #Assume it's phase 2 extended array
        oap = "P2E"
    centrefreq = 1.28 * float(min(channels) + max(channels)) / 2.
    fwhm = calc_ta_fwhm(centrefreq, array_phase=oap)
    print("Observation ID: {}".format(args.obsid))
    print("FWHM: {} deg".format(fwhm))

    detections = []
    if args.bestprof_dir:
        for bestprof_file in glob.glob("{}/*bestprof".format(
                args.bestprof_dir)):
            with open(bestprof_file, "r") as bestprof:
                lines = bestprof.readlines()
                ra, dec = lines[0].split("=")[-1].split("_")[1:3]
def beamform_and_fold(obsid,
                      DI_dir,
                      cal_obs,
                      args,
                      psrbeg,
                      psrend,
                      product_dir='/group/mwaops/vcs',
                      mwa_search_version='master'):

    #obsbeg, obsend, obsdur = file_maxmin.print_minmax(obsid)

    #wrapping for find_pulsar_in_obs.py
    names_ra_dec = np.array(fpio.grab_source_alog(max_dm=250))
    obs_data, meta_data = fpio.find_sources_in_obs([obsid],
                                                   names_ra_dec,
                                                   dt_input=100)
    channels = meta_data[-1][-1]

    oap = get_obs_array_phase(obsid)
    centrefreq = 1.28 * float(min(channels) + max(channels)) / 2.
    fwhm = calc_ta_fwhm(centrefreq, array_phase=oap)

    # Sort all the sources into 3 categories, pulsars which is for slow pulsars, vdif
    # for fast pulsars that require vdif and sp for singple pulse searches (FRBs,
    # RRATs and pulsars without ATNF periods)
    pulsar_pointing_list = []
    pulsar_name_list = []
    vdif_pointing_list = []
    vdif_name_list = []
    sp_pointing_list = []
    sp_name_list = []
    for pulsar_line in obs_data[obsid]:
        vdif_check = False
        sp_check = False

        PSRJ = pulsar_line[0]
        if not (len(PSRJ) < 11 or PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa'):
            continue

        for line in names_ra_dec:
            if PSRJ == line[0]:
                temp = [line]

        #temp = fpio.get_psrcat_ra_dec(pulsar_list=[PSRJ])
        temp = fpio.format_ra_dec(temp, ra_col=1, dec_col=2)
        jname, raj, decj = temp[0]
        #get pulsar period
        period = psrqpy.QueryATNF(params=["P0"],
                                  psrs=[jname],
                                  loadfromdb=ATNF_LOC).pandas["P0"][0]

        if math.isnan(period):
            print(
                "WARNING: Period not found in ephermeris for {0} so assuming "
                "it's an RRAT".format(jname))
            sp_check = True
            period = 0.
        elif float(period) < .05:
            vdif_check = True
        period = float(period) * 1000.
        print(
            "{0:12} RA: {1} Dec: {2} Period: {3:8.2f} (ms) Begin {4} End {5}".
            format(PSRJ, raj, decj, period, psrbeg, psrend))

        jname_temp_list = []
        if PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa':
            #Got to find all the pulsar J names with other letters
            vdif_check = True
            for pulsar_l in pulsar_lines:
                if pulsar_l.startswith(PSRJ[:-2]):
                    jname_temp_list.append(pulsar_l.split()[0])
        else:
            jname_temp_list.append(jname)

        #convert to radians
        coord = SkyCoord(raj, decj, unit=(u.hourangle, u.deg))
        rar = coord.ra.radian  #in radians
        decr = coord.dec.radian

        #make a grid around each pulsar
        grid_sep = np.radians(fwhm * 0.6)
        rads, decds = get_grid(rar, decr, grid_sep, 1)

        #convert back to sexidecimals
        coord = SkyCoord(rads, decds, unit=(u.deg, u.deg))
        rajs = coord.ra.to_string(unit=u.hour, sep=':')
        decjs = coord.dec.to_string(unit=u.degree, sep=':')
        temp = []
        for raj, decj in zip(rajs, decjs):
            temp.append([raj, decj])
        pointing_list_list = fpio.format_ra_dec(temp, ra_col=0, dec_col=1)

        # sort the pointings into the right groups
        for prd in pointing_list_list:
            if vdif_check:
                vdif_name_list.append(jname_temp_list)
                vdif_pointing_list.append("{0} {1}".format(prd[0], prd[1]))
            elif sp_check:
                sp_name_list.append(jname_temp_list)
                sp_pointing_list.append("{0} {1}".format(prd[0], prd[1]))
            else:
                pulsar_name_list.append(jname_temp_list)
                pulsar_pointing_list.append("{0} {1}".format(prd[0], prd[1]))

    print('SENDING OFF PULSAR SEARCHS')
    # Send off pulsar search
    relaunch_script = 'mwa_search_pipeline.py -o {0} -O {1} --DI_dir {2} -b {3} -e {4} --channels'.format(
        obsid, cal_obs, DI_dir, psrbeg, psrend)
    for ch in channels:
        relaunch_script = "{0} {1}".format(relaunch_script, ch)
    search_opts = search_pipe.search_options_class(
        obsid,
        cal_id=cal_obs,
        begin=psrbeg,
        end=psrend,
        channels=channels,
        args=args,
        DI_dir=DI_dir,
        relaunch_script=relaunch_script,
        search_ver=mwa_search_version)
    search_pipe.beamform(search_opts,
                         pulsar_pointing_list,
                         pulsar_list_list=pulsar_name_list)

    print('SENDING OFF VDIF PULSAR SEARCHS')
    #Send off vdif pulsar search
    relaunch_script = "{0} --vdif".format(relaunch_script)
    search_opts = search_pipe.search_options_class(
        obsid,
        cal_id=cal_obs,
        begin=psrbeg,
        end=psrend,
        channels=channels,
        args=args,
        DI_dir=DI_dir,
        relaunch_script=relaunch_script,
        search_ver=mwa_search_version,
        vdif=True)
    search_pipe.beamform(search_opts,
                         vdif_pointing_list,
                         pulsar_list_list=vdif_name_list)

    #Get the rest of the singple pulse search canidates
    orig_names_ra_dec = fpio.grab_source_alog(source_type='RRATs',
                                              max_dm=250,
                                              include_dm=True)
    # remove any RRATs without at least arc minute accuracy
    names_ra_dec = np.array(
        [s for s in orig_names_ra_dec if (len(s[1]) > 4 and len(s[2]) > 4)])
    obs_data, meta_data = fpio.find_sources_in_obs([obsid],
                                                   names_ra_dec,
                                                   dt_input=100)

    for pulsar_line in obs_data[obsid]:
        jname = pulsar_line[0]
        for line in names_ra_dec:
            if jname == line[0]:
                jname, raj, decj, dm = line
        jname_temp_list = [jname]

        #convert to radians
        coord = SkyCoord(raj, decj, unit=(u.hourangle, u.deg))
        rar = coord.ra.radian  #in radians
        decr = coord.dec.radian

        #make a grid around each pulsar
        grid_sep = np.radians(fwhm * 0.6)
        rads, decds = get_grid(rar, decr, grid_sep, 1)

        #convert back to sexidecimals
        coord = SkyCoord(rads, decds, unit=(u.deg, u.deg))
        rajs = coord.ra.to_string(unit=u.hour, sep=':')
        decjs = coord.dec.to_string(unit=u.degree, sep=':')
        temp = []
        for raj, decj in zip(rajs, decjs):
            temp.append([raj, decj])
        pointing_list_list = fpio.format_ra_dec(temp, ra_col=0, dec_col=1)

        # sort the pointings into the right groups
        for prd in pointing_list_list:
            sp_name_list.append(jname_temp_list)
            sp_pointing_list.append("{0} {1}".format(prd[0], prd[1]))

    print('SENDING OFF SINGLE PULSE SEARCHS')
    # Send off pulsar search
    relaunch_script = 'mwa_search_pipeline.py -o {0} -O {1} --DI_dir {2} -b {3} -e {4} --single_pulse --channels'.format(
        obsid, cal_obs, DI_dir, psrbeg, psrend)
    for ch in channels:
        relaunch_script = "{0} {1}".format(relaunch_script, ch)
    search_opts = search_pipe.search_options_class(
        obsid,
        cal_id=cal_obs,
        begin=psrbeg,
        end=psrend,
        channels=channels,
        args=args,
        DI_dir=DI_dir,
        relaunch_script=relaunch_script,
        search_ver=mwa_search_version,
        single_pulse=True)
    search_pipe.beamform(search_opts,
                         sp_pointing_list,
                         pulsar_list_list=sp_name_list,
                         code_comment="Single pulse search")

    return
def submit_folds(obsid,
                 DI_dir,
                 cal_obs,
                 args,
                 psrbeg,
                 psrend,
                 product_dir='/group/mwaops/vcs',
                 mwa_search_version='master',
                 vcstools_version='master',
                 relaunch=False):
    """
    Beamforms on all pulsar locations in the obsid field between some time range. Launches search pipeline when done

    Parameters:
    -----------
    obsid: int
        The observation ID
    DI_dir: str
        The directory containing the Jones matrices solutions
    cal_obs:
        The calibration observation ID
    args: object
        The args object generated from argparse. Used for documentation purposes
    psrbeg: int
        The beginning of the observing time
    psrend: int
        The end of the observing time
    product_dir: string
        OPTIONAL - The base directory to store data products. Default = '/group/mwaops/vcs'
    mwa_search_version: string
        OPTIONAL - The version of mwas_search to use. Default = 'master'
    vcstools_version: string
        OPTIONAL - The version of vcstools to use. Default = 'master'
    """
    base_dir = os.path.join(product_dir, obsid, "pointings")
    nfiles = (psrend - psrbeg + 1) // 200
    if ((psrend - psrbeg + 1) % 200 != 0):
        nfiles += 1

    #Find all pulsars in beam at at least 0.3 of zenith normlaized power
    names_ra_dec = np.array(fpio.grab_source_alog(max_dm=250))
    pow_dict, meta_data = find_pulsars_power(obsid,
                                             powers=[0.3, 0.1],
                                             names_ra_dec=names_ra_dec)
    channels = meta_data[-1][-1]
    obs_psrs = pow_dict[0.3][obsid]
    psrs_list_03 = [x[0] for x in obs_psrs]
    #Include all bright pulsars in beam at at least 0.1 of zenith normalized power
    psrs_01 = [x[0] for x in pow_dict[0.1][obsid]]
    sn_dict_01 = snfe.multi_psr_snfe(psrs_01,
                                     obsid,
                                     beg=psrbeg,
                                     end=psrend,
                                     min_z_power=0.1)
    for psr in pow_dict[0.1][obsid]:
        if psr[0] not in psrs_list_03:
            sn, sn_err = sn_dict_01[psr[0]]
            if sn is not None and sn_err is not None:
                if sn - sn_err >= 10.:
                    obs_psrs.append(psr)

    #get all the pulsars periods
    pulsar_list = []
    for o in obs_psrs:
        pulsar_list.append(o[0])
    periods = psrqpy.QueryATNF(params=["P0"],
                               psrs=pulsar_list,
                               loadfromdb=ATNF_LOC).pandas["P0"]

    oap = get_obs_array_phase(obsid)
    centrefreq = 1.28 * float(min(channels) + max(channels)) / 2.
    fwhm = calc_ta_fwhm(centrefreq, array_phase=oap)

    # Sort all the sources into 3 categories, pulsars which is for slow pulsars, vdif
    # for fast pulsars that require vdif and sp for singple pulse searches (FRBs,
    # RRATs and pulsars without ATNF periods)
    pulsar_pointing_list = []
    pulsar_name_list = []
    vdif_pointing_list = []
    vdif_name_list = []
    sp_pointing_list = []
    sp_name_list = []
    for pi, pulsar_line in enumerate(obs_psrs):
        vdif_check = False
        sp_check = False

        PSRJ = pulsar_line[0]
        #See if pulsar is in beam for times
        enter, leave = snfe.pulsar_beam_coverage(obsid,
                                                 PSRJ,
                                                 beg=psrbeg,
                                                 end=psrend)
        if enter is None or leave is None:
            print(
                "{0} is not in beam for time range. Not folding".format(PSRJ))
            continue

        if not (len(PSRJ) < 11 or PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa'):
            continue

        for line in names_ra_dec:
            if PSRJ == line[0]:
                temp = [line]

        #temp = fpio.get_psrcat_ra_dec(pulsar_list=[PSRJ])
        temp = fpio.format_ra_dec(temp, ra_col=1, dec_col=2)
        jname, raj, decj = temp[0]
        #get pulsar period
        period = periods[pi]
        if math.isnan(period):
            print(
                "WARNING: Period not found in ephermeris for {0} so assuming "
                "it's an RRAT".format(jname))
            sp_check = True
            period = 0.
        elif float(period) < .05:
            vdif_check = True
        period = float(period) * 1000.
        print(
            "{0:12} RA: {1} Dec: {2} Period: {3:8.2f} (ms) Begin {4} End {5}".
            format(PSRJ, raj, decj, period, psrbeg, psrend))

        jname_temp_list = []
        if PSRJ[-1] == 'A' or PSRJ[-2:] == 'aa':
            #Got to find all the pulsar J names with other letters
            vdif_check = True
            for pulsar_l in obs_psrs:
                pulsar_name = pulsar_l[0]
                if pulsar_name.startswith(PSRJ[:-2]):
                    jname_temp_list.append(pulsar_name)
        else:
            jname_temp_list.append(jname)

        # grid the pointings to fill 2 arcminute raduis to account for ionosphere shift
        pointing_list_list = get_pointings_required(raj, decj, fwhm, 2. / 60.)

        # sort the pointings into the right groups
        for prd in pointing_list_list:
            if vdif_check:
                vdif_name_list.append(jname_temp_list)
                vdif_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))
            elif sp_check:
                sp_name_list.append(jname_temp_list)
                sp_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))
            else:
                pulsar_name_list.append(jname_temp_list)
                pulsar_pointing_list.append("{0}_{1}".format(prd[0], prd[1]))

    print('\nSENDING OFF PULSAR PROCESSING')
    print(
        '----------------------------------------------------------------------------------------'
    )
    # Send off pulsar search
    relaunch_script = 'mwa_search_pipeline.py -o {0} -O {1} --DI_dir {2} -b {3} -e {4} --cand_type Pulsar --vcstools_version {5} --mwa_search_version {6} --channels'.format(
        obsid, cal_obs, DI_dir, psrbeg, psrend, vcstools_version,
        mwa_search_version)
    for ch in channels:
        relaunch_script = "{0} {1}".format(relaunch_script, ch)
    search_opts = search_pipe.search_options_class(
        obsid,
        cal_id=cal_obs,
        begin=psrbeg,
        end=psrend,
        channels=channels,
        args=args,
        DI_dir=DI_dir,
        relaunch_script=relaunch_script,
        search_ver=mwa_search_version,
        vcstools_ver=vcstools_version,
        data_process=True)
    pulsar_pointing_dirs = [
        os.path.join(base_dir, s) for s in pulsar_pointing_list
    ]
    for pdir in pulsar_pointing_dirs:
        # Check if fits files are there
        if len(glob.glob("{0}/{1}_*fits".format(pdir, obsid))) < nfiles:
            logger.error(
                "Can not find the {0} expected files in {1}. Exiting".format(
                    nfiles, pdir))
            sys.exit(1)
    for ppd, pnl in zip(pulsar_pointing_dirs, pulsar_name_list):
        for pulsar_name in pnl:
            # Not sure if this works with extended array obs with gridded pointings
            search_pipe.multibeam_binfind(search_opts, [ppd], None,
                                          pulsar_name)

    print('\nSENDING OFF VDIF PULSAR PROCESSING')
    print(
        '----------------------------------------------------------------------------------------'
    )
    #Send off vdif pulsar search
    relaunch_script = "{0} --vdif".format(relaunch_script)
    search_opts = search_pipe.search_options_class(
        obsid,
        cal_id=cal_obs,
        begin=psrbeg,
        end=psrend,
        channels=channels,
        args=args,
        DI_dir=DI_dir,
        relaunch_script=relaunch_script,
        search_ver=mwa_search_version,
        vcstools_ver=vcstools_version,
        vdif=True,
        data_process=True)
    vdif_pointing_dirs = [
        os.path.join(base_dir, s) for s in vdif_pointing_list
    ]
    for pdir in vdif_pointing_dirs:
        # Check if fits files are there
        if len(glob.glob("{0}/{1}_*fits".format(pdir, obsid))) < nfiles:
            print("Can not find the {0} expected files in {1}. Exiting".format(
                nfiles, pdir))
            sys.exit(1)
    for vpd, vnl in zip(vdif_pointing_dirs, vdif_name_list):
        for vdif_name in vnl:
            # Not sure if this works with extended array obs with gridded pointings
            search_pipe.multibeam_binfind(search_opts, [vpd], None, vdif_name)

    return