Skip to content

Commit

Permalink
add support for ScanFileInScanNameDir mode for detecto templates (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotan authored Jul 11, 2024
1 parent 89392c6 commit 191f8ba
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 32 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2024-07-11 Jan Kotanski <jankotan@gmail.com>
* add --online-xml-file option for nxscreate stdcomp
* add --online-xml-file option for nxscreate stdcomp (#687)
* add support for ScanFileinScanNameDir mode for detector template (#689)
* tagged as v4.11.0

2024-07-10 Jan Kotanski <jankotan@gmail.com>
Expand Down
13 changes: 11 additions & 2 deletions nxstools/pyeval/dalsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def external_data(commonblock,
fileprefix,
filepostfix,
filestartnum,
filename):
filename,
shortdetpath=None):
""" code for external_data datasource
:param commonblock: commonblock of nxswriter
Expand All @@ -40,6 +41,8 @@ def external_data(commonblock,
:type filestartnum: :obj:`int`
:param filename: file name
:type filename: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: name of saved file
:rtype: :obj:`str`
"""
Expand All @@ -60,7 +63,13 @@ def external_data(commonblock,
if not prefix.endswith("_"):
prefix = prefix + "_"
if filename:
result = (filename).split("/")[-1].split(".")[0] + "/"
sfname = (filename).split("/")
result = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == result[:-1]:
result = ""
elif shortdetpath:
result = ""

result += name + "/" + prefix + "%06i" % filestartnum \
+ postfix + "://entry/instrument/detector"
Expand Down
16 changes: 12 additions & 4 deletions nxstools/pyeval/dalsavds.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def triggermode(commonblock, name,
triggermode, framespernxfile, pixelformat, height, width,
acquisitionmode, acquisitionframecount,
filestartnum_str, nrexposedframes_str,
filename, entryname, insname):
filename, entryname, insname="instrument",
shortdetpath=None):
""" code for external_data datasource
:param commonblock: commonblock of nxswriter
Expand Down Expand Up @@ -66,6 +67,8 @@ def triggermode(commonblock, name,
:type entryname: :obj:`str`
:param insname: instrument name
:type insname: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: trigger mode
:rtype: :obj:`str`
"""
Expand Down Expand Up @@ -158,10 +161,15 @@ def triggermode(commonblock, name,
except Exception:
dtype = "uint8"

path = ""
if filename:
path = filename.split("/")[-1].split(".")[0] + "/"
else:
path = ""
sfname = (filename).split("/")
path = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == result[:-1]:
path = ""
elif shortdetpath:
path = ""

if "__root__" in commonblock.keys():
root = commonblock["__root__"]
Expand Down
24 changes: 18 additions & 6 deletions nxstools/pyeval/eigerdectris.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def triggermode_cb(commonblock, name, triggermode,
eigerdectris_str="EigerDectris",
eigerfilewriter_str="EigerFileWriter",
addfilepattern=False, shape=None,
dtype="uint32", acq_modes=""):
dtype="uint32", acq_modes="",
shortdetpath=None):
""" code for triggermode_cb datasource
:param commonblock: commonblock of nxswriter
Expand Down Expand Up @@ -63,6 +64,8 @@ def triggermode_cb(commonblock, name, triggermode,
:type addfilepattern: :obj:`bool`
:param acq_modes: acquisition modes
:type acq_modes: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: triggermode
:rtype: :obj:`str` or :obj:`int`
"""
Expand All @@ -86,12 +89,21 @@ def triggermode_cb(commonblock, name, triggermode,
wp = tango.DeviceProxy('%s/%s' % (hostname, writer))
filepattern = wp.FilenamePattern.split("/")[-1]
imagesperfile = wp.ImagesPerFile
if addfilepattern:

path = ""
sfname = []
if filename:
sfname = (filename).split("/")
path = sfname[-1].split(".")[0] + "/"
elif shortdetpath is False and addfilepattern:
path = filepattern + "/"
elif filename:
path = (filename).split("/")[-1].split(".")[0] + "/"
else:
path = ""
if filename and path:
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == path[:-1]:
path = ""
elif shortdetpath:
path = ""

path += '%s/%s_' % (name, filepattern)
totnbimages = sum(commonblock[stepindex_str])
nbfiles = (totnbimages + imagesperfile - 1) // imagesperfile
Expand Down
32 changes: 24 additions & 8 deletions nxstools/pyeval/lambdavds.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def nm_triggermode_cb(commonblock, name, triggermode,
filepostfix, framenumbers,
height, width, opmode,
savefilename, filename, entryname,
insname="instrument"):
insname="instrument",
shortdetpath=None):
""" code for triggermode_cb datasource
:param commonblock: commonblock of nxswriter
Expand Down Expand Up @@ -62,6 +63,8 @@ def nm_triggermode_cb(commonblock, name, triggermode,
:type filename: :obj:`str`
:param entryname: entry name
:type entryname: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: triggermode
:rtype: :obj:`str` or :obj:`int`
"""
Expand All @@ -88,10 +91,15 @@ def nm_triggermode_cb(commonblock, name, triggermode,
if totalframenumbers == framenumbers:
unlimited = True

path = ""
if filename:
path = (filename).split("/")[-1].split(".")[0] + "/"
else:
path = ""
sfname = (filename).split("/")
path = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == path[:-1]:
path = ""
elif shortdetpath:
path = ""

if "__root__" in commonblock.keys():
root = commonblock["__root__"]
Expand Down Expand Up @@ -169,7 +177,8 @@ def framenumbers_cb(commonblock, framenumbers, framenumbers_str):
def triggermode_cb(commonblock, name, triggermode, saveallimages,
framesperfile, height, width, opmode,
filepostfix, savefilename_str, framenumbers_str,
filename_str, entry_str):
filename_str, entry_str,
shortdetpath=None):
""" code for triggermode_cb datasource
:param commonblock: commonblock of nxswriter
Expand Down Expand Up @@ -201,6 +210,8 @@ def triggermode_cb(commonblock, name, triggermode, saveallimages,
:type filename_str: :obj:`str`
:param entry_str: entry name
:type entry_str: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: triggermode
:rtype: :obj:`str` or :obj:`int`
"""
Expand Down Expand Up @@ -231,10 +242,15 @@ def triggermode_cb(commonblock, name, triggermode, saveallimages,
except Exception:
dtype = "int32"

path = ""
if filename_str:
path = (filename_str).split("/")[-1].split(".")[0] + "/"
else:
path = ""
sfname = (filename_str).split("/")
path = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == path[:-1]:
path = ""
elif shortdetpath:
path = ""

if "__root__" in commonblock.keys():
root = commonblock["__root__"]
Expand Down
26 changes: 22 additions & 4 deletions nxstools/pyeval/lmbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def m2_external_data(commonblock,
saveallimages,
filepostfix,
filename,
modulename):
modulename,
shortdetpath=None):
""" code for external_data datasource
:param commonblock: commonblock of nxswriter
Expand All @@ -43,13 +44,21 @@ def m2_external_data(commonblock,
:type filename: :obj:`str`
:param filename: module name
:type filename: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: name of saved file
:rtype: :obj:`str`
"""
result = ""
if saveallimages:
if filename:
result = (filename).split("/")[-1].split(".")[0] + "/"
sfname = (filename).split("/")
result = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == result[:-1]:
result = ""
elif shortdetpath:
result = ""
result += name + "/" + str(savefilename) + "_" + modulename \
+ "." + str(filepostfix) + "://entry/instrument/detector"
return result
Expand All @@ -62,7 +71,8 @@ def external_data(commonblock,
framesperfile,
framenumbers,
filepostfix,
filename):
filename,
shortdetpath=None):
""" code for external_data datasource
:param commonblock: commonblock of nxswriter
Expand All @@ -81,13 +91,21 @@ def external_data(commonblock,
:type filepostfix: :obj:`str`
:param filename: file name
:type filename: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: name of saved file
:rtype: :obj:`str`
"""
result = ""
if saveallimages:
if filename:
result = (filename).split("/")[-1].split(".")[0] + "/"
sfname = (filename).split("/")
result = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == result[:-1]:
result = ""
elif shortdetpath:
result = ""
fpf = framesperfile
fn = framenumbers
spf = 0
Expand Down
17 changes: 12 additions & 5 deletions nxstools/pyeval/pilc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def triggermode_cb(commonblock, name, triggermode,
hostname, device,
filename, entryname,
insname, pilcfileprefix, pilcfiledir,
timeid=False):
timeid=False,
shortdetpath=None):
""" code for triggermode_cb datasource
:param commonblock: commonblock of nxswriter
Expand Down Expand Up @@ -60,6 +61,8 @@ def triggermode_cb(commonblock, name, triggermode,
:type pilcfiledir :obj:`str`
:param timeid: file id with timestamp
:type timeid: :obj:`bool`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: triggermode
:rtype: :obj:`str` or :obj:`int`
"""
Expand All @@ -85,11 +88,15 @@ def triggermode_cb(commonblock, name, triggermode,
except Exception:
pilcfilename = None
nblist = [nb for nb in range(nbstart, nbstart + nbfiles)]

path = ""
if filename:
path = (filename).split("/")[-1].split(".")[0] + "/"
else:
path = ""
sfname = (filename).split("/")
path = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == path[:-1]:
path = ""
elif shortdetpath:
path = ""
path += '%s/%s_' % (name, fpattern)
result = triggermode

Expand Down
13 changes: 11 additions & 2 deletions nxstools/pyeval/tangovimba.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def external_data(commonblock,
fileprefix,
filepostfix,
filestartnum,
filename):
filename,
shortdetpath=None):
""" code for external_data datasource
:param commonblock: commonblock of nxswriter
Expand All @@ -40,6 +41,8 @@ def external_data(commonblock,
:type filestartnum: :obj:`int`
:param filename: file name
:type filename: :obj:`str`
:param shortdetpath: shortdetpath
:type shortdetpath: :obj:`bool`
:returns: name of saved file
:rtype: :obj:`str`
"""
Expand All @@ -58,7 +61,13 @@ def external_data(commonblock,
if not prefix.endswith("_"):
prefix = prefix + "_"
if filename:
result = (filename).split("/")[-1].split(".")[0] + "/"
sfname = (filename).split("/")
result = sfname[-1].split(".")[0] + "/"
if shortdetpath is None and \
len(sfname) > 1 and sfname[-2] == result[:-1]:
result = ""
elif shortdetpath:
result = ""

result += name + "/" + prefix + "%06i" % filestartnum + \
postfix + "://entry/instrument/detector"
Expand Down

0 comments on commit 191f8ba

Please sign in to comment.