def to_file(self, function: Function): transform = PhasePlotter.transform() f = function.transform(transform) if function.dy is not None: f.set_dy(function.dy.transform(transform)) header = "q, (100 q)**2 Re R(q), (100 q)**2 Im R(q)" return super(ReflectionFileLoader, self).to_file(f, header=header)
def plot(self, name, f: Function, **kwargs): if f is None: return transform = self.transform() dy = f.dy if self.scale: f = f.transform(transform) if dy is not None: dy = dy.transform(transform) ylabel = "(100 q$)^2$ $R(q)$ [$10^{-4} \AA^{-2}$]" else: ylabel = "R(q) [1]" feval = f.eval() color = [None, None] if "color" in kwargs: if not isinstance(kwargs["color"], list) or len(kwargs["color"]) <= 1: color = [kwargs["color"], kwargs["color"]] kwargs.pop("color") else: color = kwargs.pop("color") if self.real: if name is not None: kwargs["label"] = "Re R(q) {}".format(name) self._do_plot(f.get_domain(), feval.real, color[0], dy, **kwargs) if self.imag: if name is not None: kwargs["label"] = "Im R(q) {}".format(name) self._do_plot(f.get_domain(), feval.imag, color[1], dy, imag=True, **kwargs) self.axs.set_xlabel("q [$\AA$]") self.axs.set_ylabel(ylabel) self.axs.legend() return self
def function_to_d(fctn: Function): return fctn.transform(lambda sin, theta: wavelength_k1 / (2*np.sin(np.deg2rad(theta))))