function [obsdata wavevector]=trimdata(spectra,cutoff,wavevector);
	# removes data according to cutoff. Cutoff dictates the first wavelength to be included
	# This module will fail unless the wavelengths are in increasing order (fixed in 5/7 version)
	if (or( (cutoff<2),(cutoff<min(wavevector)) ) )
		firstwavelength=2
	else
		ptsperlambda=(max(wavevector)-min(wavevector))/columns(wavevector)
		firstwavelength=floor((cutoff-wavevector(1))/ptsperlambda)
	endif

	#prepare data
	if (firstwavelength>0)
		obsdata=spectra(2:rows(spectra),2+firstwavelength:columns(spectra));
		wavevector= wavevector(firstwavelength+1:columns(wavevector));
	else
			firstwavelength=floor((wavevector(1)-cutoff)/ptsperlambda)
			obsdata=spectra(2:rows(spectra),1:firstwavelength);
			wavevector= wavevector(1:firstwavelength);
	endif
	size(wavevector), size(obsdata)

endfunction
