Skip to content

Commit a2b29b7

Browse files
authored
MNT: add pre-commit hooks and initial fix (#66)
1 parent aa5cda9 commit a2b29b7

File tree

60 files changed

+3555
-2461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3555
-2461
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: debug-statements
9+
- id: mixed-line-ending
10+
- repo: https://github.com/myint/autoflake
11+
rev: "v1.4"
12+
hooks:
13+
- id: autoflake
14+
args: ["--in-place", "--ignore-init-module-imports"]
15+
- repo: https://github.com/PyCQA/isort
16+
rev: 5.10.1
17+
hooks:
18+
- id: isort
19+
- repo: https://github.com/psf/black
20+
rev: 22.3.0
21+
hooks:
22+
- id: black
23+
- id: black-jupyter
24+
- repo: https://github.com/PyCQA/flake8
25+
rev: 4.0.1
26+
hooks:
27+
- id: flake8

Welcome_Pangeo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is a live session from which you can run scalable notebooks on the cloud.
77

88
A file browser listing example notebooks is available to the left.
99

10-
Dask dashboard plots are available to the right.
10+
Dask dashboard plots are available to the right.
1111
These will activate when you launch a Dask cluster and start doing work.
1212
(these cells are already written for you).
1313

ci/requirements/notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ dependencies:
3939
- wetterdienst
4040
- xarray
4141
- xmltodict
42-
42+
4343
# fix blosc/gdal error on macosx
4444
- blosc==1.21.0

notebooks/attenuation/wradlib_attenuation.ipynb

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"import wradlib as wrl\n",
7474
"import matplotlib.pyplot as pl\n",
7575
"import warnings\n",
76-
"warnings.filterwarnings('ignore')\n",
76+
"\n",
77+
"warnings.filterwarnings(\"ignore\")\n",
7778
"try:\n",
7879
" get_ipython().magic(\"matplotlib inline\")\n",
7980
"except:\n",
@@ -115,7 +116,7 @@
115116
},
116117
"outputs": [],
117118
"source": [
118-
"fpath = 'dx/raa00-dx_10908-0806021655-fbg---bin.gz'\n",
119+
"fpath = \"dx/raa00-dx_10908-0806021655-fbg---bin.gz\"\n",
119120
"f = wrl.util.get_wradlib_data_file(fpath)\n",
120121
"data, attrs = wrl.io.read_dx(f)"
121122
]
@@ -130,16 +131,16 @@
130131
},
131132
"outputs": [],
132133
"source": [
133-
"pl.figure(figsize=(10,8))\n",
134+
"pl.figure(figsize=(10, 8))\n",
134135
"ax, cf = wrl.vis.plot_ppi(data, cmap=\"viridis\")\n",
135136
"pl.xlabel(\"Easting from radar (km)\")\n",
136137
"pl.ylabel(\"Northing from radar (km)\")\n",
137138
"pl.title(\"Radar Feldberg, 2008-06-02 16:55 UTC\")\n",
138139
"cb = pl.colorbar(cf, shrink=0.8)\n",
139140
"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",
143144
"pl.grid(color=\"grey\")"
144145
]
145146
},
@@ -167,19 +168,24 @@
167168
"# just a little helper function\n",
168169
"def plot_beams(data, mybeams, sub=111):\n",
169170
" ax = fig.add_subplot(sub)\n",
170-
" labelsize=13\n",
171+
" labelsize = 13\n",
171172
" for beam in range(mybeams.start, mybeams.stop):\n",
172173
" pl.plot(data[beam], label=\"{0} deg\".format(beam))\n",
173174
" 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",
177183
" pl.xlabel(\"range (km)\", fontsize=\"large\")\n",
178184
" pl.ylabel(\"Reflectivity (dBZ)\", fontsize=\"large\")\n",
179185
" 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)"
183189
]
184190
},
185191
{
@@ -192,8 +198,8 @@
192198
},
193199
"outputs": [],
194200
"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",
197203
"plot_beams(data, mybeams)"
198204
]
199205
},
@@ -243,10 +249,8 @@
243249
"outputs": [],
244250
"source": [
245251
"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+
")"
250254
]
251255
},
252256
{
@@ -275,17 +279,15 @@
275279
"# another little helper function\n",
276280
"def plot_pia(pia, sub=111, title=None):\n",
277281
" ax = fig.add_subplot(sub)\n",
278-
" labelsize=13\n",
282+
" labelsize = 13\n",
279283
" pl.plot(pia.T)\n",
280284
" pl.grid()\n",
281-
" pl.ylim(0,30)\n",
285+
" pl.ylim(0, 30)\n",
282286
" 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)"
289291
]
290292
},
291293
{
@@ -298,10 +300,9 @@
298300
},
299301
"outputs": [],
300302
"source": [
301-
"fig = pl.figure(figsize=(10,6))\n",
303+
"fig = pl.figure(figsize=(10, 6))\n",
302304
"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",
305306
"pl.tight_layout()"
306307
]
307308
},
@@ -352,10 +353,8 @@
352353
"outputs": [],
353354
"source": [
354355
"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",
359358
"pia_harrison[pia_harrison > 4.8] = 4.8"
360359
]
361360
},
@@ -380,14 +379,13 @@
380379
},
381380
"outputs": [],
382381
"source": [
383-
"fig = pl.figure(figsize=(10,6))\n",
382+
"fig = pl.figure(figsize=(10, 6))\n",
384383
"\n",
385-
"mybeams = slice(53,56)\n",
386-
"labelsize=13\n",
384+
"mybeams = slice(53, 56)\n",
385+
"labelsize = 13\n",
387386
"\n",
388387
"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",
391389
"pl.tight_layout()"
392390
]
393391
},
@@ -426,15 +424,16 @@
426424
"source": [
427425
"pia_kraemer = wrl.atten.correct_attenuation_constrained(\n",
428426
" data,\n",
429-
" a_max=1.67e-4, \n",
427+
" a_max=1.67e-4,\n",
430428
" a_min=2.33e-5,\n",
431429
" n_a=100,\n",
432430
" b_max=0.7,\n",
433431
" b_min=0.65,\n",
434432
" n_b=6,\n",
435-
" gate_length=1.,\n",
433+
" gate_length=1.0,\n",
436434
" constraints=[wrl.atten.constraint_dbz],\n",
437-
" constraint_args=[[59.0]])"
435+
" constraint_args=[[59.0]],\n",
436+
")"
438437
]
439438
},
440439
{
@@ -458,10 +457,9 @@
458457
},
459458
"outputs": [],
460459
"source": [
461-
"fig = pl.figure(figsize=(10,6))\n",
460+
"fig = pl.figure(figsize=(10, 6))\n",
462461
"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",
465463
"pl.tight_layout()"
466464
]
467465
},
@@ -506,10 +504,10 @@
506504
" b_max=0.7,\n",
507505
" b_min=0.65,\n",
508506
" 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+
")"
513511
]
514512
},
515513
{
@@ -522,10 +520,9 @@
522520
},
523521
"outputs": [],
524522
"source": [
525-
"fig = pl.figure(figsize=(10,6))\n",
523+
"fig = pl.figure(figsize=(10, 6))\n",
526524
"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",
529526
"pl.tight_layout()"
530527
]
531528
},
@@ -561,17 +558,13 @@
561558
},
562559
"outputs": [],
563560
"source": [
564-
"fig = pl.figure(figsize=(10,12))\n",
561+
"fig = pl.figure(figsize=(10, 12))\n",
565562
"\n",
566563
"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",
575568
"pl.tight_layout()"
576569
]
577570
},

