Commit e9be78c4 authored by Carl Schreck's avatar Carl Schreck

Switching to cjs-lib version of add_map.

parent 5582fac2
......@@ -10,8 +10,6 @@ import os
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import cjs # '~carl/lib/python'
from datetime import datetime
import numpy as np
......@@ -71,16 +69,11 @@ ax = plt.axes(projection=ccrs.AlbersEqualArea(central_longitude=360-95,
plt.gca().outline_patch.set_visible(False)
ax.set_extent([-118, -75, 23.5, 50.5])
state_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_10m_admin_1_states_provinces_lakes' \
f'/ne_10m_admin_1_states_provinces_lakes.shp'
for shape in shapereader.Reader(state_shp_path).records():
if shape.attributes['adm0_a3'] == 'USA':
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor='none', facecolor='silver', zorder=1)
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
usa_only=True)
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none', zorder=3,
usa_only=True)
cjs.tstamp('Draw data')
levels = [5, 10, 25, 50, 75, 100, 125, 150, 200, 300, 500]
......
......@@ -11,8 +11,6 @@ import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import cjs # '~carl/lib/python'
from datetime import datetime
......@@ -73,16 +71,13 @@ for first_day, last_day in zip(first_days, last_days):
plt.gca().outline_patch.set_visible(False)
ax.set_extent([-118, -75, 23.5, 50.5])
state_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_10m_admin_1_states_provinces_lakes' \
f'/ne_10m_admin_1_states_provinces_lakes.shp'
for shape in shapereader.Reader(state_shp_path).records():
if shape.attributes['adm0_a3'] == 'USA':
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor='none', facecolor='silver', zorder=1)
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
usa_only=True)
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none',
zorder=3,
usa_only=True)
cjs.tstamp('Draw data')
levels = [5, 10, 25, 50, 75, 100, 125, 150, 200, 300, 500]
......
......@@ -11,13 +11,10 @@ import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import cjs # '~carl/lib/python'
from datetime import datetime
# These are some parameters that could be useful to have up top
# mpl.use('Agg')
year = 2019
month = 12
first_day = 27
......@@ -66,16 +63,11 @@ ax = plt.axes(projection=ccrs.AlbersEqualArea(central_longitude=360-95,
plt.gca().outline_patch.set_visible(False)
ax.set_extent([-118, -75, 23.5, 50.5])
state_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_10m_admin_1_states_provinces_lakes' \
f'/ne_10m_admin_1_states_provinces_lakes.shp'
for shape in shapereader.Reader(state_shp_path).records():
if shape.attributes['adm0_a3'] == 'USA':
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor='none', facecolor='silver', zorder=1)
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
usa_only=True)
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none', zorder=3,
usa_only=True)
cjs.tstamp('Draw data')
levels = list(np.arange(-5,6)*3)
......
......@@ -11,8 +11,6 @@ import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import cjs # '~carl/lib/python'
from datetime import datetime
......@@ -69,16 +67,12 @@ for first_day, last_day in zip(first_days, last_days):
plt.gca().outline_patch.set_visible(False)
ax.set_extent([-118, -75, 23.5, 50.5])
state_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_10m_admin_1_states_provinces_lakes' \
f'/ne_10m_admin_1_states_provinces_lakes.shp'
for shape in shapereader.Reader(state_shp_path).records():
if shape.attributes['adm0_a3'] == 'USA':
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor='none', facecolor='silver', zorder=1)
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
usa_only=True)
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none',
zorder=3,
usa_only=True)
cjs.tstamp('Draw data')
levels = list(np.arange(-5,6)*3)
......
......@@ -12,7 +12,6 @@ import matplotlib.path as mpath
import numpy as np
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import cjs # '~carl/lib/python'
from datetime import datetime
......@@ -97,12 +96,8 @@ for region in ['nhem', 'namer']:
levels=clevels, colors=['black'])
country_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_50m_admin_0_countries_lakes' \
f'/ne_50m_admin_0_countries_lakes.shp'
for shape in shapereader.Reader(country_shp_path).records():
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
shp_name = 'ne_50m_admin_0_countries_lakes'
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
cjs.tstamp('Add labels')
......
......@@ -11,7 +11,6 @@ import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import calendar
import cartopy.io.shapereader as shapereader
import matplotlib as mpl
import matplotlib.path as mpath
import cjs # '~carl/lib/python'
......@@ -102,13 +101,9 @@ for first_day, last_day in zip(first_days, last_days):
cont_plot = total_data.plot.contour(ax=ax, transform=ccrs.PlateCarree(),
levels=clevels, colors=['black'])
country_shp_path = f'{os.environ["DATA_DIR"]}' \
f'/geography/ne_50m_admin_0_countries_lakes' \
f'/ne_50m_admin_0_countries_lakes.shp'
for shape in shapereader.Reader(country_shp_path).records():
ax.add_geometries(shape.geometry, ccrs.PlateCarree(),
edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
shp_name = 'ne_50m_admin_0_countries_lakes'
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), linewidth=0.5,
facecolor='none', zorder=3)
cjs.tstamp('Add labels')
date_string = f'{calendar.month_name[month]} {first_day}-{last_day} {year}'
......
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