{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9e1e1ed7-f656-41e4-bc55-759247b05ee9", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "id": "56d5fdff", "metadata": {}, "source": [ "Download NCEP GFS 1 degree data file via OpenDAP\n", "\n", "extract a number of fields at 300, 500 hPa, and surface\n", "\n", "Calculate 500 hPa vorticity field\n", "\n", "Plot the fields in 4 different figures\n", "\n", "https://unidata.github.io/python-training/gallery/500hpa_absolute_vorticity_winds/ is a helfpul example" ] }, { "cell_type": "code", "execution_count": 2, "id": "dc654702-a22c-4914-9a5c-c26d5f0e4b17", "metadata": {}, "outputs": [], "source": [ "###########################################\n", "import cartopy.crs as ccrs\n", "import cartopy.feature as cfeature\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy.ndimage as ndimage\n", "import xarray as xr\n", "\n", "import metpy.calc as mpcalc\n", "from metpy.units import units\n", "\n", "from metpy.cbook import get_test_data\n", "from metpy.plots import add_metpy_logo\n", "\n", "from IPython.display import display,clear_output\n", "import os\n", "from datetime import datetime\n", "\n", "###########################################\n", "\n", "# Open the example netCDF data\n", "#ds = xr.open_dataset(get_test_data('gfs_output.nc', False))\n", "\n", "#ds = xr.open_dataset('/home/jovyan/GetGFS/gfs.20220223t00z.1p00.f012.nc')\n", "#ds = xr.open_dataset('/home/jovyan/GetGFS/gfs.20220223t00z.0p25.f012.grb2.nc')" ] }, { "cell_type": "markdown", "id": "48a4870f-0f1e-4742-9208-14b3824c6465", "metadata": {}, "source": [ "Open GFS forecasts using OpenDAP server directly. See \n", "https://earthdata.nasa.gov/collaborate/open-data-services-and-software/api/opendap" ] }, { "cell_type": "code", "execution_count": 3, "id": "d9d6f2f8-a015-4847-9461-9f0ab46a1c09", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.9/site-packages/xarray/coding/times.py:144: SerializationWarning: Ambiguous reference date string: 1-1-1 00:00:0.0. The first value is assumed to be the year hence will be padded with zeros to remove the ambiguity (the padded reference date string is: 0001-1-1 00:00:0.0). To remove this message, remove the ambiguity by padding your reference date strings with zeros.\n", " warnings.warn(warning_msg, SerializationWarning)\n" ] }, { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 129, lev: 41, lat: 181, lon: 360)\n", "Coordinates:\n", " * time (time) datetime64[ns] 2022-03-22 ... 2022-04-07\n", " * lev (lev) float64 1e+03 975.0 950.0 925.0 ... 0.04 0.02 0.01\n", " * lat (lat) float64 -90.0 -89.0 -88.0 -87.0 ... 88.0 89.0 90.0\n", " * lon (lon) float64 0.0 1.0 2.0 3.0 ... 356.0 357.0 358.0 359.0\n", "Data variables: (12/215)\n", " absvprs (time, lev, lat, lon) float32 ...\n", " no4lftxsfc (time, lat, lon) float32 ...\n", " acpcpsfc (time, lat, lon) float32 ...\n", " albdosfc (time, lat, lon) float32 ...\n", " apcpsfc (time, lat, lon) float32 ...\n", " capesfc (time, lat, lon) float32 ...\n", " ... ...\n", " vwshneg2pv (time, lat, lon) float32 ...\n", " vwshtrop (time, lat, lon) float32 ...\n", " watrsfc (time, lat, lon) float32 ...\n", " weasdsfc (time, lat, lon) float32 ...\n", " wiltsfc (time, lat, lon) float32 ...\n", " var00212m (time, lat, lon) float32 ...\n", "Attributes:\n", " title: GFS 1.0 deg starting from 00Z22mar2022, downloaded Mar 22 0...\n", " Conventions: COARDS\\nGrADS\n", " dataType: Grid\n", " history: Wed Mar 23 04:43:37 UTC 2022 : imported by GrADS Data Serve...
<xarray.DataArray 'hgtprs' (time: 129, lat: 81, lon: 360)>\n", "[3761640 values with dtype=float32]\n", "Coordinates:\n", " * time (time) datetime64[ns] 2022-03-22 2022-03-22T03:00:00 ... 2022-04-07\n", " lev float64 300.0\n", " * lat (lat) float64 10.0 11.0 12.0 13.0 14.0 ... 86.0 87.0 88.0 89.0 90.0\n", " * lon (lon) float64 0.0 1.0 2.0 3.0 4.0 ... 355.0 356.0 357.0 358.0 359.0\n", "Attributes:\n", " long_name: ** (1000 975 950 925 900.. 10 7 4 2 1) geopotential height [g...