Project

General

Profile

« Previous | Next » 

Revision e0f4e7ec

Added by Adam Wilson over 11 years ago

Started process of adding sensor zenith filter to MOD35 Processing

View differences:

climate/procedures/MOD35_L2_process.r
36 36

  
37 37
## default date and tile to play with  (will be overwritten below when running in batch)
38 38
#date="20090129"
39
#tile="h11v08"
39
#tile="h17v00"
40 40
platform="pleiades" 
41 41
verbose=T
42 42

  
......
54 54
  ## path to some executables
55 55
  ncopath="/nasa/sles11/nco/4.0.8/gcc/mpt/bin/"
56 56
  swtifpath="/nobackupp1/awilso10/software/heg/bin/swtif"
57
  swtifpath="/nobackupp4/pvotava/software/heg/bin/swtif"
58
  ## path to swath database
59
  db="/nobackupp4/pvotava/DB/export/swath_geo.sql.sqlite3.db"
60
  ## specify working directory
61
  outdir=paste("/nobackupp1/awilso10/mod35/daily/",tile,"/",sep="")  #directory for separate daily files
62
  basedir="/nobackupp1/awilso10/mod35/" #directory to hold files temporarily before transferring to lou
63
  setwd(tempdir())
64
  ## grass database
65
  gisBase="/u/armichae/pr/grass-6.4.2/"
66
  ## path to MOD11A1 file for this tile to align grid/extent
67
  gridfile=list.files("/nobackupp4/datapool/modis/MOD11A2.005/2009.01.01",pattern=paste(tile,".*[.]hdf$",sep=""),recursive=T,full=T)[1]
68
  td=readGDAL(paste("HDF4_EOS:EOS_GRID:\"",gridfile,"\":MODIS_Grid_8Day_1km_LST:LST_Day_1km",sep=""))
69
  projection(td)="+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs +datum=WGS84 +ellps=WGS84 "
70
}
57 71
  ## path to swath database
58 72
  db="/nobackupp4/pvotava/DB/export/swath_geo.sql.sqlite3.db"
59 73
  ## specify working directory
......
104 118
vars=as.data.frame(matrix(c(
105 119
  "Cloud_Mask",              "CM",
106 120
  "Quality_Assurance",       "QA"),
121
#  "Solar_Azimuth",        "SA",
122
#  "Sensor_Zenith",        "SZ"),
107 123
  byrow=T,ncol=2,dimnames=list(1:2,c("variable","varid"))),stringsAsFactors=F)
108 124

  
109 125
## vector of variables expected to be in final netcdf file.  If these are not present, the file will be deleted at the end.
......
137 153
  ## Function to generate hegtool parameter file for multi-band HDF-EOS file
138 154
  print(paste("Starting file",basename(file)))
139 155
  outfile=paste(tempdir(),"/",basename(file),sep="")
156
  ### Get 1km data
140 157
  ## First write the parameter file (careful, heg is very finicky!)
141 158
  hdr=paste("NUM_RUNS = ",length(vars$varid),"|MULTI_BAND_HDFEOS:",length(vars$varid),sep="")
142 159
  grp=paste("
......
169 186
  cat(c(hdr,grp)    , file=paste(tempdir(),"/",basename(file),"_MODparms.txt",sep=""))
170 187
  ## now run the swath2grid tool
171 188
  ## write the gridded file
172
  system(paste("(",swtifpath," -p ",tempdir(),"/",basename(file),"_MODparms.txt -d)",sep=""),intern=F,ignore.stderr=F)
189
  system(paste(swtifpath," -p ",tempdir(),"/",basename(file),"_MODparms.txt -d  -tmpLatLondir ",tempdir(),sep=""),intern=F,ignore.stderr=F)
173 190
  print(paste("Finished gridding ", file," for tile ",tile))
174 191
}  #end looping over swaths
175 192

  
......
181 198
  q("no",status=0)
182 199
}
183 200

  
201
plot=F
202
if(plot){
203
i=1
204
GDALinfo(outfiles[i])
205
d=brick(
206
  raster(paste("HDF4_EOS:EOS_GRID:\"",outfiles[i],"\":mod35:Cloud_Mask_0",sep="")),
207
  raster(paste("HDF4_EOS:EOS_GRID:\"",outfiles[i],"\":mod35:Quality_Assurance_0",sep="")),
208
  raster(paste("HDF4_EOS:EOS_GRID:\"",outfiles[i],"\":mod35:Sensor_Zenith",sep="")),
209
  raster(paste("HDF4_EOS:EOS_GRID:\"",outfiles[i],"\":mod35:Solar_Azimuth",sep="")))
210
plot(d)
211
}
212
# TODO: import sensor zenith separately and mask out bad pixels
213
system(paste("scp ",outfiles[1]," adamw@acrobates.eeb.yale.edu:/data/personal/adamw/projects/interp/tmp/",sep=""))
214

  
184 215
#####################################################
185 216
## Process the gridded files to align exactly with MODLAND tile and produce a daily summary of multiple swaths
186 217
  
climate/procedures/Pleiades.R
174 174
### Now process the climatologies
175 175
",sep=""),file=paste("mod06_climatology_qsub",sep=""))
176 176

  
177

  
177 178
## check files
178 179
system(paste("cat mod06_climatology_qsub",sep=""))        #qsub submission script
179 180
system(paste("cat notdone_climate.txt | head",sep=""))    #top of job file
climate/procedures/Pleiades_MOD35.R
118 118
### qsub script
119 119
cat(paste("
120 120
#PBS -S /bin/bash
121
#PBS -l select=100:ncpus=8:mpiprocs=8
121
#PBS -l select=1:ncpus=8:mpiprocs=8
122 122
##PBS -l select=10:ncpus=8:mpiprocs=8
123 123
##PBS -l walltime=8:00:00
124 124
#PBS -l walltime=2:00:00
......
129 129
#PBS -q devel
130 130
#PBS -V
131 131

  
132
CORES=800
132
CORES=8
133 133
#CORES=160
134 134

  
135 135
HDIR=/u/armichae/pr/

Also available in: Unified diff