def expand_array(array, expand, sample=0):
   if expand == 1:
       return array
   if sample == 1:
       return np.repeat(array, expand)

   kernel = np.ones(expand)/expand
   # The following mimic the behavior of IDL's rebin when expanding
   temp = np.convolve(np.repeat(array, expand), kernel, mode=2)
   # Discard the first "expand-1" entries
   temp = temp[expand-1:]
   # Replace the last "expand" entries with the last entry of original
   for i in range(1,expand):
       temp[-i]=array[-1]
   return temp
Expands an 1-D array by the integer factor "expand".
dataset/ETHPy150Open xraypy/xraylarch/plugins/xrf/xrf_bgr.py/expand_array