|
72 | 72 | "trans_type": "transformation_type", |
73 | 73 | "trans_vector": "vector", |
74 | 74 | "trans_offset": "offset", |
75 | | - "source": "nexdatas_source", |
| 75 | + # "source": "nexdatas_source", |
76 | 76 | "strategy": "nexdatas_strategy", |
77 | 77 | } |
78 | 78 |
|
@@ -278,18 +278,44 @@ def prepareChannels(self): |
278 | 278 | lnxpath = nxpath.split("/") |
279 | 279 | h5path = "/".join([nd.split(":")[0] for nd in lnxpath]) |
280 | 280 | root = self.__mfile.root() |
| 281 | + dataset = None |
281 | 282 | try: |
282 | 283 | self.__nxfields[key] = root.get_dataset(h5path) |
| 284 | + dataset = self.__nxfields[key] |
283 | 285 | except Exception as e: |
284 | 286 | if str(e).startswith("No node ["): |
285 | 287 | # print("S", key, shape, chunk, stream.dtype, ch) |
286 | 288 | self.__nxfields[key] = self.create_groupfield( |
287 | 289 | root, lnxpath, dtype, value=None, |
288 | 290 | shape=shape, chunk=chunk) |
| 291 | + dataset = self.__nxfields[key] |
289 | 292 | else: |
290 | 293 | self._streams.error( |
291 | 294 | "NXSFile::prepareChannels() - " % (str(e))) |
292 | 295 | raise |
| 296 | + item = ch |
| 297 | + if dataset is not None: |
| 298 | + attrs = set(item.keys()) - NOATTRS |
| 299 | + am = dataset.attributes |
| 300 | + for anm in attrs: |
| 301 | + avl = item[anm] |
| 302 | + if isinstance(avl, list): |
| 303 | + av = avl[0] |
| 304 | + while isinstance(av, list) and len(av): |
| 305 | + av = av[0] |
| 306 | + dtp = str(type(av).__name__) |
| 307 | + elif hasattr(avl, "dtype"): |
| 308 | + dtp = str(dtype.__name__) |
| 309 | + else: |
| 310 | + dtp = str(type(avl).__name__) |
| 311 | + nanm = ATTRDESC.get(anm, anm) |
| 312 | + try: |
| 313 | + self.write_attr(am, nanm, dtp, avl, item) |
| 314 | + except Exception as e: |
| 315 | + self._streams.error( |
| 316 | + "NXSFile::prepareChannels() " |
| 317 | + "- %s %s %s %s %s %s" |
| 318 | + % (am, nanm, dtp, avl, item, str(e))) |
293 | 319 |
|
294 | 320 | def write_scan_points(self): |
295 | 321 | """ write step data |
|
0 commit comments