synphot.binning.pixel_range(bins, waverange, mode='round')[source]

Calculate the number of pixels within the given wavelength range and the given bins.


Wavelengths at bin centers, each centered on a pixel. Must be 1D array.

waverangetuple of float

Lower and upper limits of the desired wavelength range, in the same unit as bins.

mode{‘round’, ‘min’, ‘max’, ‘none’}

Determines how the pixels at the edges of the wavelength range are handled. All the options, except ‘none’, will return an integer number of pixels:

  • ‘round’ - Wavelength range edges that fall in the middle of a pixel are counted if more than half of the pixel is within the given wavelength range. Edges that fall in the center of a pixel are rounded to the nearest pixel edge. This is the default.

  • ‘min’ - Only pixels wholly within the given wavelength range are counted.

  • ‘max’ - Pixels that are within the given wavelength range by any margin are counted.

  • ‘none’ - The exact number of encompassed pixels, including fractional pixels, is returned.


Number of pixels.


Given wavelength range exceeds the bounds of given bins.


Invalid mode.