Commit 4b805713 authored by Franssen, Wietse's avatar Franssen, Wietse
Browse files

improved step 3

parent c410a8cd
......@@ -9,6 +9,7 @@ source(file = "./functions/functionMakeSelection.R")
source(file = "./functions/functionBiascorrectionWUR.R")
source(file = "./functions/functionR2Netcdf.R")
source(file = "./functions/functionNetcdf2R.R")
source(file = "./functions/functionConvert.R")
submitscript <- FALSE
......@@ -20,28 +21,26 @@ if (submitscript) {
locName <- 'X'
resolution <- 'X'
obsPath <- sprintf("../DATA/wfdei_rev3.0/%sdeg/%s/", resolution, locName)
inPath <- sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", resolution, locName)
outPath <- sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_BC", resolution, locName)
inPath <- sprintf("../DATA/System4_seasonal_15_rev1.2/%sdeg/%s_noBC_biasformat", resolution, locName)
outPath <- sprintf("../DATA/System4_seasonal_15_rev1.2/%sdeg/%s_BC_biasformat", resolution, locName)
} else {
members <- c(1:15)
initYears <- c(1981:2010)
targetMonths <- 6
leadMonths <- c(0:6)
#locName <- "GHA"
locName <- "EU"
resolution <- "0.50"
locName <- "GHA"
# locName <- "EU"
resolution <- "0.75"
obsPath <- sprintf("../DATA/wfdei_rev3.0/%sdeg/%s/", resolution, locName)
inPath <- sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", resolution, locName)
outPath <- sprintf("../DATA/System4_seasonal_15_rev1.2_1.0mm_adapt/%sdeg/%s_BC", resolution, locName)
inPath <- sprintf("../DATA/System4_seasonal_15_rev1.2/%sdeg/%s_noBC_biasformat", resolution, locName)
outPath <- sprintf("../DATA/System4_seasonal_15_rev1.2/%sdeg/%s_BC_biasformat", resolution, locName)
}
variables<-names(variableInfo)
variables<-c( "tas", "tasmin", "tasmax", "rsds", "rlds", "pr", "huss", "sfcWind")
variables<-c( "tas", "tasmin", "tasmax", "rsds", "rlds", "huss", "sfcWind")
dir.create(outPath, recursive = TRUE, showWarnings = FALSE)
print("start GPCC")
print("start")
for (variableName in variables) {
for (targetMonth in targetMonths) {
for (leadMonth in leadMonths) {
......@@ -54,41 +53,27 @@ for (variableName in variables) {
targetSYear, targetEYear,
targetMonth, leadMonth)
print(sprintf("Open: %s", iPrefix))
#print(sprintf("Open: %s", iPrefix))
RData_noBC <- Netcdf2R(paste0(iPrefix, ".nc4"), variableName)
#load(file = paste0(iPrefix, ".RData"))
#RData_noBC<-RData
#rm(RData)
if (variableName == "pr") {
obsFile <- sprintf("%s/%s_wfdei_GPCC_%s_%4d-%4d_%02d.RData",
obsFile <- sprintf("%s/%s_wfdei_GPCC_%s_%4d-%4d_%02d.nc4",
obsPath, variableName, locName,
initYears[1], initYears[length(initYears)],
targetMonth)
# obsFile <- sprintf("%s/%s_wfdei_%s_%4d-%4d_%02d.RData",
# obsPath, variableName, locName,
# initYears[1], initYears[length(initYears)],
# targetMonth)
} else {
obsFile <- sprintf("%s/%s_wfdei_%s_%4d-%4d_%02d.RData",
obsFile <- sprintf("%s/%s_wfdei_%s_%4d-%4d_%02d.nc4",
obsPath, variableName, locName,
initYears[1], initYears[length(initYears)],
targetMonth)
}
print(sprintf("Open: %s", obsFile))
load(obsFile)
RData_obs <- Netcdf2R(obsFile, variableName)
RData_obs <- convert(RData_obs, toUnit = variableInfo[[variableName]]$units)
RData_obs<-RData
rm(RData)
# newGrid<-getGrid(RData_noBC)
# indexesLat<-c(which(RData$xyCoords$y==newGrid$y[1]):which(RData$xyCoords$y==newGrid$y[2]))
# indexesLon<-c(which(RData$xyCoords$x==newGrid$x[1]):which(RData$xyCoords$x==newGrid$x[2]))
# RData_new$xyCoords<-RData_noBC$xyCoords
# RData_new$Data<-RData$Data[,indexesLat,indexesLon]
# attr(RData_new$Data,"dimensions") <- c("time","lat","lon")
# RData<-RData_new
# rm(RData_new)
# print(sprintf("Open: %s", obsFile))
# load(obsFile)
# RData_obs<-RData
# rm(RData)
## Make uniform and match the selections
dates1<-as.character(as.POSIXct(RData_obs$Dates$start, tz = "GMT"))
......
......@@ -3,7 +3,7 @@
#SBATCH --time=5000
#SBATCH --mem=16024
#SBATCH --ntasks=1
#SBATCH --output=./log/log_biascorrection_<location>_<resolution>deg_targetMonth<targetMonth>_%j.txt
#SBATCH --output=./log/log_3_biascorrection_<location>_<resolution>deg_targetMonth<targetMonth>_%j.txt
#SBATCH --job-name=bia
#SBATCH --partition=ESG_Std
#SBATCH --mail-type=FAIL
......@@ -17,6 +17,6 @@ module load R/3.2.0
#
# run targetent job
echo '******** R-data Download...'
Rscript ./tmpScripts/doBiascorrection_<location>_<resolution>deg_targetMonth<targetMonth>.R
Rscript ./tmpScripts/3_doBiascorrection_<location>_<resolution>deg_targetMonth<targetMonth>.R
date
......@@ -11,11 +11,11 @@ for iTargetMonth in $(seq -f "%02g" 1 12); do
sed -e "s|<targetMonth>|$iTargetMonth|g" \
-e "s|<location>|$location|g" \
-e "s|<resolution>|$resolution|g" \
jobScriptBiascorrection > $tmpScripts"/jobScriptBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth
3_jobScriptBiascorrection > $tmpScripts"/3_jobScriptBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth
sed -e "s|submitscript <- FALSE|submitscript <- TRUE|g" \
-e "s|targetMonths <- c(X:X)|targetMonths <- c($iTargetMonth:$iTargetMonth)|g" \
-e "s|locName <- 'X'|locName <- '$location'|g" \
-e "s|resolution <- 'X'|resolution <- '$resolution'|g" \
doBiascorrection.R > $tmpScripts"/doBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth".R"
sbatch "$tmpScripts/jobScriptBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth
3_doBiascorrection.R > $tmpScripts"/3_doBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth".R"
sbatch "$tmpScripts/3_jobScriptBiascorrection_"$location"_"$resolution"deg_targetMonth"$iTargetMonth
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment