Commit d75b58c9 authored by Carl Schreck's avatar Carl Schreck

Automated Daily Commit - Mon Apr 27 12:00:21 EDT 2020

parent eb5efdd4
......@@ -28,7 +28,8 @@ def draw_station_data(ax, path, lat_column=1, lon_column=2, data_column=5,
data = asc_data[data_column]
plot = ax.scatter(x=lon, y=lat, c=data, norm=norm, cmap=cmap, zorder=2,
transform=ccrs.PlateCarree(), marker='.')
transform=ccrs.PlateCarree(), marker='.',
edgecolors='black')
return plot
def draw_station_type(ax, path, lat_column=1, lon_column=2, time_column=6):
......@@ -104,15 +105,15 @@ def read_unscaled(path, var_name, lat_column=0, lon_column=1, data_column=4,):
# path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
# f'TMAX19890203map.txt'
path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
f'TMAX_19890203_D6_A2.pnt.gz'
var_name = 'tmax'
bounds=np.arange(-30, 35, 5)
cmap = cm.get_cmap('bwr', lut=(len(bounds) + 1))
norm = mpl.colors.BoundaryNorm(bounds, cmap.N, clip=False)
# station_plot = draw_station_type(path, cmap=cmap, norm=norm)
# station_plot = draw_station_type(path)
# plt.colorbar(station_plot)
# plt.show()
data = read_unscaled(path, var_name)
\ No newline at end of file
# path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
# f'TMAX_19890203_D6_A2.pnt.gz'
# var_name = 'tmax'
#
# bounds=np.arange(-30, 35, 5)
# cmap = cm.get_cmap('bwr', lut=(len(bounds) + 1))
# norm = mpl.colors.BoundaryNorm(bounds, cmap.N, clip=False)
# # station_plot = draw_station_type(path, cmap=cmap, norm=norm)
# # station_plot = draw_station_type(path)
# # plt.colorbar(station_plot)
# # plt.show()
# data = read_unscaled(path, var_name)
\ No newline at end of file
......@@ -33,50 +33,77 @@ cmap = cm.get_cmap('bwr', lut=(len(levels) + 1))
norm = mpl.colors.BoundaryNorm(levels, cmap.N, clip=False)
cjs.tstamp('Here we go!')
fig, ax = plt.subplots(nrows=2, ncols=2,
subplot_kw={'projection': cjs.conus_projection})
cjs.tstamp('Drawing station type')
helpers.draw_station_type(ax[0, 0], station_path)
ax[0, 0].set_title('a) Station type')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
helpers.draw_station_type(ax, station_path)
ax.set_title('a) Station type')
plt.savefig(f'figures/{var_name}_station_type.png')
cjs.tstamp('Drawing station data')
helpers.draw_station_data(ax[0, 1], station_path, norm=norm, cmap=cmap)
ax[0, 1].set_title('b) Station data')
ax.set_title('b) Station data')
plt.savefig(f'figures/{var_name}_scaled.png')
cjs.tstamp('Drawing unscaled data')
plt.gca().outline_patch.set_visible(False)
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
helpers.draw_station_data(ax, station_path, norm=norm, cmap=cmap)
unscaled_data = helpers.read_unscaled(unscaled_path, var_name)
cjs.add_conus_map(ax=ax[1, 0])
plot = unscaled_data.plot(ax=ax[1, 0], transform=ccrs.PlateCarree(),
add_colorbar=False,
cmap=cmap, norm=norm, zorder=2)
ax[1, 0].set_title('c) Unscaled data')
plot = unscaled_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, norm=norm, zorder=1)
ax.set_title('c) Unscaled data')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_unscaled.png')
cjs.tstamp('Drawing scaled data')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
helpers.draw_station_data(ax, station_path, norm=norm, cmap=cmap)
scaled_ds = xr.open_dataset(scaled_path)
scaled_data = scaled_ds[var_name].sel(time=time).drop('time')
cjs.add_conus_map(ax=ax[1, 1])
plot = scaled_data.plot(ax=ax[1, 1], transform=ccrs.PlateCarree(),
add_colorbar=False,
cmap=cmap, norm=norm, zorder=2)
ax[1, 1].set_title('d) Scaled data')
cjs.tstamp('Add colorbar')
fig.subplots_adjust(bottom=0.2)
cbar_ax = fig.add_axes([0.15, 0.05, 0.80, 0.03])
fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), extend='both',
cax=cbar_ax,
orientation='horizontal')
ax[0, 0].set_extent([-100.0, -80.0, 30.0, 40.0])
ax[0, 1].set_extent([-100.0, -80.0, 30.0, 40.0])
ax[1, 0].set_extent([-100.0, -80.0, 30.0, 40.0])
ax[1, 1].set_extent([-100.0, -80.0, 30.0, 40.0])
cjs.tstamp('Drawing')
plt.savefig(f'figures/{var_name}_steps.png')
plt.show()
plot = scaled_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, norm=norm, zorder=1)
ax.set_title('d) Scaled data')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_scaled.png')
cjs.tstamp('Drawing difference data')
levels = np.arange(-6, 7, 1)
cmap = cm.get_cmap('bwr', lut=(len(levels) + 1))
norm = mpl.colors.BoundaryNorm(levels, cmap.N, clip=False)
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
cjs.add_conus_map(ax=ax)
diff_data = scaled_data - unscaled_data
plot = diff_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, norm=norm, zorder=1)
ax.set_title('d) Scaled minus unscaled')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_diff_zoom.png')
cjs.tstamp('Drawing difference data')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
cjs.add_conus_map(ax=ax)
diff_data = scaled_data - unscaled_data
plot = diff_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, norm=norm, zorder=1)
ax.set_title('d) Scaled minus unscaled')
plt.savefig(f'figures/{var_name}_diff_wide.png')
# cjs.tstamp('Add colorbar')
# fig.subplots_adjust(bottom=0.2)
# cbar_ax = fig.add_axes([0.15, 0.05, 0.80, 0.03])
# fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), extend='both',
# cax=cbar_ax,
# orientation='horizontal')
#
cjs.tstamp('Thank you, come again.')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment