Open travis-j-hahn opened 1 week ago
Hi @travis-j-hahn , thanks for raising this issue. Do you have a minimal example that can recreate this error? (e.g. a subset of the data you were using). I'll have a look into this
wrf_tb_tobac_test.zip Hi @w-k-jones, I've attached a zip with a small iris cube here containing the problematic values; it is only 2mb. Here are the feature detection parameters I used to see if you can recreate the issue:
threshold: [250,225,200,175,150]
target: 'minimum'
position_threshold: 'weighted_diff'
sigma_threshold: 0.5
n_min_threshold: 4
Then I used the snippet:
wrf_radar_features = tobac.feature_detection.feature_detection_multithreshold(test[0], dxy=1000, **params)
where test[0] is the loaded iris cube. Hope this helps!
Anecdotally, I have also seen this issue, and I agree with the proposed solution. Thanks much @travis-j-hahn
Thanks for sending the test data, I've successfully recreated the error. One thing to watch out for with the fix is that with periodic boundary conditions there are expected situations where the feature point lies outside the range of the coordinate axis (e.g. a feature a 359.5 longitude when the coord ranges 0-359), which we should ensure is handled correctly
@freemansw1 we will also have to update the new get_coordinates
functions in #354
@freemansw1 we will also have to update the new
get_coordinates
functions in #354
Yes those need fixing anyway. Good note.
Thanks for sending the test data, I've successfully recreated the error. One thing to watch out for with the fix is that with periodic boundary conditions there are expected situations where the feature point lies outside the range of the coordinate axis (e.g. a feature a 359.5 longitude when the coord ranges 0-359), which we should ensure is handled correctly
Yes, I believe our expected out would be 359.5 there, but I'm not sure how add_coordinates
handles this with PBCs, not the least of which including the changes in #354.
Add coordinates doesn't currently handle PBCs at all 😬 I have no idea how we've avoided these errors before now...
It looks like there is a chance during the feature detection step for the identification of cells on boundary edges which result in hdim1 or hdim2 values slightly outside of the maximum boundary. I.e. the feature detection can create a cell with ix value of 218.00000003 when the maximum index is 218, and this throws an error in tobac/general.py:107 with
coordinate_points = interpn(points, values, xi)
raisingValueError: One of the requested xi is out of bounds in dimension 0
Full Error:
This can be fixed by using np.clip to ensure there is no overflow: