initial commit
This commit is contained in:
commit
ae3722583f
53
signalgen.py
Normal file
53
signalgen.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
#! /minish/keh00032/.conda/envs/keh00032/bin/python
|
||||
|
||||
import logging
|
||||
from os import path
|
||||
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
|
||||
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
logFmt = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
logging.basicConfig(level=logging.INFO, format=logFmt)
|
||||
|
||||
def processList(values):
|
||||
"""
|
||||
Entry point if values.file is None and values.listfile is set.
|
||||
Processes the file for directories and iterates through by setting values.file and calling addBurst.
|
||||
"""
|
||||
with open(values.listfile, "r") as listfile:
|
||||
dirs = listfile.readlines()
|
||||
for dir in dirs:
|
||||
dataName = path.dirname(dir[:-1]) #strip the trailing slash for dirname
|
||||
values.file = path.join(dir,dataname+".fil")
|
||||
addBurst(values)
|
||||
|
||||
def addBurst(values):
|
||||
"""
|
||||
Entry point if values.file is set.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(
|
||||
description="Insert simulated bursts into GREENBURST filterbank files.",
|
||||
formatter_class=ArgumentDefaultsHelpFormatter
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l", "--listfile", dest="listfile", type=str, help="File containing list of greenburst filterbank directories."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--file", dest="file", type=str, help="Single filterbank file."
|
||||
)
|
||||
parser.set_defaults(listfile=None)
|
||||
parser.set_defaults(file=None)
|
||||
values = parser.parse_args()
|
||||
|
||||
if values.file is not None: #single file takes priority
|
||||
logging.info(f"Running with file {values.file}")
|
||||
addBurst(values)
|
||||
elif values.listfile is not None: #list of files
|
||||
logging.info(f"Looking for directories in file {values.listfile}")
|
||||
processList(values)
|
6
testfiles.txt
Normal file
6
testfiles.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
/minish/keh00032/gb/2025/data_2025-05-05_07-08-36/
|
||||
/minish/keh00032/gb/2025/data_2025-05-05_07-16-59/
|
||||
/minish/keh00032/gb/2025/data_2025-05-05_07-25-22/
|
||||
/minish/keh00032/gb/2025/data_2025-05-05_07-33-46/
|
||||
/minish/keh00032/gb/2025/data_2025-05-05_07-42-09/
|
||||
/minish/keh00032/gb/2025/data_2025-05-05_07-50-32/
|
Loading…
Reference in a new issue