Detect high values โ€‹โ€‹from numpy array

Im is working on a detection alogrim for the detection of storm cells in radar images. I have radar data in 2d numpy arrays that we build on a base map. We have data on azimuth and rangefinders, which we put in a half-grid with lat / lon coordinates.

The values โ€‹โ€‹in our numpy array are based on dBZ heights ranging from zero to a maximum of 80.

Here's a listing of our numpy array with data:

[[-31.5 -31.5 16.5 ..., -31.5 -31.5 -31.5] [-31.5 -31.5 -31.5 ..., -31.5 -31.5 -31.5] [-31.5 -31.5 -31.5 ..., -31.5 -31.5 -31.5] ..., [-31.5 -31.5 -31.5 ..., -31.5 -31.5 -31.5] [-31.5 -31.5 -31.5 ..., -31.5 -31.5 -31.5] [-31.5 11.5 -31.5 ..., -31.5 -31.5 -31.5]] 

So far, a value of -31.5 means null or hidden values. We need only positive values. Even decimal places make no sense.

So what we want to do:

Detect clusters with high values โ€‹โ€‹and make them a red square around this cell. I tried something with an image mask, but I was stuck there. Even I do not know if an image mask is a good solution to this problem.

Here is my data processing code.

 gain = 0.5 offset = -31.5 az = np.arange(0.,360.,360./scan["scan_number_azim"]) r = np.arange(scan["scan_start_azim"], (scan["scan_start_azim"] + scan["scan_number_range"] * rscale), rscale) data = gain * raw["scan2/scan_Z_data"] + offset 

Thus, the count of detections will fluctuate very often. Maybe I also need something like DBscan?

Can someone help me with this?

+6
source share
1 answer

If you can use scipy, I think something like this will work:

 import scipy.ndimage mask = data > 20 labels, num_labels = scipy.ndimage.label(mask) custers = scipy.ndimage.find_objects(labels) 

And clusters will now be a list of slicing tuples, and you can get the start and end rows and columns of your rectangles as:

 for row_slice, col_slice in clusters: start_row = row_slice.start end_row = row_slice.stop start_col = col_slice.start end_col = col_slice.stop # draw your rectangle 
+2
source

All Articles