diff --git a/Flow_class.py b/Flow_class.py index 584edc21500b2a71f8efe9896c66eefb604f5ef0..b6fdf6eec0c6ed919598b169eb1e00f490b5eca1 100644 --- a/Flow_class.py +++ b/Flow_class.py @@ -453,7 +453,7 @@ class Elbow_profile(): def make_kfac_fully(self,flowmeter = None,ret = False): rfine = np.linspace(0,1,int(1e6)) ufine = self.fully_class.get_u_u_vol(rfine) - self.up_fully = np.trapz(rfine,ufine) + self.up_fully = np.trapz(ufine,rfine) self.k_fully = 1/self.up_fully if ret: return self.up_fully,self.k_fully diff --git a/GUI_Elbow.py b/GUI_Elbow.py index fa8f11ca87e3c383153627bfc83d7840fdad1120..cc5644bfd4bd838e5b5e2e42b081397418a76486 100644 --- a/GUI_Elbow.py +++ b/GUI_Elbow.py @@ -332,7 +332,7 @@ class mainPanel(wx.Panel): self.xax_dropdown.SetSelection(0) self.xax_dropdown.Bind(wx.EVT_CHOICE, self.Onxax_dropdown) # y-axis choices - self.yax_dropdown = wx.Choice(self,choices=["error in %","k","k_dis","k_st"]) + self.yax_dropdown = wx.Choice(self,choices=["error in %","k","k_d"]) self.yax_dropdown.SetSelection(0) self.yax_dropdown.Bind(wx.EVT_CHOICE, self.Onyax_dropdown) # add the axes choices and labels to a hbox @@ -710,25 +710,59 @@ class mainPanel(wx.Panel): x = 0 y = 0 xlabel = "" - y *= 100 - y_u *= 100 + + plot_what = self.yax_dropdown.GetSelection() + spreadfac = 1 + ylimiter = 0.02 + if plot_what == 0: + y *= flow.k_fully*100 + y_u *= 100 + spreadfac = 100 + ylabel = "Error in %" + elif plot_what == 1: # this is k-factor + y = 1/(y + flow.up_fully) + ylabel = "Callibration factor k_p" + elif plot_what == 2: # this is k_st-factor + y = flow.up_fully / (y + flow.up_fully) + ylabel = "Correction factor k_d" + else: + print("no axes selected") + x = 0 + y = 0 + ylabel = "" + ylimiter *= spreadfac self.ax_meter.cla() # self.ax_meter.set_xlabel(xlabel) - self.ax_meter.set_ylabel("Error in %") + self.ax_meter.set_ylabel(ylabel) self.ax_meter.plot(x,y,'-') + + + ymin = self.ax_meter.get_ylim()[0] + ymax = self.ax_meter.get_ylim()[1] + ydiff = ymax-ymin + print(ydiff) + if ydiff < ylimiter: + ymin = self.ax_meter.get_ylim()[0]-(ylimiter-ydiff)/2 + ymax = self.ax_meter.get_ylim()[1]+(ylimiter-ydiff)/2 + # print("min") + # print(ymin) + # print("max") + # print(ymax) + self.ax_meter.set_ylim(ymin,ymax) + # + # the line-plot of the selected parameter within the x axes + self.ax_meter.plot([x_selected,x_selected],[ymin,ymax],'r-',linewidth=1) if y_u.any(): self.ax_meter.fill_between(x, y - y_u, y + y_u, facecolor='green', alpha = 0.3, interpolate=True, label="std") - self.ax_meter.text(x_selected, self.ax_meter.get_ylim()[0], " " + str(np.round(np.interp(x_selected,x, y),2)) + " | " + str(np.round(np.interp(x_selected,x, y_u),2)), fontsize=14,color='r') + self.ax_meter.text(x_selected, ymin, " " + str(np.round(np.interp(x_selected,x, y),2)) + " | " + str(np.round(np.interp(x_selected,x, y_u),2)), fontsize=14,color='r') else: - self.ax_meter.text(x_selected, min(y), " " + str(np.round(np.interp(x_selected,x, y),2)), fontsize=14,color='r') - # - # the line-plot of the selected parameter within the x axes - self.ax_meter.plot([x_selected,x_selected],self.ax_meter.get_ylim(),'r-',linewidth=1) + self.ax_meter.text(x_selected, ymin, " " + str(np.round(np.interp(x_selected,x, y),2)), fontsize=14,color='r') + self.ax_meter.grid("on") self.fig_meter.tight_layout() self.canvas_meter.draw()