Skip to content
Snippets Groups Projects
Commit 377baebf authored by Francesco Sabatini's avatar Francesco Sabatini
Browse files

Fixes to A97 to run on cluster

parent 2769fe4a
No related branches found
No related tags found
No related merge requests found
...@@ -54,9 +54,8 @@ ElevationExtract <- function(header, output, ncores){ ...@@ -54,9 +54,8 @@ ElevationExtract <- function(header, output, ncores){
print(paste(length(todo), "tiles to do")) print(paste(length(todo), "tiles to do"))
print("start main foreach loop") print("start main foreach loop")
#foreach(i = 1:nlevels(header.sp$tilenam)) %do% { foreach(i =todo) %dopar% {
foreach(i =todo[1:6]) %dopar% { print(paste("doing", i))
#for(i in todo){
#create sp and project data #create sp and project data
if(nrow(header.tiles %>% if(nrow(header.tiles %>%
filter(tilenam %in% levels(header.tiles$tilenam)[i])) ==0 ) next() filter(tilenam %in% levels(header.tiles$tilenam)[i])) ==0 ) next()
...@@ -102,7 +101,7 @@ ElevationExtract <- function(header, output, ncores){ ...@@ -102,7 +101,7 @@ ElevationExtract <- function(header, output, ncores){
DEM.res=res(raster.tile)[1]) DEM.res=res(raster.tile)[1])
#save output #save output
save(output.tile, file = paste(output, "_elevation_tile_", i, ".RData", sep="")) save(output.tile, file = paste(output, "elevation_tile_", i, ".RData", sep=""))
print(i) print(i)
} }
stopCluster(cl) stopCluster(cl)
......
...@@ -48,7 +48,7 @@ PredExtr <- function(x.shp, myfunction=NA, output, ...@@ -48,7 +48,7 @@ PredExtr <- function(x.shp, myfunction=NA, output,
print(paste(length(toassign), "plots not matched directely - seek for NN")) print(paste(length(toassign), "plots not matched directely - seek for NN"))
if(length(toassign)>0){ if(length(toassign)>0){
nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %do% { nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% {
print(i) print(i)
nearest.tmp <- tryCatch(geosphere::dist2Line(header.shp[i,], mypredictor), nearest.tmp <- tryCatch(geosphere::dist2Line(header.shp[i,], mypredictor),
error = function(e){data.frame(distance=NA, lon=NA, lat=NA,ID=NA)} error = function(e){data.frame(distance=NA, lon=NA, lat=NA,ID=NA)}
......
...@@ -18,16 +18,8 @@ options <- list ( ...@@ -18,16 +18,8 @@ options <- list (
default = default.ncores, default = default.ncores,
help = paste0("number of CPU cores to use, defaults to ", default.ncores), help = paste0("number of CPU cores to use, defaults to ", default.ncores),
metavar = "4" metavar = "4"
),
make_option(
opt_str = c("-t", "--typp"),
dest = "typp",
type = "character",
default = default.typp,
help = "Which data type? raster or shp",
metavar = "4"
) )
) )
parser <- OptionParser( parser <- OptionParser(
...@@ -43,7 +35,7 @@ cli <- parse_args(parser, positional_arguments = 2) ...@@ -43,7 +35,7 @@ cli <- parse_args(parser, positional_arguments = 2)
# assign a few shortcuts # assign a few shortcuts
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
header <- cli$args[1] header <- cli$args[1]
output <- cli$args[2] output <- cli$args[2]
ncores <- cli$options$ncores ncores <- cli$options$ncores
...@@ -54,6 +46,5 @@ ncores <- cli$options$ncores ...@@ -54,6 +46,5 @@ ncores <- cli$options$ncores
source("A97_ElevationExtract.R") source("A97_ElevationExtract.R")
PredExtr(x.shp, myfunction, output, toextract, typp, ncores, chunkn, chunk.i) ElevationExtract(header, output, ncores)
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
#$ -S /bin/bash #$ -S /bin/bash
#$ -N ElevationExtract #$ -N ElevationExtract
#$ -o /work/$USER/$JOB_NAME-$JOB_ID-$TASK_ID.log #$ -o /work/$USER/$JOB_NAME-$JOB_ID.log
#$ -j y #$ -j y
#$ -l h_rt=00:30:00:00 #$ -l h_rt=00:30:00:00
#$ -l h_vmem=60G #$ -l h_vmem=1G
#$ -pe smp 20-32 #$ -pe smp 4-32
#$ -cwd #$ -cwd
...@@ -22,4 +22,4 @@ Rscript \ ...@@ -22,4 +22,4 @@ Rscript \
cli_A97.r \ cli_A97.r \
--cores ${NSLOTS:-1} \ --cores ${NSLOTS:-1} \
/data/splot/_data_splot3/header.shp.shp \ /data/splot/_data_splot3/header.shp.shp \
"$output" "$output"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment