Commit ddac3071 authored by abuddenberg's avatar abuddenberg

Some copypasta removed; config file refactored. I feel a rollback in my future

parent 32a91901
......@@ -6,44 +6,17 @@ Created on Nov 20, 2012
DATA_DIR = '/Users/abuddenberg/workspace/plot_precip_maps/data/'
NA_PRECIP_FILES = [
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp85_2071-2099_NA_percent_change.eps'),
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp26_2071-2099_NA_percent_change.eps'),
(DATA_DIR + 'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_sresa2_2071-2099_NA_percent_change.eps')
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp85_2071-2099_NA_{}.eps'),
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp26_2071-2099_NA_{}.eps'),
(DATA_DIR + 'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_sresa2_2071-2099_NA_{}.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'),
(DATA_DIR + 'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_sresa2_2071-2099_NA_percent_change_categories.eps')
]
GLOBAL_PRECIP_FILES = [
(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')
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp26_2071-2099_global_{}.eps'),
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc', 'pr_rcp85_2071-2099_global_{}.eps')
]
HI_PRECIP_FILES = [
(DATA_DIR + 'pr_rcp85_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp85_2071-2099_HI_percent_change_grads15.eps'),
(DATA_DIR + 'pr_rcp26_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_rcp26_2071-2099_HI_percent_change_grads15.eps'),
(DATA_DIR + 'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc', 'pr_sresa2_2071-2099_HI_percent_change_grads15.eps')
]
SEASONS = {
'Annual': ('annual_percent_change', 'annual_stipple'),
......
No preview for this file type
'''
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
......@@ -10,9 +10,9 @@ from numpy.ma import masked_equal
import numpy as np
import matplotlib.pyplot as plt
from config import GLOBAL_CATEGORY_FILES
from config import GLOBAL_PRECIP_FILES
for infilename, outfilename in GLOBAL_CATEGORY_FILES:
for infilename, outfilename in GLOBAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
......@@ -66,5 +66,5 @@ for infilename, outfilename in GLOBAL_CATEGORY_FILES:
# print np.any(np.logical_and(third_cat_mask, stipples_mask))
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
plt.savefig('../dist/' + outfilename.format('categories'), format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -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('percent_change'), format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -8,13 +8,13 @@ from mpl_toolkits.basemap import Basemap
from numpy import meshgrid
import matplotlib.pyplot as plt
from config import HI_PRECIP_FILES, SEASONS
from config import NA_PRECIP_FILES, SEASONS
for infilename, outfilename in HI_PRECIP_FILES:
for infilename, outfilename in NA_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data - 360.
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
......@@ -47,16 +47,14 @@ for infilename, outfilename in HI_PRECIP_FILES:
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_15, extend='both')
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.savefig('../dist/' + outfilename.format('HI_percent_change'), format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -8,13 +8,13 @@ from mpl_toolkits.basemap import Basemap
from numpy import meshgrid
import matplotlib.pyplot as plt
from config import NA_ANNUAL_PRECIP_FILES, SEASONS
from config import GLOBAL_PRECIP_FILES, SEASONS
for infilename, outfilename in NA_ANNUAL_PRECIP_FILES:
for infilename, outfilename in GLOBAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data - 360.
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
......@@ -54,6 +54,5 @@ for infilename, outfilename in NA_ANNUAL_PRECIP_FILES:
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.savefig('../dist/' + outfilename.format('annual_percent_change'), format='eps', dpi=200)
# plt.show()
\ No newline at end of file
......@@ -24,13 +24,13 @@ from numpy.ma import masked_equal
import numpy as np
import matplotlib.pyplot as plt
from config import GLOBAL_ANNUAL_PRECIP_FILES, SEASONS
from config import GLOBAL_PRECIP_FILES, SEASONS
for infilename, outfilename in GLOBAL_ANNUAL_PRECIP_FILES:
for infilename, outfilename in GLOBAL_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data - 360.
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
......@@ -91,6 +91,6 @@ for infilename, outfilename in GLOBAL_ANNUAL_PRECIP_FILES:
# print np.any(np.logical_and(third_cat_mask, stipples_mask))
plt.savefig('../dist/' + outfilename + '.test.eps', format='eps', dpi=200)
plt.savefig('../dist/' + outfilename.format('north_american_categories'), format='eps', dpi=200)
# plt.show()
......@@ -21,7 +21,7 @@ for infilename, outfilename in NA_PRECIP_FILES:
nc = netcdf_file(infilename)
lat_data = nc.variables['lat'].data
lon_data = nc.variables['lon'].data - 360.
lon_data = nc.variables['lon'].data
fig = plt.figure(figsize=(25,16), dpi=100, tight_layout=True)
......@@ -54,8 +54,6 @@ for infilename, outfilename in NA_PRECIP_FILES:
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')
......@@ -65,5 +63,5 @@ for infilename, outfilename in NA_PRECIP_FILES:
# m.colorbar(hatching,location='right',pad="5%")
plt.savefig('../dist/' + outfilename, format='eps', dpi=200)
plt.savefig('../dist/' + outfilename.format('percent_change'), format='eps', dpi=200)
# plt.show()
\ No newline at end of file
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