Skip to content

Commit

Permalink
add fromzero switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotan committed Dec 18, 2024
1 parent 36d4f81 commit 5820878
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nxstools/pyeval/pco.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def postrun(commonblock,
nbframes,
filepostfix,
fileprefix,
filestartnum_str):
filestartnum_str, fromzero=False):
""" code for postrun datasource
:param commonblock: commonblock of nxswriter
Expand All @@ -53,14 +53,20 @@ def postrun(commonblock,
unixdir = "/data" + unixdir[2:]
if unixdir and unixdir[-1] == "/":
unixdir = unixdir[:-1]
filestartnumer = commonblock[filestartnum_str]
if fromzero:
filestartnumer = commonblock[filestartnum_str]
else:
filestartnumer = commonblock[filestartnum_str] - 1
if fileprefix.endswith("_"):
fileprefix = fileprefix[:-1]
result = "" + unixdir + "/" + fileprefix + "_%05d."
if filepostfix.startswith("."):
filepostfix = filepostfix[1:]
result += filepostfix + ":"
filelastnumber = filestartnum
if fromzero:
filelastnumber = filestartnum
else:
filelastnumber = filestartnum - 1
if "__root__" in commonblock.keys():
root = commonblock["__root__"]
if hasattr(root, "currentfileid") and hasattr(root, "stepsperfile"):
Expand Down
4 changes: 4 additions & 0 deletions test/NXSCreateOnlineCPFS_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def test_onlinecp_typelist_none(self):
"lambdavdsnm",
"limaccd", "limaccds", "marccd", "mca_xia",
"mythen", "mythen2", "pco", "pco4000", "pcoedge",
"pcovds",
"pedetector", "perkinelmer",
"perkinelmerdetector",
"pilatus", "pilatus100k",
Expand Down Expand Up @@ -377,6 +378,7 @@ def test_onlinecp_typelist_single(self):
"pilctimeid",
'marccd', # +
'pcoedge', #
"pcovds",
'pilatus100k', #
'tangovimba', #
'cobold',
Expand Down Expand Up @@ -443,6 +445,7 @@ def test_onlinecp_typelist_single(self):
"lambdavds", "lambdavdsnm",
"limaccd", "limaccds", "marccd", "mca_xia",
"mythen", "mythen2", "pco", "pco4000", "pcoedge",
"pcovds",
"pedetector", "perkinelmer",
"perkinelmerdetector",
"pilatus", "pilatus100k",
Expand Down Expand Up @@ -519,6 +522,7 @@ def test_onlinecp_typelist_multiple(self):
"lambdavds", "lambdavdsnm",
"limaccd", "limaccds", "marccd", "mca_xia",
"mythen", "mythen2", "pco", "pco4000", "pcoedge",
"pcovds",
"pedetector", "perkinelmer",
"perkinelmerdetector",
"pilatus", "pilatus100k",
Expand Down
6 changes: 6 additions & 0 deletions test/NXSCreatePyEvalH5Cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,12 +1812,18 @@ def test_pco_postrun(self):
commonblock[filestartnum_str] = 1

sfn1 = "/tmp/current/scan213123_%05d.tif:0:19"
sfn2 = "/tmp/current/scan213123_%05d.tif:1:20"

fn1 = pco.postrun(
commonblock, filestartnum, filedir, nbframes,
filepostfix, fileprefix, filestartnum_str)
self.assertEqual(fn1, sfn1)

fn1 = pco.postrun(
commonblock, filestartnum, filedir, nbframes,
filepostfix, fileprefix, filestartnum_str, fromzero=True)
self.assertEqual(fn1, sfn2)

tstroot.stepsperfile = 20
tstroot.currentfileid = 1
fn1 = pco.postrun(
Expand Down

0 comments on commit 5820878

Please sign in to comment.