Exemplo n.º 1
0
    def binned_pixelrange(self, waverange, **kwargs):
        """Calculate the number of pixels within the given wavelength
        range and `binset`.

        Parameters
        ----------
        waverange : tuple of float or `~astropy.units.quantity.Quantity`
            Lower and upper limits of the desired wavelength range.
            If not a Quantity, assumed to be in Angstrom.

        kwargs : dict
            Keywords accepted by :func:`synphot.binning.pixel_range`.

        Returns
        -------
        npix : number
            Number of pixels.

        Raises
        ------
        synphot.exceptions.UndefinedBinset
            Undefined `binset`.

        """
        if self.binset is None:
            raise synexceptions.UndefinedBinset(
                'No binset specified for this passband.')

        x = units.validate_quantity(
            waverange, self._internal_wave_unit, equivalencies=u.spectral())

        return binning.pixel_range(self.binset.value, x.value, **kwargs)
Exemplo n.º 2
0
    def binned_waverange(self, cenwave, npix, **kwargs):
        """Calculate the wavelength range covered by the given number
        of pixels centered on the given central wavelengths of `binset`.

        Parameters
        ----------
        cenwave : float or `~astropy.units.quantity.Quantity`
            Desired central wavelength.
            If not a Quantity, assumed to be in Angstrom.

        npix : int
            Desired number of pixels, centered on ``cenwave``.

        kwargs : dict
            Keywords accepted by :func:`synphot.binning.wave_range`.

        Returns
        -------
        waverange : `~astropy.units.quantity.Quantity`
            Lower and upper limits of the wavelength range,
            in the unit of ``cenwave``.

        Raises
        ------
        synphot.exceptions.UndefinedBinset
            Undefined `binset`.

        """
        if self.binset is None:
            raise synexceptions.UndefinedBinset(
                'No binset specified for this passband.')

        # Calculation is done in the unit of cenwave.
        if not isinstance(cenwave, u.Quantity):
            cenwave = cenwave * self._internal_wave_unit

        bin_wave = units.validate_quantity(self.binset,
                                           cenwave.unit,
                                           equivalencies=u.spectral())

        return binning.wave_range(bin_wave.value, cenwave.value, npix, **
                                  kwargs) * cenwave.unit