mmspy.compute.particle.interpolate.interpolate_distribution#

mmspy.compute.particle.interpolate.interpolate_distribution(ds, grid, variable='f', mode='mean', method='histogram', roll=None)#

Interpolate a particle distribution function onto a regular grid.

Parameters:
  • ds (Dataset) – Dataset containing the variable and the coordinates used to interpolate.

  • grid (dict of ParticleGrid) – Dictionary containing the coordinates (keys) and the regular grid (values) used for interpolation.

  • variable (str) – Variable used for interpolation.

  • mode ({'mean', 'spread', 'error'}) – Only applicable for method='histogram'. Use ‘mean’ to calculate the mean of the variable in each bin, ‘spread’ to calculate its standard deviation, and ‘error’ to propagate error.

  • method ({'histogram', 'nearest', 'linear', 'cubic'}) – Method of interpolation. ‘histogram’ is performed with scipy.stats.binned_statistics_dd. Other methods are performed with scipy.interpolate.griddata.

  • roll (int, optional) – Whether to roll the data in time before interpolation. Set to specify the rolling window.

Returns:

da (DataArray) – Interpolated data array defined on grid.