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
30d07d40
Commit
30d07d40
authored
Dec 04, 2012
by
abuddenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This is just a save point for me to fall back on while I eliminate the copy pasta
parent
75ed3724
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
209 additions
and
12 deletions
+209
-12
data/pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
...2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
+0
-0
data/pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
...2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
+0
-0
src/config.py
src/config.py
+20
-2
src/plot_global_annual_precip.py
src/plot_global_annual_precip.py
+49
-0
src/plot_global_categories.py
src/plot_global_categories.py
+70
-0
src/plot_global_precip.py
src/plot_global_precip.py
+4
-4
src/plot_north_american_annual.py
src/plot_north_american_annual.py
+59
-0
src/plot_north_american_categories.py
src/plot_north_american_categories.py
+7
-6
No files found.
data/pr_rcp26_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
0 → 100644
View file @
30d07d40
File added
data/pr_rcp85_2071-2099_percent_change-1.nc_hatched_global_ar5_white.nc
0 → 100644
View file @
30d07d40
File added
src/config.py
View file @
30d07d40
...
...
@@ -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'
),
...
...
src/plot_global_annual_precip.py
0 → 100644
View file @
30d07d40
'''
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
src/plot_global_categories.py
0 → 100644
View file @
30d07d40
'''
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
src/plot_global_precip.py
View file @
30d07d40
...
...
@@ -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
(
2
2
1
+
i
)
ax
=
fig
.
add_subplot
(
2
3
1
+
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
src/plot_north_american_annual.py
0 → 100644
View file @
30d07d40
'''
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
src/plot_north_american_categories.py
View file @
30d07d40
...
...
@@ -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
(
2
2
1
+
i
)
ax
=
fig
.
add_subplot
(
2
3
1
+
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()
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