notebooks/basics/wradlib_get_rainfall.ipynb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"import wradlib as wrl\n",
3838
"import matplotlib.pyplot as pl\n",
3939
"import warnings\n",
40-
"warnings.filterwarnings('ignore')\n",
40+
"\n",
41+
"warnings.filterwarnings(\"ignore\")\n",
4142
"try:\n",
4243
" get_ipython().magic(\"matplotlib inline\")\n",
4344
"except:\n",
@@ -58,7 +59,7 @@
5859
"metadata": {},
5960
"outputs": [],
6061
"source": [
61-
"dBZ = np.array([20., 30., 40., 45., 50., 55.])\n",
62+
"dBZ = np.array([20.0, 30.0, 40.0, 45.0, 50.0, 55.0])\n",
6263
"print(dBZ)"
6364
]
6465
},
@@ -92,7 +93,7 @@
9293
"metadata": {},
9394
"outputs": [],
9495
"source": [
95-
"R = wrl.zr.z_to_r(Z, a=200., b=1.6)\n",
96+
"R = wrl.zr.z_to_r(Z, a=200.0, b=1.6)\n",
9697
"print(np.round(R, 2))"
9798
]
9899
},
@@ -139,11 +140,12 @@
139140
"outputs": [],
140141
"source": [
141142
"def read_data(dtimes):\n",
142-
" \"\"\"Helper function to read raw data for a list of datetimes <dtimes>\n",
143-
" \"\"\"\n",
144-
" data = np.empty((len(dtimes),360,128))\n",
143+
" \"\"\"Helper function to read raw data for a list of datetimes <dtimes>\"\"\"\n",
144+
" data = np.empty((len(dtimes), 360, 128))\n",
145145
" for i, dtime in enumerate(dtimes):\n",
146-
" f = wrl.util.get_wradlib_data_file('dx/raa00-dx_10908-{0}-fbg---bin.gz'.format(dtime))\n",
146+
" f = wrl.util.get_wradlib_data_file(\n",
147+
" \"dx/raa00-dx_10908-{0}-fbg---bin.gz\".format(dtime)\n",
148+
" )\n",
147149
" data[i], attrs = wrl.io.read_dx(f)\n",
148150
" return data"
149151
]
@@ -162,11 +164,11 @@
162164
"outputs": [],
163165
"source": [
164166
"# Read\n",
165-
"dtimes = [\"0806021735\",\"0806021740\",\"0806021745\"]\n",
167+
"dtimes = [\"0806021735\", \"0806021740\", \"0806021745\"]\n",
166168
"dBZ = read_data(dtimes)\n",
167169
"# Convert to rainfall intensity (mm/h)\n",
168170
"Z = wrl.trafo.idecibel(dBZ)\n",
169-
"R = wrl.zr.z_to_r(Z, a=200., b=1.6)\n",
171+
"R = wrl.zr.z_to_r(Z, a=200.0, b=1.6)\n",
170172
"# Convert to rainfall depth (mm)\n",
171173
"depth = wrl.trafo.r_to_depth(R, 300)\n",
172174
"# Accumulate 15 minute rainfall depth over all three 5 minute intervals\n",
@@ -186,15 +188,15 @@
186188
"metadata": {},
187189
"outputs": [],
188190
"source": [
189-
"pl.figure(figsize=(10,8))\n",
191+
"pl.figure(figsize=(10, 8))\n",
190192
"ax, cf = wrl.vis.plot_ppi(accum, cmap=\"viridis\")\n",
191193
"pl.xlabel(\"Easting from radar (km)\")\n",
192194
"pl.ylabel(\"Northing from radar (km)\")\n",
193195
"pl.title(\"Radar Feldberg\\n15 min. rainfall depth, 2008-06-02 17:30-17:45 UTC\")\n",
194196
"cb = pl.colorbar(cf, shrink=0.8)\n",
195197
"cb.set_label(\"mm\")\n",
196-
"pl.xlim(-128,128)\n",
197-
"pl.ylim(-128,128)\n",
198+
"pl.xlim(-128, 128)\n",
199+
"pl.ylim(-128, 128)\n",
198200
"pl.grid(color=\"grey\")"
199201
]
200202
}

notebooks/basics/wradlib_introduction.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"outputs": [],
4949
"source": [
5050
"import wradlib\n",
51+
"\n",
5152
"print(wradlib.__version__)"
5253
]
5354
}

0 commit comments

Comments
 (0)