class_docstr: A class to open and interact with fits files from SDSS
  
  Parameters
  ----------
  buf : string or file buffer (optional)
      file path, buffer, or url of SDSS spectra fits file
      if None, then initialize an empty instance.
  
  Notes
  -----
  This class only provides access to a subset of the information available
  in the sdss spectra fits file.  The raw fits data can be accessed using
  the fits object directly.  This can be found in the attribute
  ``hdulist``.  For details, please refer to the data description:
  http://www.sdss.org/dr7/dm/flatFiles/spSpec.html
docstr: Rebin the spectrum to a new grid.
  
  Parameters
  ----------
  rebin_coeff0: float
       log minimum wavelength
  rebin_coeff1: float
       log wavelength bin width
  rebin_length: int
       number of bins
  
  Returns
  -------
  S_new: SDSSfits object
      The new spectrum, rebinned to the desired wavelength binning
docstr_tok: ["Rebin","the","spectrum","to","a","new","grid",".","Parameters","--","--","--","--","--","rebin_coeff0",":","float","log","minimum","wavelength","rebin_coeff1",":","float","log","wavelength","bin","width","rebin_length",":","int","number","of","bins","Returns","--","--","--","-","S_new",":","SDSSfits","object","The","new","spectrum",",","rebinned","to","the","desired","wavelength","binning"]
code: def rebin(self, rebin_coeff0, rebin_coeff1, rebin_length):
      """Rebin the spectrum to a new grid.
  
      Parameters
      ----------
      rebin_coeff0: float
           log minimum wavelength
      rebin_coeff1: float
           log wavelength bin width
      rebin_length: int
           number of bins
  
      Returns
      -------
      S_new: SDSSfits object
          The new spectrum, rebinned to the desired wavelength binning
      """
      snew = self.copy()
      snew.spectrum = np.zeros(rebin_length)
      snew.error = np.zeros(rebin_length)
      snew.coeff0 = rebin_coeff0
      snew.coeff1 = rebin_coeff1
  
      N_old = len(self.spectrum)
      N_new = len(snew.spectrum)
  
      log_w_old = (
          self.coeff0 + (np.arange(N_old + 1) - 0.5) * self.coeff1
      )
      log_w_new = (
          snew.coeff0 + (np.arange(N_new + 1) - 0.5) * snew.coeff1
      )
  
      # Perform the interpolation.  We'll interpolate the cumulative sum
      #  so that the total flux of the spectrum is conserved.
  
      # interpolate spectrum
      spec_cuml_old = self.spectrum.cumsum()
      tck = interpolate.splrep(
          log_w_old, np.hstack(([0], spec_cuml_old))
      )
      spec_cuml_new = interpolate.splev(log_w_new, tck)
      spec_cuml_new[log_w_new >= log_w_old[-1]] = log_w_old[-1]
      spec_cuml_new[log_w_new <= log_w_old[0]] = 0
      snew.spectrum = np.diff(spec_cuml_new)
      snew.spectrum *= self.coeff1 / snew.coeff1
  
      # interpolate error
      err_cuml_old = self.error.cumsum()
      tck = interpolate.splrep(
          log_w_old, np.hstack(([0], err_cuml_old))
      )
      err_cuml_new = interpolate.splev(log_w_new, tck)
      err_cuml_new[log_w_new >= log_w_old[-1]] = log_w_old[-1]
      err_cuml_new[log_w_new <= log_w_old[0]] = 0
      snew.error = np.diff(err_cuml_new)
      snew.error *= self.coeff1 / snew.coeff1
  
      return snew
  
imports: import gc
  import numpy
  from scipy.ndimage import gaussian_filter1d, uniform_filter1d
  from scipy import interpolate
  from .None import download_with_progress_bar
label_desc: Use image node_id 17 for calling the SDSSfits obj's underlying member method code with example usage: obj.rebin(rebin_coeff0, rebin_coeff1, rebin_length) and returns: snew