added a bit of argparse
This commit is contained in:
@ -1,5 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/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
|
import os
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -25,8 +38,11 @@ def get_fn(fns, contains):
|
|||||||
|
|
||||||
|
|
||||||
print("globbing")
|
print("globbing")
|
||||||
fns = "/sf/alvra/data/p18938/raw/**/*.PVCHANNELS.h5"
|
fns_pattern = "/sf/{}/data/{}/raw/**/*.PVCHANNELS.h5".format(instrument, pgroup)
|
||||||
fns = sorted(glob(fns, recursive=True))
|
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):
|
for i, fn_pv in enumerate(fns):
|
||||||
fn_bs = fn_pv.replace(".PVCHANNELS.h5", ".BSDATA.h5")
|
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")
|
print(new_fn_pv, "exists... skipping")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ch_evts = "SAR-CVME-TIFALL4:EvtSet"
|
# ch_evts = "SAR-CVME-TIFALL4:EvtSet"
|
||||||
#ch_evts = "SAR-CVME-TIFALL5:EvtSet"
|
# ch_evts = "SAR-CVME-TIFALL5:EvtSet"
|
||||||
|
ch_evts = bs_source_channel
|
||||||
|
|
||||||
with h5py.File(fn_bs, "r") as f:
|
with h5py.File(fn_bs, "r") as f:
|
||||||
try:
|
try:
|
||||||
|
@ -1,11 +1,29 @@
|
|||||||
#!/usr/bin/env python
|
#!/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
|
import os
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import json
|
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/")
|
new_fn_si = fn_si.replace("/raw/", "/res/epics/")
|
||||||
print(fn_si, new_fn_si)
|
print(fn_si, new_fn_si)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user