Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2026-02-28 Jan Kotanski <jankotan@gmail.com>
* add attributes of streamed channels from datadesc (#26)
* tagged as v0.0.8

2026-02-28 Jan Kotanski <jankotan@gmail.com>
* remove file object after closing it (#23)
* tagged as v0.0.7
Expand Down
28 changes: 27 additions & 1 deletion nxsblisswriter/NXSFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"trans_type": "transformation_type",
"trans_vector": "vector",
"trans_offset": "offset",
"source": "nexdatas_source",
# "source": "nexdatas_source",
"strategy": "nexdatas_strategy",
}

Expand Down Expand Up @@ -278,18 +278,44 @@ def prepareChannels(self):
lnxpath = nxpath.split("/")
h5path = "/".join([nd.split(":")[0] for nd in lnxpath])
root = self.__mfile.root()
dataset = None
try:
self.__nxfields[key] = root.get_dataset(h5path)
dataset = self.__nxfields[key]
except Exception as e:
if str(e).startswith("No node ["):
# print("S", key, shape, chunk, stream.dtype, ch)
self.__nxfields[key] = self.create_groupfield(
root, lnxpath, dtype, value=None,
shape=shape, chunk=chunk)
dataset = self.__nxfields[key]
else:
self._streams.error(
"NXSFile::prepareChannels() - " % (str(e)))
raise
item = ch
if dataset is not None:
attrs = set(item.keys()) - NOATTRS
am = dataset.attributes
for anm in attrs:
avl = item[anm]
if isinstance(avl, list):
av = avl[0]
while isinstance(av, list) and len(av):
av = av[0]
dtp = str(type(av).__name__)
elif hasattr(avl, "dtype"):
dtp = str(dtype.__name__)
else:
dtp = str(type(avl).__name__)
nanm = ATTRDESC.get(anm, anm)
try:
self.write_attr(am, nanm, dtp, avl, item)
except Exception as e:
self._streams.error(
"NXSFile::prepareChannels() "
"- %s %s %s %s %s %s"
% (am, nanm, dtp, avl, item, str(e)))

def write_scan_points(self):
""" write step data
Expand Down
2 changes: 1 addition & 1 deletion nxsblisswriter/Release.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
""" release version module """

#: version number
__version__ = "0.0.7"
__version__ = "0.0.8"