Esempio n. 1
0
 def fit(self, p0={}):
     if p0 == {}:
         p0 = {"a": 1, "Imax": 50, "y0": self.Y[len(self.Y) - 1]}
     fit = lmfit(self.__func, self.Y, self.Irel, p0=p0, verbose=False, plot=False)
     self.fit = fit
     self.__Y0 = fit.P["y0"]
     self.__a = fit.P["a"]
     x = linspace(self.__xlim[0], self.__xlim[1], 100)
     fig, axes = plt.subplots(figsize=(8, 5), dpi=100)
     axes.set_title(r"IR Power vs. Surface Position")
     axes.plot(self.Y, self.Irel, "o", color="w")
     axes.plot(
         x,
         fit(x),
         "b-",
         label=(r"$\mathrm{erfc}[ %.2f \cdot \left(Y_\mathrm{S} - %.2f \right)]$") % (self.__a, self.__Y0),
     )
     axes.set_ylabel(r"$I/I_\mathrm{max}\ [\%]$")
     axes.set_xlim(self.__xlim)
     axes.set_ylim(self.__ylim)
     axes.xaxis.set_major_locator(MultipleLocator(0.5))
     axes.xaxis.set_minor_locator(MultipleLocator(0.1))
     axes.yaxis.set_major_locator(MultipleLocator(10))
     axes.grid(which="minor", axis="x")
     axes.grid(which="major", axis="x")
     axes.grid(which="major", axis="y")
     axes.legend(loc="best")
     plt.show(fig)
Esempio n. 2
0
 def fit(self, func=None, p0={}, verbose=False, plot=False):
     self.__moments = None
     if func == None:
         func = self.__fitargs["func"]
     x, y = self.__fitargs["data"]
     if p0 == {}:
         p0 = self.__estimate_p0(x, y)
     self.__fit = lmfit(func, x, y, p0, plot=plot, verbose=verbose)