Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #343 from jrleeman/post_jsu_cleanup
Browse files Browse the repository at this point in the history
Post jsu cleanup
  • Loading branch information
jrleeman authored Sep 28, 2018
2 parents 0b0f636 + 1f3e6bb commit 9ca4df0
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
matrix:
- Python=3.5
- Python=3.6
- Python=3.7

before_install:
# Taken from: http://conda.pydata.org/docs/travis.html
Expand All @@ -33,7 +34,7 @@ before_install:
- conda update -q conda
- conda install -q pyyaml
- conda info -a
- sed -i -e "s/python=3.6/python=$Python/" environment.yml
- sed -i -e "s/python=3/python=$Python/" environment.yml

install:
- conda env create -q -f environment.yml
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:

matrix:
- PYTHON_VERSION: "3.6"
- PYTHON_VERSION: "3.7"

platform:
- x64
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
channels:
- conda-forge
dependencies:
- python=3.6
- python=3
- numpy
- nomkl
- matplotlib
- cartopy
- jupyter
Expand Down
51 changes: 39 additions & 12 deletions notebooks/MetPy_Advanced/Isentropic Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"metadata": {},
"outputs": [],
"source": [
"isen_level = np.array([295]) * units.kelvin\n",
"isen_level = np.array([320]) * units.kelvin\n",
"isen_press, isen_u, isen_v = mpcalc.isentropic_interpolation(isen_level, press,\n",
" temperature, u, v)"
]
Expand Down Expand Up @@ -234,6 +234,7 @@
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import cartopy.crs as ccrs\n",
"import cartopy.feature as cfeature\n",
"\n",
"# Create a plot and basic map projection\n",
"fig = plt.figure(figsize=(14, 8))\n",
Expand All @@ -245,18 +246,24 @@
"levels = np.arange(300, 1000, 25)\n",
"cntr = ax.contour(lon, lat, isen_press, transform=ccrs.PlateCarree(),\n",
" colors='black', levels=levels)\n",
"ax.clabel(cntr, fmt='%.0f')\n",
"ax.clabel(cntr, fmt='%d')\n",
"\n",
"# Set up slices to subset the wind barbs--the slices below are the same as `::5`\n",
"# We put these here so that it's easy to change and keep all of the ones below matched\n",
"# up.\n",
"lon_slice = slice(None, None, 5)\n",
"lat_slice = slice(None, None, 5)\n",
"lat_slice = slice(None, None, 3)\n",
"ax.barbs(lon[lon_slice], lat[lat_slice],\n",
" isen_u[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_v[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_u[lat_slice, lon_slice].to('knots').magnitude,\n",
" isen_v[lat_slice, lon_slice].to('knots').magnitude,\n",
" transform=ccrs.PlateCarree(), zorder=2)\n",
"\n",
"ax.add_feature(cfeature.LAND)\n",
"ax.add_feature(cfeature.OCEAN)\n",
"ax.add_feature(cfeature.COASTLINE)\n",
"ax.add_feature(cfeature.BORDERS, linewidth=2)\n",
"ax.add_feature(cfeature.STATES, linestyle=':')\n",
"\n",
"ax.set_extent((-120, -70, 25, 55), crs=ccrs.PlateCarree())"
]
},
Expand Down Expand Up @@ -313,19 +320,26 @@
"levels = np.arange(300, 1000, 25)\n",
"cntr = ax.contour(lon, lat, isen_press, transform=ccrs.PlateCarree(),\n",
" colors='black', levels=levels)\n",
"ax.clabel(cntr, fmt='%.0f')\n",
"ax.clabel(cntr, fmt='%d')\n",
"\n",
"lon_slice = slice(None, None, 8)\n",
"lat_slice = slice(None, None, 8)\n",
"ax.barbs(lon[lon_slice], lat[lat_slice],\n",
" isen_u[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_v[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_u[lat_slice, lon_slice].to('knots').magnitude,\n",
" isen_v[lat_slice, lon_slice].to('knots').magnitude,\n",
" transform=ccrs.PlateCarree(), zorder=2)\n",
"\n",
"#\n",
"# YOUR CODE: Contour/Contourf the mixing ratio values\n",
"#\n",
"\n",
"\n",
"ax.add_feature(cfeature.LAND)\n",
"ax.add_feature(cfeature.OCEAN)\n",
"ax.add_feature(cfeature.COASTLINE)\n",
"ax.add_feature(cfeature.BORDERS, linewidth=2)\n",
"ax.add_feature(cfeature.STATES, linestyle=':')\n",
"\n",
"ax.set_extent((-120, -70, 25, 55), crs=ccrs.PlateCarree())"
]
},
Expand Down Expand Up @@ -367,20 +381,26 @@
"levels = np.arange(300, 1000, 25)\n",
"cntr = ax.contour(lon, lat, isen_press, transform=ccrs.PlateCarree(),\n",
" colors='black', levels=levels)\n",
"ax.clabel(cntr, fmt='%.0f')\n",
"ax.clabel(cntr, fmt='%d')\n",
"\n",
"lon_slice = slice(None, None, 8)\n",
"lat_slice = slice(None, None, 8)\n",
"ax.barbs(lon[lon_slice], lat[lat_slice],\n",
" isen_u[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_v[lon_slice, lat_slice].to('knots').magnitude,\n",
" isen_u[lat_slice, lon_slice].to('knots').magnitude,\n",
" isen_v[lat_slice, lon_slice].to('knots').magnitude,\n",
" transform=ccrs.PlateCarree(), zorder=2)\n",
"\n",
"\\# Contourf the mixing ratio values\n",
"mixing_levels = [0.001, 0.002, 0.004, 0.006, 0.010, 0.012, 0.014, 0.016, 0.020]\n",
"ax.contourf(lon, lat, isen_mixing, transform=ccrs.PlateCarree(),\n",
" levels=mixing_levels, cmap='YlGn')\n",
"\n",
"ax.add_feature(cfeature.LAND)\n",
"ax.add_feature(cfeature.OCEAN)\n",
"ax.add_feature(cfeature.COASTLINE)\n",
"ax.add_feature(cfeature.BORDERS, linewidth=2)\n",
"ax.add_feature(cfeature.STATES, linestyle=':')\n",
"\n",
"ax.set_extent((-120, -70, 25, 55), crs=ccrs.PlateCarree())\n",
"</pre></code>\n",
"</div>"
Expand Down Expand Up @@ -482,7 +502,7 @@
"\n",
"levels = np.arange(300, 1000, 25)\n",
"cntr = ax.contour(lon, lat, isen_press, transform=ccrs.PlateCarree(), colors='black', levels=levels)\n",
"ax.clabel(cntr, fmt='%.0f')\n",
"ax.clabel(cntr, fmt='%d')\n",
"\n",
"lon_slice = slice(None, None, 5)\n",
"lat_slice = slice(None, None, 5)\n",
Expand All @@ -500,6 +520,13 @@
"</pre></code>\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion notebooks/Metpy_Introduction/Introduction to MetPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"metadata": {},
"source": [
"### Temperature\n",
"Temperature units are actually relatively tricky (more like absolutely tricky as you'll see). Temperature is a non-multiplicative unit - they are in a system with a reference point. That means that not only is there a scaling factor, but also an offset. This makes the math and unit book-keeping a little more complex. Imagine adding 10 degrees Celsius to 100 degrees Celsius. Is the answer 110 degrees Celsius or 383.15 degrees Celsius (283.15 K + 272.15 K)? That's why there are delta degrees units in the unit registry for offset units. For more examples and explanation you can watch [MetPy Monday #13](https://www.youtube.com/watch?v=iveJCqxe3Z4).\n",
"Temperature units are actually relatively tricky (more like absolutely tricky as you'll see). Temperature is a non-multiplicative unit - they are in a system with a reference point. That means that not only is there a scaling factor, but also an offset. This makes the math and unit book-keeping a little more complex. Imagine adding 10 degrees Celsius to 100 degrees Celsius. Is the answer 110 degrees Celsius or 383.15 degrees Celsius (283.15 K + 373.15 K)? That's why there are delta degrees units in the unit registry for offset units. For more examples and explanation you can watch [MetPy Monday #13](https://www.youtube.com/watch?v=iveJCqxe3Z4).\n",
"\n",
"Let's take a look at how this works and fails:"
]
Expand Down
11 changes: 1 addition & 10 deletions notebooks/Model_Output/Downloading model fields with NCSS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds['time']"
"ds['time1']"
]
},
{
Expand Down Expand Up @@ -257,13 +257,6 @@
"cax.set_label(var.attrs['units'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -481,9 +474,7 @@
"metadata": {},
"outputs": [],
"source": [
"from metpy.calc import lcl, dry_lapse, parcel_profile\n",
"from metpy.plots import SkewT\n",
"from metpy.units import concatenate\n",
"\n",
"# Create a new figure. The dimensions here give a good aspect ratio\n",
"fig = plt.figure(figsize=(9, 9))\n",
Expand Down
19 changes: 13 additions & 6 deletions notebooks/NumPy/Numpy Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@
}
},
"source": [
"Indexing in Python is 0-based, so the command below looks for the 2nd item along the first dimension (row) and the 3rd along the second dimension (column)."
"Indexing in Python is 0-based, so the command below looks for the 2nd item along the first dimension (row) and the 3rd along the second dimension (column).\n",
"\n",
"![](array_index.png)"
]
},
{
Expand Down Expand Up @@ -670,7 +672,7 @@
"Slicing syntax is written as `start:stop[:step]`, where all numbers are optional.\n",
"- defaults: \n",
" - start = 0\n",
" - end = len(dim)\n",
" - stop = len(dim)\n",
" - step = 1\n",
"- The second colon is also optional if no step is used.\n",
"\n",
Expand Down Expand Up @@ -753,10 +755,15 @@
"The goal of this tutorial is to provide an overview of the use of the NumPy library. It tries to hit all of the important parts, but it is by no means comprehensive. For more information, try looking at the:\n",
"- [Tentative NumPy Tutorial](http://wiki.scipy.org/Tentative_NumPy_Tutorial)\n",
"- [NumPy User Guide](http://docs.scipy.org/doc/numpy/user/)\n",
"- [Introduction to NumPy from SAM](http://www.sam.math.ethz.ch/~raoulb/teaching/PythonTutorial/intro_numpy.html)\n",
"- [Matplotlib Documentation](http://matplotlib.org)\n",
"- [Matplotlib `plot` documentation](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot)"
"- [Introduction to NumPy from SAM](http://www.sam.math.ethz.ch/~raoulb/teaching/PythonTutorial/intro_numpy.html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -775,7 +782,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
Binary file added notebooks/NumPy/array_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion notebooks/Satellite_Data/Working with Satellite Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"\n",
"The first step is to find the satellite data. Normally, we would browse over to http://thredds.ucar.edu/thredds/ and find the top-level [THREDDS Data Server (TDS)](https://www.unidata.ucar.edu/software/thredds/current/tds/TDS.html) catalog. From there we can drill down to find satellite data products.\n",
"\n",
"For this tutorial, we want to utilize the new GOES-16 imagery. This is found at http://thredds-test.unidata.ucar.edu/. For current data, you could navigate to the `Test Datasets` directory, then `GOES-16 Products` and `GOES-16`. There are subfolders for the CONUS, full disk, mesoscale sector images, and other products. In each of these is a folder for each [channel of the ABI](http://www.goes-r.gov/education/ABI-bands-quick-info.html). In each channel there is a folder for every day in the month-long rolling archive. As you can see, there is a massive amount of data coming down from GOES-16! For the workshop we will be using archived case study data from Irma located at [http://thredds-test.unidata.ucar.edu/thredds/catalog/casestudies/irma/goes16](http://thredds-test.unidata.ucar.edu/thredds/catalog/casestudies/irma/goes16).\n",
"For this tutorial, we want to utilize the new GOES-16 imagery. This is found at http://thredds-test.unidata.ucar.edu/. For current data, you could navigate to the `Test Datasets` directory, then `GOES-16 Products` and `GOES-16`. There are subfolders for the CONUS, full disk, mesoscale sector images, and other products. In each of these is a folder for each [channel of the ABI](http://www.goes-r.gov/education/ABI-bands-quick-info.html). In each channel there is a folder for every day in the month-long rolling archive. As you can see, there is a massive amount of data coming down from GOES-16! For the workshop we will be using archived case study data from Irma located at [http://thredds-test.unidata.ucar.edu/thredds/catalog/casestudies/irma/goes16/catalog.html](http://thredds-test.unidata.ucar.edu/thredds/catalog/casestudies/irma/goes16/catalog.html).\n",
"\n",
"We could download the files to our computers from here, but that can become tedious for downloading many files, requires us to store them on our computer, and does not lend itself to automation.\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/Siphon/Siphon Overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"outputs": [],
"source": [
"from datetime import datetime, timedelta\n",
"request_time = datetime(date.year, date.month, date.day, 18, 30)\n",
"request_time = date.replace(hour=18, minute=30)\n",
"ds = cat.datasets.filter_time_nearest(request_time)\n",
"ds"
]
Expand Down Expand Up @@ -172,7 +172,7 @@
"<code><pre>\n",
"date = datetime.utcnow() - timedelta(days=1)\n",
"cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/satellite/SFC-T/SUPER-NATIONAL_1km/{dt:%Y%m%d}/catalog.xml'.format(dt=date))\n",
"request_time = datetime(date.year, date.month, date.day, 12, 0)\n",
"request_time = date.replace(hour=12, minute=0, second=0)\n",
"datasets = cat.datasets.filter_time_range(request_time, request_time + timedelta(hours=6))\n",
"print(datasets)\n",
"</pre></code>\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/Skew_T/Hodograph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"<a name=\"upperairdata\"></a>\n",
"## Obtain upper air data\n",
"\n",
"Just as we learned in the siphon basics and upper air and skew-T notebook, we need to obtain upperair data to plot. We are going to stick with September 10, 2017 at 00Z for Key West, Fl. If you need a review on obtaining upper air data, please review those lessons."
"Just as we learned in the siphon basics and upper air and skew-T notebook, we need to obtain upperair data to plot. We are going to get a sounding from October 4, 1998 00Z at Norman, OK. If you need a review on obtaining upper air data, please review those lessons."
]
},
{
Expand Down
13 changes: 5 additions & 8 deletions notebooks/Surface_Data/Surface Data with Siphon and MetPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"source": [
"import numpy as np\n",
"\n",
"from metpy.calc import wind_components\n",
"import metpy.calc as mpcalc\n",
"from metpy.units import units\n",
"\n",
"# Since we used the CSV data, this is just a dictionary of arrays\n",
Expand All @@ -177,7 +177,7 @@
"alt = data['altimeter_setting']\n",
"\n",
"# Convert wind to components\n",
"u, v = wind_components(data['wind_speed'], data['wind_direction'] * units.degree)\n",
"u, v = mpcalc.wind_components(data['wind_speed'], data['wind_direction'] * units.degree)\n",
"\n",
"# Need to handle missing (NaN) and convert to proper code\n",
"cloud_cover = 8 * data['sky_coverage'] / 100.\n",
Expand Down Expand Up @@ -220,8 +220,7 @@
"import cartopy.feature as cfeature\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from metpy.plots import StationPlot\n",
"from metpy.plots.wx_symbols import sky_cover\n",
"from metpy.plots import StationPlot, sky_cover\n",
"\n",
"# Set up a plot with map features\n",
"fig = plt.figure(figsize=(12, 12))\n",
Expand Down Expand Up @@ -258,14 +257,12 @@
"metadata": {},
"outputs": [],
"source": [
"from metpy.calc import reduce_point_density\n",
"\n",
"# Project points so that we're filtering based on the way the stations are laid out on the map\n",
"proj = ccrs.Stereographic(central_longitude=-95, central_latitude=35)\n",
"xy = proj.transform_points(ccrs.PlateCarree(), lons, lats)\n",
"\n",
"# Reduce point density so that there's only one point within a 200km circle\n",
"mask = reduce_point_density(xy, 200000)"
"mask = mpcalc.reduce_point_density(xy, 200000)"
]
},
{
Expand Down Expand Up @@ -351,7 +348,7 @@
"<div id=\"sol1\" class=\"collapse\">\n",
"<code><pre>\n",
"# Use reduce_point_density\n",
"mask = reduce_point_density(xy, 75000)\n",
"mask = mpcalc.reduce_point_density(xy, 75000)\n",
"\n",
"\\# Set up a plot with map features\n",
"fig = plt.figure(figsize=(12, 12))\n",
Expand Down

0 comments on commit 9ca4df0

Please sign in to comment.