code: def ut12frame(treq, ind, ut1_unix):
      
      if treq is None:  # have to do this since interp1 will return last index otherwise
          return
  
      treq = atleast_1d(treq)
  # %% handle human specified string scalar case
      if treq.size == 1:
          treq = datetime2unix(treq[0])
  # %% handle time range case
      elif treq.size == 2:
          tstartreq = datetime2unix(treq[0])
          tendreq = datetime2unix(treq[1])
          treq = ut1_unix[(ut1_unix > tstartreq) & (ut1_unix < tendreq)]
      else:  # otherwise, it's a vector of requested values
          treq = datetime2unix(treq)
  # %% get indices
      """
      We use nearest neighbor interpolation to pick a frame index for each requested time.
      """
      f = interp1d(ut1_unix, ind, kind='nearest', bounds_error=True,
                   assume_sorted=True)  # it won't output nan for int case in Numpy 1.10 and other versions too
      framereq = f(treq).astype(int64)
      framereq = framereq[framereq >= 0]  # discard outside time limits
      return framereq
docs: Given treq, output index(ces) to extract via rawDMCreader
      treq: scalar or vector of ut1_unix time (seconds since Jan 1, 1970)
      ind: zero-based frame index corresponding to ut1_unix, corresponding to input data file.