Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation with NaN's, no overshoot and robustness #19

Closed
uniomni opened this issue Apr 8, 2011 · 8 comments
Closed

Interpolation with NaN's, no overshoot and robustness #19

uniomni opened this issue Apr 8, 2011 · 8 comments
Assignees

Comments

@uniomni
Copy link
Member

uniomni commented Apr 8, 2011

Implement and test 2D interpolation where some numbers are NaN (IEEE Not-a-Number).
Apply this in the context of ASCII grids where NODATA of -9999 gets replaced by NaN.

@ghost ghost assigned uniomni Apr 12, 2011
@uniomni
Copy link
Member Author

uniomni commented Apr 28, 2011

This should also be written to guarantee that interpolated values remain within the extrema of the source data.
A test for that, which is currently failing (slightly) is available but currently disabled in test_engine.py.

When this issue is being addressed it'll be a good idea to change the tolerances in test_interpolation_tsunami as indicated in the FIXME.

uniomni added a commit that referenced this issue Apr 28, 2011
@uniomni
Copy link
Member Author

uniomni commented Jun 27, 2011

Also observed this traceback (for the Kampung Bali data set). It was not reproducible, but hints at the need for more robust interpolation.

Traceback:
File "/home/nielso/dev/riab_env/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/nielso/dev/riab_env/lib/python2.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
  2.     resp = view_func(_args, *_kwargs)
    
    File "/home/nielso/dev/riab_env/lib/python2.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
  3.     return view_func(_args, *_kwargs)
    
    File "/home/nielso/dev/riab/impact/views.py" in calculate
  4.                                    impact_function=impact_function)
    
    File "/home/nielso/dev/riab/impact/engine/core.py" in calculate_impact
  5. F = impact_function.run(layers)
    
    File "/home/nielso/dev/riab/impact/plugins/earthquake/hot_building_impact_model.py" in run
  6.     H = H.interpolate(E)
    
    File "/home/nielso/dev/riab/impact/storage/raster.py" in interpolate
  7.         return interpolate_raster_vector(self, X, name)
    
    File "/home/nielso/dev/riab/impact/engine/interpolation.py" in interpolate_raster_vector
  8. f = raster_spline(longitudes, latitudes, A)
    
    File "/home/nielso/dev/riab/impact/engine/interpolation.py" in raster_spline
  9. F = RectBivariateSpline(latitudes, longitudes, A)
    
    File "/usr/lib/python2.6/dist-packages/scipy/interpolate/fitpack2.py" in init
  10.                                                 kx,ky,s)
    

Exception Type: error at /api/v1/calculate/
Exception Value: (my>ky) failed for hidden my: regrid_smth:my=2

@uniomni
Copy link
Member Author

uniomni commented Jun 28, 2011

Write unit test using HOT data to reproduce this problem.
However, this can't really be done until we can enter new data seamlessly: #104

@uniomni
Copy link
Member Author

uniomni commented Aug 10, 2011

Saw the same error today with the full HOT OSM dataset.

uniomni added a commit that referenced this issue Aug 14, 2011
@uniomni
Copy link
Member Author

uniomni commented Aug 14, 2011

Wrapped underlying interpolation function in try-except to provide a better error message:
f467032

@uniomni
Copy link
Member Author

uniomni commented Oct 19, 2011

Updated code everywhere to use NaN internally for missing values:
73f097b

All 84 tests pass.

uniomni added a commit that referenced this issue Oct 19, 2011
uniomni added a commit that referenced this issue Oct 19, 2011
@uniomni
Copy link
Member Author

uniomni commented Oct 23, 2011

I think we can remove the dependency on scipy for now, but not game to just do it without having a fresh installation to test it on.

uniomni added a commit that referenced this issue Oct 23, 2011
@uniomni
Copy link
Member Author

uniomni commented Oct 23, 2011

Could close this now, except for a few minor outstanding issues:
1: Retirement of scipy
2: Start actively using NaNs for missing values everywhere
3: Should consider using the piecewise constant mode - maybe control this from a Risiko configuration set?

These have been moved to three new tickets: #165, #166, #167

@uniomni uniomni closed this as completed Oct 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant