Commit 30d07d40 authored by abuddenberg's avatar abuddenberg

This is just a save point for me to fall back on while I eliminate the copy pasta

parent 75ed3724
......@@ -11,6 +11,23 @@ NA_PRECIP_FILES = [
(DATA_DIR + 'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_sresa2_2071-2099_NA_percent_change.eps')
]
NA_ANNUAL_PRECIP_FILES = [
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_NA_annual_percent_change.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_NA_annual_percent_change.eps'),
]
GLOBAL_ANNUAL_PRECIP_FILES = [
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_global_annual_percent_change.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_global_annual_percent_change.eps')
]
GLOBAL_CATEGORY_FILES = [
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_global_annual_categories.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_global_annual_categories.eps')
]
NA_CATEGORY_FILES = [
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp85_2071-2099_NA_percent_change_categories.eps'),
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp26_2071-2099_NA_percent_change_categories.eps'),
......@@ -18,8 +35,8 @@ NA_CATEGORY_FILES = [
]
GLOBAL_PRECIP_FILES = [
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_global_percent_change_grads15.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_global_percent_change_grads15.eps')
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_global_percent_change_grads15.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_global_percent_change_grads15.eps')
]
HI_PRECIP_FILES = [
......@@ -29,6 +46,7 @@ HI_PRECIP_FILES = [
]
SEASONS = {
'Annual': ('annual_percent_change', 'annual_stipple'),
'Winter': ('DJF_percent_change', 'DJF_stipple'),
'Spring': ('MAM_percent_change', 'MAM_stipple'),
'Summer': ('JJA_percent_change', 'JJA_stipple'),
......
'''
Created on Nov 30, 2012
@author: abuddenberg
'''
from scipy.io.netcdf import netcdf_file
from mpl_toolkits.basemap import Basemap
from numpy import meshgrid
import matplotlib.pyplot as plt
from config import GLOBAL_ANNUAL_PRECIP_FILES, SEASONS
for infilename, outfilename in GLOBAL_ANNUAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
data = nc.variables['annual_percent_change'].data
signif = nc.variables['annual_stipple'].data
plt.title('Annual')
m = Basemap(
projection='eck4',
lon_0=0,
resolution='l',area_thresh=10000
)
m.drawcoastlines()
m.drawcountries()
lons, lats = meshgrid(lon_data, lat_data)
x,y = m(lons, lats)
levels_15 = [-45, -30, -15, 0, 15, 30, 45]
levels_10 = [-30, -20, -10, 0, 10, 20, 30]
prcp = m.contourf(x, y, data, cmap=plt.get_cmap('BrBG'), levels=levels_10, extend='both')
m.colorbar(prcp, location='bottom',pad="5%")
hatching = m.contourf(x,y, signif, 1, colors='none',hatches=[None, '//'])
# m.colorbar(hatching,location='right',pad="5%")
# plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
plt.show()
\ No newline at end of file
'''
Created on Nov 30, 2012
@author: abuddenberg
'''
from scipy.io.netcdf import netcdf_file
from mpl_toolkits.basemap import Basemap
from numpy import meshgrid
from numpy.ma import masked_equal
import numpy as np
import matplotlib.pyplot as plt
from config import GLOBAL_CATEGORY_FILES
for infilename, outfilename in GLOBAL_CATEGORY_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
data = nc.variables['annual_percent_change'].data
signif = nc.variables['annual_stipple'].data
plt.title('Annual')
m = Basemap(
projection='eck4',
lon_0=0,
resolution='l',area_thresh=10000
)
m.drawcoastlines()
m.drawstates()
m.drawcountries()
lons, lats = meshgrid(lon_data, lat_data)
x,y = m(lons, lats)
#Build boolean masks of the gridpoint for each category
stipples_mask = np.ma.getmask(np.ma.masked_equal(signif, 1.))
zeros_mask = np.ma.getmask(masked_equal(data, 0.0))
both_mask = np.ma.mask_or(stipples_mask, zeros_mask)
third_cat_mask = ~both_mask
#There's got to be a better way of doing this than copying the array
data = np.ma.masked_array(data)
data.mask = stipples_mask
data = np.ma.masked_array(data.filled(3.0)) #3.0 denotes areas of statistical significance
data.mask = zeros_mask
data = np.ma.masked_array(data.filled(1.0)) #1.0 denotes areas little change
data.mask = third_cat_mask
data = np.ma.masked_array(data.filled(2.0)) #2.0 denotes areas of statistical uncertainty
weird = m.pcolor(x,y, data)
m.colorbar(weird,location='right',pad="5%")
#Tests for overlap (There shouldn't be any)
# print np.any(np.logical_and(stipples_mask, zeros_mask))
# print np.any(np.logical_and(third_cat_mask, zeros_mask))
# print np.any(np.logical_and(third_cat_mask, stipples_mask))
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -25,13 +25,13 @@ for infilename, outfilename in GLOBAL_PRECIP_FILES:
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
for i, season in enumerate(['Winter', 'Spring', 'Summer', 'Fall']):
for i, season in enumerate(['Winter', 'Spring', 'Summer', 'Fall', 'Annual']):
data_var, signif_var = SEASONS[season]
data = nc.variables[data_var].data
signif = nc.variables[signif_var].data
ax = fig.add_subplot(221 + i)
ax = fig.add_subplot(231 + i)
plt.title(season)
m = Basemap(
projection='eck4',
......@@ -55,5 +55,5 @@ for infilename, outfilename in GLOBAL_PRECIP_FILES:
# m.colorbar(hatching,location='right',pad="5%")
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
# plt.show()
\ No newline at end of file
# plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
plt.show()
\ No newline at end of file
'''
Created on Nov 30, 2012
@author: abuddenberg
'''
from scipy.io.netcdf import netcdf_file
from mpl_toolkits.basemap import Basemap
from numpy import meshgrid
import matplotlib.pyplot as plt
from config import NA_ANNUAL_PRECIP_FILES, SEASONS
for infilename, outfilename in NA_ANNUAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data - 360.
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
data = nc.variables['annual_percent_change'].data
signif = nc.variables['annual_stipple'].data
plt.title('Annual')
m = Basemap(
projection='aea',
lon_0=-96,
lat_0=37.5,
lat_1=29.5,
lat_2=45.5,
# lat_ts=median(lats),
llcrnrlat=12,
urcrnrlat=80,
llcrnrlon=-135,
urcrnrlon=-25,
resolution='l',area_thresh=10000
)
m.drawcoastlines()
m.drawstates()
m.drawcountries()
lons, lats = meshgrid(lon_data, lat_data)
x,y = m(lons, lats)
levels_15 = [-45, -30, -15, 0, 15, 30, 45]
levels_10 = [-30, -20, -10, 0, 10, 20, 30]
prcp = m.contourf(x, y, data, cmap=plt.get_cmap('BrBG'), levels=levels_10, extend='both')
m.colorbar(prcp, location='bottom',pad="5%")
hatching = m.contourf(x,y, signif, 1, colors='none',hatches=[None, '//'])
# m.colorbar(hatching,location='right',pad="5%")
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -24,9 +24,9 @@ from numpy.ma import masked_equal
import numpy as np
import matplotlib.pyplot as plt
from config import NA_CATEGORY_FILES, SEASONS
from config import GLOBAL_ANNUAL_PRECIP_FILES, SEASONS
for infilename, outfilename in NA_CATEGORY_FILES:
for infilename, outfilename in GLOBAL_ANNUAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
......@@ -34,13 +34,13 @@ for infilename, outfilename in NA_CATEGORY_FILES:
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
for i, season in enumerate(['Winter', 'Spring', 'Summer', 'Fall']):
for i, season in enumerate(['Winter', 'Spring', 'Summer', 'Fall', 'Annual']):
data_var, signif_var = SEASONS[season]
data = nc.variables[data_var].data
signif = nc.variables[signif_var].data
ax = fig.add_subplot(221 + i)
ax = fig.add_subplot(231 + i)
plt.title(season)
m = Basemap(
projection='aea',
......@@ -91,5 +91,6 @@ for infilename, outfilename in NA_CATEGORY_FILES:
# print np.any(np.logical_and(third_cat_mask, stipples_mask))
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
# plt.show()
\ No newline at end of file
plt.savefig('../dist/' + outfilename + '.test.eps', format='eps', dpi=200)
# plt.show()
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