From 5820878f235692f13b4e29773b4a972908ed6782 Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Wed, 18 Dec 2024 18:50:30 +0100 Subject: [PATCH] add fromzero switch --- nxstools/pyeval/pco.py | 12 +++++++++--- test/NXSCreateOnlineCPFS_test.py | 4 ++++ test/NXSCreatePyEvalH5Cpp_test.py | 6 ++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nxstools/pyeval/pco.py b/nxstools/pyeval/pco.py index 10a19667..fdacb618 100644 --- a/nxstools/pyeval/pco.py +++ b/nxstools/pyeval/pco.py @@ -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 @@ -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"): diff --git a/test/NXSCreateOnlineCPFS_test.py b/test/NXSCreateOnlineCPFS_test.py index 3e3cd19c..d4da9cc7 100644 --- a/test/NXSCreateOnlineCPFS_test.py +++ b/test/NXSCreateOnlineCPFS_test.py @@ -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", @@ -377,6 +378,7 @@ def test_onlinecp_typelist_single(self): "pilctimeid", 'marccd', # + 'pcoedge', # + "pcovds", 'pilatus100k', # 'tangovimba', # 'cobold', @@ -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", @@ -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", diff --git a/test/NXSCreatePyEvalH5Cpp_test.py b/test/NXSCreatePyEvalH5Cpp_test.py index a45362bd..b95f1ecf 100644 --- a/test/NXSCreatePyEvalH5Cpp_test.py +++ b/test/NXSCreatePyEvalH5Cpp_test.py @@ -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(