Revision 3959e686
Added by Adam Wilson about 12 years ago
climate/procedures/MOD06_L2_process.r | ||
---|---|---|
220 | 220 |
system(paste("r.mapcalc <<EOF |
221 | 221 |
COT_denom=",paste("!isnull(COT2_",1:nfs,")",sep="",collapse="+")," |
222 | 222 |
COT_numer=",paste("if(isnull(COT2_",1:nfs,"),0,COT2_",1:nfs,")",sep="",collapse="+")," |
223 |
COT_daily=COT_numer/COT_denom
|
|
223 |
COT_daily=int((COT_numer/COT_denom)*100)
|
|
224 | 224 |
CER_denom=",paste("!isnull(CER2_",1:nfs,")",sep="",collapse="+")," |
225 | 225 |
CER_numer=",paste("if(isnull(CER2_",1:nfs,"),0,CER2_",1:nfs,")",sep="",collapse="+")," |
226 |
CER_daily=CER_numer/CER_denom
|
|
227 |
CLD_daily=max(",paste("if(isnull(CM_cloud_",1:nfs,"),0,CM_cloud_",1:nfs,")",sep="",collapse=","),")
|
|
226 |
CER_daily=int(100*(CER_numer/CER_denom))
|
|
227 |
CLD_daily=int((max(",paste("if(isnull(CM_cloud_",1:nfs,"),0,CM_cloud_",1:nfs,")",sep="",collapse=","),"))*100)
|
|
228 | 228 |
EOF",sep="")) |
229 | 229 |
|
230 | 230 |
#### Write the files to a geotiff |
231 |
execGRASS("r.out.gdal",input="CER_daily",output=paste(outdir,"/CER_",date,".tif",sep=""),nodata=-999,flags=c("quiet")) |
|
232 |
execGRASS("r.out.gdal",input="COT_daily",output=paste(outdir,"/COT_",date,".tif",sep=""),nodata=-999,flags=c("quiet")) |
|
233 |
execGRASS("r.out.gdal",input="CLD_daily",output=paste(outdir,"/CLD_",date,".tif",sep=""),nodata=99,flags=c("quiet")) |
|
231 |
# execGRASS("r.out.gdal",input="CER_daily",output=paste(outdir,"/CER_",date,".tif",sep=""),nodata=-999,flags=c("quiet"))
|
|
232 |
# execGRASS("r.out.gdal",input="COT_daily",output=paste(outdir,"/COT_",date,".tif",sep=""),nodata=-999,flags=c("quiet"))
|
|
233 |
# execGRASS("r.out.gdal",input="CLD_daily",output=paste(outdir,"/CLD_",date,".tif",sep=""),nodata=99,flags=c("quiet"))
|
|
234 | 234 |
|
235 |
### Write the files to a netcdf file |
|
236 |
## create image group to facilitate export as multiband netcdf |
|
237 |
execGRASS("i.group",group="mod06",input=c("CER_daily","COT_daily","CLD_daily")) ; print("") |
|
238 |
|
|
239 |
ncfile=paste(outdir,"/MOD06_",date,".nc",sep="") |
|
240 |
execGRASS("r.out.gdal",input="mod06",output=ncfile,type="Int16",nodata=-32768,flags=c("quiet"),createopt=c("WRITE_GDAL_TAGS=YES","WRITE_LONLAT=NO"),format="netCDF") |
|
241 |
system(paste("/nasa/nco/3.9.8/bin/ncecat -O -u time ",ncfile," ",ncfile,sep="")) |
|
242 |
system(paste("/nasa/nco/3.9.8/bin/ncap -O -s 'time[time]=",as.integer(fs$date[fs$dateid==date]-as.Date("2000-01-01")),"'",ncfile," ",ncfile)) |
|
243 |
system(paste("/nasa/nco/3.9.8/bin/ncatted -a calendar,time,c,c,\"standard\" -a long_name,time,c,c,\"time\" -a units,time,c,c,\"days since 2000-01-01 12:00:00\"",ncfile)) |
|
244 |
system(paste("/nasa/nco/3.9.8/bin/ncrename -v Band1,CER -v Band2,COT -v Band3,CLD",ncfile)) |
|
245 |
system(paste("/nasa/nco/3.9.8/bin/ncatted -a scale_factor,CER,o,d,0.001 -a missing_value,CER,o,d,-32768 -a long_name,CER,o,c,\"Effective Radius\"",ncfile)) |
|
246 |
system(paste("/nasa/nco/3.9.8/bin/ncatted -a scale_factor,COT,o,d,0.001 -a missing_value,CER,o,d,-32768 -a long_name,COT,o,c,\"Optical Thickness\"",ncfile)) |
|
247 |
system(paste("/nasa/nco/3.9.8/bin/ncatted -a scale_factor,CLD,o,d,0.001 -a missing_value,CER,o,d,-32768 -a long_name,CLD,o,c,\"Cloud Mask\"",ncfile)) |
|
248 |
|
|
249 |
|
|
235 | 250 |
### delete the temporary files |
236 | 251 |
unlink_.gislock() |
237 | 252 |
system("/nobackupp1/awilso10/software/grass-6.4.3svn/etc/clean_temp") |
climate/procedures/Pleiades.R | ||
---|---|---|
11 | 11 |
|
12 | 12 |
cat(paste(" |
13 | 13 |
#PBS -S /bin/bash |
14 |
#PBS -l select=64:ncpus=4:mpiprocs=4:model=wes
|
|
14 |
#PBS -l select=32:ncpus=4:mpiprocs=4:model=wes
|
|
15 | 15 |
####old PBS -l select=64:ncpus=4:mpiprocs=4:model=wes |
16 | 16 |
####### old: select=48:ncpus=8:mpiprocs=8:model=neh |
17 |
#PBS -l walltime=10:00:00
|
|
17 |
#PBS -l walltime=1:00:00 |
|
18 | 18 |
#PBS -j oe |
19 | 19 |
#PBS -m e |
20 | 20 |
#PBS -V |
21 | 21 |
####PBS -W group_list=s1007 |
22 |
###PBS -q devel
|
|
23 |
###PBS -o log/log_^array_index^
|
|
22 |
#PBS -q devel |
|
23 |
#PBS -o log/log_^array_index^ |
|
24 | 24 |
#PBS -o log/log_DataCompile |
25 | 25 |
#PBS -M adam.wilson@yale.edu |
26 | 26 |
#PBS -N MOD06 |
... | ... | |
43 | 43 |
export R_LIBS=\"/u/awilso10/R/x86_64-unknown-linux-gnu-library/2.15/\" |
44 | 44 |
export TMPDIR=/nobackupp1/awilso10/mod06/tmp |
45 | 45 |
## load modules |
46 |
module load gcc mpi-sgi/mpt.2.06r6 hdf4 udunits R |
|
46 |
module load gcc mpi-sgi/mpt.2.06r6 hdf4 udunits R nco
|
|
47 | 47 |
## Run the script! |
48 | 48 |
TMPDIR=$TMPDIR Rscript --verbose --vanilla /u/awilso10/environmental-layers/climate/procedures/MOD06_L2_process.r |
49 | 49 |
exit 0 |
... | ... | |
59 | 59 |
#system("qsub MOD06_process") |
60 | 60 |
|
61 | 61 |
## work in interactive mode |
62 |
#system("qsub -I -lselect=1:ncpus=2:model=wes -q devel") |
|
62 |
#system("qsub -I -l walltime=1:00:00 -lselect=1:ncpus=2:model=wes -q devel")
|
|
63 | 63 |
|
64 | 64 |
## check progress |
65 | 65 |
system("qstat -u awilso10") |
... | ... | |
70 | 70 |
|
71 | 71 |
|
72 | 72 |
### copy the files back to Yale |
73 |
system("scp 2_daily/* adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/") |
|
73 |
list.files("2_daily") |
|
74 |
system("scp 2_daily/* adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/data/modis/Venezuela") |
|
75 |
|
|
76 |
system("scp /tmp/Rtmp6I6tFn/MOD06_L2.A2000061.1615.051.2010273184629.hdf adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/data/modis/Venezuela") |
|
77 |
system("scp 2_daily/MOD06_20000410.nc adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/data/modis/Venezuela") |
|
74 | 78 |
|
75 |
system("scp /tmp/Rtmp6I6tFn/MOD06_L2.A2000061.1615.051.2010273184629.hdf adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/") |
|
76 | 79 |
|
77 | 80 |
list.files(" /tmp/Rtmp6I6tFn") |
Also available in: Unified diff
Updated MOD06 process to output NetCDF files instead of geotif for faster post-processing