diff --git a/FlowMeter.py b/FlowMeter.py index f80a116624757f89d98ac3aa367b066c47d69b2c..771a17254a2dc996dbb1d9ab90442d24a425f83c 100644 --- a/FlowMeter.py +++ b/FlowMeter.py @@ -4,7 +4,7 @@ Created on Tue Sep 27 11:27:34 2022 @author: weisse02 """ - +import numpy as np # a new class for the flow meter class FlowMeter(): def __init__(self): @@ -48,4 +48,8 @@ class FlowMeter(): self.selectedOptions[2] = value def setOption3(self,value): self.selectedOptions[3] = value - #def set_k_values \ No newline at end of file + #def set_k_values + + def set_name(self): + # set a unique name for the selected flow meter depending on the selected options + self.name = self.options[0][self.selectedOptions[0]] + '_' + self.options[1][self.selectedOptions[1]] + '_' + self.selectedOptions[2] + '_' + self.selectedOptions[3] \ No newline at end of file diff --git a/FlowMeters/DoubleElbow/data_usV30.npz b/FlowMeters/DoubleElbow/Ultrasonic_diametral_1_30.npz similarity index 100% rename from FlowMeters/DoubleElbow/data_usV30.npz rename to FlowMeters/DoubleElbow/Ultrasonic_diametral_1_30.npz diff --git a/FlowMeters/DoubleElbow/old_scipy_Ultrasonic_diametral_1_30.npz b/FlowMeters/DoubleElbow/old_scipy_Ultrasonic_diametral_1_30.npz deleted file mode 100644 index fccfd045747784bd91e9fee74fa642969e3410df..0000000000000000000000000000000000000000 Binary files a/FlowMeters/DoubleElbow/old_scipy_Ultrasonic_diametral_1_30.npz and /dev/null differ diff --git a/FlowMeters/SingleElbow/old_scipy_Ultrasonic_diametral_1_30.npz b/FlowMeters/SingleElbow/Ultrasonic_diametral_1_30.npz similarity index 99% rename from FlowMeters/SingleElbow/old_scipy_Ultrasonic_diametral_1_30.npz rename to FlowMeters/SingleElbow/Ultrasonic_diametral_1_30.npz index 05613f8915fa73ad1429618f01340f8357f6dd02..25f9b7f403f65529ca2cce218d6fc510a4b00406 100644 Binary files a/FlowMeters/SingleElbow/old_scipy_Ultrasonic_diametral_1_30.npz and b/FlowMeters/SingleElbow/Ultrasonic_diametral_1_30.npz differ diff --git a/FlowMeters/SingleElbow/data_usV30.npz b/FlowMeters/SingleElbow/transpose_Ultrasonic_diametral_1_30.npz similarity index 100% rename from FlowMeters/SingleElbow/data_usV30.npz rename to FlowMeters/SingleElbow/transpose_Ultrasonic_diametral_1_30.npz diff --git a/Flow_class.py b/Flow_class.py index 175456e78e01ff79afb709164aa23516dcea626d..2a308511bae1b5e401f4cc080c0889b91f29380f 100644 --- a/Flow_class.py +++ b/Flow_class.py @@ -633,7 +633,7 @@ class Elbow_profile(): # # if no distnces and Rcs given it will calculate them for all # the sampled distances and Rc - if dists == None: dists = np.concatenate((self.dist[0:1],self.dist[1:-1:5],self.dist[-1:])) + if dists == None: dists = self.dist #np.concatenate((self.dist[0:1],self.dist[1:-1:5],self.dist[-1:])) if Rcs == None: Rcs = self.Rk if dls == None: dls = self.dl # get the distances and length of the us-paths diff --git a/GUI_Elbow.py b/GUI_Elbow.py index 50ae60905576809bf9414ce3d8420c382529ec60..00a1c75567b68b1eaa301993e7af394d4c5209a4 100644 --- a/GUI_Elbow.py +++ b/GUI_Elbow.py @@ -328,7 +328,7 @@ class mainPanel(wx.Panel): # x-axis choices xax_label = wx.StaticText(self, wx.ID_ANY, label ="x-axis") yax_label = wx.StaticText(self, wx.ID_ANY, label ="y-axis") - self.xax_dropdown = wx.Choice(self,choices=["distance","Rc","phi"]) + self.xax_dropdown = wx.Choice(self,choices=["distance","Rc","phi","dl"]) self.xax_dropdown.SetSelection(0) self.xax_dropdown.Bind(wx.EVT_CHOICE, self.Onxax_dropdown) # y-axis choices @@ -437,23 +437,29 @@ class mainPanel(wx.Panel): return vbox , slider , label_value, label_uncert_value # + + def loadFlowmeter(self): + global fm + try: + print("try to load the flow meter") + self.pathint = np.load("./FlowMeters/"+flow.case + "/" + fm.name+".npz",allow_pickle=True)["pathint"] + if flow.case == "SingleElbow": + self.regint_fm = interpol.RegularGridInterpolator((flow.Rk,flow.dist,flow.phi[:,0]),self.pathint,method = "cubic",bounds_error = False,fill_value=None) + else: + self.regint_fm = interpol.RegularGridInterpolator((flow.Rk,flow.dl,flow.dist,flow.phi[:,0]),self.pathint,method = "cubic",bounds_error = False,fill_value=None) + print("Flow meter successfully loaded from file") + return 1 + except Exception as e: + print("flow meter could not be loaded -> it will be calculated, this takes some time " + str(e)) + return 0 def OnClicked_btn_flowmeter(self,e): + global fm + # set the name of the flow meter + fm.set_name() print("This is your selected Flow Meter:") print(fm.optNames) - fm_name = fm.options[0][fm.selectedOptions[0]] + '_' + fm.options[1][fm.selectedOptions[1]] + '_' + fm.selectedOptions[2] + '_' + fm.selectedOptions[3] - print(fm.options[0][fm.selectedOptions[0]] + ', ' + fm.options[1][fm.selectedOptions[1]] + ', ' + fm.selectedOptions[2] + ', ' + fm.selectedOptions[3]) - # - # - # load the flow meter if it was already calculated - fmdirs = os.listdir("./FlowMeters/"+flow.case) - print(fmdirs) - if fm_name+".npz" in fmdirs: - print("--- flow meter is loaded from data --- ") - # load the flow meter results - data = np.load("./FlowMeters/"+flow.case + "/" + fm_name+".npz",allow_pickle=True) - self.regint_fm = data["regint_fm"][()] - del data - else: + print(fm.name) + if not self.loadFlowmeter(): # calculate the flow meter integrals for all paths distances and curvature radii import time start_time = time.time() @@ -463,8 +469,8 @@ class mainPanel(wx.Panel): print("pathint shape") print(self.pathint.shape) # save the flowmeterinterpolation - np.savez("./FlowMeters/"+flow.case+"/" + fm_name + ".npz",regint_fm=self.regint_fm,allow_pickle=True) - np.savez("./FlowMeters/"+flow.case+"/" + fm_name + "_data.npz",pathint=self.pathint,allow_pickle=True) + #np.savez("./FlowMeters/"+flow.case+"/" + fm.name + ".npz",regint_fm=self.regint_fm,allow_pickle=True) + np.savez("./FlowMeters/"+flow.case+"/" + fm.name + ".npz",pathint=self.pathint,allow_pickle=True) self.pathint = np.array([1]) # a regular grid interpolator for the flow meter values #self.regint_fm = interpol.RegularGridInterpolator((flow.Rk,flow.dl,flow.dist,flow.phi[:,0]),self.pathint) @@ -672,21 +678,30 @@ class mainPanel(wx.Panel): y_u = np.zeros(0) if plot_over == 0: # this is "distance" x = flow.dist - y, y_u = self.interpol_meter(self.Rc,self.dl,flow.dist,self.phi) + y, y_u = self.interpol_meter(self.Rc,self.dl,x,self.phi) xlabel = "distance in z/D" # the selected x-value from the sliders x_selected = self.dist # elif plot_over == 1: # this is "Rc" - x = flow.Rk - y, y_u = self.interpol_meter(flow.Rk,self.dl,self.dist,self.phi) + x = np.linspace(flow.Rk[0],flow.Rk[-1],200) + y, y_u = self.interpol_meter(x,self.dl,self.dist,self.phi) xlabel = "curvature radius in Rc/D" # the selected x-value from the sliders x_selected = self.Rc # elif plot_over == 2: # this is "phi" - x = flow.phi[:,0]/pi*180 - y,y_u = self.interpol_meter(self.Rc,self.dl,self.dist,flow.phi[:,0]) + x = flow.phi[:,0] + y,y_u = self.interpol_meter(self.Rc,self.dl,self.dist,x) + x = x/pi*180 + xlabel = "angle in grad" + # the selected x-value from the sliders + x_selected = self.phi/pi*180 + # + elif plot_over == 3 and flow.case != "SingleElbow": # this is dl + x = np.linspace(flow.dl[0],flow.dl[-1],200) + y,y_u = self.interpol_meter(self.Rc,self.dl,self.dist,x) + x = x/pi*180 xlabel = "angle in grad" # the selected x-value from the sliders x_selected = self.phi/pi*180 @@ -1056,7 +1071,7 @@ class Main(wx.Frame): if __name__ == "__main__": # - flow = Elbow_profile('DoubleElbow') + flow = Elbow_profile('SingleElbow') fm = FlowMeter() # app = wx.App()