Skip to content
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.

CoordInterpGrid incorrectly gives DimensionMismatch error #29

Closed
tomasaschan opened this issue Jun 26, 2014 · 3 comments
Closed

CoordInterpGrid incorrectly gives DimensionMismatch error #29

tomasaschan opened this issue Jun 26, 2014 · 3 comments

Comments

@tomasaschan
Copy link
Collaborator

Try the following:

xg = -10:.5:10
yg = -3:.15:3.5
zg = Float64[sin(x)*cos(y) for x in xg, y in yg]
CoordInterpGrid((xg,yg),zg, 0, InterpLinear)
ERROR: DimensionMismatch("Coordinate lengths do not match grid size.")
 in CoordInterpGrid at /home/tlycken/.julia/v0.3/Grid/src/coord.jl:7
 in CoordInterpGrid at /home/tlycken/.julia/v0.3/Grid/src/coord.jl:13
 in CoordInterpGrid at /home/tlycken/.julia/v0.3/Grid/src/coord.jl:21

This happens because for certain combinations of boundary conditions and interpolation types, the matrix with interpolation coefficients is extended with a "frame" of extra values. Because of this, size(grid) from here doesn't return the size of the original data array, and thus the assertion here fails, although the data provided by the user is actually valid.

I think the easiest fix is to provide methods for size which take this into account, and I'll probably try to put together a PR to this effect. (There might be further problems with InterpCubic related to this matrix resize, too...) However, it'll be a while, since I currently have to focus on finishing up my thesis.

@timholy
Copy link
Owner

timholy commented Jun 27, 2014

Thanks for reporting this and figuring out the problem!

Off-topic, but it turns out our travis script was not actually running the tests. I just turned that on, and also fixed another problem that cropped up due to changes in Julia over the last couple of weeks. Hopefully we'll be good to go, but it's possible we may get PkgEvaluator failures for a little bit.

@simonp0420
Copy link

I am still getting this error with InterpCubic:

using Grid
x = 0:0.1:6
y = 10:0.1:15
z = sin(x * y')
zi = CoordInterpGrid((x,y),z, BCnil,InterpCubic)

Results in
ERROR: DimensionMismatch("Coordinate lengths do not match grid size.")
in CoordInterpGrid at c:\home\simonp.julia\v0.3\Grid\src\coord.jl:7

@tomasaschan
Copy link
Collaborator Author

@simonp0420 InterpCubic isn't correctly implemented for all boundary conditions (yet). I thought I had made sure that attempting to construct an InterpGrid with boundary conditions that don't work correctly threw an error, but it seems I didn't :(

Thanks for reporting the issue - I'll see if I can spend some time on correctly implementing the remaining boundary conditions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants