When attempting to interpolate values exactly at the end of the domain (x = x0 + lx) interpolation will be attempted using values at both the beginning and end of the domain (including x = x0). This gives large errors at the end of the domain. I'll see if I can fix this soon.
Rupert
Grid2DInterpolator updated
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Grid2DInterpolator updated
Last edited by rgladstone on 13 Nov 2013, 03:02, edited 2 times in total.
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Re: Grid2DInterpolator updated
I fixed the issue with interpolating data points at the end of the domain.
I also tidied up the noData implementation a little. Would you like to have the noData value and a tolerance available as optional keywords in the sif solver syntax? Let me know if so and I'll add that.
I've tested with my simple interpolation data and it seems to work fine. Let me know if there are any problems.
Cheers,
Rupert
I also tidied up the noData implementation a little. Would you like to have the noData value and a tolerance available as optional keywords in the sif solver syntax? Let me know if so and I'll add that.
I've tested with my simple interpolation data and it seems to work fine. Let me know if there are any problems.
Cheers,
Rupert
Re: Grid2DInterpolator updated
Hi Ruppet,
regards
Olivier
Yes, that would be nice.Would you like to have the noData value and a tolerance available as optional keywords in the sif solver syntax? Let me know if so and I'll add that.
regards
Olivier
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Re: Grid2DInterpolator updated
I have added the option of specifying "no data" and "no data tol". Modified wiki text here:
http://elmerice.elmerfem.org/wiki/doku. ... terpolator
Rupppert
http://elmerice.elmerfem.org/wiki/doku. ... terpolator
Rupppert
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Re: Grid2DInterpolator updated
Is this a bug? If someone can confirm I can fix this in the repository.
I found these two lines in the InterpolateDEM function:
ix = INT((x-xb0)/dbx)+1
iy = INT((y-yb0)/dbx)+1
Surely the second line should be divide by dby not dbx? This would be a problem for grids with non-square cells with variation in the y-direction.
Rupert
I found these two lines in the InterpolateDEM function:
ix = INT((x-xb0)/dbx)+1
iy = INT((y-yb0)/dbx)+1
Surely the second line should be divide by dby not dbx? This would be a problem for grids with non-square cells with variation in the y-direction.
Rupert
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Re: Grid2DInterpolator updated
The default in the 2d grid interpolator in the event of one to three neighbouring points having the noData value is to take the mean of valid points. I have written a few lines to instead carry out linear interpolation. Shall I set this as the default (which makes more sense to me) or as an option (for full backwards compatibility)?
Re: Grid2DInterpolator updated
Hi Rupert,
I'm replying to your two last posts.
- with only one node, it can only be estimated as the value at that node
- with two nodes, it should work, but one as to determine the direction of the interpolation (x or y)
- with three nodes, it would work only if the point at which you want the value is included in the triangle defined by the three nodes.
So, I would be interested to know more about the strategy you have developed to handle this interpolation.
An other solution should be to use extrapolation from the neighbouring cells.
Nevertheless, missing data should only concern a very limited number of points and at the margin of the domain. Else, you are in trouble...
Regards
Olivier
I'm replying to your two last posts.
Yes, this is indeed a bug. Thanks for seeing it!I found these two lines in the InterpolateDEM function:
ix = INT((x-xb0)/dbx)+1
iy = INT((y-yb0)/dbx)+1
Surely the second line should be divide by dby not dbx? This would be a problem for grids with non-square cells with variation in the y-direction.
I'm not sure a linear interpolation is possible in all cases:The default in the 2d grid interpolator in the event of one to three neighbouring points having the noData value is to take the mean of valid points. I have written a few lines to instead carry out linear interpolation. Shall I set this as the default (which makes more sense to me) or as an option (for full backwards compatibility)?
- with only one node, it can only be estimated as the value at that node
- with two nodes, it should work, but one as to determine the direction of the interpolation (x or y)
- with three nodes, it would work only if the point at which you want the value is included in the triangle defined by the three nodes.
So, I would be interested to know more about the strategy you have developed to handle this interpolation.
An other solution should be to use extrapolation from the neighbouring cells.
Nevertheless, missing data should only concern a very limited number of points and at the margin of the domain. Else, you are in trouble...
Regards
Olivier
-
- Posts: 64
- Joined: 15 Apr 2013, 16:23
- Antispam: Yes
Re: Grid2DInterpolator updated
Thanks Olivier. I'll check in the bug fix.
For interpolation in presence of noData, I calculate weights for normal bilinear interpolation, set the weights to zero for noData points, then scale the remaining weights so that they total one. You are right, this isn't obvious/trivial and can lead to problems (e.g. if you want to get the value of a node at the exact location of a noData point). If I check in this change then I will make sure to leave the old approach as the default, make this new approach an option triggered by a sif keyword, and document it in the wiki.
Regards,
Rupert
For interpolation in presence of noData, I calculate weights for normal bilinear interpolation, set the weights to zero for noData points, then scale the remaining weights so that they total one. You are right, this isn't obvious/trivial and can lead to problems (e.g. if you want to get the value of a node at the exact location of a noData point). If I check in this change then I will make sure to leave the old approach as the default, make this new approach an option triggered by a sif keyword, and document it in the wiki.
Regards,
Rupert