ARGODEV-138: find_25boxes
Jira Issue
https://jira.ceh.ac.uk/browse/ARGODEV-138
Python Implementation
Uses latitude and longitude to find grid point references:
| -5 5 15 ... 355 365
----|----------------------------
85 | 631 1 19 ... 631 1
75 | 632 2 20 ... 632 2
65 | 633 3 21 ... 633 3
...|... ... ... ... ... ...
-85| 648 18 36 ... 648 18
returning the 25 WMO boxes with the float profile in the very centre. I tried using multiple interpolation tools, including interp2d, RectBivariateSpline, and map_coordinates. None quite mirrored the Matlab implimentation, so I made my own function called nearest_neighbour
to do the job for me.
Testing
6 tests were written:
- Is the matlab matrix (wmo_boxes.mat) loadable?
- Does
nearest_neighbour
return the expected grid point? - Does
nearest_neighbour
return a value that exists in the grid? - Does
find_25boxes
return a matrix of the expected shape? - Does
find_25boxes
return a matrix ofNaN
if the longitude and latitude inputs areNaN
? - Does
find_25boxes
return a matrix where each row of the matrix exists in wmo_boxes.mat?
Old Matlab Implementation
Very similar to my python set up, but used inbuilt interpolation functions, as well as using full matrices, instead of axes for the interpolation. Input arguments are a longitude [int], latitude [int], and the wmo_boxes [matlab matrix]. The function handles wrapping of longitudinal inputs.