1
|
## script to visualize cloud frequency data
|
2
|
|
3
|
setwd("~/acrobates/adamw/projects/cloud/")
|
4
|
|
5
|
library(rasterVis)
|
6
|
|
7
|
## 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
|
|
16
|
#### Evaluate MOD35 Cloud data
|
17
|
mc=brick("~/acrobates/adamw/projects/cloud/data/mod09.nc",varname="CF")
|
18
|
NAvalue(mc)=-1
|
19
|
|
20
|
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
|
r=mm[[i]]
|
25
|
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
|
|
30
|
#### Evaluate MOD35 Cloud data
|
31
|
mmc=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim_mean.nc",varname="CF")
|
32
|
names(mmc)=month.name
|
33
|
NAvalue(mmc)=-1
|
34
|
|
35
|
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
|
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
|
layer(sp.lines(coast))
|
43
|
dev.off()
|
44
|
}
|
45
|
|
46
|
|
47
|
## climatologies
|
48
|
mac=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim_mac.nc",varname="CF_annual")
|
49
|
|
50
|
pdf("output/mod09_climatology.pdf",width=11,height=8.5)
|
51
|
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
|
dev.off()
|
54
|
|
55
|
|
56
|
## Compare with worldclim and NPP
|
57
|
wc=stack(as.list(paste("/mnt/data/jetzlab/Data/environ/global/worldclim/prec_",1:12,".bil",sep="")))
|
58
|
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
|
|
61
|
|
62
|
pdf("output/mod09_worldclim.pdf",width=11,height=8.5)
|
63
|
regs=list(
|
64
|
Cascades=extent(c(-122.8,-118,44.9,47)),
|
65
|
Hawaii=extent(c(-156.5,-154,18.75,20.5)),
|
66
|
Boliva=extent(c(-71,-63,-20,-15)),
|
67
|
Venezuela=extent(c(-69,-59,0,7)),
|
68
|
CFR=extent(c(17.75,22.5,-34.8,-32.6)),
|
69
|
Madagascar=extent(c(46,52,-17,-12))
|
70
|
#reg2=extent(c(-81,-70,-4,10))
|
71
|
)
|
72
|
for(r in 1:length(regs)){
|
73
|
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)
|
74
|
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)
|
75
|
#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) #"NPP"=p_npp,
|
76
|
p3=c("WorldClim Mean Annual Precip (mm)"=p_map,"MOD09 Cloud Frequency (%)"=p_mac,x.same=T,y.same=T,merge.legends=T,layout=c(2,1))
|
77
|
print(p3)
|
78
|
}
|
79
|
dev.off()
|
80
|
|
81
|
|
82
|
## reduced resolution
|
83
|
|
84
|
## read in GEWEX 1-degree data
|
85
|
gewex=raster("data/gewex/CA_PATMOSX_NOAA.nc")
|
86
|
|
87
|
mod09_8km=aggregate(mod09_mac,8)
|
88
|
|
89
|
pdf("output/mod09_resolution.pdf",width=11,height=8.5)
|
90
|
p1=levelplot(mod09_mac,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
91
|
p2=levelplot(mod09_8km,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
92
|
p3=levelplot(mod09_1deg,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
93
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
94
|
|
95
|
|
96
|
p1=levelplot(crop(mod09_mac,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
97
|
p2=levelplot(crop(mod09_8km,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
98
|
p3=levelplot(crop(mod09_1deg,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
99
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
100
|
|
101
|
p1=levelplot(crop(mod09_mac,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
102
|
p2=levelplot(crop(mod09_8km,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
103
|
p3=levelplot(crop(mod09_1deg,reg3),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e5)
|
104
|
print(c(p1,p2,p3,x.same=T,y.same=T,merge.legends=F))
|
105
|
|
106
|
dev.off()
|
107
|
|