def candplots(fil_file,source_name,snr_cut,filter_cut,maxCandSec,noplot,minMem,kill_chans,kill_time_range,nogpu,gcands,fl,fh,tint,Ttot,nchan):
    if(nogpu is not True):
        #os.chdir(basedir)
        #os.system("cd %s" % (basedir))
        #print "Inside : %s" % (basedir) 
        os.system("rm *_all.cand")
        os.system("rm *.ar *.norm")
        os.system("coincidencer *.cand")	
        os.system("trans_gen_overview.py -cands_file *_all.cand")
        os.system("mv overview_1024x768.tmp.png %s.overview.png" % (source_name))
        os.system("frb_detector_bl.py  -gdm 6 -cands_file *_all.cand -filter_cut %d -snr_cut %f -max_cands_per_sec %f -min_members_cut %f -verbose" % (filter_cut,snr_cut,maxCandSec,minMem))
        os.system("frb_detector_bl.py  -gdm 6 -cands_file *_all.cand -filter_cut %d -snr_cut %f -max_cands_per_sec %f -min_members_cut %f  > FRBcand" % (filter_cut,snr_cut,maxCandSec,minMem))
        if(os.stat("FRBcand").st_size is not 0):
            frb_cands = np.loadtxt("FRBcand",dtype={'names': ('snr','time','samp_idx','dm','filter','prim_beam'),'formats': ('f4', 'f4', 'i4','f4','i4','i4')})
        else:
            print "No candidate found"
            return
        #print frb_cands['time'],frb_cands['dm']
    else:
        if(gcands is not ""):
            os.system("rm *.ar *.norm")
            dt = np.dtype(dtype={'names': ('snr','time','samp_idx','dm','filter','prim_beam'),'formats': ('f4', 'f4', 'i4','f4','i4','i4')})
            frb_cands = np.zeros(len(gcands),dt)
            for i,dd in enumerate(gcands):
                frb_cands[i] = np.array([(dd.sigma,dd.time,dd.sample,dd.dm,dd.dfact,0)][0],dt)
        else:
            print "No candidate found"
            return

    extractPlotCand(fil_file,frb_cands,noplot,fl,fh,tint,Ttot,kill_time_range,kill_chans,source_name,nchan)
Esempio n. 2
0
def candplots(fil_file, source_name, snr_cut, filter_cut, maxCandSec, noplot,
              minMem, kill_chans, kill_time_range, nogpu, gcands, fl, fh, tint,
              Ttot, nchan, mask_file, smooth, zerodm, csv_file, ml_model):
    if (nogpu is not True):
        #os.chdir(basedir)
        #os.system("cd %s" % (basedir))
        #print "Inside : %s" % (basedir)
        os.system("rm *_all.cand")
        os.system("rm *.ar *.norm")
        run_in_env("coincidencer *.cand")
        os.system('pwd')
        os.system("trans_gen_overview.py -cands_file *_all.cand")
        os.system("mv overview_1024x768.tmp.png %s.overview.png" %
                  (source_name))
        os.system(
            "%s/frb_detector_bl.py  -gdm 6 -cands_file *_all.cand -filter_cut %d -snr_cut %f -max_cands_per_sec %f -min_members_cut %f -verbose"
            % (SPANDAK_PATH, filter_cut, snr_cut, maxCandSec, minMem))
        os.system(
            "%s/frb_detector_bl.py  -gdm 6 -cands_file *_all.cand -filter_cut %d -snr_cut %f -max_cands_per_sec %f -min_members_cut %f  > FRBcand"
            % (SPANDAK_PATH, filter_cut, snr_cut, maxCandSec, minMem))
        if ml_model:
            print("ML model given")
            FRBcand = os.path.abspath("FRBcand")
            os.system(
                "python /home/vgajjar/hey-aliens/simulateFRBclassification/predict.py %s %s %s"
                % (ml_model, fil_file, FRBcand))
        if (os.stat("FRBcand").st_size is not 0):
            if ml_model and os.stat("FRBcand_prob.txt").st_size is not 0:
                frb_cands = np.loadtxt("FRBcand_prob.txt",
                                       dtype={
                                           'names':
                                           ('snr', 'time', 'samp_idx', 'dm',
                                            'filter', 'prim_beam', 'FRBprob'),
                                           'formats': ('f4', 'f4', 'i4', 'f4',
                                                       'i4', 'i4', 'f4')
                                       })
            else:
                frb_cands = np.loadtxt("FRBcand",
                                       dtype={
                                           'names':
                                           ('snr', 'time', 'samp_idx', 'dm',
                                            'filter', 'prim_beam'),
                                           'formats':
                                           ('f4', 'f4', 'i4', 'f4', 'i4', 'i4')
                                       })
        else:
            print("No candidate found")
            return
        #print frb_cands['time'],frb_cands['dm']
    else:
        if (gcands is not ""):
            os.system("rm *.ar *.norm")
            dt = np.dtype(
                dtype={
                    'names': ('snr', 'time', 'samp_idx', 'dm', 'filter',
                              'prim_beam'),
                    'formats': ('f4', 'f4', 'i4', 'f4', 'i4', 'i4')
                })
            frb_cands = np.zeros(len(gcands), dt)
            for i, dd in enumerate(gcands):
                frb_cands[i] = np.array([(dd.sigma, dd.time, dd.sample, dd.dm,
                                          dd.dfact, 0)][0], dt)
        else:
            print("No candidate found")
            return

    extractPlotCand(fil_file, frb_cands, noplot, fl, fh, tint, Ttot,
                    kill_time_range, kill_chans, source_name, nchan, mask_file,
                    smooth, zerodm, csv_file)