def  prune_and_normalize(cls, data, wavelengths, shotnoisefilt):
    """prune_and_normalize(cls, data, wavelengths, shotnoisefilt)

    Subset LIBS data to only use wavelengths below 850 nm,
    set negative values to zero,
    then normalize responses for each of the three spectrometers.

    If shotnoisefilt >= 3, run a median filter on the data with width as specified.

    Return the pruned and normalized data.
    """

    print 'Pruning and normalizing the data.'

    # Only use data between 270 and 820 nm (ends are noisy)
    use = np.where(np.logical_and(wavelengths >= 270,
                                  wavelengths < 820))[0]
    # Instead of stripping these bands out now, first do shot noise
    # filtering (if desired).  Then strip the bands later.

    # If desired, apply a median filter to strip out impulsive noise
    # Note: this is slow. :)  Probably can be optimized in some awesome fashion.
    if shotnoisefilt >= 3:
      printt('Filtering out shot noise with width %d.' % shotnoisefilt)
      # Create a vector of 0's (to ignore) and 1's (to use).
      fw = np.zeros((data.shape[0],1))
      fw[use] = 1
      data = LIBSData.medfilter(data, shotnoisefilt, fw)

    # Now remove bands we do not use
    wavelengths = wavelengths[use]
    data        = data[use,:]