Project

General

Profile

Download (4.28 KB) Statistics
| Branch: | Revision:
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 d6ddb3e2 Adam M. Wilson
NAvalue(mc)=-1
19 9a19743f Adam M. Wilson
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
regs=list(
64 d6ddb3e2 Adam M. Wilson
  Cascades=extent(c(-122.8,-118,44.9,47)),
65 d86b0a4a Adam M. Wilson
  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 d6ddb3e2 Adam M. Wilson
  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 d86b0a4a Adam M. Wilson
  )
72 d6ddb3e2 Adam M. Wilson
for(r in 1:length(regs)){
73 d86b0a4a Adam M. Wilson
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 d6ddb3e2 Adam M. Wilson
#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 d7dc526e Adam M. Wilson
print(p3)
78 d6ddb3e2 Adam M. Wilson
}
79 d86b0a4a Adam M. Wilson
dev.off()
80 d7dc526e Adam M. Wilson
81
82
## reduced resolution
83 ba7057c4 Adam M. Wilson
84
## read in GEWEX 1-degree data
85
gewex=raster("data/gewex/CA_PATMOSX_NOAA.nc")
86
87 d86b0a4a Adam M. Wilson
mod09_8km=aggregate(mod09_mac,8)
88 d7dc526e Adam M. Wilson
89
pdf("output/mod09_resolution.pdf",width=11,height=8.5)
90 d86b0a4a Adam M. Wilson
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 d7dc526e Adam M. Wilson
95 9a19743f Adam M. Wilson
96 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)
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 9a19743f Adam M. Wilson
101 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)
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 9a19743f Adam M. Wilson
106 d86b0a4a Adam M. Wilson
dev.off()