Verified Commit d0fc1fba authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Added interp_nans to tools.py

parent 90501ff6
......@@ -15,6 +15,7 @@
* [replace\_command](#.swmfpy.paramin.replace_command)
* [read\_command](#.swmfpy.paramin.read_command)
* [swmfpy.tools](#.swmfpy.tools)
* [interp\_nans](#.swmfpy.tools.interp_nans)
* [carrington\_rotation\_number](#.swmfpy.tools.carrington_rotation_number)
* [swmfpy.tecplottools](#.swmfpy.tecplottools)
* [apply\_equations](#.swmfpy.tecplottools.apply_equations)
......@@ -500,6 +501,27 @@ values for the parameters.
Tools to be used in swmfpy functions and classes. Some of the functions are
*hidden functions*.
<a name=".swmfpy.tools.interp_nans"></a>
#### interp\_nans
```python
interp_nans(x_vals, y_vals)
```
Returns a numpy array with NaNs interpolated.
**Arguments**:
x_vals (np.array):
x values to interpolate.
y_vals (np.array):
y values including NaNs.
**Returns**:
- `(np.array)` - numpy array with NaNs interpolated.
<a name=".swmfpy.tools.carrington_rotation_number"></a>
#### carrington\_rotation\_number
......
......@@ -6,6 +6,24 @@ __author__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu'
import datetime as dt
import numpy as np
def interp_nans(x_vals, y_vals):
"""Returns a numpy array with NaNs interpolated.
Args:
x_vals (np.array):
x values to interpolate.
y_vals (np.array):
y values including NaNs.
Returns:
(np.array): numpy array with NaNs interpolated.
"""
nonans = np.nonzero(np.isnan(y_vals) == 0)
return np.interp(x_vals, x_vals[nonans], y_vals[nonans])
def carrington_rotation_number(the_time='now'):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment