Commit 59795b18 authored by Carl Schreck's avatar Carl Schreck

About to switch to categories and precip amount

parent 95043af2
""" Draw the categories for one or the other precip occurrence."""
__author__ = "Carl Schreck"
__email__ = "cjschrec@ncsu.edu"
__copyright__ = "Copyright 2020, North Carolina State University"
__license__ = "BSD-3.0"
import xarray as xr
import matplotlib.pyplot as plt
import os
import numpy as np
import cartopy.crs as ccrs
import cjs # '~carl/lib/python'
import helpers
cjs.tstamp('Here we go!')
# These are some parameters that could be useful to have up top
time = '2018-09-14'
var_name = 'prcp'
base_path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/04precip-steps' \
f'/option2-florence/'
station_path = f'{base_path}{var_name.upper()}-20180914-map.txt'
scaled_path = f'{base_path}{var_name}-201809-grd-scaled.nc'
extent = [-85.0, -75.0, 32.0, 38.0]
central_longitude = np.mean(extent[0:2])
ax = plt.axes(
projection=ccrs.AlbersEqualArea(central_longitude=central_longitude),
extent=extent,
)
helpers.draw_station_data(ax, station_path, levels=0.1, cmap='Blues',
data_column=6)
anu_occur_path = f'{base_path}BPRC_20180914_D6_A2.pnt.gz'
anu_occur_data = helpers.read_unscaled(anu_occur_path, var_name, data_column=5)
sph_occur_path = f'{base_path}BPRC_20180914_D6_S1.pnt.gz'
sph_occur_data = helpers.read_unscaled(sph_occur_path, var_name, data_column=2)
categories = anu_occur_data * 0
categories += np.where(anu_occur_data > 0.4, 0, 1)
categories += np.where(sph_occur_data > 0.9, 0, 2)
categories.plot(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.5, 1.5, 2.5], cmap='Set1')
ax.set_extent(extent)
plt.savefig(f'figures/prcp_categories.png', dpi=200)
plt.show()
cjs.tstamp('Thank you, come again.')
......@@ -8,7 +8,6 @@ __license__ = "BSD-3.0"
import xarray as xr
import matplotlib.pyplot as plt
import os
import argparse
import numpy as np
import cartopy.crs as ccrs
import cjs # '~carl/lib/python'
......@@ -53,7 +52,7 @@ plot = anu_occur_data.plot(ax=ax, transform=ccrs.PlateCarree(),
vmin=-np.inf, vmax=np.inf, extend='both',
)
sph_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.4], zorder=2,
levels=[0.9], zorder=2,
colors='magenta')
anu_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.4], zorder=2,
......@@ -73,7 +72,7 @@ plot = sph_occur_data.plot(ax=ax, transform=ccrs.PlateCarree(),
vmin=-np.inf, vmax=np.inf, extend='both',
)
sph_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.4], zorder=2,
levels=[0.9], zorder=2,
colors='magenta')
anu_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.4], zorder=2,
......@@ -99,9 +98,15 @@ plot = anusplin_data.plot(ax=ax, transform=ccrs.PlateCarree(),
cmap=cmap, levels=precip_levels, zorder=1,
vmin=-np.inf, vmax=np.inf, extend='both',
)
anusplin_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.1], zorder=2,
colors='black')
# anusplin_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
# levels=[0.1], zorder=2,
# colors='black')
sph_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.9], zorder=2,
colors='magenta')
anu_occur_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=[0.4], zorder=2,
colors='darkorange')
ax.set_title(f'(c) Anusplin Precipitation', loc='left')
ax.set_extent(extent)
ax.outline_patch.set_visible(True)
......
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