Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
plot-precip-maps
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Andrew Buddenberg
plot-precip-maps
Commits
f3e4ec68
Commit
f3e4ec68
authored
Nov 29, 2012
by
abuddenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new category plot. Added descriptive comments
parent
226b3046
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
5 deletions
+119
-5
src/config.py
src/config.py
+9
-3
src/config.pyc
src/config.pyc
+0
-0
src/plot_global_precip.py
src/plot_global_precip.py
+7
-1
src/plot_north_american_categories.py
src/plot_north_american_categories.py
+95
-0
src/plot_north_american_precip.py
src/plot_north_american_precip.py
+8
-1
No files found.
src/config.py
View file @
f3e4ec68
...
...
@@ -6,9 +6,15 @@ 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_grads15.eps'
),
(
DATA_DIR
+
'pr_rcp26_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc'
,
'pr_rcp26_2071-2099_NA_percent_change_grads15.eps'
),
(
DATA_DIR
+
'pr_sresa2_2071-2099_percent_change.nc_hatched_north_america_ar5_white.nc'
,
'pr_sresa2_2071-2099_NA_percent_change_grads15.eps'
)
(
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'
)
]
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
=
[
...
...
src/config.pyc
View file @
f3e4ec68
No preview for this file type
src/plot_global_precip.py
View file @
f3e4ec68
...
...
@@ -2,6 +2,13 @@
Created on Nov 21, 2012
@author: abuddenberg
Creates a contour plot of projected precipitation change
globally for each emmissions scenario at the end of the
21st century vs the base period (presumably 1971-1999).
The hatched area denotes areas of higher statistical significance.
'''
from
scipy.io.netcdf
import
netcdf_file
from
mpl_toolkits.basemap
import
Basemap
...
...
@@ -33,7 +40,6 @@ for infilename, outfilename in GLOBAL_PRECIP_FILES:
)
m
.
drawcoastlines
()
# m.drawstates()
m
.
drawcountries
()
lons
,
lats
=
meshgrid
(
lon_data
,
lat_data
)
...
...
src/plot_north_american_categories.py
0 → 100644
View file @
f3e4ec68
'''
Created on Nov 29, 2012
@author: abuddenberg
The purpose of this program is to plot the categories of statistical
significance for the various emissions scenarios in the North American
area. This plot is used in conjection with the accompanying contour plots
to spot-check anomalies caused by the smoothing in those plots (as well as to
verify the data itself).
The categories are as follows:
1.0 denotes areas little change
2.0 denotes areas of statistical uncertainty
3.0 denotes areas of statistical significance
Fun stuff
'''
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
NA_CATEGORY_FILES
,
SEASONS
for
infilename
,
outfilename
in
NA_CATEGORY_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
)
for
i
,
season
in
enumerate
([
'Winter'
,
'Spring'
,
'Summer'
,
'Fall'
]):
data_var
,
signif_var
=
SEASONS
[
season
]
data
=
nc
.
variables
[
data_var
].
data
signif
=
nc
.
variables
[
signif_var
].
data
ax
=
fig
.
add_subplot
(
221
+
i
)
plt
.
title
(
season
)
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
)
#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
src/plot_north_american_precip.py
View file @
f3e4ec68
...
...
@@ -2,6 +2,13 @@
Created on Nov 16, 2012
@author: abuddenberg
Creates a very lovely contour plot of projected precipitation change
over North American for each emmissions scenario at the end of the
21st century vs the base period (presumably 1971-1999).
The hatched area denotes areas of higher statistical significance.
'''
from
scipy.io.netcdf
import
netcdf_file
from
mpl_toolkits.basemap
import
Basemap
...
...
@@ -51,7 +58,7 @@ for infilename, outfilename in NA_PRECIP_FILES:
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_1
5
,
extend
=
'both'
)
prcp
=
m
.
contourf
(
x
,
y
,
data
,
cmap
=
plt
.
get_cmap
(
'BrBG'
),
levels
=
levels_1
0
,
extend
=
'both'
)
m
.
colorbar
(
prcp
,
location
=
'bottom'
,
pad
=
"5%"
)
hatching
=
m
.
contourf
(
x
,
y
,
signif
,
1
,
colors
=
'none'
,
hatches
=
[
None
,
'//'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment