|
73 | 73 | "import wradlib as wrl\n", |
74 | 74 | "import matplotlib.pyplot as pl\n", |
75 | 75 | "import warnings\n", |
76 | | - "warnings.filterwarnings('ignore')\n", |
| 76 | + "\n", |
| 77 | + "warnings.filterwarnings(\"ignore\")\n", |
77 | 78 | "try:\n", |
78 | 79 | " get_ipython().magic(\"matplotlib inline\")\n", |
79 | 80 | "except:\n", |
|
115 | 116 | }, |
116 | 117 | "outputs": [], |
117 | 118 | "source": [ |
118 | | - "fpath = 'dx/raa00-dx_10908-0806021655-fbg---bin.gz'\n", |
| 119 | + "fpath = \"dx/raa00-dx_10908-0806021655-fbg---bin.gz\"\n", |
119 | 120 | "f = wrl.util.get_wradlib_data_file(fpath)\n", |
120 | 121 | "data, attrs = wrl.io.read_dx(f)" |
121 | 122 | ] |
|
130 | 131 | }, |
131 | 132 | "outputs": [], |
132 | 133 | "source": [ |
133 | | - "pl.figure(figsize=(10,8))\n", |
| 134 | + "pl.figure(figsize=(10, 8))\n", |
134 | 135 | "ax, cf = wrl.vis.plot_ppi(data, cmap=\"viridis\")\n", |
135 | 136 | "pl.xlabel(\"Easting from radar (km)\")\n", |
136 | 137 | "pl.ylabel(\"Northing from radar (km)\")\n", |
137 | 138 | "pl.title(\"Radar Feldberg, 2008-06-02 16:55 UTC\")\n", |
138 | 139 | "cb = pl.colorbar(cf, shrink=0.8)\n", |
139 | 140 | "cb.set_label(\"dBZ\")\n", |
140 | | - "pl.plot([0,105.6],[0,73.4],\"-\", color=\"white\", lw=2)\n", |
141 | | - "pl.xlim(-128,128)\n", |
142 | | - "pl.ylim(-128,128)\n", |
| 141 | + "pl.plot([0, 105.6], [0, 73.4], \"-\", color=\"white\", lw=2)\n", |
| 142 | + "pl.xlim(-128, 128)\n", |
| 143 | + "pl.ylim(-128, 128)\n", |
143 | 144 | "pl.grid(color=\"grey\")" |
144 | 145 | ] |
145 | 146 | }, |
|
167 | 168 | "# just a little helper function\n", |
168 | 169 | "def plot_beams(data, mybeams, sub=111):\n", |
169 | 170 | " ax = fig.add_subplot(sub)\n", |
170 | | - " labelsize=13\n", |
| 171 | + " labelsize = 13\n", |
171 | 172 | " for beam in range(mybeams.start, mybeams.stop):\n", |
172 | 173 | " pl.plot(data[beam], label=\"{0} deg\".format(beam))\n", |
173 | 174 | " pl.grid()\n", |
174 | | - " pl.text(0.99, 0.88, \"Reflectivity along beams\", \n", |
175 | | - " horizontalalignment='right', \n", |
176 | | - " transform = ax.transAxes, fontsize=\"large\")\n", |
| 175 | + " pl.text(\n", |
| 176 | + " 0.99,\n", |
| 177 | + " 0.88,\n", |
| 178 | + " \"Reflectivity along beams\",\n", |
| 179 | + " horizontalalignment=\"right\",\n", |
| 180 | + " transform=ax.transAxes,\n", |
| 181 | + " fontsize=\"large\",\n", |
| 182 | + " )\n", |
177 | 183 | " pl.xlabel(\"range (km)\", fontsize=\"large\")\n", |
178 | 184 | " pl.ylabel(\"Reflectivity (dBZ)\", fontsize=\"large\")\n", |
179 | 185 | " pl.legend(loc=\"upper left\")\n", |
180 | | - " ax.tick_params(axis='x', labelsize=labelsize)\n", |
181 | | - " ax.tick_params(axis='y', labelsize=labelsize)\n", |
182 | | - " pl.xlim(0,128)" |
| 186 | + " ax.tick_params(axis=\"x\", labelsize=labelsize)\n", |
| 187 | + " ax.tick_params(axis=\"y\", labelsize=labelsize)\n", |
| 188 | + " pl.xlim(0, 128)" |
183 | 189 | ] |
184 | 190 | }, |
185 | 191 | { |
|
192 | 198 | }, |
193 | 199 | "outputs": [], |
194 | 200 | "source": [ |
195 | | - "mybeams = slice(53,56)\n", |
196 | | - "fig = pl.figure(figsize=(10,3))\n", |
| 201 | + "mybeams = slice(53, 56)\n", |
| 202 | + "fig = pl.figure(figsize=(10, 3))\n", |
197 | 203 | "plot_beams(data, mybeams)" |
198 | 204 | ] |
199 | 205 | }, |
|
243 | 249 | "outputs": [], |
244 | 250 | "source": [ |
245 | 251 | "pia_hibo = wrl.atten.correct_attenuation_hb(\n", |
246 | | - " data, \n", |
247 | | - " coefficients = dict(a=8.e-5, b=0.731, gate_length=1.0),\n", |
248 | | - " mode=\"warn\", \n", |
249 | | - " thrs=59.)" |
| 252 | + " data, coefficients=dict(a=8.0e-5, b=0.731, gate_length=1.0), mode=\"warn\", thrs=59.0\n", |
| 253 | + ")" |
250 | 254 | ] |
251 | 255 | }, |
252 | 256 | { |
|
275 | 279 | "# another little helper function\n", |
276 | 280 | "def plot_pia(pia, sub=111, title=None):\n", |
277 | 281 | " ax = fig.add_subplot(sub)\n", |
278 | | - " labelsize=13\n", |
| 282 | + " labelsize = 13\n", |
279 | 283 | " pl.plot(pia.T)\n", |
280 | 284 | " pl.grid()\n", |
281 | | - " pl.ylim(0,30)\n", |
| 285 | + " pl.ylim(0, 30)\n", |
282 | 286 | " pl.ylabel(\"PIA (dB)\", fontsize=\"large\")\n", |
283 | | - " pl.text(0.01, 0.88, title, \n", |
284 | | - " transform = ax.transAxes, fontsize=\"large\")\n", |
285 | | - " ax.tick_params(axis='x', labelsize=labelsize)\n", |
286 | | - " ax.tick_params(axis='y', labelsize=labelsize)\n", |
287 | | - " pl.xlim(0,128)\n", |
288 | | - " " |
| 287 | + " pl.text(0.01, 0.88, title, transform=ax.transAxes, fontsize=\"large\")\n", |
| 288 | + " ax.tick_params(axis=\"x\", labelsize=labelsize)\n", |
| 289 | + " ax.tick_params(axis=\"y\", labelsize=labelsize)\n", |
| 290 | + " pl.xlim(0, 128)" |
289 | 291 | ] |
290 | 292 | }, |
291 | 293 | { |
|
298 | 300 | }, |
299 | 301 | "outputs": [], |
300 | 302 | "source": [ |
301 | | - "fig = pl.figure(figsize=(10,6))\n", |
| 303 | + "fig = pl.figure(figsize=(10, 6))\n", |
302 | 304 | "plot_beams(data, mybeams, 211)\n", |
303 | | - "plot_pia(pia_hibo[mybeams], 212, \n", |
304 | | - " \"PIA according to Hitchfeld and Bordan\")\n", |
| 305 | + "plot_pia(pia_hibo[mybeams], 212, \"PIA according to Hitchfeld and Bordan\")\n", |
305 | 306 | "pl.tight_layout()" |
306 | 307 | ] |
307 | 308 | }, |
|
352 | 353 | "outputs": [], |
353 | 354 | "source": [ |
354 | 355 | "pia_harrison = wrl.atten.correct_attenuation_hb(\n", |
355 | | - " data, \n", |
356 | | - " coefficients = dict(a=4.57e-5, b=0.731, gate_length=1.0),\n", |
357 | | - " mode=\"warn\", \n", |
358 | | - " thrs=59.)\n", |
| 356 | + " data, coefficients=dict(a=4.57e-5, b=0.731, gate_length=1.0), mode=\"warn\", thrs=59.0\n", |
| 357 | + ")\n", |
359 | 358 | "pia_harrison[pia_harrison > 4.8] = 4.8" |
360 | 359 | ] |
361 | 360 | }, |
|
380 | 379 | }, |
381 | 380 | "outputs": [], |
382 | 381 | "source": [ |
383 | | - "fig = pl.figure(figsize=(10,6))\n", |
| 382 | + "fig = pl.figure(figsize=(10, 6))\n", |
384 | 383 | "\n", |
385 | | - "mybeams = slice(53,56)\n", |
386 | | - "labelsize=13\n", |
| 384 | + "mybeams = slice(53, 56)\n", |
| 385 | + "labelsize = 13\n", |
387 | 386 | "\n", |
388 | 387 | "plot_beams(data, mybeams, 211)\n", |
389 | | - "plot_pia(pia_harrison[mybeams], 212, \n", |
390 | | - " \"PIA according to Harrison\")\n", |
| 388 | + "plot_pia(pia_harrison[mybeams], 212, \"PIA according to Harrison\")\n", |
391 | 389 | "pl.tight_layout()" |
392 | 390 | ] |
393 | 391 | }, |
|
426 | 424 | "source": [ |
427 | 425 | "pia_kraemer = wrl.atten.correct_attenuation_constrained(\n", |
428 | 426 | " data,\n", |
429 | | - " a_max=1.67e-4, \n", |
| 427 | + " a_max=1.67e-4,\n", |
430 | 428 | " a_min=2.33e-5,\n", |
431 | 429 | " n_a=100,\n", |
432 | 430 | " b_max=0.7,\n", |
433 | 431 | " b_min=0.65,\n", |
434 | 432 | " n_b=6,\n", |
435 | | - " gate_length=1.,\n", |
| 433 | + " gate_length=1.0,\n", |
436 | 434 | " constraints=[wrl.atten.constraint_dbz],\n", |
437 | | - " constraint_args=[[59.0]])" |
| 435 | + " constraint_args=[[59.0]],\n", |
| 436 | + ")" |
438 | 437 | ] |
439 | 438 | }, |
440 | 439 | { |
|
458 | 457 | }, |
459 | 458 | "outputs": [], |
460 | 459 | "source": [ |
461 | | - "fig = pl.figure(figsize=(10,6))\n", |
| 460 | + "fig = pl.figure(figsize=(10, 6))\n", |
462 | 461 | "plot_beams(data, mybeams, 211)\n", |
463 | | - "plot_pia(pia_kraemer[mybeams], 212, \n", |
464 | | - " \"PIA according to Kraemer\")\n", |
| 462 | + "plot_pia(pia_kraemer[mybeams], 212, \"PIA according to Kraemer\")\n", |
465 | 463 | "pl.tight_layout()" |
466 | 464 | ] |
467 | 465 | }, |
|
506 | 504 | " b_max=0.7,\n", |
507 | 505 | " b_min=0.65,\n", |
508 | 506 | " n_b=6,\n", |
509 | | - " gate_length=1.,\n", |
510 | | - " constraints=[wrl.atten.constraint_dbz, \n", |
511 | | - " wrl.atten.constraint_pia], \n", |
512 | | - " constraint_args=[[59.0],[20.0]])" |
| 507 | + " gate_length=1.0,\n", |
| 508 | + " constraints=[wrl.atten.constraint_dbz, wrl.atten.constraint_pia],\n", |
| 509 | + " constraint_args=[[59.0], [20.0]],\n", |
| 510 | + ")" |
513 | 511 | ] |
514 | 512 | }, |
515 | 513 | { |
|
522 | 520 | }, |
523 | 521 | "outputs": [], |
524 | 522 | "source": [ |
525 | | - "fig = pl.figure(figsize=(10,6))\n", |
| 523 | + "fig = pl.figure(figsize=(10, 6))\n", |
526 | 524 | "plot_beams(data, mybeams, 211)\n", |
527 | | - "plot_pia(pia_mkraemer[mybeams], 212, \n", |
528 | | - " \"PIA according to modified Kraemer\")\n", |
| 525 | + "plot_pia(pia_mkraemer[mybeams], 212, \"PIA according to modified Kraemer\")\n", |
529 | 526 | "pl.tight_layout()" |
530 | 527 | ] |
531 | 528 | }, |
|
561 | 558 | }, |
562 | 559 | "outputs": [], |
563 | 560 | "source": [ |
564 | | - "fig = pl.figure(figsize=(10,12))\n", |
| 561 | + "fig = pl.figure(figsize=(10, 12))\n", |
565 | 562 | "\n", |
566 | 563 | "plot_beams(data, mybeams, 511)\n", |
567 | | - "plot_pia(pia_hibo[mybeams], 512, \n", |
568 | | - " \"PIA according to Hitschfeld and Bordan\" )\n", |
569 | | - "plot_pia(pia_harrison[mybeams], 513, \n", |
570 | | - " \"PIA according to Harrison\")\n", |
571 | | - "plot_pia(pia_kraemer[mybeams], 514, \n", |
572 | | - " \"PIA according to Kraemer\")\n", |
573 | | - "plot_pia(pia_mkraemer[mybeams], 515, \n", |
574 | | - " \"PIA according to modified Kraemer\")\n", |
| 564 | + "plot_pia(pia_hibo[mybeams], 512, \"PIA according to Hitschfeld and Bordan\")\n", |
| 565 | + "plot_pia(pia_harrison[mybeams], 513, \"PIA according to Harrison\")\n", |
| 566 | + "plot_pia(pia_kraemer[mybeams], 514, \"PIA according to Kraemer\")\n", |
| 567 | + "plot_pia(pia_mkraemer[mybeams], 515, \"PIA according to modified Kraemer\")\n", |
575 | 568 | "pl.tight_layout()" |
576 | 569 | ] |
577 | 570 | }, |
|
0 commit comments