def set_Wp(self, Wp, Epmin=None, Epmax=None, amplitude_name=None):
        """ Normalize particle distribution so that the total energy in protons
        between Epmin and Epmax is Wp

        Parameters
        ----------
        Wp : :class:`~astropy.units.Quantity` float
            Desired energy in protons.

        Epmin : :class:`~astropy.units.Quantity` float, optional
            Minimum proton energy for energy content calculation.

        Epmax : :class:`~astropy.units.Quantity` float, optional
            Maximum proton energy for energy content calculation.

        amplitude_name : str, optional
            Name of the amplitude parameter of the particle distribution. It
            must be accesible as an attribute of the distribution function.
            Defaults to ``amplitude``.
        """

        Wp = validate_scalar("Wp", Wp, physical_type="energy")
        oldWp = self.compute_Wp(Epmin=Epmin, Epmax=Epmax)

        if amplitude_name is None:
            try:
                self.particle_distribution.amplitude *= (
                    Wp / oldWp
                ).decompose()
            except AttributeError:
                log.error(
                    "The particle distribution does not have an attribute"
                    " called amplitude to modify its normalization: you can"
                    " set the name with the amplitude_name parameter of set_Wp"
                )
        else:
            oldampl = getattr(self.particle_distribution, amplitude_name)
            setattr(
                self.particle_distribution,
                amplitude_name,
                oldampl * (Wp / oldWp).decompose(),
            )
def set_Wp ( self , Wp , Epmin = None , Epmax = None , amplitude_name = None ) : Wp = validate_scalar ( "Wp" , Wp , physical_type = "energy" ) oldWp = self . compute_Wp ( Epmin = Epmin , Epmax = Epmax ) if amplitude_name is None : try : self . particle_distribution . amplitude *= ( Wp / oldWp ) . decompose ( ) except AttributeError : log . error ( "The particle distribution does not have an attribute" " called amplitude to modify its normalization: you can" " set the name with the amplitude_name parameter of set_Wp" ) else : oldampl = getattr ( self . particle_distribution , amplitude_name ) setattr ( self . particle_distribution , amplitude_name , oldampl * ( Wp / oldWp ) . decompose ( ) , )
Normalize particle distribution so that the total energy in protons
        between Epmin and Epmax is Wp

        Parameters
        ----------
        Wp : :class:`~astropy.units.Quantity` float
            Desired energy in protons.

        Epmin : :class:`~astropy.units.Quantity` float, optional
            Minimum proton energy for energy content calculation.

        Epmax : :class:`~astropy.units.Quantity` float, optional
            Maximum proton energy for energy content calculation.

        amplitude_name : str, optional
            Name of the amplitude parameter of the particle distribution. It
            must be accesible as an attribute of the distribution function.
            Defaults to ``amplitude``.