Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
short_nM = options.nM // 1000000
# The basename of the data files
if argv[1].endswith(".dat"):
basename = "../"+argv[1][:-4]
else:
basename = "../"+argv[1]
# Get the bird file (the first birdie file in the directory!)
birdname = glob("../*.birds")
if birdname:
birdname = birdname[0]
outnamebase = options.outdir+basename[3:]
inf = read_inffile(basename)
idata = infodata.infodata(basename+".inf")
N = inf.N
t0i = inf.mjd_i
t0f = inf.mjd_f
num = 0
point = 0
T = options.nM * inf.dt / 86400.0
baryv = get_baryv(idata.RA, idata.DEC, idata.epoch, T, obs='GB')
print("Baryv = ", baryv)
inf.N = options.nM
inf.numonoff = 0
nM = options.nM // 1000000
while point + options.nM < N:
pM = point // 1000000
outname = basename[3:]+'_%03dM'%nM+'_%02d'%num
stdout.write('\n'+outname+'\n\n')
inf.name = outname
#!/usr/bin/env python
from __future__ import (print_function,division)
import presto.psr_utils as pu
import sys
from presto.infodata import infodata
if len(sys.argv) != 2:
print("chooseN ")
print(" Prints a good value for fast FFTs to be used for -numout in prepdata/prepsubband")
sys.exit(1)
if sys.argv[1].endswith('.inf'):
inf = infodata(sys.argv[1])
n = inf.N
else:
try:
n = int(sys.argv[1])
except:
print("chooseN ")
print(" Prints a good value for fast FFTs to be used for -numout in prepdata/prepsubband")
sys.exit(2)
print(pu.choose_N(n))
opts.is_no_detrend = True # we don't do detrending for events
if opts.mjd == '' and not opts.is_chandra:
print("Error: for events' file start MJD _must_ be given with --mjd option or --chandra option!")
sys.exit(1)
if opts.nbins == -1:
print("Error: number of bins _must_ be given with --nbins option!")
sys.exit(1)
if opts.rebin != 1:
print("Event data can not be re-binned")
opts.rebin = 1
else:
if (opts.mjd == '' and not opts.is_chandra) or opts.tsamp == '' or opts.psrname == '':
# reading inf-file to get corresponding info
inffile = datfile.split(".dat")[0] + ".inf"
try:
id = inf.infodata(inffile)
tsamp = id.dt # sampling time
startmjd = id.epoch # start MJD
source = id.object # pulsar name
except:
print("Error: Can't read the inf-file '%s'!" % (inffile,))
sys.exit(1)
# overwriting MJD, tsamp, pulsarname from the command line if given
if opts.is_chandra:
opts.mjd = "50814.0"
print("Chandra event file. Reference start MJD is %s" % (opts.mjd))
if opts.mjd != '':
startmjd = float(opts.mjd)
if opts.tsamp != '':
tsamp = float(opts.tsamp)
if opts.psrname != '':
def get_obs_info(inffile):
"""Read in an .inf file to extract observation information.
Return observation RA, Dec, duration, and source name.
"""
inf = infodata.infodata(inffile)
T = inf.dt * inf.N # total observation time (s)
RA = inf.RA
dec = inf.DEC
src = inf.object
MJD = inf.epoch
telescope = inf.telescope
freq = (inf.numchan/2-0.5)*inf.chan_width+inf.lofreq # center freq
return {'T': T, 'RA': RA, 'dec': dec, 'src': src, 'MJD': MJD, 'telescope': telescope, 'freq': freq}
def get_obs_info(inffile):
"""Read in an .inf file to extract observation information.
Return observation RA, Dec, duration, and source name.
"""
inf = infodata.infodata(inffile)
T = inf.dt * inf.N # total observation time (s)
RA = inf.RA
dec = inf.DEC
src = inf.object
MJD = inf.epoch
telescope = inf.telescope
freq = (inf.numchan/2-0.5)*inf.chan_width+inf.lofreq # center freq
return {'T': T, 'RA': RA, 'dec': dec, 'src': src, 'MJD': MJD, 'telescope': telescope, 'freq': freq}
PLOTTYPE = rrattrap_config.PLOTTYPE
RANKS_TO_WRITE = rrattrap_config.RANKS_TO_WRITE
RANKS_TO_PLOT = rrattrap_config.RANKS_TO_PLOT
else:
CLOSE_DM = options.close_dm
MIN_GROUP = options.min_group
TIME_THRESH = options.time_thresh
DM_THRESH = options.dm_thresh
MIN_SIGMA = options.min_sigma
PLOT = options.plot
PLOTTYPE = options.plottype
RANKS_TO_WRITE = list(RANKS[RANKS>options.min_ranktowrite])
RANKS_TO_PLOT = list(RANKS[RANKS>options.min_ranktoplot])
inffile = options.inffile
inf = infodata.infodata(inffile)
print_debug("Beginning read_sp_files... "+strftime("%Y-%m-%d %H:%M:%S"))
groups = spio.read_sp_files(args[1:])[0]
print_debug("Finished read_sp_files, beginning create_groups... " +
strftime("%Y-%m-%d %H:%M:%S"))
print_debug("Number of single pulse events: %d " % len(groups))
groups = create_groups(groups, inffile, min_nearby=1, ignore_obs_end=10, time_thresh=TIME_THRESH, dm_thresh=DM_THRESH, use_dmplan=options.use_DMplan) # ignore the last 10 seconds of the obs, for palfa
print_debug("Number of groups: %d " % len(groups))
print_debug("Finished create_groups, beginning grouping_sp_dmt... " +
strftime("%Y-%m-%d %H:%M:%S"))
grouping_sp_dmt(groups, use_dmplan=options.use_DMplan, time_thresh=TIME_THRESH, dm_thresh=DM_THRESH)
print_debug("Number of groups (after initial grouping): %d " % len(groups))
print_debug("Finished grouping_sp_dmt, beginning flag_noise... " +
strftime("%Y-%m-%d %H:%M:%S"))