Project

General

Profile

Download (2.88 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 d7dc526e Adam M. Wilson
mod09=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
  r=mod09[[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 9a19743f Adam M. Wilson
30 d7dc526e Adam M. Wilson
#### Evaluate MOD35 Cloud data
31
mod09=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim.nc",varname="CF")
32
NAvalue(mod09)=-1
33 9a19743f Adam M. Wilson
34 d7dc526e Adam M. Wilson
cols=colorRampPalette(c("#000000","#00FF00","#FF0000"))#"black","blue","red"))
35
for(i in 1:12){
36
png(paste("output/mod09_animation_",i,".png",sep=""),width=2000,height=1000)
37
  print(i)
38
  r=mod09[[i]]
39
  print(levelplot(r,col.regions=cols(100),at=seq(0,100,len=100),margin=F,maxpixels=1e6,ylim=c(-60,70),main=paste(month.name[i])))+
40
    layer(sp.lines(coast))
41
dev.off()
42
}
43 9a19743f Adam M. Wilson
44
45
## climatologies
46 d7dc526e Adam M. Wilson
mod09a=brick("~/acrobates/adamw/projects/cloud/data/mod09_clim2.nc",varname="CF")
47
48
pdf("output/mod09_climatology.pdf",width=11,height=8.5)
49 9a19743f Adam M. Wilson
levelplot(mod09c,col.regions=cols(100),at=seq(0,100,len=100),margin=F,max.pixels=1e7)
50 d7dc526e Adam M. Wilson
dev.off()
51
52
53
## Compare with worldclim
54
wc=stack(as.list(paste("/mnt/data/jetzlab/Data/environ/global/worldclim/prec_",1:12,".bil",sep="")))
55
reg=extent(c(-83,-45,-5,13))
56
reg2=extent(c(-81,-70,-4,10))
57
58
59
wc_map=mean(crop(wc,reg))
60
61
twc_12=crop(wc[[12]],reg)
62
mod09_12=crop(mod09[[12]],reg)
63
64
65
p1=levelplot(wc_map,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,colorkey=list("top"))
66
p2=levelplot(mod09_12,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,colorkey=list("bottom"))
67
68
p3=c(p1,p2,x.same=T,y.same=T,merge.legends=F)
69
print(p3)
70
71
plot(mod09_12)
72
73
74
## reduced resolution
75
mod09_8km=aggregate(mod09_12,8)
76
mod09_1deg=aggregate(mod09_12,110)
77
78
pdf("output/mod09_resolution.pdf",width=11,height=8.5)
79
p1=levelplot(mod09_12,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
80
p2=levelplot(mod09_8km,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
81
p3=levelplot(mod09_1deg,col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
82
print(c(p1,p2,p3))
83
84 9a19743f Adam M. Wilson
85 d7dc526e Adam M. Wilson
p1=levelplot(crop(mod09_12,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
86
p2=levelplot(crop(mod09_8km,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
87
p3=levelplot(crop(mod09_1deg,reg2),col.regions=grey(seq(0,1,len=100)),cuts=99,margin=F,max.pixels=1e6)
88
print(c(p1,p2,p3),x.same=T,y.same=T)
89 9a19743f Adam M. Wilson
90 d7dc526e Adam M. Wilson
dev.off()
91 9a19743f Adam M. Wilson