Skip to content

Commit 3d8edc2

Browse files
authored
Merge pull request #8 from kmuehlbauer/fix-zonal-mask
FIX: zonal mask, fixes #125
2 parents 76ea072 + df0f5fe commit 3d8edc2

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

notebooks/zonalstats/wradlib_zonalstats_example.ipynb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@
165165
"buffer = 5000.\n",
166166
"bbox = dict(left=bbox[0] - buffer, right=bbox[1] + buffer,\n",
167167
" bottom=bbox[2] - buffer, top=bbox[3] + buffer)\n",
168-
"mask, shape = wrl.zonalstats.mask_from_bbox(xy[..., 0], xy[..., 1],\n",
169-
" bbox)\n",
168+
"mask = (((xy[..., 1] > bbox['bottom']) & (xy[..., 1] < bbox['top'])) &\n",
169+
" ((xy[..., 0] > bbox['left']) & (xy[..., 0] < bbox['right'])))\n",
170170
"xy_ = np.vstack((xy[..., 0][mask].ravel(), xy[..., 1][mask].ravel())).T\n",
171171
"data_ = data[mask]"
172172
]
@@ -487,10 +487,8 @@
487487
"bbox = dict(left=bbox[0] - buffer, right=bbox[1] + buffer,\n",
488488
" bottom=bbox[2] - buffer, top=bbox[3] + buffer)\n",
489489
"\n",
490-
"mask, shape = wrl.zonalstats.mask_from_bbox(radar_gkc[..., 0],\n",
491-
" radar_gkc[..., 1],\n",
492-
" bbox,\n",
493-
" polar=True)\n",
490+
"mask = (((radar_gkc[..., 1] > bbox['bottom']) & (radar_gkc[..., 1] < bbox['top'])) &\n",
491+
" ((radar_gkc[..., 0] > bbox['left']) & (radar_gkc[..., 0] < bbox['right'])))\n",
494492
"\n",
495493
"radar_gkc_ = radar_gkc[mask, :]\n",
496494
"radar_gk_ = radar_gk[mask]\n",

notebooks/zonalstats/wradlib_zonalstats_quickstart.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@
230230
"buffer = 5000.\n",
231231
"bbox = dict(left=bbox[0] - buffer, right=bbox[1] + buffer,\n",
232232
" bottom=bbox[2] - buffer, top=bbox[3] + buffer)\n",
233-
"mask, shape = wrl.zonalstats.mask_from_bbox(xy[..., 0], \n",
234-
" xy[..., 1],\n",
235-
" bbox)\n",
233+
"mask = (((xy[..., 1] > bbox['bottom']) & (xy[..., 1] < bbox['top'])) &\n",
234+
" ((xy[..., 0] > bbox['left']) & (xy[..., 0] < bbox['right'])))\n",
236235
"xy_ = np.dstack((xy[..., 0][mask].ravel(), xy[..., 1][mask].ravel()))\n",
237236
"data_ = data[mask]"
238237
]
@@ -452,7 +451,7 @@
452451
"name": "python",
453452
"nbconvert_exporter": "python",
454453
"pygments_lexer": "ipython3",
455-
"version": "3.6.3"
454+
"version": "3.6.4"
456455
},
457456
"livereveal": {
458457
"scroll": true

0 commit comments

Comments
 (0)