# spacepy.datamodel.resample

`spacepy.datamodel.``resample`(data, time=[], winsize=0, overlap=0, st_time=None, outtimename='Epoch')

  resample a SpaceData to a new time interval

  Parameters: | data : SpaceData or dmarray SpaceData with data to resample or dmarray with data to resample, variables can only be 1d or 2d, if time is specified only variables the same length as time are resampled, otherwise only variables with length equal to the longest length are resampled time : array-like dmarray of times the correspond to the data winsize : datetime.timedelta Time frame to average the data over overlap : datetime.timedelta Overlap in the moving average st_time : datetime.datetime Starting time for the resample, if not specified the time of the first data point is used (see spacepy.toolbox.windowMean)
  Returns: | ans : SpaceData Resampled data, included keys are in the input keys (with the data caveats above) and Epoch which contains the output time

  Examples

      >>> import datetime
      >>> import spacepy.datamodel as dm
      >>> a = dm.SpaceData()
      >>> a.attrs['foo'] = 'bar'
      >>> a['a'] = dm.dmarray(range(10*2)).reshape(10,2)
      >>> a['b'] = dm.dmarray(range(10)) + 4
      >>> a['c'] = dm.dmarray(range(3)) + 10
      >>> times = [datetime.datetime(2010, 1, 1) + datetime.timedelta(hours=i) for i in range(10)]
      >>> out = dm.resample(a, times, winsize=datetime.timedelta(hours=2), overlap=datetime.timedelta(hours=0))
      >>> out.tree(verbose=1, attrs=1)
      # +
      # :|____foo (str [3])
      # |____Epoch (spacepy.datamodel.dmarray (4,))
      # |____a (spacepy.datamodel.dmarray (4, 2))
      # :|____DEPEND_0 (str [5])
      #
      # Things to note:
      #    - attributes are preserved
      #    - the output variables have their DEPEND_0 changed to Epoch (or outtimename)
      #    - each dimension of a 2d array is resampled individually