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

Fixed minor bugs for submitting array jobs

parent 9539a520
Branches
Tags
No related merge requests found
...@@ -7,11 +7,14 @@ PredExtr <- function(x.shp, myfunction=NA, output, ...@@ -7,11 +7,14 @@ PredExtr <- function(x.shp, myfunction=NA, output,
require(doParallel) require(doParallel)
require(raster) require(raster)
require(rgeos) require(rgeos)
require(rgdal)
print(paste("Loading", typp, "data :", toextract)) print(paste("Loading", typp, "data :", toextract))
if(typp=="raster"){ mypredictor <- raster(toextract)} else if(typp=="raster"){ mypredictor <- raster(toextract)} else
mypredictor <- readOGR(toextract) mypredictor <- readOGR(toextract)
header.shp <-readOGR(x.shp) header.shp <-readOGR(x.shp)
crs(mypredictor) <- crs(header.shp) #should be verified beforehand!
## Divide in chunks if requested ## Divide in chunks if requested
if(chunkn>1 & !is.na(chunk.i)){ if(chunkn>1 & !is.na(chunk.i)){
print(paste("divide in chunks and run on chunk n.", chunk.i)) print(paste("divide in chunks and run on chunk n.", chunk.i))
...@@ -41,6 +44,8 @@ PredExtr <- function(x.shp, myfunction=NA, output, ...@@ -41,6 +44,8 @@ PredExtr <- function(x.shp, myfunction=NA, output,
} else { } else {
out <- sp::over(x=header.shp, y=mypredictor) out <- sp::over(x=header.shp, y=mypredictor)
toassign <- header.shp[which(is.na(out[,1])),] toassign <- header.shp[which(is.na(out[,1])),]
print(paste(length(toassign), "plots not matched directely - seek for NN"))
nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% { nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% {
nearest.tmp <- geosphere::dist2Line(toassign[i,], mypredictor) nearest.tmp <- geosphere::dist2Line(toassign[i,], mypredictor)
......
...@@ -30,7 +30,7 @@ options <- list ( ...@@ -30,7 +30,7 @@ options <- list (
metavar = "4" metavar = "4"
), ),
make_option( make_option(
opt_str = c("-c", "--chunkn"), opt_str = c("-n", "--chunkn"),
dest = "chunkn", dest = "chunkn",
type = "integer", type = "integer",
default = 1, default = 1,
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#$ -j y #$ -j y
#$ -l h_rt=00:30:00:00 #$ -l h_rt=00:30:00:00
#$ -l h_vmem=3G #$ -l h_vmem=1G
#$ -pe smp 4-32 #$ -pe smp 8-32
#$ -cwd #$ -cwd
...@@ -26,10 +26,10 @@ output=/work/$USER/output_pred/$(basename $filename .shp).csv ...@@ -26,10 +26,10 @@ output=/work/$USER/output_pred/$(basename $filename .shp).csv
Rscript \ Rscript \
cli_A98.r \ cli_A98.r \
--cores ${NSLOTS:-1} \ --cores ${NSLOTS:-1} \
--typp \ --typp "shp" \
--chunk.i $SGE_TASK_ID \ --chunk.i $SGE_TASK_ID \
--chunkn 99 \ --chunkn 99 \
/data/splot/_data/header.shp.RData \ /data/splot/_data_splot3/header.shp.shp \
robust.mean \ robust.mean \
"$output" \ "$output" \
"$filename" "$filename"
\ 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