Commit ddf9dc2d authored by Franssen, Wietse's avatar Franssen, Wietse
Browse files

Renaming issues solved

parent a45e3a80
......@@ -3,8 +3,8 @@ library(fields) # e.g: using the fields library
library(abind)
library(ncdf4)
library(ecomsUDG.Raccess)
source(file = "./functions/functionReformat.R")
source(file = "./functions/functionsGeneral.R")
source(file = "./functions/functionReformat.R")
source(file = "./functions/functionR2Netcdf.R")
source(file = "./functions/infoGeneral.R")
......@@ -17,7 +17,7 @@ if (submitscript) {
locName <- 'X'
resolution<-"0.75"
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.0/%s_%s", locName, resolution)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", resolution, locName)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1REF/%sdeg/%s_noBC", resolution, locName)
} else {
members <-c(1:2)
initYears <-c(1981:1982)
......@@ -48,14 +48,16 @@ for (initMonth in initMonths) {
RDataAllLeadMonths <- reformat2Bias(members, initYears, initMonth, variableNameECOMS, locName, iFile = inFile)
for (leadMonth in leadMonths) {
currMonth<-indexesOfDaysPerMonth(initMonth,7,0000)[leadMonth+1,"month"]
print(sprintf("currmonth: %s, leadMonth: %s",currMonth, leadMonth))
targetMonth <- getInitTargetInfo( initYear = 0000, initMonth = initMonth, leadMonth = leadMonth )$targetMonth
targetSYear <- getInitTargetInfo( initYear = initYears[1], initMonth = initMonth, leadMonth = leadMonth )$targetYear
targetEYear <- getInitTargetInfo( initYear = initYears[length(initYears)], initMonth = initMonth, leadMonth = leadMonth )$targetYear
print(sprintf("targetmonth: %s, leadMonth: %s",targetMonth, leadMonth))
oPrefix <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_%4d-%4d_%02d_LM%d",
oPrefix <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_TAR%4d-%4d_%02d_LM%d",
outPath, variableName, locName,
members[1], members[length(members)],
initYears[1], initYears[length(initYears)],
currMonth, leadMonth)
targetSYear, targetEYear,
targetMonth, leadMonth)
print(oPrefix)
RData<-RDataAllLeadMonths[[paste0("LeadMonth_",leadMonth)]]
......@@ -79,8 +81,6 @@ for (initMonth in initMonths) {
## add some extra attributes
attr(RData,"contact") <- "Wietse Franssen (wietse.franssen@wur.nl)"
#print(names(RDataAllLeadMonths))
# print(names(RData))
save(RData, file = paste0(oPrefix, ".RData"))
#R2Netcdf(paste0(oPrefix, ".nc4"), RData)
}
......
rm(list=ls())
library(ecomsUDG.Raccess)
library(downscaleR)
source(file = "./functions/functionsGeneral.R")
source(file = "./functions/infoGeneral.R")
submitscript <- FALSE
......@@ -8,17 +9,17 @@ submitscript <- FALSE
if (submitscript) {
members <- c(1:15)
initYears <-c(1981:2010)
currMonths <- c(X:X)
targetMonths <- c(X:X)
leadMonths<-c(0:6)
locName <- 'X'
fromResolution <- "0.75"
toResolution <- "0.50"
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", fromResolution, locName)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", toResolution, locName)
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1TAR_old/%sdeg/%s_noBC", fromResolution, locName)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1TAR_old/%sdeg/%s_noBC", toResolution, locName)
} else {
members <-c(1:15)
initYears <-c(1981:2010)
currMonths<-1
targetMonths<-1
leadMonths<-c(0:6)
#locName<-"GHA"
locName<-"EU"
......@@ -30,18 +31,20 @@ if (submitscript) {
variables<-names(variableInfo)
variables<-c("tasmin", "tasmax", "pr", "psl", "rsds", "rlds", "huss", "sfcWind" )
dir.create(outPath, recursive = TRUE, showWarnings = FALSE)
print("start")
for (variableName in variables) {
for (currMonth in currMonths) {
for (targetMonth in targetMonths) {
for (leadMonth in leadMonths) {
iFile <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_%4d-%4d_%02d_LM%d.RData",
targetSYear <- getInitTargetInfo( initYear = initYears[1], targetMonth = targetMonth, leadMonth = leadMonth )$targetYear
targetEYear <- getInitTargetInfo( initYear = initYears[length(initYears)], targetMonth = targetMonth, leadMonth = leadMonth )$targetYear
iFile <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_TAR%4d-%4d_%02d_LM%d.RData",
inPath, variableName, locName,
members[1], members[length(members)],
initYears[1], initYears[length(initYears)],
currMonth, leadMonth)
targetSYear, targetEYear,
targetMonth, leadMonth)
print(sprintf("Open: %s", iFile))
load(iFile)
......@@ -54,17 +57,18 @@ for (variableName in variables) {
print(sprintf("Regridding..."))
RData <- interpGridData(RData, new.grid = newGrid, method = "bilinear");
# RData <- interpGridData(RData, new.grid = newGrid, method = "nearest");
## set all negative precipitation values 0
if (variableName == "pr") {
RData$Data[RData$Data < 0] <- 0
}
oFile <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_%4d-%4d_%02d_LM%d.RData",
oFile <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_TAR%4d-%4d_%02d_LM%d.RData",
outPath, variableName, locName,
members[1], members[length(members)],
initYears[1], initYears[length(initYears)],
currMonth, leadMonth)
targetSYear, targetEYear,
targetMonth, leadMonth)
print(sprintf("Saving: %s", oFile))
save(file= oFile, RData)
......
rm(list=ls())
source(file = "./functions/functionsGeneral.R")
source(file = "./functions/infoGeneral.R")
submitscript <- FALSE
members <-c(1:15)
initYears <-c(1981:2010)
targetMonths<-c(1:12)
leadMonths<-c(0:6)
#locName<-"GHA"
locName<-"EU"
resolution <- "0.50"
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_BC", resolution, locName)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_BC", resolution, locName)
variables<-names(variableInfo)
#variables<-c("tasmin", "tasmax", "pr", "psl", "rsds", "rlds", "huss", "sfcWind" )
variables<-c( "pr" )
print("start")
for (variableName in variables) {
for (targetMonth in targetMonths) {
for (leadMonth in leadMonths) {
targetSYear <- getInitTargetInfo( initYear = initYears[1], targetMonth = targetMonth, leadMonth = leadMonth )$targetYear
targetEYear <- getInitTargetInfo( initYear = initYears[length(initYears)], targetMonth = targetMonth, leadMonth = leadMonth )$targetYear
iFile <- sprintf("%s/%s_forcing_seas15_%s_BC_E%02d-%02d_%4d-%4d_%02d_LM%d.RData",
inPath, variableName, locName,
members[1], members[length(members)],
initYears[1],initYears[length(initYears)],
targetMonth, leadMonth)
print(sprintf("From: %s", iFile))
oFile <- sprintf("%s/%s_forcing_seas15_%s_BC_E%02d-%02d_TAR%4d-%4d_%02d_LM%d.RData",
outPath, variableName, locName,
members[1], members[length(members)],
targetSYear, targetEYear,
targetMonth, leadMonth)
print(sprintf("To: %s", oFile))
file.rename(iFile, oFile)
}
}
}
......@@ -3,7 +3,7 @@
#SBATCH --time=5000
#SBATCH --mem=16024
#SBATCH --ntasks=1
#SBATCH --output=./log/log_regrid_<location>_currMonth<currMonth>_%j.txt
#SBATCH --output=./log/log_regrid_<location>_targetMonth<targetMonth>_%j.txt
#SBATCH --job-name=regr
#SBATCH --partition=ESG_Std
#SBATCH --mail-type=FAIL
......@@ -17,6 +17,6 @@ module load R/3.2.0
#
# run current job
echo '******** start Rscript...'
Rscript ./tmpScripts/doRegrid_<location>_currMonth<currMonth>.R
Rscript ./tmpScripts/doRegrid_<location>_targetMonth<targetMonth>.R
date
......@@ -4,7 +4,7 @@ tmpScripts="./tmpScripts"
location="EU"
mkdir -p $tmpScripts
for iCurrMonth in $(seq -f "%1g" 1 12); do
for iCurrMonth in $(seq -f "%02g" 1 12); do
echo "leadMonth: $iCurrMonth"
sed -e "s|<currMonth>|$iCurrMonth|g" \
-e "s|<location>|$location|g" \
......
#!/bin/bash
tmpScripts="./tmpScripts"
#location="GHA"
location="EU"
mkdir -p $tmpScripts
for iCurrMonth in $(seq -f "%02g" 1 12); do
echo "leadMonth: $iCurrMonth"
sed -e "s|<currMonth>|$iCurrMonth|g" \
-e "s|<location>|$location|g" \
jobScriptBiascorrection > $tmpScripts"/jobScriptBiascorrection_"$location"_currMonth"$iCurrMonth
sed -e "s|submitscript <- FALSE|submitscript <- TRUE|g" \
-e "s|currMonths <- c(X:X)|currMonths <- c($iCurrMonth:$iCurrMonth)|g" \
-e "s|locName <- 'X'|locName <- '$location'|g" \
doBiascorrection_GPCC.R > $tmpScripts"/doBiascorrection_"$location"_currMonth"$iCurrMonth".R"
sbatch "$tmpScripts/jobScriptBiascorrection_"$location"_currMonth"$iCurrMonth
done
......@@ -4,7 +4,7 @@ tmpScripts="./tmpScripts"
location="EU"
mkdir -p $tmpScripts
for iLeadMonth in $(seq -f "%1g" 0 6); do
for iLeadMonth in $(seq -f "%02g" 0 6); do
echo "leadMonth: $iLeadMonth"
sed -e "s|<leadMonth>|$iLeadMonth|g" \
-e "s|<location>|$location|g" \
......
......@@ -4,7 +4,7 @@ tmpScripts="./tmpScripts"
location="EU"
mkdir -p $tmpScripts
for iInitMonth in $(seq -f "%1g" 1 12); do
for iInitMonth in $(seq -f "%02g" 1 12); do
echo "leadMonth: $iInitMonth"
sed -e "s|<initMonth>|$iInitMonth|g" \
-e "s|<location>|$location|g" \
......
......@@ -4,14 +4,14 @@ tmpScripts="./tmpScripts"
location="EU"
mkdir -p $tmpScripts
for iCurrMonth in $(seq -f "%1g" 1 12); do
echo "leadMonth: $iCurrMonth"
sed -e "s|<currMonth>|$iCurrMonth|g" \
for iTargetMonth in $(seq -f "%02g" 1 12); do
echo "leadMonth: $iTargetMonth"
sed -e "s|<targetMonth>|$iTargetMonth|g" \
-e "s|<location>|$location|g" \
jobScriptRegrid > $tmpScripts"/jobScriptRegrid_"$location"_currMonth"$iCurrMonth
jobScriptRegrid > $tmpScripts"/jobScriptRegrid_"$location"_targetMonth"$iTargetMonth
sed -e "s|submitscript <- FALSE|submitscript <- TRUE|g" \
-e "s|currMonths <- c(X:X)|currMonths <- c($iCurrMonth:$iCurrMonth)|g" \
-e "s|targetMonths <- c(X:X)|targetMonths <- c($iTargetMonth:$iTargetMonth)|g" \
-e "s|locName <- 'X'|locName <- '$location'|g" \
doRegrid.R > $tmpScripts"/doRegrid_"$location"_currMonth"$iCurrMonth".R"
sbatch "$tmpScripts/jobScriptRegrid_"$location"_currMonth"$iCurrMonth
doRegrid.R > $tmpScripts"/doRegrid_"$location"_targetMonth"$iTargetMonth".R"
sbatch "$tmpScripts/jobScriptRegrid_"$location"_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