[docs]classSimpleBinner(Binner):"""Bins to a wavenumber grid given by ``wngrid``. The method places flux into the correct bins using histogramming methods. This is fast but can suffer as it assumes that there are no gaps in the wavenumber grid. This can cause weird results and may cause the flux to be higher in the boundary of points between two distinct regions (such as WFC3 + Spitzer) Parameters ---------- wngrid: :obj:`array` Wavenumber grid. Quantity values are converted to inverse centimetres; wavelength quantities are also accepted. wngrid_width: :obj:`array`, optional Must have same shape as ``wngrid`` Full bin widths for each wavenumber grid point given in ``wngrid``. Quantity values are converted to inverse centimetres. If not provided then this is automatically computed from ``wngrid``. """def__init__(self,wngrid:npt.NDArray[np.float64],wngrid_width:t.Optional[npt.NDArray[np.float64]]=None,):"""Initialize SimpleBinner. Parameters ---------- wngrid: :obj:`array` Wavenumber grid wngrid_width: :obj:`array`, optional Must have same shape as ``wngrid`` Full bin widths for each wavenumber grid point given in ``wngrid``. If not provided then this is automatically computed from ``wngrid``. """self._wngrid=np.asarray(convert_to_unit_value(wngrid,u.k,equivalencies=u.spectral()))self._wn_width=(Noneifwngrid_widthisNoneelsenp.asarray(convert_to_unit_value(wngrid_width,u.k)))ifself._wn_widthisNone:self._wn_width=compute_bin_edges(self._wngrid)[-1]
[docs]defbindown(self,wngrid:npt.NDArray[np.float64],spectrum:npt.NDArray[np.float64],grid_width:t.Optional[npt.NDArray[np.float64]]=None,error:t.Optional[npt.NDArray[np.float64]]=None,)->BinDownType:"""Bins down spectrum. Parameters ---------- wngrid : :obj:`array` The wavenumber grid of the spectrum to be binned down. spectrum: :obj:`array` The spectra we wish to bin-down. Must be same shape as ``wngrid``. grid_width: :obj:`array`, optional Wavenumber grid full-widths for the spectrum to be binned down. Must be same shape as ``wngrid``. Optional. error: :obj:`array`, optional Associated errors or noise of the spectrum. Must be same shape as ``wngrid``.Optional parameter. Returns ------- binned_wngrid : :obj:`array` New wavenumber grid spectrum: :obj:`array` Binned spectrum. grid_width: :obj:`array` New grid-widths error: :obj:`array` or None Binned error if given else ``None`` """return(self._wngrid,bindown(wngrid,spectrum,self._wngrid),None,self._wn_width,)