This file contains hidden or 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
| import matplotlib.pyplot as plt | |
| from mpl_toolkits.axes_grid1 import make_axes_locatable | |
| data1 = np.random.random([5,5]) | |
| data2 = np.random.random([5,5]) | |
| fig = plt.figure(1, figsize=[16, 4]) | |
| ax1 = fig.add_subplot(121) | |
| ax2 = fig.add_subplot(122) | |
| this_plot = ax1.pcolormesh(data1, cmap='magma') |
This file contains hidden or 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
| # Method 1: when you are using plt | |
| from matplotlib.dates import DateFormatter | |
| formatter = DateFormatter('%Y-%m-%d %H:%M:%S') | |
| plt.gcf().axes[0].xaxis.set_major_formatter(formatter) | |
| # Method 2: when you have already axessed the axes | |
| from matplotlib.dates import DateFormatter | |
| formatter = DateFormatter('%Y-%m-%d %H:%M:%S') | |
| ax1.xaxis.set_major_formatter(formatter) |
This file contains hidden or 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
| # Brian Blaylock | |
| # March 24, 2017 Yesterday Salt Lake had lots of rain | |
| """ | |
| Fast download of HRRR grib2 files with threading | |
| """ | |
| from queue import Queue | |
| from threading import Thread | |
| from datetime import datetime, timedelta |
This file contains hidden or 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
| # Brian Blaylock | |
| # March 14, 2017 It's Pi Day!! (3.14) | |
| """ | |
| Get data from a HRRR grib2 file on the MesoWest HRRR S3 Archive | |
| Requires cURL on your linux system | |
| """ | |
| import os |
This file contains hidden or 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
| # Brian Blaylock | |
| # March 10, 2017 | |
| # updated: July 26, 2017 | |
| """ | |
| Download a single variable from the HRRR archive using cURL | |
| Steps: | |
| 1) Read the lines from the Metadata .idx file | |
| 2) Identify the byte range for the variable of interest |
This file contains hidden or 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
| # Brian Blaylock | |
| # February 13, 2018 | |
| # Updated December 10, 2018 for Python 3 | |
| """ | |
| Download archived HRRR files from MesoWest Pando S3 archive system. | |
| Please register before downloading from our HRRR archive: | |
| http://hrrr.chpc.utah.edu/hrrr_download_register.html |
This file contains hidden or 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
| # More here: http://matplotlib.org/api/legend_api.html | |
| # No boarder, transparent frame | |
| legend = ax1.legend(frameon=True, framealpha=.5) | |
| legend.get_frame().set_linewidth(0) | |
| # Limit scatterpoints in legend | |
| plt.legend(scatterpoints=1) |
This file contains hidden or 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
| # Greek Letters | |
| plt.title(r'$\theta$') | |
| plt.title(r'$\alpha$') | |
| plt.title(r'$\Delta$') | |
| # Superscript (wind speed m/s) | |
| plt.ylabel(r'Wind Speed (m s$\mathregular{^{-1}}$)') | |
| # Subscript (CO_2, theta_surface) | |
| plt.ylabel(r'CO$_2$ (ppm)') |
This file contains hidden or 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
| from datetime import datetime, timedelta | |
| # create a list of dates from a starting date for a certian number of hours | |
| base = datetime(2017, 5, 10) | |
| hours = 36 | |
| DATES = np.array([base + timedelta(hours=x) for x in range(0, hours)]) | |
| # create a list of datetimes between two dates for each hour | |
| sDATE = datetime(2017, 5, 10) | |
| eDATE = datetime(2017, 5, 12) |
This file contains hidden or 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
| import os | |
| DIR = '/this/is/the/directory/name/' | |
| if not os.path.exists(DIR): | |
| os.makedirs(DIR) |