/*******************************************************************

DPUSER function CROPDATA:
extract the central fraction of a set of data points

function input:
- data:		1xN data vector
- fraction:	fraction of data points to use (0<x<1)

function output:
cropped data set

example:

DPUSER> hhh = [1:10]
DPUSER> print hhh,/values
  1    2    3    4    5    6    7    8    9   10
DPUSER> print cropdata(hhh, 0.6),/values
  3    4    5    6    7    8

********************************************************************/


function cropdata, data, fraction {

  mydata = data[sort(data)]
  nn = nelements(data)
  lowcut = (1-fraction)/2
  upcut = lowcut + fraction

  nmin = round(nn*lowcut)+1
  nmax = round(nn*upcut)
  set = mydata[nmin:nmax]

  cropdata = set
}
