Commit 27dc2ae2 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema

Remove create option, specify frequency

parent dd2e9a8c
......@@ -21,7 +21,7 @@ try:
except:
print("Could not connect to console, no RA/DEC recorded")
def create_filterbank(outfile, source, infile=None, date=None, create=False):
def create_filterbank(outfile, source, infile=None, date=None, headeronly=False, centerfrequency=420., time=30):
"""
Create a filterbank file from the CAMRAS-format, which is generated
by pulsar_record.
......@@ -48,7 +48,7 @@ def create_filterbank(outfile, source, infile=None, date=None, create=False):
src_raj = 0.
src_dej = 0.
if telescope_found:
dt = telescope(consoleHost='console')
dt = telescope()
az_start = (180*u.deg + dt.getAzEl(waitForUpdate=True)[0]).to(u.deg).value
za_start = (90*u.deg - dt.getAzEl()[1]).to(u.deg).value
src_raj = dt.getRaDec().ra.to_string(unit=u.hour, sep='')
......@@ -82,7 +82,7 @@ def create_filterbank(outfile, source, infile=None, date=None, create=False):
fil_header["tstart"] = date
fil_header["tsamp"] = 0.00046811428571414528 # 1.0/35e6*256 chans*64 decimation
fil_header["nbits"] = 16
fil_header["fch1"] = 441.4
fil_header["fch1"] = centerfrequency+21.4
fil_header["foff"] = -35.0/256.0
fil_header["nchans"] = 256
fil_header["nifs"] = 1
......@@ -90,15 +90,20 @@ def create_filterbank(outfile, source, infile=None, date=None, create=False):
# Write header
out = filterbank.create_filterbank_file(outfile, fil_header, nbits=16)
if create:
os.system("./pulsar_filterbank 3600 "+outfile)
if headeronly:
print("Wrote filterbank header only")
out.close()
return
if not infile:
out.close()
cmd = "./pulsar_filterbank " + str(time) + " " + outfile
print("Running "+cmd)
os.system(cmd)
return
# Read file
print("Converting "+infile)
f = open(infile)
filesize = os.stat(infile).st_size
......@@ -121,22 +126,18 @@ def create_filterbank(outfile, source, infile=None, date=None, create=False):
offset += 256*CHUNKSIZE*4
# Close file
out.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert a camras pulsar file (output of pulsar_record) to filterbank format")
parser = argparse.ArgumentParser(description="Create a filterbank file from the output of the CAMRAS backend in pulsar mode.")
parser.add_argument("outfile", help="Name of output file, e.g. 'B0329.fil'")
parser.add_argument("sourcename", help="Name of the source, e.g. 'B0329+54'")
parser.add_argument("-i", "--infile", help="Input CAMRAS pulsar file. If empty, create just the header.")
parser.add_argument("-d", "--date", help="Start date/time of observation, in 'isot' format (defaults to creation date of file, or now if no infile given)", default=None)
parser.add_argument("-c", "--create", help="Create new observation by calling pulsar_filterbank", default=False, action="store_true")
parser.add_argument("-i", "--infile", help="Input CAMRAS pulsar file. If empty, it will start a new recording.")
parser.add_argument("-d", "--date", help="Start date/time of observation, in 'isot' format (defaults to now, or creation date of infile)", default=None)
parser.add_argument("--header", help="Only record a header", default=False, action="store_true")
parser.add_argument("-f", "--frequency", help="Center frequency in MHz, default: 420.", default=420., type=float)
parser.add_argument("-t", "--time", help="Time for observing in seconds, default: 300s (5min)", default=300)
args = parser.parse_args()
if args.infile is None and not(args.create):
parser.error("One of --infile or --create is required")
if args.infile is None and args.source is None:
parser.error("Without infile, --source must be specified")
create_filterbank(args.outfile, args.sourcename, infile=args.infile, date=args.date, create=args.create)
create_filterbank(args.outfile, args.sourcename, infile=args.infile, date=args.date, headeronly=args.header, centerfrequency=args.frequency, time=args.time)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment