ddemidov / mba

Scattered data interpolation with multilevel B-Splines
MIT License
73 stars 23 forks source link

Quadrants visible in interpolation result #5

Closed jmswaney closed 6 years ago

jmswaney commented 6 years ago

Going through the python example, I noticed that the interpolated surface has 4 clearly distinguished quadrants. I thought the cubic splines would smoothly transition between the control point grid, so I'm confused why these quadrants are so apparent. Am I missing something?

ddemidov commented 6 years ago

Can you be more specific (what cell in the python example)? I don't see any quadrant boundaries there. Could those be pixels on the surface plots?

jmswaney commented 6 years ago

In the cell where plot_surface is called the pcolor plot looks like it’s split at x = 0.5 and y = 0.5. The quadrants are much bigger than one of the pixels

ddemidov commented 6 years ago

Are you looking at the notebook hosted on jupyter.org, or do you run the example yourself? Here is what I see in the hosted notebook:

download

The surfaces look rather smooth to me.

ddemidov commented 6 years ago

Hmm, I just tried to rerun the example, and here is what I see now:

download 1

Is this what you see as well? This is clearly a bug, I'll try to look into it.

jmswaney commented 6 years ago

Yeah that's what I'm getting. When I look at the notebook on github it looks great, but I get those quadrants when I run it locally.

ddemidov commented 6 years ago

git bisect points to 9b3dfc87be2459a as the first bad commit, but I can not yet see what is wrong with that. The commit mostly updates pybind11 and resolves a resulting issue. EDIT: wrong commit.

ddemidov commented 6 years ago

It looks like this was a data layout issue with numpy. transpose() changes strides of the array, but does not touch the actual data layout. It looks like at some point pybind11 stopped making copies of the arrays, which made this bug visible. copy() after transpose() fixes the issue for me.

Thank you for reporting!

ddemidov commented 6 years ago

To clarify, the fix is contained within cell [3] of the notebook.

ddemidov commented 6 years ago

And of course I forgot to update the notebook in the source tree (sorry, coding while on vacation). 8203404 takes care of that.

jmswaney commented 6 years ago

Great, it's working for me now. Thanks!