def plot_error(self, spectrum, covariance_matrix=None, emin=None, emax=None, npts=100, autoscale=None, **kwargs): if covariance_matrix is None: covariance_matrix = spectrum['covariance_matrix'] if emin is None and emax is None: emin, emax=self.axes.get_xlim() emin = emin*self.axes.energy_units_obj emax = emax*self.axes.energy_units_obj energies_units = logspace_units(emin, emax, npts) dnde = self.get_dnde(spectrum, energies_units) dnde_error = self.get_dnde_error(spectrum, covariance_matrix,energies_units) energies, e2_dnde = self.axes.convert_points(energies_units, dnde) energies, e2_dnde_error = self.axes.convert_points(energies_units, dnde_error) # clip very small values, problems with log scale otherwise low=e2_dnde-e2_dnde_error low[low<1e-100]=1e-100 high=e2_dnde+e2_dnde_error if autoscale is not None: old_autoscale=self.axes.get_autoscale_on() self.axes.autoscale(autoscale) self.axes.fill_between(energies, low, high, **kwargs) if autoscale is not None: self.axes.autoscale(old_autoscale)
def plot(self, spectrum, emin=None, emax=None, npts=100, autoscale=None, **kwargs): if emin is None and emax is None: emin, emax = self.axes.get_xlim() emin = emin * self.axes.energy_units_obj emax = emax * self.axes.energy_units_obj energies = logspace_units(emin, emax, npts) dnde = self.get_dnde(spectrum, energies) energies, e2_dnde = self.axes.convert_points(energies, dnde) if autoscale is not None: old_autoscale = self.axes.get_autoscale_on() self.axes.autoscale(autoscale) self.axes.plot(energies, e2_dnde, **kwargs) if autoscale is not None: self.axes.autoscale(old_autoscale)
def plot(self, spectrum, emin=None, emax=None, npts=100, autoscale=None, **kwargs): if emin is None and emax is None: emin, emax=self.axes.get_xlim() emin = emin*self.axes.energy_units_obj emax = emax*self.axes.energy_units_obj energies = logspace_units(emin, emax, npts) dnde = self.get_dnde(spectrum, energies) energies, e2_dnde = self.axes.convert_points(energies, dnde) if autoscale is not None: old_autoscale=self.axes.get_autoscale_on() self.axes.autoscale(autoscale) self.axes.plot(energies, e2_dnde, **kwargs) if autoscale is not None: self.axes.autoscale(old_autoscale)
def plot_error(self, spectrum, covariance_matrix=None, emin=None, emax=None, npts=100, autoscale=None, **kwargs): if covariance_matrix is None: covariance_matrix = spectrum['covariance_matrix'] if emin is None and emax is None: emin, emax = self.axes.get_xlim() emin = emin * self.axes.energy_units_obj emax = emax * self.axes.energy_units_obj energies_units = logspace_units(emin, emax, npts) dnde = self.get_dnde(spectrum, energies_units) dnde_error = self.get_dnde_error(spectrum, covariance_matrix, energies_units) energies, e2_dnde = self.axes.convert_points(energies_units, dnde) energies, e2_dnde_error = self.axes.convert_points( energies_units, dnde_error) # clip very small values, problems with log scale otherwise low = e2_dnde - e2_dnde_error low[low < 1e-100] = 1e-100 high = e2_dnde + e2_dnde_error if autoscale is not None: old_autoscale = self.axes.get_autoscale_on() self.axes.autoscale(autoscale) self.axes.fill_between(energies, low, high, **kwargs) if autoscale is not None: self.axes.autoscale(old_autoscale)