Commit f6ceceec authored by Carl Schreck's avatar Carl Schreck

New iteration of temp_steps.py

parent 684b73aa
......@@ -59,7 +59,8 @@ def draw_station_type(ax, path, lat_column=1, lon_column=2, time_column=6):
ax.plot(group.lon, group.lat, transform=ccrs.PlateCarree(),
marker='.', linestyle='', label=labels[type_ind],
zorder=zorders[type_ind], c=colors[type_ind])
ax.legend(labels=labels, loc='lower left')
ax.legend(labels=labels, loc='upper center', bbox_to_anchor=[0.5, 0],
ncol=2)
return asc_data
......
......@@ -28,80 +28,87 @@ station_path = f'{base_path}{var_name.upper()}19890203map.txt'
unscaled_path = f'{base_path}{var_name.upper()}_19890203_D6_A2.pnt.gz'
scaled_path = f'{base_path}{var_name.upper()}-198902-grd-scaled.nc'
levels = np.arange(-40, 35, 5)
levels = np.arange(-40, 20, 5)
# cmap = cm.get_cmap('bwr', lut=(len(levels) + 1))
cmap = 'RdBu_r'
cjs.tstamp('Here we go!')
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(6.4, 6.4),
subplot_kw={'projection': cjs.conus_projection, })
cjs.tstamp('Drawing station type')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
ax = axes[0, 0]
helpers.draw_station_type(ax, station_path)
ax.set_title('a) Station type')
plt.savefig(f'figures/{var_name}_station_type.png')
ax.set_title('a) Station type', loc='left')
ax.set_anchor('N')
cjs.tstamp('Drawing unscaled data')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
ax = axes[0, 1]
helpers.draw_station_data(ax, station_path, levels=levels, cmap=cmap)
unscaled_data = helpers.read_unscaled(unscaled_path, var_name)
plot = unscaled_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, levels=levels, zorder=1,
vmin = -np.inf, vmax = np.inf, extend = 'both',
vmin=-np.inf, vmax=np.inf, extend='both',
cbar_kwargs={'orientation': 'horizontal',
'label': '°C',
'pad': 0.05,
}
)
ax.set_title('c) Unscaled data')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_unscaled_east.png')
ax.set_title('b) Unscaled data', loc='left')
ax.set_extent([-120.0, -100.0, 35.0, 45.0])
plt.savefig(f'figures/{var_name}_unscaled_west.png')
ax.outline_patch.set_visible(True)
ax.set_anchor('N')
cjs.tstamp('Drawing scaled data')
fig, ax = plt.subplots(nrows=1, ncols=1,
subplot_kw={'projection': cjs.conus_projection})
ax = axes[1, 0]
helpers.draw_station_data(ax, station_path, levels=levels, cmap=cmap)
scaled_ds = xr.open_dataset(scaled_path)
scaled_data = scaled_ds[var_name].sel(time=time).drop('time')
plot = scaled_data.plot(ax=ax, transform=ccrs.PlateCarree(),
add_colorbar=True,
cmap=cmap, levels=levels, zorder=1,
vmin=-np.inf, vmax=np.inf, extend='both'
vmin=-np.inf, vmax=np.inf, extend='both',
cbar_kwargs={'orientation': 'horizontal',
'label': '°C',
'pad': 0.05,
}
)
ax.set_title('d) Scaled data')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_scaled_east.png')
ax.set_title('c) Scaled data', loc='left')
ax.set_extent([-120.0, -100.0, 35.0, 45.0])
plt.savefig(f'figures/{var_name}_scaled_west.png')
ax.outline_patch.set_visible(True)
ax.set_anchor('N')
cjs.tstamp('Drawing difference data')
ax = axes[1, 1]
levels = np.arange(-6, 7, 1)
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, levels=levels, zorder=1,
vmin = -np.inf, vmax = np.inf, extend = 'both',
vmin=-np.inf, vmax=np.inf, extend='both',
cbar_kwargs={'orientation': 'horizontal',
'label': '°C',
'pad': 0.05,
}
)
ax.set_title('d) Scaled minus unscaled')
plt.savefig(f'figures/{var_name}_diff_conus.png')
ax.set_extent([-100.0, -80.0, 30.0, 40.0])
plt.savefig(f'figures/{var_name}_diff_east.png')
ax.set_extent([-120.0, -100.0, 35.0, 45.0])
plt.savefig(f'figures/{var_name}_diff_west.png')
ax.set_title('d) Scaled minus unscaled', loc='left')
ax.set_anchor('N')
# 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(levels=levels, cmap=cmap), extend='both',
# fig.colorbar(plot, extend='both',
# cax=cbar_ax,
# orientation='horizontal')
#
cjs.tstamp('Drawing figure')
plt.tight_layout()
plt.savefig('figures/temp_steps.png')
plt.show()
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