Skip to content

Commit

Permalink
more error fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
gijzelaerr authored and scottransom committed Nov 12, 2019
1 parent 605eaa0 commit eb78f7c
Show file tree
Hide file tree
Showing 20 changed files with 1,431 additions and 1,918 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions bin/event_peak.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#!/usr/bin/env python
from __future__ import print_function
import numpy as num
import sys
import presto.events as evts
from presto import kuiper
from presto.Pgplot import *


if len(sys.argv) != 2:
print("\nusage: {} file\n".format(sys.argv[0]))
sys.exit(1)


def calc_phases(events, f, fd):
return num.fmod(events*(f+(0.5*fd*events)), 1.0)


events = num.loadtxt(sys.argv[1])
events.sort()
print("Read %d events from '%s'." % (events.size, sys.argv[1]))
Expand Down
56 changes: 28 additions & 28 deletions bin/fb_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

import sys
import copy
import optparse
from argparse import ArgumentParser
import numpy as np
from presto import filterbank

BLOCKSIZE = 1e5 # Number of spectra to manipulate at once

def main():


def main(args):
infn = args[0]
print("Reading filterbank file (%s)" % infn)
fil = filterbank.FilterbankFile(infn)
Expand Down Expand Up @@ -106,36 +108,34 @@ def main():


if __name__ == '__main__':
parser = optparse.OptionParser(prog='fb_truncate.py', \
version="v0.1 Patrick Lazarus (Aug. 28, 2012)")
parser.add_option("-L", "--lo-freq", dest="lo_freq", type='float', \
help="Desired low frequency for output file. Note: " \
"actual low frequency will be rounded to the nearest" \
"channel (Default: Don't truncate low-freq channels)", \
parser = ArgumentParser(description="v0.1 Patrick Lazarus (Aug. 28, 2012)")
parser.add_argument("-L", "--lo-freq", dest="lo_freq", type=float,
help="Desired low frequency for output file. Note: "
"actual low frequency will be rounded to the nearest"
"channel (Default: Don't truncate low-freq channels)",
default=None)
parser.add_option("-H", "--hi-freq", dest="hi_freq", type='float', \
help="Desired high frequency for output file. Note: " \
"actual high frequency will be rounded to the nearest" \
"channel (Default: Don't truncate high-freq channels)", \
parser.add_argument("-H", "--hi-freq", dest="hi_freq", type=float,
help="Desired high frequency for output file. Note: "
"actual high frequency will be rounded to the nearest"
"channel (Default: Don't truncate high-freq channels)",
default=None)
parser.add_option("-s", "--start-time", dest="start_time", type='float', \
help="Start of desired range of input file to write " \
"to output file. Note: The actual start time will " \
"be rounded to the nearest sample.(Default: Don't " \
parser.add_argument("-s", "--start-time", dest="start_time", type=float,
help="Start of desired range of input file to write "
"to output file. Note: The actual start time will "
"be rounded to the nearest sample.(Default: Don't "
"truncate from start of file.)", default=None)
parser.add_option("-e", "--end-time", dest="end_time", type='float', \
help="End of desired range of input file to write " \
"to output file. Note: The actual end time will " \
"be rounded to the nearest sample. (Default: " \
parser.add_argument("-e", "--end-time", dest="end_time", type=float,
help="End of desired range of input file to write "
"to output file. Note: The actual end time will "
"be rounded to the nearest sample. (Default: "
"Don't truncate from end of file.)", default=None)
parser.add_option("--block-size", dest='block_size', default=BLOCKSIZE, \
type='float', \
help="Number of spectra per block. This is the amount " \
"of data manipulated/written at a time. (Default: " \
parser.add_argument("--block-size", dest='block_size', default=BLOCKSIZE,
type=float,
help="Number of spectra per block. This is the amount "
"of data manipulated/written at a time. (Default: "
" %d spectra)" % BLOCKSIZE)
parser.add_option("-o", "--outname", dest='outname', action='store', \
parser.add_argument("-o", "--outname", dest='outname', action='store', required=True,
help="The name of the output file.")
(options, args) = parser.parse_args()
if not hasattr(options, 'outname'):
raise ValueError("An output file name _must_ be provided!")
main()

main(args)
6 changes: 6 additions & 0 deletions bin/filter_zerolags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import numpy as N
import sys, scipy.io, scipy.signal


if len(sys.argv) != 2:
print("\nusage: {} file\n".format(sys.argv[0]))
sys.exit(1)


plot=0

infilenm = sys.argv[1]
Expand Down
4 changes: 4 additions & 0 deletions bin/fit_circular_orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
period = num.asarray([])
time = num.asarray([])


def parse_eph(filenm):
global period, time
suffix = filenm.split(".")[-1]
Expand Down Expand Up @@ -41,14 +42,17 @@ def parse_eph(filenm):
period = num.concatenate((period, newps))
print("%13.7f (%0.1f sec): " % (epoch, T), fs)


def orbeqn(Ppxt, times):
# P = Ppsr, p = Porb, x = a*sin(i)/s, t = T_o
phi = pu.TWOPI*(times - Ppxt[3])*86400.0/Ppxt[1]
return Ppxt[0]*(1.0+pu.TWOPI*Ppxt[2]/Ppxt[1]*num.cos(phi))


def funct(Ppxt, times, measured):
return orbeqn(Ppxt, times) - measured


if __name__ == '__main__':
if len(sys.argv)==1:
print("\nusage: fit_circular_orbit.py P_psr P_orb X_orb parfiles or bestprofs")
Expand Down
12 changes: 6 additions & 6 deletions bin/guppidrift2fil.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ def main(fits_fn, outfn, nbits, \
input_nbits=input_nbits)
if flip_band:
subint = np.fliplr(subint)
subint /= scale_fac
outfil.append_spectra(subint)
pcnt = "%d" % (i*100.0/output_subints)
if pcnt != oldpcnt:
sys.stdout.write("% 4s%% complete\r" % pcnt)
sys.stdout.flush()
subint /= scale_fac
outfil.append_spectra(subint)
pcnt = "%d" % (i*100.0/output_subints)
if pcnt != oldpcnt:
sys.stdout.write("% 4s%% complete\r" % pcnt)
sys.stdout.flush()

print("Done ")
outfil.close()
Expand Down
File renamed without changes.
Loading

0 comments on commit eb78f7c

Please sign in to comment.