Project

General

Profile

« Previous | Next » 

Revision e4e30b86

Added by Adam Wilson over 11 years ago

updated swtif error checking to use r.neighbor instead of r.mapcalc. Submitted job for northern block of tiles

View differences:

climate/procedures/MOD35_Climatology.r
27 27
### path to NCO
28 28
ncopath="/nasa/sles11/nco/4.0.8/gcc/mpt/bin/"
29 29

  
30
### Vector of variables that must be in file or they will be deleted.
31
###  Formated as output from system(paste("cdo -s showvar ",fdly$path[i]),intern=T)
32
#finalvars=" CER COT CLD"
33

  
34

  
35 30
################################################################################
36 31
## Get list of all daily files
37 32
if(verbose) print(paste("Checking daily output in preparation for generating climatology:",tile))
......
60 55

  
61 56
## merge all daily files to create a single file with all dates
62 57
system(paste(ncopath,"ncrcat -O ",outdir,"/*nc ",outdir2,"/MOD35_",tile,"_daily.nc",sep=""))
58
system(paste("ncdump -h ",outdir2,"/MOD35_",tile,"_daily.nc",sep=""))
63 59
 
64 60
## Update attributes
65 61
system(paste(ncopath,"ncatted ",
66
" -a valid_min,PClear,o,b,0 ",
67
" -a valid_max,PClear,o,b,100 ",
68
#" -a valid_range,PClear,o,b,\"0,255\" ",
69
#" -a missing_value,PClear,o,b,255 ",
70
#" -a _FillValue,PClear,d,b,255 ",
71
" -a units,time,o,c,\"days since 2000-1-1 0:0:0\" ",
72 62
" -a title,global,o,c,\"MODIS Cloud Product (MOD35) Summaries\" ",
73 63
" -a institution,global,o,c,\"Yale University\" ",
74 64
" -a source,global,o,c,\"MODIS Collection 6 Cloud Mask (MOD35)\" ",
......
94 84

  
95 85
## Overall Means
96 86
if(verbose) print(paste("Calculating the overall mean:",tile))
97
system(paste("cdo -O -b I8 -v sorttimestamp -setyear,",myear," -setmon,1 -setday,1 -mulc,-1 -subc,100 -timmean -selyear,2009 ",outdir2,"/MOD35_",tile,"_daily.nc ",outdir2,"/MOD35_",tile,"_2009mean.nc",sep=""),wait=T)
98
system(paste(ncopath,"ncrename -v PClear,PCloud ",outdir2,"/MOD35_",tile,"_2009mean.nc",sep=""))
87
system(paste("cdo -O -b I8 -v sorttimestamp -setyear,",myear," -setmon,1 -setday,1 -mulc,100 -timmean -lec,1 ",outdir2,"/MOD35_",tile,"_daily.nc ",outdir2,"/MOD35_",tile,"_mean.nc",sep=""),wait=T)
88
system(paste(ncopath,"ncrename -v CMday,CFday -v CMnight,CFnight ",outdir2,"/MOD35_",tile,"_mean.nc",sep=""))
99 89
system(paste(ncopath,"ncatted ",
100
" -a long_name,PCloud,o,c,\"Mean Probability of Cloud\" ",
101
" -a missing_value,PCloud,o,b,255 ",
102
" -a _FillValue,PCloud,d,b,255 ",
103
outdir2,"/MOD35_",tile,"_2009mean.nc",sep=""))
90
" -a long_name,CFday,o,c,\"Daytime Cloud Frequency\" ",
91
" -a missing_value,CFday,o,b,255 ",
92
" -a _FillValue,CFday,d,b,255 ",
93
" -a long_name,CFnight,o,c,\"Nighttime Cloud Frequency\" ",
94
" -a missing_value,CFnight,o,b,255 ",
95
" -a _FillValue,CFnight,d,b,255 ",
96
outdir2,"/MOD35_",tile,"_mean.nc",sep=""))
104 97

  
105 98
## Monthly means
106 99
if(verbose) print(paste("Calculating the monthly means:",tile))
107
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)
108
system(paste(ncopath,"ncrename -v PClear,PCloud ",tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""))
100
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -mulc,100  -ymonmean -lec,1 ",outdir2,"/MOD35_",tile,"_daily.nc ",tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""),wait=T)
101
system(paste(ncopath,"ncrename -v CMday,CFday -v CMnight,CFnight ",tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""))
109 102
system(paste(ncopath,"ncatted ",
110
" -a long_name,PCloud,o,c,\"Mean Probability of Cloud\" ",
111
" -a missing_value,PCloud,o,b,255 ",
112
" -a _FillValue,PCloud,d,b,255 ",
103
" -a long_name,CFday,o,c,\"Daytime Cloud Frequency\" ",
104
" -a units,CFday,o,c,\"Proportion (%)\" ",
105
" -a missing_value,CFday,o,b,255 ",
106
" -a _FillValue,CFday,d,b,255 ",
107
" -a long_name,CFnight,o,c,\"Nighttime Cloud Frequency\" ",
108
" -a units,CFnight,o,c,\"Proportion (%)\" ",
109
" -a missing_value,CFnight,o,b,255 ",
110
" -a _FillValue,CFnight,d,b,255 ",
113 111
tsdir,"/MOD35_",tile,"_ymonmean.nc",sep=""))
114 112

  
115 113

  
......
123 121

  
124 122
## Monthly standard deviation
125 123
if(verbose) print(paste("Calculating the monthly SD:",tile))
126
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -ymonstd -mulc,-1 -subc,100 -monmean ",
124
system(paste("cdo -O -b I8 sorttimestamp -setyear,",myear," -setday,15 -ymonstd -mulc,100 -monmean -lec,1 ",
127 125
    outdir2,"/MOD35_",tile,"_daily.nc ",
128 126
    tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
129
system(paste(ncopath,"ncrename -v PClear,PCloud_sd ",tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
127
system(paste(ncopath,"ncrename -v CMday,CFday_sd -v CMnight,CFnight_sd ",tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
130 128
system(paste(ncopath,"ncatted ",
131
" -a long_name,PCloud_sd,o,c,\"Standard Deviation of p(cloud)\" ",
129
" -a long_name,CFnight_sd,o,c,\"Standard Deviation of monthly nighttime cloud frequency\" ",
130
" -a long_name,CFday_sd,o,c,\"Standard Deviation of monthly daytime cloud frequency\" ",
132 131
tsdir,"/MOD35_",tile,"_ymonstd.nc",sep=""))
133 132

  
134 133
## frequency of cloud days p(clear<90%)  
135
if(verbose) print(paste("Calculating the proportion of cloudy and probably cloudy days:",tile))
136
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=""))
137
system(paste(ncopath,"ncrename -v PClear,CF ",tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
138
system(paste(ncopath,"ncatted ",
139
" -a long_name,CF,o,c,\"Cloud Frequency: Proportion of Days with probability of clear < 90%\" ",
140
" -a units,CF,o,c,\"Proportion (%)\" ",
141
tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
134
#if(verbose) print(paste("Calculating the proportion of cloudy and probably cloudy days:",tile))
135
#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=""))
136
#system(paste(ncopath,"ncrename -v PClear,CF ",tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
137
#system(paste(ncopath,"ncatted ",
138
#" -a long_name,CF,o,c,\"Cloud Frequency: Proportion of Days with probability of clear < 90%\" ",
139
#" -a units,CF,o,c,\"Proportion (%)\" ",
140
#tsdir,"/MOD35_",tile,"_ymoncld01.nc",sep=""))
142 141

  
143 142
## number of observations
144 143
if(verbose) print(paste("Calculating the number of missing variables:",tile))
145
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=""))
146
system(paste(ncopath,"ncrename -v PClear,Pmiss ",tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
144
system(paste("cdo -O -b I8 sorttimestamp  -setyear,",myear," -setday,15 -ymonmean -mulc,100  -eqc,9999 -setmisstoc,9999 ",outdir2,"/MOD35_",tile,"_daily.nc ",tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
145
system(paste(ncopath,"ncrename -v CMday,CFday_pmiss -v CMnight,CFnight_pmiss ",tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
147 146
system(paste(ncopath,"ncatted ",
148
             " -a long_name,Pmiss,o,c,\"Proportion of Days with missing data\" ",
149
             " -a units,Pmiss,o,c,\"Proportion (%)\" ",
147
             " -a long_name,CFday_pmiss,o,c,\"Proportion of Days with missing data\" ",
148
             " -a units,CFday_pmiss,o,c,\"Proportion (%)\" ",
149
             " -a long_name,CFnight_pmiss,o,c,\"Proportion of Days with missing data\" ",
150
             " -a units,CFnight_pmiss,o,c,\"Proportion (%)\" ",
150 151
             tsdir,"/MOD35_",tile,"_ymonmiss.nc",sep=""))
151 152

  
152 153
## TODO: fix projection information so GDAL can read it correctly.
......
156 157
if(verbose) print(paste("Append all monthly climatologies into a single file:",tile))
157 158
system(paste(ncopath,"ncks -O ",tsdir,"/MOD35_",tile,"_ymonmean.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
158 159
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymonstd.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
159
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymoncld01.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
160
#system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymoncld01.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
160 161
system(paste(ncopath,"ncks -A ",tsdir,"/MOD35_",tile,"_ymonmiss.nc  ",tsdir,"/MOD35_",tile,"_ymon.nc",sep=""))
161 162

  
162 163
## append sinusoidal grid from one of input files as CDO doesn't transfer all attributes

Also available in: Unified diff