spacepy.toolbox.interpol — SpacePy v0.1.5 Manual

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »

# spacepy.toolbox.interpol

`spacepy.toolbox.` `interpol`(newx, x, y, wrap=None, **kwargs)

  1-D linear interpolation with interpolation of hours/longitude

  Parameters: | newx : array_like x values where we want the interpolated values x : array_like x values of the original data (must be monotonically increasing or wrapping) y : array_like y values of the original data wrap : string, optional for continuous x data that wraps in y at ‘hours’ (24), ‘longitude’ (360), or arbitrary value (int, float) kwargs : dict additional keywords, currently accepts baddata that sets baddata for masked arrays
  Returns: | out : numpy.masked_array interpolated data values for new abscissa values

  Examples

  For a simple interpolation

      >>> import spacepy.toolbox as tb
      >>> import numpy
      >>> x = numpy.arange(10)
      >>> y = numpy.arange(10)
      >>> tb.interpol(numpy.arange(5)+0.5, x, y)
      array([ 0.5,  1.5,  2.5,  3.5,  4.5])

  To use the wrap functionality, without the wrap keyword you get the wrong answer

      >>> y = range(24)*2
      >>> x = range(len(y))
      >>> tb.interpol([1.5, 10.5, 23.5], x, y, wrap='hour').compressed() # compress removed the masked array
      array([  1.5,  10.5,  23.5])
      >>> tb.interpol([1.5, 10.5, 23.5], x, y)
      array([  1.5,  10.5,  11.5])

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »