Commit dd2e9a8c authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema

Make sourcename non-optional

parent 407e44f6
......@@ -21,7 +21,7 @@ try:
print("Could not connect to console, no RA/DEC recorded")
def create_filterbank(outfile, infile=None, date=None, source=None, create=False):
def create_filterbank(outfile, source, infile=None, date=None, create=False):
Create a filterbank file from the CAMRAS-format, which is generated
by pulsar_record.
......@@ -33,14 +33,7 @@ def create_filterbank(outfile, infile=None, date=None, source=None, create=False
source: name of the source to be used; default is guessed from filename
if not source:
if not infile:
raise RuntimeError("If no input file is given, you must specify source")
match = re.match("[BJ][0-9]*[+-][0-9]*", infile)
if match:
source = "PSR " +
raise ValueError("Could not guess source name from filename")
source = "PSR " + source
if not date:
if infile:
......@@ -134,9 +127,9 @@ def create_filterbank(outfile, infile=None, date=None, source=None, create=False
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert a camras pulsar file (output of pulsar_record) to filterbank format")
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("-s", "--source", help="Name of the source, e.g. 'PSR B0329+54' (default: guessed from input filename)", default=None)
parser.add_argument("-c", "--create", help="Create new observation by calling pulsar_filterbank", default=False, action="store_true")
args = parser.parse_args()
......@@ -146,4 +139,4 @@ if __name__ == "__main__":
if args.infile is None and args.source is None:
parser.error("Without infile, --source must be specified")
create_filterbank(args.outfile, infile=args.infile,, source=args.source, create=args.create)
create_filterbank(args.outfile, args.sourcename, infile=args.infile,, create=args.create)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment