Skip to content

Instantly share code, notes, and snippets.

@scollis
Created May 8, 2020 18:41
Show Gist options
  • Save scollis/e7bbc206988e73987677f5837d75c040 to your computer and use it in GitHub Desktop.
Save scollis/e7bbc206988e73987677f5837d75c040 to your computer and use it in GitHub Desktop.
Quick and dirty plot of GridSat using XArray
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import xarray as xr
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
import urllib
import tempfile
url1 = "https://www.ncei.noaa.gov/thredds/fileServer/satellite/gridsat-goes-conus/2011/04/GridSat-CONUS.goes13.2011.04.25.0915.v01.nc"
mytfile = tempfile.NamedTemporaryFile()
urllib.request.urlretrieve(url1, mytfile.name)
ds = xr.open_dataset(mytfile.name)
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='50m',
facecolor='none')
myf = plt.figure(figsize = [15,10])
ax = plt.subplot(projection=ccrs.PlateCarree())
ds['ch3'].plot(ax=ax, x='lon', y='lat', transform=ccrs.PlateCarree(),
cmap='plasma_r', vmin = 210, vmax = 250)
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=2, color='gray', alpha=0.5, linestyle='--')
ax.coastlines('10m', color='r')
ax.add_feature(states_provinces, edgecolor='gray')
plt.xlim(-100, -92)
ax.plot(-97.4882, 36.6077, 'or', transform=ccrs.PlateCarree())
ax.annotate('ARM SGP Site', xy=(-97.4882 + .5, 36.6077 - .2), xycoords=ccrs.PlateCarree()._as_mpl_transform(ax),
ha='right', va='top', fontsize=14, fontweight='bold')
plt.ylim(33,39)
gl.xlabels_top = False
gl.ylabels_left = False
plt.grid() #36.6077° N, 97.4882° W
plt.savefig('GOES.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment