From 26eebc650bde68a51ea9542cb9dc6d47ee73d3ba Mon Sep 17 00:00:00 2001 From: reiche Date: Wed, 11 Sep 2024 17:06:10 +0200 Subject: [PATCH] updating snapshot and loading datasets --- app/spectralanalysis.py | 8 +++++++- interface/__init__.py | 1 + interface/load.py | 16 ++++++++++++++-- interface/slic.py | 2 +- interface/snap.py | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/spectralanalysis.py b/app/spectralanalysis.py index abc895e..1a15c31 100644 --- a/app/spectralanalysis.py +++ b/app/spectralanalysis.py @@ -19,6 +19,7 @@ class SpectralAnalysis: self.bs.stop() self.channel = None self.channels = [channel_dict[x] for x in names] + self.hasBStream=False def connect_name(self, name): index = names.index(name) @@ -30,7 +31,12 @@ class SpectralAnalysis: self.channel = self.channels[ich] print('Connecting to BS-Channel:',self.channel) self.bs.channels.clear() - self.bs.get_vars(self.channel) # this starts the stream into the cache + self.hasBStream=True + try: + self.bs.get_vars(self.channel) # this starts the stream into the cache + except ValueError: + print('Cannot find requested channels in BS stream') + self.hasBStream=False self.pv = PV(self.channel[0].replace('_Y','_X')) def terminate(self): diff --git a/interface/__init__.py b/interface/__init__.py index 4621928..7aca08e 100644 --- a/interface/__init__.py +++ b/interface/__init__.py @@ -9,5 +9,6 @@ from .save import getDatasetFileName from .load import loadDataset from .elog import writeElog from .slic import SlicScan +from .slic import importSlicScan from .doocs import doocsread from .doocs import doocswrite diff --git a/interface/load.py b/interface/load.py index 748aecb..9d82b6d 100644 --- a/interface/load.py +++ b/interface/load.py @@ -3,10 +3,22 @@ import h5py def loadDataset(filename): hid = h5py.File(filename, "r") + icount = 0 snap = loadSnap(hid) - data = loadData(hid) - act = loadActuator(hid) + data =[] + act = [] + for key in hid.keys(): + if 'scan' in key: + ID = int(key.split('_')[1]) + print('Reading scan_%d' % ID) + data.append(loadData(hid,ID)) + act.append(loadActuator(hid,ID)) + icount +=1 hid.close() + if icount == 0: + return None, None, None + elif icount == 1: + return data[0], act[0],snap return data,act,snap def loadSnap(hid): diff --git a/interface/slic.py b/interface/slic.py index a37b814..fc86dcd 100644 --- a/interface/slic.py +++ b/interface/slic.py @@ -62,7 +62,7 @@ class SlicScan(QObject): Thread(name='Snap-Acquisition',target=self.Tsnap).start() def Tsnap(self): - self.snap = getSnap() + self.snap = getSnap() print('Acquired snap') self.sigsnap.emit(True) diff --git a/interface/snap.py b/interface/snap.py index 5842b73..d4a6a3e 100644 --- a/interface/snap.py +++ b/interface/snap.py @@ -103,7 +103,7 @@ def loadSnap(filename): if '.' in val: res[pv]=float(val) else: - res[pv]= val + res[pv]= val # might be string!!!! return res