boutproject / xBOUT

Collects BOUT++ data from parallelized simulations into xarray.
https://xbout.readthedocs.io/en/latest/
Apache License 2.0
21 stars 10 forks source link

Crashes when interpolating NaN #112

Open johnomotani opened 4 years ago

johnomotani commented 4 years ago

I've come across a problem where Python would crash when trying to interpolate. I think the problem is when the input contains NaN (for me these were coming from corner boundary cells). The help (scipy-1.4.1) for scipy.interpolate.interp1d says "Note that calling interp1d with NaNs present in input values results in undefined behaviour", which sounds like this is a bug that scipy does not intend to fix. That probably makes it an xarray issue really, but I don't have a minimal working example to report it at the moment.

A workaround for my issue is to set keep_xboundaries=False when calling open_boutdataset, so that the corners are not included but we can still have y-boundary cells that are useful for parallel interpolation.

TomNicholas commented 4 years ago

Have you seen that xarray has a DataArray.interpolate_na method?

http://xarray.pydata.org/en/stable/generated/xarray.DataArray.interpolate_na.html

On Wed, 25 Mar 2020 at 19:41, johnomotani notifications@github.com wrote:

I've come across a problem where Python would crash when trying to interpolate. I think the problem is when the input contains NaN (for me these were coming from corner boundary cells). The help (scipy-1.4.1) for scipy.interpolate.interp1d says "Note that calling interp1d with NaNs present in input values results in undefined behaviour", which sounds like this is a bug that scipy does not intend to fix. That probably makes it an xarray issue really, but I don't have a minimal working example to report it at the moment.

A workaround for my issue is to set keep_xboundaries=False when calling open_boutdataset, so that the corners are not included but we can still have y-boundary cells that are useful for parallel interpolation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/boutproject/xBOUT/issues/112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISNPIZLOAU26YDND7FX5QDRJJM65ANCNFSM4LTWRM3A .

-- Thomas Nicholas (he/him) | PhD Student | Computational plasma physics for nuclear fusion University of York | Based at Culham Centre for Fusion Energy http://www.ccfe.ac.uk/ (D3/2.15) GitHub https://github.com/TomNicholas | LinkedIn https://www.linkedin.com/in/tom-nicholas/