Project

General

Profile

« Previous | Next » 

Revision be64daa8

Added by Adam Wilson over 11 years ago

Updated swath-grid section of MOD35 processing to add buffer and (hopefully) reduce edge artifacts in tiles

View differences:

climate/procedures/MOD35_Climatology.r
33 33

  
34 34
################################################################################
35 35
## Get list of all daily files
36
if(verbose) print("Checking daily output in preparation for generating climatology")
36
if(verbose) print(paste("Checking daily output in preparation for generating climatology:",tile))
37 37

  
38 38
 fdly=data.frame(path=list.files(outdir,pattern="nc$",full=T),stringsAsFactors=F)
39 39
  fdly$file=basename(fdly$path)
......
44 44
nrow(fdly)
45 45

  
46 46
## print some summaries
47
if(verbose) print("Summary of available daily files")
47
if(verbose) print(paste("Summary of available daily files:",tile))
48 48
print(table(fdly$year))
49 49
print(table(fdly$month))
50 50
#print(table(fdly$fvar))
51 51

  
52 52
#################################################################################
53 53
## Combine the year-by-year files into a single daily file in the summary directory (for archiving)
54
if(verbose) print("Merging daily files into single file output")
54
if(verbose) print(paste("Merging daily files into single file output:",tile))
55 55

  
56 56
## create temporary directory to put intermediate files (will be deleted when R quits)
57 57
tsdir=paste(tempdir(),"/summary",sep="")
......
87 87

  
88 88
#############################
89 89
##  Generate the Climatologies
90
if(verbose) print("Generate monthly climatologies")
90
if(verbose) print(paste("Generate monthly climatologies: ",tile))
91 91

  
92 92
myear=as.integer(max(fdly$year))  #this year will be used in all dates of monthly climatologies (and day will = 15)
93 93

  
94 94
## Monthly means
95
if(verbose) print("Calculating the monthly means")
95
if(verbose) print(paste("Calculating the monthly means:",tile))
96 96
system(paste("cdo -O -b I8 -v sorttimestamp -setyear,",myear," -setday,15 -mulc,-1 -subc,100 -ymonmean ",outdir2,"/MOD35_",tile,"_daily.nc ",tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""),wait=T)
97 97
system(paste(ncopath,"ncrename -v PClear,PCloud ",tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""))
98 98
system(paste(ncopath,"ncatted ",
......
112 112

  
113 113

  
114 114
## Monthly standard deviation
115
if(verbose) print("Calculating the monthly SD")
116
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -ymonstd -monmean ",
115
if(verbose) print(paste("Calculating the monthly SD:",tile))
116
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -ymonstd -mulc,-1 -subc,100 -monmean ",
117 117
    outdir2,"/MOD35_",tile,"_daily.nc ",
118 118
    tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
119 119
system(paste(ncopath,"ncrename -v PClear,PCloud_sd ",tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
......
122 122
tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
123 123

  
124 124
## frequency of cloud days p(clear<90%)  
125
if(verbose) print("Calculating the proportion of cloudy and probably cloudy days")
125
if(verbose) print(paste("Calculating the proportion of cloudy and probably cloudy days:",tile))
126 126
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -ymonmean  -mulc,100 -lec,90 -selvar,PClear ",outdir2,"/MOD35_",tile,"_daily.nc ",tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
127 127
system(paste(ncopath,"ncrename -v PClear,CF ",tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
128 128
system(paste(ncopath,"ncatted ",
......
131 131
tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
132 132

  
133 133
## number of observations
134
if(verbose) print("Calculating the number of missing variables")
134
if(verbose) print(paste("Calculating the number of missing variables:",tile))
135 135
system(paste("cdo -O -b I8 sorttimestamp  -setyear,",myear," -setday,15 -ymonmean -mulc,100  -eqc,9999 -setmisstoc,9999   -selvar,PClear ",outdir2,"/MOD35_",tile,"_daily.nc ",tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
136 136
system(paste(ncopath,"ncrename -v PClear,Pmiss ",tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
137 137
system(paste(ncopath,"ncatted ",
......
143 143
## clean up variables?
144 144

  
145 145
## append variables to a single file
146
if(verbose) print("Append all monthly climatologies into a single file")
146
if(verbose) print(paste("Append all monthly climatologies into a single file:",tile))
147 147
system(paste(ncopath,"ncks -O ",tsdir,"/MOD35_",tile,"_ymonmean.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
148 148
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymonstd.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
149 149
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymoncld01.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
150 150
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymonmiss.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
151 151

  
152 152
## append sinusoidal grid from one of input files as CDO doesn't transfer all attributes
153
if(verbose) print("Clean up file (update attributes, flip latitudes, add grid description")
153
if(verbose) print(paste("Clean up file (update attributes, flip latitudes, add grid description:",tile))
154 154

  
155 155
#system(paste(ncopath,"ncea -d time,0,1 -v sinusoidal ",list.files(outdir,full=T,pattern="[.]nc$")[1],"  ",tsdir,"/sinusoidal.nc",sep=""))
156 156
#system(paste(ncopath,"ncks -A -d time,0,1 -v sinusoidal ",list.files(outdir,full=T,pattern="[.]nc$")[1],"  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))

Also available in: Unified diff