code: def trim_data(xmin, xmax, xdata, *args):
      
  
      # make sure it's a numpy array
      if not isinstance(xdata, _n.ndarray): xdata = _n.array(xdata)
  
      # make sure xmin and xmax are numbers
      if xmin is None: xmin = min(xdata)
      if xmax is None: xmax = max(xdata)
  
      # get all the indices satisfying the trim condition
      ns = _n.argwhere((xdata >= xmin) & (xdata <= xmax)).transpose()[0]
  
      # trim the xdata
      output = []
      output.append(xdata[ns])
  
      # trim the rest
      for a in args:
          # make sure it's a numpy array
          if not isinstance(a, _n.ndarray): a = _n.array(a)
          output.append(a[ns])
  
      return output
docs: Removes all the data except that in which xdata is between xmin and xmax. 
      This does not mutilate the input arrays, and additional arrays
      can be supplied via args (provided they match xdata in shape)
  
      xmin and xmax can be None