Пример #1
0
    def plot(self, filename=None,
             axes=None, 
             fignum=None, figsize=(4,4),
             data_kwargs=dict()):
        """ Plot the SED using matpotlib. """

        if axes is None:
            fig = P.figure(fignum,figsize)
            axes = fig.add_axes((0.22,0.15,0.75,0.8))
            self.set_xlim(axes,
                          float(self.lower_energy[0]/self.energy_units),
                          float(self.upper_energy[-1]/self.energy_units))
        self.axes = axes

        ce = lambda x: units.tonumpy(x, self.energy_units)
        cf = lambda y: units.tonumpy(
            y.multiply_elementwise(self.energy).multiply_elementwise(self.energy),
            self.flux_units/units.cm**2/units.s)

        SED._plot_points(
            x=ce(self.energy), 
            xlo=ce(self.lower_energy), 
            xhi=ce(self.upper_energy), 
            y=cf(self.dnde),
            y_err=cf(self.dnde_err),
            y_ul=cf(self.dnde_ul),
            significant=self.significant,
            energy_units=self.energy_units_str,
            flux_units=self.flux_units_str,
            axes=axes, **data_kwargs)

        if filename is not None: P.savefig(filename)
        return axes
Пример #2
0
    def plot(self,
             filename=None,
             axes=None,
             fignum=None,
             figsize=(4, 4),
             data_kwargs=dict()):
        """ Plot the SED using matpotlib. """

        if axes is None:
            fig = P.figure(fignum, figsize)
            axes = fig.add_axes((0.22, 0.15, 0.75, 0.8))
            self.set_xlim(axes,
                          float(self.lower_energy[0] / self.energy_units),
                          float(self.upper_energy[-1] / self.energy_units))
        self.axes = axes

        ce = lambda x: units.tonumpy(x, self.energy_units)
        cf = lambda y: units.tonumpy(
            y.multiply_elementwise(self.energy).multiply_elementwise(
                self.energy), self.flux_units / units.cm**2 / units.s)

        SED._plot_points(x=ce(self.energy),
                         xlo=ce(self.lower_energy),
                         xhi=ce(self.upper_energy),
                         y=cf(self.dnde),
                         y_err=cf(self.dnde_err),
                         y_ul=cf(self.dnde_ul),
                         significant=self.significant,
                         energy_units=self.energy_units_str,
                         flux_units=self.flux_units_str,
                         axes=axes,
                         **data_kwargs)

        if filename is not None: P.savefig(filename)
        return axes
Пример #3
0
 def get_dnde_error(spectrum, covariance_matrix, energies):
     """ assume energies has energy units and return flux in flux units. """
     energies = units.tonumpy(energies, units.MeV)
     dnde_error = SpectrumPlotter.get_dnde_error_mev(
         spectrum, covariance_matrix, energies)
     return units.tosympy(dnde_error,
                          units.ph / units.cm**2 / units.s / units.MeV)
Пример #4
0
    def convert_points(self, energies, dnde):
        # (b) create E^2 dN/dE in acutal units
        e2_dnde = dnde.multiply_elementwise(energies).multiply_elementwise(energies)
        # (c) convert to desired units
        e2_dnde = units.tonumpy(e2_dnde,self.flux_units_obj/units.cm**2/units.s)

        energies = self.convert_energies(energies)

        return energies, e2_dnde
Пример #5
0
    def convert_points(self, energies, dnde):
        # (b) create E^2 dN/dE in acutal units
        e2_dnde = dnde.multiply_elementwise(energies).multiply_elementwise(
            energies)
        # (c) convert to desired units
        e2_dnde = units.tonumpy(e2_dnde,
                                self.flux_units_obj / units.cm**2 / units.s)

        energies = self.convert_energies(energies)

        return energies, e2_dnde
Пример #6
0
 def get_dnde_error(spectrum,covariance_matrix,energies):
     """ assume energies has energy units and return flux in flux units. """
     energies=units.tonumpy(energies,units.MeV)
     dnde_error=SpectrumPlotter.get_dnde_error_mev(spectrum,covariance_matrix,energies)
     return units.tosympy(dnde_error,units.ph/units.cm**2/units.s/units.MeV)
Пример #7
0
 def get_dnde(spectrum,energies):
     """ assume energies has energy units and return flux in flux units. """
     energies=units.tonumpy(energies,units.MeV)
     dnde=SpectrumPlotter.get_dnde_mev(spectrum,energies)
     return units.tosympy(dnde,units.ph/units.cm**2/units.s/units.MeV)
Пример #8
0
 def convert_energies(self, energies):
     return units.tonumpy(energies,self.energy_units_obj)
Пример #9
0
 def get_dnde(spectrum, energies):
     """ assume energies has energy units and return flux in flux units. """
     energies = units.tonumpy(energies, units.MeV)
     dnde = SpectrumPlotter.get_dnde_mev(spectrum, energies)
     return units.tosympy(dnde,
                          units.ph / units.cm**2 / units.s / units.MeV)
Пример #10
0
 def convert_energies(self, energies):
     return units.tonumpy(energies, self.energy_units_obj)