Commit edb456bc authored by Carl Schreck's avatar Carl Schreck

Working on Imke's figures... Added scatter plot of station data.

parent bb2b117e
""" Helpers to make plots for Imke's nClimGrid-Daily paper. """
__author__ = "Carl Schreck"
__email__ = ""
__copyright__ = "Copyright 2020, North Carolina State University"
__license__ = "BSD-3.0"
import xarray as xr
import matplotlib.pyplot as plt
import as ccrs
import as cm
import matplotlib as mpl
import os
import pandas as pd
import numpy as np
import cjs # '~carl/lib/python'
def draw_station_data(path, lat_column=1, lon_column=2, data_column=5,
norm=None, cmap=None):
cjs.tstamp(f'Reading {path}')
asc_data = pd.read_csv(path, sep=' ', header=None, skipinitialspace=True)
ax = plt.axes(projection=ccrs.AlbersEqualArea(central_longitude=360 - 95,
standard_parallels=(40, 60)))
# ax.set_extent([-118, -75, 23.5, 50.5])
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none',
zorder=3, usa_only=True)
lat = asc_data[lat_column]
lon = asc_data[lon_column]
data = asc_data[data_column]
plot = ax.scatter(x=lon, y=lat, c=data, norm=norm, cmap=cmap, zorder=2,
transform=ccrs.PlateCarree(), marker='.')
return plot
path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
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_data(path, cmap=cmap, norm=norm)
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment