From a11d4d9d6fec679eaa7ba6b648931bfd76bb2493 Mon Sep 17 00:00:00 2001 From: chrin Date: Mon, 16 Sep 2024 18:29:31 +0200 Subject: [PATCH] devl --- readdatafile.py | 48 +++++--- src/analysis.py | 295 ++++++++++++++++++++++++++---------------------- src/gui.py | 6 +- tina.json | 29 +++-- tina.py | 36 +++--- tina.sh | 2 +- 6 files changed, 230 insertions(+), 186 deletions(-) diff --git a/readdatafile.py b/readdatafile.py index 6b300bb..2faf0da 100644 --- a/readdatafile.py +++ b/readdatafile.py @@ -1,4 +1,5 @@ import h5py as hdf +import math import numpy as np from scipy import signal from scipy.signal import hilbert @@ -19,9 +20,14 @@ file.close() t = [] y1 = [] y2 = [] -idx = [] -t_stepsize = 0.0000000004*50 -t_stepsize = 0.00000002 +yall1 = [] +yall2 = [] +idxall = [] +#t_stepsize = 0.0000000004*50 +t_stepsize = 1/(50.6328*10**6)/50 # 0.00000002 +print(t_stepsize) +print(1/(2.5*10**9)) +#t_stepsize = 1/(2.5*10**9) t_offset = 2500002/2 t_inc = 0 @@ -52,9 +58,9 @@ for count, entry in enumerate(content[5:]): #else: # val[2]=0 - y1.append(float(val[1])*(-1)) - y2.append(float(val[2])) - idx.append(t_inc) #count + yall1.append(float(val[1])*(-1)) + yall2.append(float(val[2])) + idxall.append(t_inc) #count #if count < 200: # break # print(val[1], val[2], count, t_inc ) @@ -69,14 +75,17 @@ count = 0 t_inc = 0 idx = [] for val in range(start,stop,50): - _test1_array = y1[val : val+50] - _test2_array = y2[val : val+50] + _test1_array = yall1[val : val+50] + _test2_array = yall2[val : val+50] _y1.append(np.array(_test1_array).max()) _y2.append(np.array(_test2_array).max()) count += 1 t_inc += t_stepsize idx.append(t_inc) - + +idx = np.array(idx) - t_offset*t_stepsize + + y1 = _y1 y2 = _y2 print(y1[0:50], y2[0:50] ) @@ -92,8 +101,8 @@ print(y1[0:50], y2[0:50] ) ] y2= [ i*5 for i in y2] ''' - -f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-07-03_15:44:14.h5','a') #5Tina_2024-08-07_10:41:04.h5','a') +f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-09-13_15:57:07.h5','a') +#f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-07-03_15:44:14.h5','a') #5Tina_2024-08-07_10:41:04.h5','a') grp = f1.require_group('Raw_data') if 't' in grp: del grp['t'] @@ -103,14 +112,19 @@ if 't_idx' in grp: del grp['t_idx'] if 'y2' in grp: del grp['y2'] +if 'yall1' in grp: + del grp['yall1'] +if 'yall2' in grp: + del grp['yall2'] +dset_yall1 = grp.create_dataset('yall1', data=yall1) +dset_yall2 = grp.create_dataset('yall2', data=yall2) +dset_t = grp.create_dataset("t", data=t) dset_y1 = grp.create_dataset('y1', data=y1) dset_y2 = grp.create_dataset('y2', data=y2) -dset_t = grp.create_dataset("t", data=t) dset_t_idx = grp.create_dataset("t_idx", data=idx) print(dset_y1.name) f1.close() -idx = np.array(idx) - t_offset*t_stepsize analytic_signal_1 = y1 #hilbert(y1) amplitude_envelope_1 = np.abs(analytic_signal_1) #analytic_signal_1 # @@ -243,7 +257,7 @@ print("time index", idx[np.argmax(corr)]) #0.000433, 0.000206, 0.000231, 0.000130] subplots = 4 -ln=100 +ln=500 ln2=1239770 ln3=1260230 @@ -255,10 +269,12 @@ if subplots == 4: ax[0,0].ticklabel_format(useOffset=False, style='plain') #ax[0,0].plot(idx[0:ln], amplitude_envelope_1[0:ln], 'b') #y1 - ax[0,0].plot(idx[0:ln], normalized_amplitude_envelope_1[0:ln], 'ro') + ax[0,0].plot(idxall[0:ln], yall1[0:ln], 'ro') + ###ax[0,0].plot(idx[0:ln2], normalized_amplitude_envelope_1[0:ln2], 'ro') #ax1.set_ylim([-0.05, 0.05]) #y2 - ax[1,0].plot(idx[0:ln], normalized_amplitude_envelope_2[0:ln], 'ro') + ###ax[1,0].plot(idx[0:ln2], normalized_amplitude_envelope_2[0:ln2], 'ro') + ax[1,0].plot(idxall[0:ln], yall2[0:ln], 'ro') #ax[1,0].plot(idx[0:ln], amplitude_envelope_2[0:ln], 'g') #else: # fig, (ax3, ax4) = plt.subplots(2, figsize=(20,12)) diff --git a/src/analysis.py b/src/analysis.py index 7cbb224..3e3acd8 100644 --- a/src/analysis.py +++ b/src/analysis.py @@ -4,6 +4,7 @@ Analysis class from datetime import datetime import inspect import logging +import math import os from statistics import mean import time @@ -11,6 +12,7 @@ import time import matplotlib import matplotlib.pyplot as plt +from matplotlib import ticker import numpy as np from scipy import signal from scipy.signal import chirp, hilbert @@ -48,7 +50,7 @@ class AnalysisProcedure(QObject): self.logger.debug("Logging activated in analysis procedure") self.abort = False - + self.trigger_abort.connect(self.receive_abort) #Package the data as so: self.all_data = {} @@ -59,21 +61,28 @@ class AnalysisProcedure(QObject): self.all_data['Figure data'] = {} self.all_data['Raw data'] = {} self.raw_data = {} - self.trigger_abort.connect(self.receive_abort) + + self.ring_cyclotron = 'Cyclotron' + self.injector_2 = 'Injector' + #Declare input parameters self.input_data = None self.debug = False self.log_level = logging.INFO - self.simulation = True - self.accelerator = 'Cyclotron' + self.simulation = False + self.accelerator = self.ring_cyclotron self.harmonic_no = 6 self.N_turns = None #self.t_stepsize = 0.000000019750043 #0.00000002 - self.rf_freq =50.6328 #10**6 - self.t_stepsize = 1/(50.6328*10**6) + self.rf_freq = 50.6328 #10**6 + self.rf_sample =2.5 #10**6 + self.pulse_stepsize = 1/(self.rf_freq*10**6) + self.t_stepsize = 1/(self.rf_sample*10**9) self.dTcable = 44 #ns - self.dNpickup = 1 + self.dNpickup = -1 + self.mod_freq = 500 #GHz + self.duty_cycle = 1 # percentage #Turn off DEBUG for MATLAB mat_logger = logging.getLogger('matplotlib') mat_logger.setLevel(logging.ERROR) @@ -103,12 +112,14 @@ class AnalysisProcedure(QObject): if self.debug: self.logger.debug("INPUT DATA to LOG:{0}".format(self.input_data)) - - + self.simulation = bool(self.input_data['simulation']) print("INPUT:", self.input_data) + self.rf_freq = float(self.input_data['freqrf']) + self.rf_sample = float(self.input_data['freqsampling']) + try: self.accelerator = self.input_data['accelerator'] @@ -127,16 +138,18 @@ class AnalysisProcedure(QObject): print("self.accelerator-F", self.accelerator, flush=True) self.harmonic_no = float( self.input_data[self.accelerator]['harmonic']) - self.rf_freq = float( - self.input_data[self.accelerator]['freqrf']) self.dTcable = int( self.input_data[self.accelerator]['deltaTcable']) self.dNpickup = int( self.input_data[self.accelerator]['deltaNpickup']) + if self.injector_2 in self.accelerator: + self.mod_freq = float( + self.input_data[self.accelerator]['freqmod']) #* 10**9 #GHz + self.duty_cycle = float( + self.input_data[self.accelerator]['dutycycle']) # * 0.01 - - + print("logging info level==>", self.logger.getEffectiveLevel(), flush=True) self.loglevel = self.input_data['loggingLevel'] @@ -146,9 +159,10 @@ class AnalysisProcedure(QObject): self.logger.info("INPUT PARAMETERS") self.logger.info("Accelerator: {0}".format(self.accelerator)) - self.logger.info("Simulation {0}".format(self.simulation)) + self.logger.info("Simulation {0}".format(self.simulation)) + self.logger.info("RF Frequency (10**6 Hz) {0}".format(self.rf_freq)) + self.logger.info("RF Sampling (10**9 Hz) {0}".format(self.rf_sample)) self.logger.info("Harmonic No. {0}".format(self.harmonic_no)) - self.logger.info("RF Frequency (Hz) {0}".format(self.rf_freq)) self.logger.info("dT Cable {0}".format(self.dTcable)) self.logger.info("dN Pickup {0}".format(self.dNpickup)) @@ -180,7 +194,7 @@ class AnalysisProcedure(QObject): #Step 2 - Perform measurement and return data for processing self.raw_data = self.measure() - print("raw data", self.raw_data) + #print("raw data", self.raw_data) if self.raw_data is None: self.parent.trigger_progressbar.emit(PROGRESS_BAR_THREAD_ERROR) @@ -209,7 +223,7 @@ class AnalysisProcedure(QObject): self.raw_data = raw_data - print("loadH5Recursive", self.raw_data) + print("loadH5Recursive", self.raw_data, flush=True) return self.raw_data @@ -281,27 +295,78 @@ class AnalysisProcedure(QObject): def measure(self): self.parent.from_hdf = False + #Start and Stop Run + #Collect Data and out into numpy array + #Read Data file if simulation - for i in range (1, 90): - if i%10 == 0: - self.parent.trigger_progressbar.emit(i) - time.sleep(0.1) - if self.abort: - self.aborting(utils.line_no()) - return None + #raw data + self.y1_sample = [] + self.y2_sample = [] + self.t_sample = [] + #filtered raw data correspoding to max amplitude of pulse + self.y1_pulse = [] + self.y2_pulse = [] + self.t_pulse = [] + + def extract_raw_data(): + t_inc = 0 + for count, entry in enumerate(self.content[5:]): + entry=entry.replace('\n','') + val=entry.split('\t') + self.t_sample.append(t_inc) + self.y1_sample.append(float(val[1])*(-1)) + self.y2_sample.append(float(val[2])) + t_inc += self.t_stepsize + + def extract_peak_data(): + pt = self.pulse_stepsize/self.t_stepsize + interval = math.ceil(pt) + self.interval = interval + index_max_y1 = np.argmax(self.y1_sample[0:int(interval*1.5)]) + index_max_y2 = np.argmax(self.y2_sample[0:int(interval*1.5)]) + index_max = min(index_max_y1, index_max_y2) + print(interval, index_max_y1, index_max_y2, flush=True) + start = interval - index_max + stop = min(len(self.y1_sample), len(self.y2_sample)) + t_inc = 0 + icount = 0 + for val in range(start, stop, interval): + search_array1 = self.y1_sample[val:val+interval] + search_array2 = self.y2_sample[val:val+interval] + self.y1_pulse.append(np.array(search_array1).max()) + self.y2_pulse.append(np.array(search_array2).max()) + + self.t_pulse.append(t_inc) + #t_inc += self.t_stepsize * interval + #t_inc += self.pulse_stepsize + icount +=1 + t_offset = icount/2 + self.t_pulse = np.array(self.t_pulse) - t_offset*self.t_stepsize*interval + + + if self.simulation: + file = open('/hipa/bd/data/measurements/tina/20240710-223007_2000.txt','r') + self.content = file.readlines() + file.close() + extract_raw_data() + extract_peak_data() + + #Fill Raw data here raw_data = { - 'test': 'testing' + 'y1': self.y1_sample, + 'y2': self.y2_sample, + 't': self.t_sample } - + return raw_data def unpack_hdf_data(self): - self.analytic_signal_1 = self.raw_data['y1'] - self.analytic_signal_2 = self.raw_data['y2'] + self.y1_pulse = self.raw_data['y1'] + self.y2_pulse = self.raw_data['y2'] def process(self, from_hdf5=False): @@ -310,135 +375,89 @@ class AnalysisProcedure(QObject): if from_hdf5: self.unpack_hdf_data() - self.mean_amplitude_envelope_1 = np.mean(self.analytic_signal_1, - keepdims=True) - self.mean_amplitude_envelope_2 = np.mean(self.analytic_signal_2, - keepdims=True) + self.mean_amplitude_y1 = np.mean(self.y1_pulse, keepdims=True) + self.mean_amplitude_y2 = np.mean(self.y2_pulse, keepdims=True) self.normalized_amplitude_envelope_1 = ( - self.analytic_signal_1 - self.mean_amplitude_envelope_1) + self.y1_pulse - self.mean_amplitude_y1) self.normalized_amplitude_envelope_2 = ( - self.analytic_signal_2 - self.mean_amplitude_envelope_2) - corr_full = signal.correlate( + self.y2_pulse - self.mean_amplitude_y2) + self.corr_full = signal.correlate( self.normalized_amplitude_envelope_2, self.normalized_amplitude_envelope_1, mode='full', method='auto') - lags_full_array = signal.correlation_lags( + self.lags_full_array = signal.correlation_lags( len(self.normalized_amplitude_envelope_2), len(self.normalized_amplitude_envelope_1), mode='full') - self.lag_full = lags_full_array[np.argmax(corr_full)] - self.delay = self.lag_full * self.t_stepsize - print(self.delay, flush=True) - print(self.dTcable, flush=True) - print(self.rf_freq, flush=True) - print(self.harmonic_no, flush=True) - print(self.dNpickup, flush=True) + self.lag_full = self.lags_full_array[np.argmax(self.corr_full)] + self.delay = self.lag_full * self.t_stepsize*self.interval + self.delay = self.lag_full * self.pulse_stepsize + print("lag", self.lag_full) + print("delay", self.delay, flush=True) + print("dTcable", self.dTcable, flush=True) + print("rf freq", self.rf_freq, flush=True) + print("harmonic", self.harmonic_no, flush=True) + print("dN pickup", self.dNpickup, flush=True) - self.N_turns = (((self.delay-self.dTcable*10**(-9))*self.rf_freq*10**6)/self.harmonic_no)-self.dNpickup + self.N_turns = ( + ((self.delay-self.dTcable*10**(-9))*self.rf_freq*10**6) \ + /self.harmonic_no) + self.dNpickup print("lag = {0}, delay = {1}, nturns={2}".format( self.lag_full, self.delay, self.N_turns)) - - ####envelope - duration = 1.0 - fs = 400.0 #400.0 - samples = int(fs*duration) - t = np.arange(samples) / fs - #We create a chirp of which the frequency increases from - #20 Hz to 100 Hz and apply an amplitude modulation. - signal_chirp = chirp(t, 20.0, t[-1], 100.0) - signal_chirp *= (1.0 + 0.5 * np.sin(2.0*np.pi*3.0*t)) - ''' - The amplitude envelope is given by magnitude of the analytic signal. - The instantaneous frequency can be obtained by differentiating the - instantaneous phase in respect to time. The instantaneous phase - corresponds to the phase angle of the analytic signal. - ''' - analytic_signal = hilbert(signal_chirp) - self.amplitude_envelope = np.abs(analytic_signal) - instantaneous_phase = np.unwrap(np.angle(analytic_signal)) - self.instantaneous_frequency = ( - np.diff(instantaneous_phase) / (2.0*np.pi) * fs) - self.signal_chirp = signal_chirp - self.t = t - - ###cross-correlation - rng = np.random.default_rng() - self.sig = np.repeat([0., 1., 1., 0., 1., 0., 0., 1.], 128) - self.sig_noise = self.sig + rng.standard_normal(len(self.sig)) - analytic = hilbert(self.sig_noise) - self.correlation_envelope = np.abs(analytic) - ##self.sig = signal_chirp - #self.corr = signal.correlate(self.sig_noise, np.ones(128), mode='same') / 128 - self.corr = signal.correlate(self.correlation_envelope, np.ones(128), mode='same') / 128 - self.clock = np.arange(64, len(self.sig), 128) - + #Fill Raw data here + proc_data = { + 'y1': self.y1_pulse, + 'y2': self.y2_pulse, + 't': self.t_pulse, + 'lag': self.lag_full, + 'delay': self.delay, + 'nturns': self.N_turns + } - proc_data = {"nturns": self.N_turns} return proc_data def make_figs(self): + fig, (ax) = plt.subplots(nrows=2, ncols=1, figsize=(18,9), layout='tight') + fig2, (ax2) = plt.subplots(nrows=1, ncols=1, figsize=(18,9)) + fig.patch.set_facecolor('#FAF9F6') + fig2.patch.set_facecolor('#FAF9F6') + ln=500 + off = 10000 + s = off + e = off +ln + + #ax[0].ticklabel_format(useOffset=False, style='plain') + + ax[0].plot(self.t_sample[s:e], self.y1_sample[s:e], 'r-', label='') + ax[1].plot(self.t_sample[s:e], self.y2_sample[s:e], '.r-', label='' ) - fig, (ax_orig, ax_envelope, ax_noise, ax_corr) = plt.subplots(4, 1, sharex=True) #True - ax_orig.plot(self.sig) - ax_orig.plot(self.clock, self.sig[self.clock], 'ro') - ax_orig.set_title('Original signal') - ax_orig.plot(self.t, self.signal_chirp, label='signal') - #ax_orig.plot(self.t, self.amplitude_envelope, label='envelope') - #ax_orig.set_xlabel("t (s)") - #ax_orig.set_ylabel("Amplitude") - #ax_orig.legend() - ax_noise.plot(self.sig_noise) - ax_noise.set_title('Signal with noise') - ax_corr.plot(self.corr) - ax_corr.plot(self.clock, self.corr[self.clock], 'ro') - ax_corr.axhline(0.5, ls=':') - ax_corr.set_title('Cross-correlated with rectangular pulse') - ax_orig.margins(0, 0.1) - ax_envelope.plot(self.correlation_envelope) - ax_envelope.set_title('Envelope signal') - fig.tight_layout() - #fig_data = {'Canvas 1': [fig]} - - fig2, (ax0, ax1) = plt.subplots(nrows=2) - ax0.plot(self.t, self.signal_chirp, label='signal') - ax0.plot(self.t, self.amplitude_envelope, label='envelope') - ax0.set_xlabel("t (s)") - ax0.set_ylabel("Amplitude") - ax0.legend() - ax1.plot(self.t[1:], self.instantaneous_frequency) - ax1.set_xlabel("t (s)") - ax1.set_ylabel("f (Hz)") - ax1.set_ylim(0.0, 120.0) - #fig2.tight_layout() - fig_data = {'Canvas 1': [fig, fig2]} + ax[0].xaxis.set_major_locator(ticker.MultipleLocator(self.t_stepsize*self.interval)) + ax[0].set_xlabel('Time [s]') + ax[0].set_ylabel('Amplitude') + ax[0].set_title('Pulse at Entry') + ax[0].set_facecolor("lightgrey") + #ax[0].legend() + ax[0].grid(visible=True, which='major', axis='both', linestyle='--', linewidth=0.8) + ax[1].xaxis.set_major_locator(ticker.MultipleLocator(self.t_stepsize*self.interval)) + ax[1].set_xlabel('Time [s]') + ax[1].set_ylabel('Amplitude') + ax[1].set_title('Pulse at Exit') + ax[1].set_facecolor("lightgray") + ax[1].grid(visible=True, which='major', axis='both', linestyle='--', linewidth=0.8) + #ax[1].legend() - ''' - # Data for plotting - t = np.arange(0.0, 2.0, 0.01) - s = 1 + np.sin(2 * np.pi * t) - fig, ax = plt.subplots() #figsize=(0.3, 0.2)) - ax.plot(t, s) - ax.set(xlabel='Time (s)', ylabel='Voltage (mV)', - title='Sinusoidal Wave-1') - ax.grid() - t = np.arange(0.0, 3.0, 0.01) - s = 1 + np.sin(3 * np.pi * t) - - fig2, ax = plt.subplots() - ax.plot(t, s) - ax.set(xlabel='Time (s)', ylabel='Voltage (mV)', - title='Sinusoidal Wave-2') - ax.grid() - fig3, ax = plt.subplots() - ax.plot(t, s) - ax.set(xlabel='Time (s)', ylabel='Voltage (mV)', - title='Sinusoidal Wave-3') - ax.grid() - fig_data = {'Canvas 1': [fig, fig2]} - fig_data['Canvas 2'] = fig3 - ''' + ax2.set_facecolor("#F5F5F5") + ax2.plot(self.lags_full_array[:], self.corr_full[:]) + xmin, xmax, ymin, ymax = ax2.axis() + lineStart = ymin #self.corr_full.min() + lineEnd = ymax #self.corr_full.max() + print("start end ", lineStart, lineEnd) + ax2.plot([1107, 1107], [lineStart, lineEnd], 'k-', color = 'r') + ax2.set_ylim(lineStart, lineEnd) + #ax2[1].plot(self.lags_full_array[:], self.corr_full[:], 'yo') + fig_data = {'Canvas 1': [fig2], 'Canvas 2': [fig]} return fig_data diff --git a/src/gui.py b/src/gui.py index 72d9810..d44d142 100644 --- a/src/gui.py +++ b/src/gui.py @@ -44,11 +44,11 @@ class AppGui(QWidget): self.input_parameters = self.parent.input_parameters self.input_labels = self.parent.input_labels self.expert_parameters = self.parent.expert_parameters - self.gui_frame.expert_parameters_group.setFixedWidth(260) + self.gui_frame.expert_parameters_group.setFixedWidth(310) self.gui_frame.expert_parameters_group.setFixedHeight(130) self.gui_frame.operator_parameters_group.setFixedWidth(260) - self.gui_frame.operator_parameters_group.setFixedHeight(330) + self.gui_frame.operator_parameters_group.setFixedHeight(380) self.gui_frame.measurement_tab_wgt.setFixedWidth(496) - self.gui_frame.measurement_tab_wgt.setFixedHeight(410) + self.gui_frame.measurement_tab_wgt.setFixedHeight(460) self.gui_frame.operator_wgt.setFixedHeight(640) self.gui_frame.expert_wgt.setFixedHeight(240) diff --git a/tina.json b/tina.json index 27d1f30..57b3103 100755 --- a/tina.json +++ b/tina.json @@ -19,33 +19,38 @@ "HIPA2": {"test": ["Injector", "Ring"]}, "QTabAccelerator":{ "Injector": { - "harmonic" : {"data":{ "widget": "QLineRead", "text" :"Harmonic No.:", "value": 10}}, - "freqrf" : {"data":{ "widget": "QLineEdit", "text" :"RF Freq (10^6/s):", "value" : 50.6328 }}, + "harmonic" : {"data":{ "widget": "QLineRead", "text" :"Harmonic No: ", "value": 10}}, "deltaTcable" : {"data":{ "widget": "QLineRead", "text" : "dT Cable (ns):", "value": 6.9 }}, - "deltaNpickup" : {"data":{ "widget": "QLineEdit", "text" : "dN pickup:", "value": 4 }} + "deltaNpickup" : {"data":{ "widget": "QLineEdit", "text" : "dN Pickup:", "value": 4 }}, + "freqmod" : {"data":{ "widget": "QLineRead", "text" :"Mod. Freq (GHz):", "value" : 500}}, + "dutycycle" : {"data":{ "widget": "QLineRead", "text" :"Duty Cycle (%):", "value" : 1}} }, - "Cyclotron": { - "harmonic" : {"data":{ "widget": "QLineRead", "text" :"Harmonic No:", "value" : 6}}, - "freqrf" : {"data":{ "widget": "QLineEdit", "text" :"RF Freq (10^6/s):", "value" : 50.6328 }}, - "deltaTcable" : {"data":{ "widget": "QLineRead", "text" : "dT Cable (ns)", "value": 44 }}, - "deltaNpickup" : {"data":{ "widget": "QLineEdit", "text" : "dN Pickup:", "value": 1 }} + "Cyclotron": { + "harmonic" : {"data":{ "widget": "QLineRead", "text" :"Harmonic No: ", "value" : 6}}, + "deltaTcable" : {"data":{ "widget": "QLineRead", "text" : "dT Cable (ns):", "value": 44 }}, + "deltaNpickup" : {"data":{ "widget": "QLineEdit", "text" : "dN Pickup:", "value": -1 }} } }, "Parameters":{ "facility": {"flag": 0, "data" : {"widget": "QComboBox", "text" : "Facility:", "link": ["HIPA"],"layout" : "Horizontal"}}, + "freqrf" : {"flag": 1, "data":{ "widget": "QLineEdit", "text" :"RF Freq (10^6/s):", "value" : 50.6328 }}, + "freqsampling" : {"flag": 1, "data":{ "widget": "QLineRead", "text" :"Sampling Freq (GHz):", "value" : 2.5 }}, + + "drawLine" : {"flag" : 1, "data":{ "widget": "QHLine", "text" : "None", "value" : "None"}}, + "accelerator" : {"flag" : 1, "data":{ "widget": "QTabWidget", "text" : "Accelerator: ", "link" : "QTabAccelerator", "value" : 1, "color" : ["#0080aa", "#0000ff"]}} - + }, "Expert":{ "debug": {"flag" : 1, "data":{ "widget": "None", "text" : "Debug", "value" : 0}}, - "simulation": {"flag" : 1, "data":{ "widget": "None", "text" : "Simulation", "value" : 0}} + "simulation": {"flag" : 1, "data":{ "widget": "None", "text" : "Simulation", "value" : 1}} }, "GUI": { "resultsTabTitle" : "Plots", - "subResultsTabTitle" : ["Correlations"], - "resultsSeq" : [10, 1] + "subResultsTabTitle" : ["Correlations", "Raw Data"], + "resultsSeq" : [1, 1] } } diff --git a/tina.py b/tina.py index a720c67..8de63c5 100644 --- a/tina.py +++ b/tina.py @@ -52,9 +52,11 @@ class StartMain(BaseWindow): def prepare_results_message(self): """Prepare results message """ - - self.no_turns = self.all_data["Processed data"]["nturns"] - + try: + self.no_turns = self.all_data["Processed data"]["nturns"] + except KeyError as ex: + self.no_turns = 180 + try: self.accelerator = self.all_data["Input data"]["accelerator"] except KeyError as ex: @@ -117,6 +119,7 @@ class StartMain(BaseWindow): self.show_log_message(MsgSeverity.INFO, _pymodule, utils.line_no(), self.message) + ''' @Slot() def save_to_hdf_dialog(self): @@ -129,7 +132,7 @@ class StartMain(BaseWindow): return False BaseWindow.save_to_hdf_dialog(self) - + ''' @Slot() @@ -137,6 +140,7 @@ class StartMain(BaseWindow): if not self.verify_save_to_hdf(): return False + ''' if self.from_hdf: _mess = ("This is a repeat analysis from HDF. \n" + "Saving duplicate data to HDF is declined.") @@ -144,7 +148,7 @@ class StartMain(BaseWindow): QApplication.processEvents() return False - + ''' if self.all_data is not None: self.save_hdf_thread = self.HDFSave(self, from_dialog) @@ -161,18 +165,18 @@ class StartMain(BaseWindow): """ if self.all_data is not None: #All but 'Figure data' - #self.all_data['Raw data']['Input_data'] = self.all_data[ - # 'Input data'] - #self.all_data['Raw data']['Ambient_data'] = self.all_data[ - # 'Ambient data'] - #self.all_data['Raw data']['Processed_data'] = self.all_data[ - # 'Processed data'] - #self.all_data['Raw data']['Raw_data'] = self.all_data[ - # 'Application Raw data'] - self.all_data['Raw_data'] = self.all_data['Application Raw data'] - del self.all_data['Figure data'] + self.all_data['Raw data']['Input_data'] = self.all_data[ + 'Input data'] + self.all_data['Raw data']['Ambient_data'] = self.all_data[ + 'Ambient data'] + self.all_data['Raw data']['Processed_data'] = self.all_data[ + 'Processed data'] + self.all_data['Raw data']['Raw_data'] = self.all_data[ + 'Application Raw data'] + #self.all_data['Raw_data'] = self.all_data['Application Raw data'] + #del self.all_data['Figure data'] h5_storage.saveH5Recursive( - self.hdf_filename, self.all_data, dataH5) + self.hdf_filename, self.all_data['Raw data'], dataH5) @Slot() def send_to_elog(self): diff --git a/tina.sh b/tina.sh index 117af44..384de19 100755 --- a/tina.sh +++ b/tina.sh @@ -22,7 +22,7 @@ _EPICS_HOST_ARCH=${RHREL}-x86_64 # Select Python Version here. Currently one of 3.5, 3.7, 3.8 and 3.10 PYTHON_VERSION=3.10 -PYTHON_PATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.20.0-gcc-7.5.0/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.11.0 +PYTHON_PATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.20.0-gcc-7.5.0/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.12.0 if [ "$1" ]; then