added a bit of argparse

This commit is contained in:
2021-05-17 11:46:22 +02:00
parent 18c62e4874
commit 66b49fd941
2 changed files with 41 additions and 6 deletions

View File

@ -1,5 +1,18 @@
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("instrument")
parser.add_argument("pgroup")
parser.add_argument("-c", "--channel", default="SAR-CVME-TIFALL4:EvtSet", help="BS channel used as source for the timestamp/pulseID mapping")
clargs = parser.parse_args()
instrument = clargs.instrument
pgroup = clargs.pgroup
bs_source_channel = clargs.channel
import os
from glob import glob
import numpy as np
@ -25,8 +38,11 @@ def get_fn(fns, contains):
print("globbing")
fns = "/sf/alvra/data/p18938/raw/**/*.PVCHANNELS.h5"
fns = sorted(glob(fns, recursive=True))
fns_pattern = "/sf/{}/data/{}/raw/**/*.PVCHANNELS.h5".format(instrument, pgroup)
fns = sorted(glob(fns_pattern, recursive=True))
if not fns:
raise SystemExit("no file found for: {}".format(fns_pattern))
for i, fn_pv in enumerate(fns):
fn_bs = fn_pv.replace(".PVCHANNELS.h5", ".BSDATA.h5")
@ -43,8 +59,9 @@ for i, fn_pv in enumerate(fns):
print(new_fn_pv, "exists... skipping")
continue
ch_evts = "SAR-CVME-TIFALL4:EvtSet"
#ch_evts = "SAR-CVME-TIFALL5:EvtSet"
# ch_evts = "SAR-CVME-TIFALL4:EvtSet"
# ch_evts = "SAR-CVME-TIFALL5:EvtSet"
ch_evts = bs_source_channel
with h5py.File(fn_bs, "r") as f:
try:

View File

@ -1,11 +1,29 @@
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("instrument")
parser.add_argument("pgroup")
clargs = parser.parse_args()
instrument = clargs.instrument
pgroup = clargs.pgroup
import os
from glob import glob
import json
fns = "/sf/alvra/data/p18938/raw/scan_info/**.json"
for fn_si in sorted(glob(fns, recursive=True)):
print("globbing")
fns_pattern = "/sf/{}/data/{}/raw/scan_info/**.json".format(instrument, pgroup)
fns = sorted(glob(fns_pattern, recursive=True))
if not fns:
raise SystemExit("no file found for: {}".format(fns_pattern))
for fn_si in fns:
new_fn_si = fn_si.replace("/raw/", "/res/epics/")
print(fn_si, new_fn_si)