Commit 8c3077b6 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema

Automatic outfile

parent 1703d50b
......@@ -21,13 +21,13 @@ try:
except:
print("Could not connect to console, no RA/DEC recorded")
def create_filterbank(outfile, source, infile=None, date=None, headeronly=False, centerfrequency=420., time=30):
def create_filterbank(source, infile=None, outfile=None, date=None, headeronly=False, centerfrequency=420., time=30):
"""
Create a filterbank file from the CAMRAS-format, which is generated
by pulsar_record.
outfile: name of the filterbank file to be created
infile: name of the file generated by pulsar_record
outfile: name of the filterbank file to be created
date: the date to be used; default is the file creation date of infile
if given, the date must be in a format the astropy.time understands
source: name of the source to be used; default is guessed from filename
......@@ -54,6 +54,9 @@ def create_filterbank(outfile, source, infile=None, date=None, headeronly=False,
else:
date = Time(date, format='isot')
if not outfile:
outfile = date.iso.replace(' ','-')[0:19]+'_'+source[4:]+'.fil'
print("Input file: {}".format(infile))
print("Output file: {}".format(outfile))
print("Source name: {}".format(source))
......@@ -130,8 +133,8 @@ def create_filterbank(outfile, source, infile=None, date=None, headeronly=False,
if __name__ == "__main__":
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("-o", "--outfile", help="Name of output file, e.g. 'B0329.fil'")
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")
......@@ -140,4 +143,4 @@ if __name__ == "__main__":
args = parser.parse_args()
create_filterbank(args.outfile, args.sourcename, infile=args.infile, date=args.date, headeronly=args.header, centerfrequency=args.frequency, time=args.time)
create_filterbank(args.sourcename, infile=args.infile, outfile=args.outfile, 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