Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/myint/autoflake
rev: "v1.4"
hooks:
- id: autoflake
args: ["--in-place", "--ignore-init-module-imports"]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion Welcome_Pangeo.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is a live session from which you can run scalable notebooks on the cloud.

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

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

Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ dependencies:
- wetterdienst
- xarray
- xmltodict

# fix blosc/gdal error on macosx
- blosc==1.21.0
115 changes: 54 additions & 61 deletions notebooks/attenuation/wradlib_attenuation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"import wradlib as wrl\n",
"import matplotlib.pyplot as pl\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"try:\n",
" get_ipython().magic(\"matplotlib inline\")\n",
"except:\n",
Expand Down Expand Up @@ -115,7 +116,7 @@
},
"outputs": [],
"source": [
"fpath = 'dx/raa00-dx_10908-0806021655-fbg---bin.gz'\n",
"fpath = \"dx/raa00-dx_10908-0806021655-fbg---bin.gz\"\n",
"f = wrl.util.get_wradlib_data_file(fpath)\n",
"data, attrs = wrl.io.read_dx(f)"
]
Expand All @@ -130,16 +131,16 @@
},
"outputs": [],
"source": [
"pl.figure(figsize=(10,8))\n",
"pl.figure(figsize=(10, 8))\n",
"ax, cf = wrl.vis.plot_ppi(data, cmap=\"viridis\")\n",
"pl.xlabel(\"Easting from radar (km)\")\n",
"pl.ylabel(\"Northing from radar (km)\")\n",
"pl.title(\"Radar Feldberg, 2008-06-02 16:55 UTC\")\n",
"cb = pl.colorbar(cf, shrink=0.8)\n",
"cb.set_label(\"dBZ\")\n",
"pl.plot([0,105.6],[0,73.4],\"-\", color=\"white\", lw=2)\n",
"pl.xlim(-128,128)\n",
"pl.ylim(-128,128)\n",
"pl.plot([0, 105.6], [0, 73.4], \"-\", color=\"white\", lw=2)\n",
"pl.xlim(-128, 128)\n",
"pl.ylim(-128, 128)\n",
"pl.grid(color=\"grey\")"
]
},
Expand Down Expand Up @@ -167,19 +168,24 @@
"# just a little helper function\n",
"def plot_beams(data, mybeams, sub=111):\n",
" ax = fig.add_subplot(sub)\n",
" labelsize=13\n",
" labelsize = 13\n",
" for beam in range(mybeams.start, mybeams.stop):\n",
" pl.plot(data[beam], label=\"{0} deg\".format(beam))\n",
" pl.grid()\n",
" pl.text(0.99, 0.88, \"Reflectivity along beams\", \n",
" horizontalalignment='right', \n",
" transform = ax.transAxes, fontsize=\"large\")\n",
" pl.text(\n",
" 0.99,\n",
" 0.88,\n",
" \"Reflectivity along beams\",\n",
" horizontalalignment=\"right\",\n",
" transform=ax.transAxes,\n",
" fontsize=\"large\",\n",
" )\n",
" pl.xlabel(\"range (km)\", fontsize=\"large\")\n",
" pl.ylabel(\"Reflectivity (dBZ)\", fontsize=\"large\")\n",
" pl.legend(loc=\"upper left\")\n",
" ax.tick_params(axis='x', labelsize=labelsize)\n",
" ax.tick_params(axis='y', labelsize=labelsize)\n",
" pl.xlim(0,128)"
" ax.tick_params(axis=\"x\", labelsize=labelsize)\n",
" ax.tick_params(axis=\"y\", labelsize=labelsize)\n",
" pl.xlim(0, 128)"
]
},
{
Expand All @@ -192,8 +198,8 @@
},
"outputs": [],
"source": [
"mybeams = slice(53,56)\n",
"fig = pl.figure(figsize=(10,3))\n",
"mybeams = slice(53, 56)\n",
"fig = pl.figure(figsize=(10, 3))\n",
"plot_beams(data, mybeams)"
]
},
Expand Down Expand Up @@ -243,10 +249,8 @@
"outputs": [],
"source": [
"pia_hibo = wrl.atten.correct_attenuation_hb(\n",
" data, \n",
" coefficients = dict(a=8.e-5, b=0.731, gate_length=1.0),\n",
" mode=\"warn\", \n",
" thrs=59.)"
" data, coefficients=dict(a=8.0e-5, b=0.731, gate_length=1.0), mode=\"warn\", thrs=59.0\n",
")"
]
},
{
Expand Down Expand Up @@ -275,17 +279,15 @@
"# another little helper function\n",
"def plot_pia(pia, sub=111, title=None):\n",
" ax = fig.add_subplot(sub)\n",
" labelsize=13\n",
" labelsize = 13\n",
" pl.plot(pia.T)\n",
" pl.grid()\n",
" pl.ylim(0,30)\n",
" pl.ylim(0, 30)\n",
" pl.ylabel(\"PIA (dB)\", fontsize=\"large\")\n",
" pl.text(0.01, 0.88, title, \n",
" transform = ax.transAxes, fontsize=\"large\")\n",
" ax.tick_params(axis='x', labelsize=labelsize)\n",
" ax.tick_params(axis='y', labelsize=labelsize)\n",
" pl.xlim(0,128)\n",
" "
" pl.text(0.01, 0.88, title, transform=ax.transAxes, fontsize=\"large\")\n",
" ax.tick_params(axis=\"x\", labelsize=labelsize)\n",
" ax.tick_params(axis=\"y\", labelsize=labelsize)\n",
" pl.xlim(0, 128)"
]
},
{
Expand All @@ -298,10 +300,9 @@
},
"outputs": [],
"source": [
"fig = pl.figure(figsize=(10,6))\n",
"fig = pl.figure(figsize=(10, 6))\n",
"plot_beams(data, mybeams, 211)\n",
"plot_pia(pia_hibo[mybeams], 212, \n",
" \"PIA according to Hitchfeld and Bordan\")\n",
"plot_pia(pia_hibo[mybeams], 212, \"PIA according to Hitchfeld and Bordan\")\n",
"pl.tight_layout()"
]
},
Expand Down Expand Up @@ -352,10 +353,8 @@
"outputs": [],
"source": [
"pia_harrison = wrl.atten.correct_attenuation_hb(\n",
" data, \n",
" coefficients = dict(a=4.57e-5, b=0.731, gate_length=1.0),\n",
" mode=\"warn\", \n",
" thrs=59.)\n",
" data, coefficients=dict(a=4.57e-5, b=0.731, gate_length=1.0), mode=\"warn\", thrs=59.0\n",
")\n",
"pia_harrison[pia_harrison > 4.8] = 4.8"
]
},
Expand All @@ -380,14 +379,13 @@
},
"outputs": [],
"source": [
"fig = pl.figure(figsize=(10,6))\n",
"fig = pl.figure(figsize=(10, 6))\n",
"\n",
"mybeams = slice(53,56)\n",
"labelsize=13\n",
"mybeams = slice(53, 56)\n",
"labelsize = 13\n",
"\n",
"plot_beams(data, mybeams, 211)\n",
"plot_pia(pia_harrison[mybeams], 212, \n",
" \"PIA according to Harrison\")\n",
"plot_pia(pia_harrison[mybeams], 212, \"PIA according to Harrison\")\n",
"pl.tight_layout()"
]
},
Expand Down Expand Up @@ -426,15 +424,16 @@
"source": [
"pia_kraemer = wrl.atten.correct_attenuation_constrained(\n",
" data,\n",
" a_max=1.67e-4, \n",
" a_max=1.67e-4,\n",
" a_min=2.33e-5,\n",
" n_a=100,\n",
" b_max=0.7,\n",
" b_min=0.65,\n",
" n_b=6,\n",
" gate_length=1.,\n",
" gate_length=1.0,\n",
" constraints=[wrl.atten.constraint_dbz],\n",
" constraint_args=[[59.0]])"
" constraint_args=[[59.0]],\n",
")"
]
},
{
Expand All @@ -458,10 +457,9 @@
},
"outputs": [],
"source": [
"fig = pl.figure(figsize=(10,6))\n",
"fig = pl.figure(figsize=(10, 6))\n",
"plot_beams(data, mybeams, 211)\n",
"plot_pia(pia_kraemer[mybeams], 212, \n",
" \"PIA according to Kraemer\")\n",
"plot_pia(pia_kraemer[mybeams], 212, \"PIA according to Kraemer\")\n",
"pl.tight_layout()"
]
},
Expand Down Expand Up @@ -506,10 +504,10 @@
" b_max=0.7,\n",
" b_min=0.65,\n",
" n_b=6,\n",
" gate_length=1.,\n",
" constraints=[wrl.atten.constraint_dbz, \n",
" wrl.atten.constraint_pia], \n",
" constraint_args=[[59.0],[20.0]])"
" gate_length=1.0,\n",
" constraints=[wrl.atten.constraint_dbz, wrl.atten.constraint_pia],\n",
" constraint_args=[[59.0], [20.0]],\n",
")"
]
},
{
Expand All @@ -522,10 +520,9 @@
},
"outputs": [],
"source": [
"fig = pl.figure(figsize=(10,6))\n",
"fig = pl.figure(figsize=(10, 6))\n",
"plot_beams(data, mybeams, 211)\n",
"plot_pia(pia_mkraemer[mybeams], 212, \n",
" \"PIA according to modified Kraemer\")\n",
"plot_pia(pia_mkraemer[mybeams], 212, \"PIA according to modified Kraemer\")\n",
"pl.tight_layout()"
]
},
Expand Down Expand Up @@ -561,17 +558,13 @@
},
"outputs": [],
"source": [
"fig = pl.figure(figsize=(10,12))\n",
"fig = pl.figure(figsize=(10, 12))\n",
"\n",
"plot_beams(data, mybeams, 511)\n",
"plot_pia(pia_hibo[mybeams], 512, \n",
" \"PIA according to Hitschfeld and Bordan\" )\n",
"plot_pia(pia_harrison[mybeams], 513, \n",
" \"PIA according to Harrison\")\n",
"plot_pia(pia_kraemer[mybeams], 514, \n",
" \"PIA according to Kraemer\")\n",
"plot_pia(pia_mkraemer[mybeams], 515, \n",
" \"PIA according to modified Kraemer\")\n",
"plot_pia(pia_hibo[mybeams], 512, \"PIA according to Hitschfeld and Bordan\")\n",
"plot_pia(pia_harrison[mybeams], 513, \"PIA according to Harrison\")\n",
"plot_pia(pia_kraemer[mybeams], 514, \"PIA according to Kraemer\")\n",
"plot_pia(pia_mkraemer[mybeams], 515, \"PIA according to modified Kraemer\")\n",
"pl.tight_layout()"
]
},
Expand Down
26 changes: 14 additions & 12 deletions notebooks/basics/wradlib_get_rainfall.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"import wradlib as wrl\n",
"import matplotlib.pyplot as pl\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"try:\n",
" get_ipython().magic(\"matplotlib inline\")\n",
"except:\n",
Expand All @@ -58,7 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
"dBZ = np.array([20., 30., 40., 45., 50., 55.])\n",
"dBZ = np.array([20.0, 30.0, 40.0, 45.0, 50.0, 55.0])\n",
"print(dBZ)"
]
},
Expand Down Expand Up @@ -92,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"R = wrl.zr.z_to_r(Z, a=200., b=1.6)\n",
"R = wrl.zr.z_to_r(Z, a=200.0, b=1.6)\n",
"print(np.round(R, 2))"
]
},
Expand Down Expand Up @@ -139,11 +140,12 @@
"outputs": [],
"source": [
"def read_data(dtimes):\n",
" \"\"\"Helper function to read raw data for a list of datetimes <dtimes>\n",
" \"\"\"\n",
" data = np.empty((len(dtimes),360,128))\n",
" \"\"\"Helper function to read raw data for a list of datetimes <dtimes>\"\"\"\n",
" data = np.empty((len(dtimes), 360, 128))\n",
" for i, dtime in enumerate(dtimes):\n",
" f = wrl.util.get_wradlib_data_file('dx/raa00-dx_10908-{0}-fbg---bin.gz'.format(dtime))\n",
" f = wrl.util.get_wradlib_data_file(\n",
" \"dx/raa00-dx_10908-{0}-fbg---bin.gz\".format(dtime)\n",
" )\n",
" data[i], attrs = wrl.io.read_dx(f)\n",
" return data"
]
Expand All @@ -162,11 +164,11 @@
"outputs": [],
"source": [
"# Read\n",
"dtimes = [\"0806021735\",\"0806021740\",\"0806021745\"]\n",
"dtimes = [\"0806021735\", \"0806021740\", \"0806021745\"]\n",
"dBZ = read_data(dtimes)\n",
"# Convert to rainfall intensity (mm/h)\n",
"Z = wrl.trafo.idecibel(dBZ)\n",
"R = wrl.zr.z_to_r(Z, a=200., b=1.6)\n",
"R = wrl.zr.z_to_r(Z, a=200.0, b=1.6)\n",
"# Convert to rainfall depth (mm)\n",
"depth = wrl.trafo.r_to_depth(R, 300)\n",
"# Accumulate 15 minute rainfall depth over all three 5 minute intervals\n",
Expand All @@ -186,15 +188,15 @@
"metadata": {},
"outputs": [],
"source": [
"pl.figure(figsize=(10,8))\n",
"pl.figure(figsize=(10, 8))\n",
"ax, cf = wrl.vis.plot_ppi(accum, cmap=\"viridis\")\n",
"pl.xlabel(\"Easting from radar (km)\")\n",
"pl.ylabel(\"Northing from radar (km)\")\n",
"pl.title(\"Radar Feldberg\\n15 min. rainfall depth, 2008-06-02 17:30-17:45 UTC\")\n",
"cb = pl.colorbar(cf, shrink=0.8)\n",
"cb.set_label(\"mm\")\n",
"pl.xlim(-128,128)\n",
"pl.ylim(-128,128)\n",
"pl.xlim(-128, 128)\n",
"pl.ylim(-128, 128)\n",
"pl.grid(color=\"grey\")"
]
}
Expand Down
1 change: 1 addition & 0 deletions notebooks/basics/wradlib_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"outputs": [],
"source": [
"import wradlib\n",
"\n",
"print(wradlib.__version__)"
]
}
Expand Down
Loading