Commit 1452223a authored by Carl Schreck's avatar Carl Schreck

Stable prism plotting

parent 5405e381
......@@ -16,15 +16,37 @@ import cjs # '~carl/lib/python'
import matplotlib.pyplot as plt
# These are some parameters that could be useful to have up top
var_name = 'tmin'
var_name = 'ppt'
if(var_name == 'tmin'):
year = 1983
month = 12
day = 25
levels = list(np.arange(-50, 60, 10))
levels = list(np.arange(-50, 70, 10))
units = 'Degrees Fahrenheit'
cmap = 'BuPu_r'
elif (var_name == 'tmax'):
year = 2006
month = 7
day = 17
levels = list(np.arange(50, 130, 10))
units = 'Degrees Fahrenheit'
cmap = 'OrRd'
elif (var_name == 'tmean'):
year = 1989
month = 2
day = 3
levels = list(np.arange(-30, 80, 10))
units = 'Degrees Fahrenheit'
cmap = 'RdBu_r'
elif(var_name == 'ppt'):
year = 2015
month = 12
day = 14
levels = [1, 2, 5, 10, 20, 30, 40, 50, 60, 70, 80]
units = 'mm'
cmap = 'GnBu'
cjs.tstamp('Here we go!')
var_name_to_long_name = {
......@@ -42,9 +64,12 @@ var_name_to_units = {
file_name = f'PRISM_{var_name}_{year}{month:02}{day:02}'
in_path = f'{os.environ["DATA_DIR"]}/prism/{file_name}.txt'
cjs.tstamp('Reading')
in_data = pd.read_csv(in_path, sep=' ', header=None, skiprows=6,
na_values=-9999, skipinitialspace=True)
in_data = (in_data[::-1] * 9 / 5) + 32
in_data = in_data[::-1]
if(var_name != 'ppt'):
in_data = (in_data * 9 / 5) + 32
xllcorner = -125.020833333333
yllcorner = 24.062499999979
......@@ -94,10 +119,11 @@ plot = data.plot(ax=ax, transform=ccrs.PlateCarree(),
cbar_kwargs={'orientation': 'horizontal',
'label': units,
'pad': 0.0})
# plot.colorbar.set_ticklabels(levels)
# plot.colorbar.set_ticks(levels)
plot.colorbar.set_ticklabels(levels)
plot.colorbar.set_ticks(levels)
plt.title(f'PRISM {var_name.upper()}: {day} {calendar.month_name[month]} {year}')
plt.savefig(f'figures/{var_name}-{year}-{month:02}-{day:02}.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