diff --git a/src/settings.py b/src/settings.py index 6d35bb0..8387401 100644 --- a/src/settings.py +++ b/src/settings.py @@ -343,7 +343,7 @@ def __init__(self, parent): self.parent = parent self.path = parent.path self.convert_units = parent.convert_units - self.load_style = 'new_tranter' + self.load_style = 'tranter_v1_0' # self.load_full_series_box = parent.load_full_series_box # self.set_load_full_set() # self.load_full_series_box.stateChanged.connect(lambda: self.set_load_full_set()) @@ -354,14 +354,14 @@ def parameters(self, file_path): lines = f.read().splitlines() if lines[0] == '[Date]': # new Tranter style - self.load_style = 'new_tranter' - parameters = self.read_tranter_exp_new(lines) + self.load_style = 'tranter_v1_0' + parameters = self.read_tranter_exp_v1(lines) elif lines[0] == '"[Expt Parameters]"': # old Tranter style - self.load_style = 'old_tranter' - parameters = self.read_tranter_exp_old(lines) + self.load_style = 'tranter_v0_1' + parameters = self.read_tranter_exp_v0(lines) else: - self.load_style = 'new_tranter' - parameters = self.read_tranter_exp_new(lines) + self.load_style = 'tranter_v1_0' + parameters = self.read_tranter_exp_v1(lines) # Units are assumed to be: T1 [°C], P1 [Torr], u1 [mm/μs], P4 [psi] parameters['T1'] = self.convert_units(parameters['T1'], '°C', '2ct') @@ -372,7 +372,7 @@ def parameters(self, file_path): return parameters - def read_tranter_exp_new(self, lines): + def read_tranter_exp_v1(self, lines): def get_config(section, key): val = self.config[section][key] for delimiter in ['"', "'"]: # remove delimiters @@ -399,28 +399,38 @@ def get_config(section, key): if mol_frac != 0: # continue if mole fraction is not zero mix[species] = mol_frac - # Throw errors if P1, T1, tOpt, or PT Spacing are zero + # Throw errors if P1, T1, or Sample Rate are zero if float(get_config('Expt Params', 'P1')) == 0: raise Exception('Exception in Experiment File: P1 is zero') elif float(get_config('Expt Params', 'T1')) == 0: raise Exception('Exception in Experiment File: T1 is zero') - elif float(get_config('Expt Params', 'tOpt')) == 0: - raise Exception('Exception in Experiment File: tOpt is zero') - elif float(get_config('Expt Params', 'PT Spacing')) == 0: - raise Exception('Exception in Experiment File: PT Spacing is zero') elif float(get_config('Expt Params', 'SampRate')) == 0: raise Exception('Exception in Experiment File: Sample Rate is zero') - + + # Throw errors for u1 and calculate/get it from VelatObs or tOpt/PT Spacing + if self.config.has_option('Expt Params', 'VelatObs'): # Tranter exp file v1.1 gives velocity + u1 = float(get_config('Expt Params', 'VelatObs')) + if u1 == 0: + raise Exception('Exception in Experiment File: Velocity at observation is zero') + else: + tOpt = float(get_config('Expt Params', 'tOpt')) + PT_spacing =float(get_config('Expt Params', 'PT Spacing')) + u1 = PT_spacing/tOpt + if tOpt == 0: + raise Exception('Exception in Experiment File: tOpt is zero') + elif PT_spacing == 0: + raise Exception('Exception in Experiment File: PT Spacing is zero') + parameters = {'T1': float(get_config('Expt Params', 'T1')), - 'P1': float(get_config('Expt Params', 'P1')), - 'u1': float(get_config('Expt Params', 'PT Spacing'))/float(get_config('Expt Params', 'tOpt')), - 'P4': float(get_config('Expt Params', 'P4')), - 'exp_mix': deepcopy(mix), 'thermo_mix': deepcopy(mix), - 'Sample_Rate': float(get_config('Expt Params', 'SampRate'))} + 'P1': float(get_config('Expt Params', 'P1')), + 'u1': u1, + 'P4': float(get_config('Expt Params', 'P4')), + 'exp_mix': deepcopy(mix), 'thermo_mix': deepcopy(mix), + 'Sample_Rate': float(get_config('Expt Params', 'SampRate'))} return parameters - def read_tranter_exp_old(self, lines): + def read_tranter_exp_v0(self, lines): parameters = {'T1': None, 'P1': None, 'u1': None, 'exp_mix': {}, 'thermo_mix': {}} key = None @@ -491,7 +501,7 @@ def is_numeric(strings): def exp_data(self, file_path): exp_data, nonnumeric = self.csv(file_path) - if self.load_style == 'old_tranter': + if self.load_style == 'tranter_v0_1': exp_data = np.array(exp_data) exp_data = exp_data[:,[0,2]] exp_data = exp_data[:-1,:]