Skip to content

Commit a772e67

Browse files
committed
Attempt 2 to fix live display during experiment
1 parent 47a9b5b commit a772e67

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

application.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def reactUpdate(self, event):
134134

135135
# In this case we should have a list of spectra as given by
136136
# Spectrum_Storage[folder_id, :, channel_id] :
137-
# [(subfolder_id, spectrum), ...]
137+
# {subfolder_id: spectrum, ...}
138138

139139
# To find some other colormap ideas :
140140
# https://matplotlib.org/examples/color/colormaps_reference.html
@@ -143,7 +143,7 @@ def reactUpdate(self, event):
143143
# StackOverflow question :
144144
# Using colomaps to set color of line in matplotlib
145145

146-
values = [tup[0] for tup in tp_instruction[1]]
146+
values = list(tp_instruction[1].keys())
147147

148148
colormap = plt.get_cmap("plasma")
149149

@@ -152,7 +152,7 @@ def reactUpdate(self, event):
152152
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=colormap)
153153

154154
for idx in range(len(values)):
155-
spectrum = tp_instruction[idx][1]
155+
spectrum = tp_instruction[idx]
156156
colorVal = scalarMap.to_rgba(values[idx])
157157
plotting_area.plot(
158158
spectrum.lambdas, spectrum.values,
@@ -629,7 +629,7 @@ def get_timestamp(self):
629629

630630
def experiment(self):
631631
self.processing_text["text"] = "Preparing experiment..."
632-
exp_timestamp = self.spectra_storage.createStorageUnit()
632+
raw_timestamp = self.spectra_storage.createStorageUnit()
633633
experiment_logger.info("Starting experiment.")
634634
self.experiment_on = True
635635
self.pause_live_display.set()
@@ -662,6 +662,8 @@ def experiment(self):
662662

663663
self.avh.prepareAll(p_T, True, p_N_c)
664664

665+
abs_timestamp = self.spectra_storage.createStorageUnit()
666+
665667
if not self.spectra_storage.blackIsSet():
666668
experiment_logger.warning("Black not set, aborting.")
667669
abort = True
@@ -719,9 +721,9 @@ def experiment(self):
719721
float(pulse.experimentTuple[BNC.dPHASE].get())
720722
tp_scopes = self.avh.getScopes()
721723
self.avh.stopAll()
722-
self.spectra_storage.putSpectra(exp_timestamp, n_d, tp_scopes)
724+
self.spectra_storage.putSpectra(raw_timestamp, n_d, tp_scopes)
723725
self.liveDisplay.putSpectrasAndUpdate(
724-
3, self.spectra_storage[exp_timestamp, n_d, :])
726+
3, self.spectra_storage[raw_timestamp, n_d, :])
725727

726728
black_corrected_scopes = dict([])
727729

@@ -742,12 +744,12 @@ def experiment(self):
742744
tp_absorbance[key]-correction_spectrum[key]
743745

744746
self.spectra_storage.putSpectra(
745-
exp_timestamp, n_d, tp_absorbance)
747+
abs_timestamp, n_d, tp_absorbance)
746748

747749
self.liveDisplay.putSpectrasAndUpdate(
748750
4,
749751
self.spectra_storage[
750-
exp_timestamp, :, first_absorbance_spectrum_name])
752+
abs_timestamp, :, first_absorbance_spectrum_name])
751753

752754
if not self.experiment_on:
753755
experiment_logger.info("Experiment stopped.")
@@ -760,7 +762,7 @@ def experiment(self):
760762
experiment_logger.warning("Experiment aborted.")
761763
abort = True
762764
self.experiment_on = False
763-
self.treatSpectras(exp_timestamp)
765+
self.treatSpectras(raw_timestamp)
764766
self.avh.release()
765767
self.pause_live_display.clear()
766768
self.processing_text["text"] = "No running experiment..."

spectro.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,10 @@ def putSpectra(self, folder_id, subfolder_id, spectra):
853853
raise IndexError(
854854
"{} is not a correct folder id.".format(folder_id)
855855
)
856-
"""
857856
if subfolder_id in self._hidden_directory[folder_id]:
858857
raise IndexError(
859858
"{} is already in folder {}.".format(subfolder_id, folder_id)
860859
)
861-
"""
862860

863861
if not isinstance(subfolder_id, int) and folder_id != "Basic":
864862
raise TypeError(

0 commit comments

Comments
 (0)