1 |
9a19743f
|
Adam M. Wilson
|
## script to visualize cloud frequency data
|
2 |
|
|
|
3 |
|
|
setwd("~/acrobates/adamw/projects/cloud/")
|
4 |
|
|
|
5 |
|
|
library(rasterVis)
|
6 |
|
|
|
7 |
d7dc526e
|
Adam M. Wilson
|
## read in global coasts for nice plotting
|
8 |
|
|
library(maptools)
|
9 |
|
|
|
10 |
|
|
data(wrld_simpl)
|
11 |
|
|
coast <- unionSpatialPolygons(wrld_simpl, rep("land",nrow(wrld_simpl)), threshold=5)
|
12 |
|
|
coast=as(coast,"SpatialLines")
|
13 |
|
|
#coast=spTransform(coast,CRS(projection(mod35)))
|
14 |
|
|
|
15 |
9a19743f
|
Adam M. Wilson
|
|
16 |
|
|
#### Evaluate MOD35 Cloud data
|
17 |
d86b0a4a
|
Adam M. Wilson
|
mc=brick("~/acrobates/adamw/projects/cloud/data/mod09.nc",varname="CF")
|
18 |
9a19743f
|
Adam M. Wilson
|
NAvalue(mod09)=-1
|
19 |
|
|
|
20 |
d7dc526e
|
Adam M. Wilson
|
cols=colorRampPalette(c("#000000","#00FF00","#FF0000"))#"black","blue","red"))
|
21 |
|
|
for(i in 1:156){
|
22 |
|
|
png(paste("output/mod09_fullanimation_",i,".png",sep=""),width=2000,height=1000)
|
23 |
|
|
print(i)
|
24 |
d86b0a4a
|
Adam M. Wilson
|
r=mm[[i]]
|
25 |
d7dc526e
|
Adam M. Wilson
|
print(levelplot(r,col.regions=cols(100),at=seq(0,100,len=100),margin=F,maxpixels=1e6,ylim=c(-60,70),main=paste(names(mod09)[i])))+
|
26 |
|
|
layer(sp.lines(coast))
|
27 |
|
|
dev.off()
|
28 |
|
|
}
|
29 |
9a19743f
|
Adam M. Wilson
|
|
30 |
d7dc526e
|
Adam M. Wilson
|
#### Evaluate MOD35 Cloud data
|
31 |
d86b0a4a
|
Adam M. Wilson
|
mmc=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim_mean.nc",varname="CF")
|
32 |
|
|
names(mmc)=month.name
|
33 |
|
|
NAvalue(mmc)=-1
|
34 |
9a19743f
|
Adam M. Wilson
|
|
35 |
d7dc526e
|
Adam M. Wilson
|
cols=colorRampPalette(c("#000000","#00FF00","#FF0000"))#"black","blue","red"))
|
36 |
|
|
for(i in 1:12){
|
37 |
|
|
png(paste("output/mod09_animation_",i,".png",sep=""),width=2000,height=1000)
|
38 |
|
|
print(i)
|
39 |
d86b0a4a
|
Adam M. Wilson
|
r=mmc[[i]]
|
40 |
|
|
print(levelplot(r,col.regions=cols(100),at=seq(0,100,len=100),margin=F,maxpixels=1e7,ylim=c(-60,70),
|
41 |
|
|
main=paste(month.name[i]),cex.main=3,scales=list(draw=F),cuts=99))+
|
42 |
d7dc526e
|
Adam M. Wilson
|
layer(sp.lines(coast))
|
43 |
|
|
dev.off()
|
44 |
|
|
}
|
45 |
9a19743f
|
Adam M. Wilson
|
|
46 |
|
|
|
47 |
|
|
## climatologies
|
48 |
d86b0a4a
|
Adam M. Wilson
|
mac=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim_mac.nc",varname="CF_annual")
|
49 |
d7dc526e
|
Adam M. Wilson
|
|
50 |
|
|
pdf("output/mod09_climatology.pdf",width=11,height=8.5)
|
51 |
d86b0a4a
|
Adam M. Wilson
|
levelplot(mac,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)+
|
52 |
|
|
layer(sp.lines(coast,lwd=.5,col="black"))
|
53 |
d7dc526e
|
Adam M. Wilson
|
dev.off()
|
54 |
|
|
|
55 |
|
|
|
56 |
d86b0a4a
|
Adam M. Wilson
|
## Compare with worldclim and NPP
|
57 |
d7dc526e
|
Adam M. Wilson
|
wc=stack(as.list(paste("/mnt/data/jetzlab/Data/environ/global/worldclim/prec_",1:12,".bil",sep="")))
|
58 |
d86b0a4a
|
Adam M. Wilson
|
wc_map=stack(as.list(paste("/mnt/data/jetzlab/Data/environ/global/worldclim/bio_12.bil",sep="")))
|
59 |
|
|
npp=raster("/mnt/data/jetzlab/Data/environ/global/MODIS/MOD17A3/MOD17A3_Science_NPP_mean_00_12.tif",sep="")
|
60 |
d7dc526e
|
Adam M. Wilson
|
|
61 |
|
|
|
62 |
d86b0a4a
|
Adam M. Wilson
|
pdf("output/mod09_worldclim.pdf",width=11,height=8.5)
|
63 |
|
|
p1=levelplot(wc_map,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,maxpixels=1e5,colorkey=list("top"))
|
64 |
|
|
p2=levelplot(mac,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,maxpixels=1e5,colorkey=list("bottom"))
|
65 |
|
|
p3=c(p1,p2,x.same=T,y.same=T,merge.legends=T)
|
66 |
|
|
print(p3)
|
67 |
d7dc526e
|
Adam M. Wilson
|
|
68 |
|
|
|
69 |
d86b0a4a
|
Adam M. Wilson
|
regs=list(
|
70 |
|
|
Hawaii=extent(c(-156.5,-154,18.75,20.5)),
|
71 |
|
|
Boliva=extent(c(-71,-63,-20,-15)),
|
72 |
|
|
Venezuela=extent(c(-69,-59,0,7)),
|
73 |
|
|
reg=extent(c(-83,-45,-5,13)),
|
74 |
|
|
reg2=extent(c(-81,-70,-4,10))
|
75 |
|
|
)
|
76 |
d7dc526e
|
Adam M. Wilson
|
|
77 |
d86b0a4a
|
Adam M. Wilson
|
r=3 #set region
|
78 |
|
|
p_map=levelplot(crop(wc_map,regs[[r]]),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,maxpixels=1e5,colorkey=list(space="bottom",height=.75),xlab="",ylab="",main=names(regs)[r],useRaster=T)
|
79 |
|
|
p_mac=levelplot(crop(mac,regs[[r]]),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,maxpixels=1e5,colorkey=list(space="bottom",height=.75),useRaster=T)
|
80 |
|
|
p_npp=levelplot(crop(npp,regs[[r]]),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,maxpixels=1e5,colorkey=list(space="bottom",height=.5),zscaleLog=T,useRaster=T)
|
81 |
|
|
p3=c("WorldClim Mean Annual Precip (mm)"=p_map,"MOD09 Cloud Frequency (%)"=p_mac,"NPP"=p_npp,x.same=T,y.same=T,merge.legends=T,layout=c(3,1))
|
82 |
d7dc526e
|
Adam M. Wilson
|
print(p3)
|
83 |
|
|
|
84 |
d86b0a4a
|
Adam M. Wilson
|
dev.off()
|
85 |
d7dc526e
|
Adam M. Wilson
|
|
86 |
|
|
|
87 |
|
|
## reduced resolution
|
88 |
d86b0a4a
|
Adam M. Wilson
|
mod09_8km=aggregate(mod09_mac,8)
|
89 |
|
|
mod09_1deg=aggregate(mod09_mac,110)
|
90 |
d7dc526e
|
Adam M. Wilson
|
|
91 |
|
|
pdf("output/mod09_resolution.pdf",width=11,height=8.5)
|
92 |
d86b0a4a
|
Adam M. Wilson
|
p1=levelplot(mod09_mac,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
93 |
|
|
p2=levelplot(mod09_8km,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
94 |
|
|
p3=levelplot(mod09_1deg,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
95 |
|
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
96 |
d7dc526e
|
Adam M. Wilson
|
|
97 |
9a19743f
|
Adam M. Wilson
|
|
98 |
d86b0a4a
|
Adam M. Wilson
|
p1=levelplot(crop(mod09_mac,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
99 |
|
|
p2=levelplot(crop(mod09_8km,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
100 |
|
|
p3=levelplot(crop(mod09_1deg,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
101 |
|
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
102 |
9a19743f
|
Adam M. Wilson
|
|
103 |
d86b0a4a
|
Adam M. Wilson
|
p1=levelplot(crop(mod09_mac,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
104 |
|
|
p2=levelplot(crop(mod09_8km,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
105 |
|
|
p3=levelplot(crop(mod09_1deg,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
106 |
|
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
107 |
9a19743f
|
Adam M. Wilson
|
|
108 |
d86b0a4a
|
Adam M. Wilson
|
dev.off()
|