diff --git a/modules/util/plot.py b/modules/util/plot.py index 66b33daa3cfc50d0985d0163811540648fd2cbd1..2f18d5a3452fbd60900193134603cdd1902b6d80 100644 --- a/modules/util/plot.py +++ b/modules/util/plot.py @@ -11,6 +11,7 @@ import tensorflow as tf import matplotlib import matplotlib.pyplot as plt import cartopy.crs as ccrs +import xarray as xr import os from util.setup import home_dir @@ -196,4 +197,23 @@ def plot_image2(image, cmap='Greys'): # Wrap up fig.clf() # Otherwise fig stays open every time - plt.close() # Close current figure \ No newline at end of file + plt.close() # Close current figure + + +# Example GOES file to retrieve GEOS parameters in MetPy form (CONUS) +exmp_file = '/Users/tomrink/data/OR_ABI-L1b-RadC-M6C14_G16_s20193140811215_e20193140813588_c20193140814070.nc' + + +def plot_image3(image, cmap='Greys'): + exmpl_ds = xr.open_dataset(exmp_file) + mdat = exmpl_ds.metpy.parse_cf('Rad') + geos = mdat.metpy.cartopy_crs + x = mdat.x + y = mdat.y + + fig = plt.figure(figsize=(15, 12)) + ax = fig.add_subplot(1, 1, 1, projection=geos) + ax.imshow(image, origin='upper', extent=(x.min(), x.max(), y.min(), y.max()), transform=geos) + ax.coastlines(resolution='50m', color='black', linewidth=0.25) + ax.add_feature(ccrs.cartopy.feature.STATES, linewidth=0.25) + plt.title('GOES-16', loc='left', fontweight='bold', fontsize=15)