Commit a95ad306 authored by Carl Schreck's avatar Carl Schreck

Near-final version of station_type.py

parent a6034384
......@@ -45,9 +45,9 @@ def draw_station_type(ax, path, lat_column=2, lon_column=3, time_column=7):
obs_time = asc_data[time_column]
network = asc_data[0].str[2]
labels = ['RAWS', 'SNOTEL', 'NWS Midnight', 'NWS Morning']
zorders = np.array([4, 5, 3, 2]) + 5
colors = cjs.tab[[0, 3, 2, 1]]
markersize = [1, 1, 2, 1]
zorders = np.array([4, 5, 6, 2]) + 5
colors = cjs.tab[[3, 2, 0, 1]]
markersize = [2, 1, 2, 1]
station_type = np.full(lat.shape, fill_value=3)
station_type = np.where(network == 'R', 0, station_type)
station_type = np.where(network == 'S', 1, station_type)
......@@ -57,10 +57,10 @@ def draw_station_type(ax, path, lat_column=2, lon_column=3, time_column=7):
df = pd.DataFrame(dict(lon=lon, lat=lat, station_type=station_type))
groups = df.groupby('station_type')
for type_ind, group in groups:
plot = ax.plot(group.lon, group.lat, transform=ccrs.PlateCarree(),
marker='.', markersize=markersize[type_ind],
linestyle='', label=labels[type_ind],
zorder=zorders[type_ind], c=colors[type_ind])
ax.plot(group.lon, group.lat, transform=ccrs.PlateCarree(),
marker='.', markersize=markersize[type_ind],
linestyle='', label=labels[type_ind],
zorder=zorders[type_ind], c=colors[type_ind])
# ax.legend(labels=labels, loc='upper center', bbox_to_anchor=[0.5, 0],
# ncol=2)
return None
......
......@@ -13,37 +13,46 @@ import helpers
# These are some parameters that could be useful to have up top
base_path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/stn-maps/'
var_names = np.array(['PRCP', 'TMAX'])
var_names = np.array(['TMAX', 'PRCP'])
dates = np.array(['19510101', '20091106', '20191231'])
var_name_to_long_name = {
'TMAX': 'Maximum Temperature',
'PRCP': 'Precipitation',
}
var_name_to_time_column = {
'TMAX': 7,
'PRCP': 8,
}
cjs.tstamp('Here we go!')
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(6.4, 8.0),
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(6.4, 6.4),
subplot_kw={'projection': cjs.conus_projection, })
i = 0
for var_name in var_names:
for date in dates:
ax = axes[date==dates, var_name==var_names][0]
station_path = f'{base_path}/{var_name}_{date}_D6_A2_time.txt'
plot = helpers.draw_station_type(ax, station_path)
plot = helpers.draw_station_type(
ax, station_path, time_column=var_name_to_time_column[var_name])
ax.set_anchor('N')
ax.set_title(f'{cjs.number_to_letter(i)}'
f'{var_name_to_long_name[var_name]}: '
f'{date[:4]}',
loc='left')
ax.set_title(f'{cjs.number_to_letter(i)}', loc='left')
i += 1
handles, labels = ax.axes.get_legend_handles_labels()
for ax, var_name in zip(axes[0], var_names):
ax.text(0.5, 1.3, var_name_to_long_name[var_name],
size='large', transform=ax.transAxes, horizontalalignment='center')
for ax, date in zip(axes[:,0], dates):
ax.text(-0.3, 0.5, date[:4], size='large', transform=ax.transAxes)
handles, labels = axes[2,0].axes.get_legend_handles_labels()
fig.legend(handles, labels, loc='lower center', ncol=4,
markerscale=10)
cjs.tstamp('Drawing figure')
plt.tight_layout()
plt.savefig(f'figures/station_type.png', dpi=200, bbox_inches="tight")
plt.savefig(f'figures/station_type.png', dpi=200)
plt.show()
cjs.tstamp('Thank you, come again.')
......
......@@ -16,7 +16,7 @@ import helpers
# These are some parameters that could be useful to have up top
parser = argparse.ArgumentParser()
parser.add_argument('--var_name', default='tavg')
parser.add_argument('--var_name', default='tmin')
args = parser.parse_args()
var_name = args.var_name
time = '1989-02-03'
......
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