generated from ProjectPythia/cookbook-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7d4fde
commit eda08e3
Showing
64 changed files
with
14,834 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,8 @@ | |
gtag('config', 'G-T52X8HNYE8'); | ||
</script> | ||
<script>const THEBE_JS_URL = "https://unpkg.com/[email protected]/lib/index.js"; const thebe_selector = ".thebe,.cell"; const thebe_selector_input = "pre"; const thebe_selector_output = ".output, .cell_output"</script> | ||
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> | ||
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> | ||
<script>DOCUMENTATION_OPTIONS.pagename = 'README';</script> | ||
<link rel="icon" href="_static/favicon.ico"/> | ||
<link rel="index" title="Index" href="genindex.html" /> | ||
|
@@ -376,10 +378,20 @@ | |
<li class="toctree-l2"><a class="reference internal" href="notebooks/synoptic/xarray_500hPa_map.html">Using Xarray for Data read and selection</a></li> | ||
</ul> | ||
</details></li> | ||
<li class="toctree-l1 has-children"><a class="reference internal" href="notebooks/skewt/index.html">Skew-T Analysis</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="simple"> | ||
<li class="toctree-l1 has-children"><a class="reference internal" href="notebooks/skewt/index.html">Skew-T Analysis</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Advanced_Sounding.html">Advanced Sounding</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Foundational_Sounding.html">MetPy Skew-T Cookbook</a></li> | ||
|
||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Skew-T_Analysis.html">Skew-T Analysis</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Skew-T_Hodograph_Inset.html">Hodograph Inset</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Skew-T_Layout_Hodograph.html">Skew-T with Complex Layout</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Sounding_Calculations.html">Sounding Calculation Examples</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Sounding_LCL_Dataset.html">Sounding as Dataset Example</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/skewt/Sounding_Plotter.html">Sounding Plotter</a></li> | ||
</ul> | ||
</details></li> | ||
<li class="toctree-l1 has-children"><a class="reference internal" href="notebooks/convective/index.html">Convective Calculations</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/convective/MUCAPE.html">Most-Unstable Convective Available Potential Energy (MUCAPE)</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/convective/miller_composite.html">Miller Composite Chart</a></li> | ||
</ul> | ||
</details></li> | ||
|
@@ -389,7 +401,9 @@ | |
<li class="toctree-l2"><a class="reference internal" href="notebooks/specialty/Smoothing_Contours.html">Smoothing Contours</a></li> | ||
</ul> | ||
</details></li> | ||
<li class="toctree-l1 has-children"><a class="reference internal" href="notebooks/declarative/index.html">Simplified Plotting</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="simple"> | ||
<li class="toctree-l1 has-children"><a class="reference internal" href="notebooks/declarative/index.html">Simplified Plotting</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/declarative/Declarative_300hPa.html">MetPy Declarative - 300 hPa</a></li> | ||
<li class="toctree-l2"><a class="reference internal" href="notebooks/declarative/declarative_500_hPa.html">Declarative 500-hPa Absolute Vorticity</a></li> | ||
</ul> | ||
</details></li> | ||
</ul> | ||
|
@@ -426,7 +440,7 @@ | |
<img src="_static/NSF-Unidata_lockup_horizontal_2023_light.png" alt="NSF-Unidata Logo" width="35%"/> | ||
</div> | ||
<div class="column"> | ||
<img src="_static/metpy_150x150.png" alt="MetPy Logo" width="100%"/> | ||
<img src="_static/metpy_150x150.png" alt="MetPy Logo" width="35%"/> | ||
</div> | ||
</div> | ||
<section class="tex2jax_ignore mathjax_ignore" id="metpy-cookbook"> | ||
|
Binary file added
BIN
+29 KB
...13/_images/0d8b4da5877b635b64ad090c4a73c3612c1f29ee324dc522c523f3b54360d0fd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+258 KB
...13/_images/1259bfb6e9d8d512fe0ea2d3a6b852b637e2cb92446c33181c1cfb40bbbbdc5a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+225 KB
...13/_images/215d53661e883ad6038e6a6e3d5867b87a803552f55588bbbdca3273e8a04d61.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+240 KB
...13/_images/471ac4635b9d18280191c406291e20a9896a11645e0642d9a8bc08250b75639a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+458 KB
...13/_images/91e2a36e59538fb57450f0a945256e7d62dd73a6e6e12523b4d7d8345adf29b0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+214 KB
...13/_images/9ce94906e406937fc213ce8c8c8d19b3fc7957cff5e1df5e8f28a759db6f23e1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+202 KB
...13/_images/9ed8a7da1ae1f900513904e62372cac672fdd225b4ef8a539280b7724131efe1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+191 KB
...13/_images/bd7e59c922c4651450502a76823feb97178695fcd6f5ae499a8fbc18c5f6b528.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+436 KB
...13/_images/d333531f29bb5443a5f6a77e5542a2c9ee5aa54bfa8159b49bde434026705a3b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+220 KB
...13/_images/e3453ea841389167a27588071b431f8cc0f35af0eeaf2da2f2c0d7b90ed616fb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 193 additions & 0 deletions
193
_preview/13/_sources/notebooks/declarative/Declarative_300hPa.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"cell_marker": "\"\"\"" | ||
}, | ||
"source": [ | ||
"MetPy Declarative - 300 hPa\n", | ||
"===========================\n", | ||
"\n", | ||
"By: Kevin Goebbert\n", | ||
"\n", | ||
"This example uses the declarative syntax available through the MetPy\n", | ||
"package to allow a more convenient method for creating simple maps of\n", | ||
"atmospheric data. The key thing the declarative language does is to\n", | ||
"reduce the number of packages that users will need to know in detail and\n", | ||
"instead allow them to set key parameters to get the map they desire. One\n", | ||
"key element is the use of xarray as the data object, which allows\n", | ||
"coordinate information to be associated with atmospheric variables." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from datetime import datetime\n", | ||
"\n", | ||
"import metpy.calc as mpcalc\n", | ||
"from metpy.plots.declarative import *\n", | ||
"from metpy.units import units\n", | ||
"import xarray as xr" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"cell_marker": "######################################################################" | ||
}, | ||
"source": [ | ||
"Open dataset using xarray module and subset global GFS to be over the\n", | ||
"CONUS.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds = xr.open_dataset('https://thredds.ucar.edu/thredds/dodsC/casestudies'\n", | ||
" '/python-gallery/GFS_20101026_1200.nc').sel(\n", | ||
" lon=slice(360-150, 360-50, 2), lat=slice(65, 20, 2))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"cell_marker": "######################################################################" | ||
}, | ||
"source": [ | ||
"Calculate Variable and Add to Dataset\n", | ||
"-------------------------------------\n", | ||
"\n", | ||
"Here it is demonstrated how you can calculate a new variable and add it\n", | ||
"to the xarray dataset (ds) so that it can be plotted with the\n", | ||
"declarative syntax. The key to adding a variable to an xarray dataset\n", | ||
"for use in the declarative syntax is the need to add a ``grid_mapping``\n", | ||
"and ``units`` attribute.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Calculate New Variables and place into Xarray Dataset\n", | ||
"uwnd = ds['u-component_of_wind_isobaric']\n", | ||
"vwnd = ds['v-component_of_wind_isobaric']\n", | ||
"\n", | ||
"# Compute wind speed using MetPy\n", | ||
"wspd = mpcalc.wind_speed(uwnd, vwnd)\n", | ||
"\n", | ||
"# Place wind speed (wspd) into xarray dataset and attach needed attributes\n", | ||
"ds['wind_speed'] = wspd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"cell_marker": "######################################################################" | ||
}, | ||
"source": [ | ||
"Declarative Plot\n", | ||
"----------------\n", | ||
"\n", | ||
"The following settings create a single panel map plot of 300 hPa\n", | ||
"geopotential heights, wind speed, and wind barbs.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Countour Plot of Geopotential Heights\n", | ||
"contour = ContourPlot()\n", | ||
"contour.data = ds\n", | ||
"contour.time = datetime(2010, 10, 31, 12)\n", | ||
"contour.field = 'Geopotential_height_isobaric'\n", | ||
"contour.level = 300 * units.hPa\n", | ||
"contour.linecolor = 'black'\n", | ||
"contour.linestyle = '-'\n", | ||
"contour.linewidth = 2\n", | ||
"contour.clabels = True\n", | ||
"contour.contours = list(range(0, 20000, 120))\n", | ||
"\n", | ||
"# Colorfilled Plot of Wind Speed\n", | ||
"cfill = FilledContourPlot()\n", | ||
"cfill.data = ds\n", | ||
"cfill.field = 'wind_speed'\n", | ||
"cfill.level = 300 * units.hPa\n", | ||
"cfill.colormap = 'BuPu'\n", | ||
"cfill.contours = list(range(50, 171, 20))\n", | ||
"cfill.colorbar = 'vertical'\n", | ||
"cfill.plot_units = 'kt'\n", | ||
"\n", | ||
"# Plot wind barbs\n", | ||
"barb = BarbPlot()\n", | ||
"barb.data = ds\n", | ||
"barb.level = 300 * units.hPa\n", | ||
"barb.field = ['u-component_of_wind_isobaric', 'v-component_of_wind_isobaric']\n", | ||
"barb.skip = (3, 3)\n", | ||
"barb.color = 'black'\n", | ||
"barb.barblength = 6.5\n", | ||
"barb.earth_relative = False\n", | ||
"barb.plot_units = 'kt'\n", | ||
"\n", | ||
"# Panel for plot with Map features\n", | ||
"panel = MapPanel()\n", | ||
"panel.layout = (1, 1, 1)\n", | ||
"panel.area = (-124, -72, 20, 53)\n", | ||
"panel.projection = 'lcc'\n", | ||
"panel.layers = ['coastline', 'borders', 'states', 'land']\n", | ||
"panel.plots = [cfill, contour, barb]\n", | ||
"\n", | ||
"# Bringing it all together\n", | ||
"pc = PanelContainer()\n", | ||
"pc.size = (15, 9)\n", | ||
"pc.panels = [panel]\n", | ||
"\n", | ||
"pc.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"jupytext": { | ||
"cell_metadata_filter": "-all", | ||
"main_language": "python", | ||
"notebook_metadata_filter": "-all" | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.