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

minor updates in reorder functions

parent 82dcccd3
......@@ -17,23 +17,28 @@ if (submitscript) {
initYears <-c(1981:2010)
initMonths <- c(X:X)
locName <- 'X'
resolution<-"0.75"
# inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1REF/%sdeg/%s_noBC", resolution, locName)
# outPath<-sprintf("../DATA/System4_seasonal_15_rev1.0/%s_%s", locName, resolution)
resolution<-"0.50"
bcInfo<-"BC"
# bcInfo<-"noBC"
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_%s", resolution, locName, bcInfo)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_%s_final3", resolution, locName, bcInfo)
} else {
members <-c(1:15)
initYears <-c(1981:2010)
initMonths<-c(1:1)
locName<-"GHA"
#locName<-"EU"
resolution<-"0.75"
#locName<-"GHA"
locName<-"EU"
resolution<-"0.50"
inPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC", resolution, locName)
outPath<-sprintf("../DATA/System4_seasonal_15_rev1.1/%sdeg/%s_noBC_out", resolution, locName)
}
mask<-Netcdf2R(inFile = sprintf("../DATA/mask/mask_wfdei_%s.nc4", locName),"mask")
variables<-names(variableInfo)
#variables<-c( "pr" , "psl" , "rsds" , "rlds" , "tasmin","tasmax", "huss" , "sfcWind")
variables<-c( "pr")
variables<-c( "pr" , "psl" , "rsds" , "rlds" , "tas","tasmin","tasmax", "huss" , "sfcWind")
variables<-c( "rsds", "rlds", "tas", "tasmin", "tasmax", "huss", "sfcWind")
#variables<-c( "tas")
#variables<-c( "pr")
dir.create(outPath, recursive = TRUE, showWarnings = FALSE)
leadMonths<-c(0:6)
......@@ -60,15 +65,23 @@ for (initMonth in initMonths) {
targetEYear <- getInitTargetInfo( initYear = initYears[length(initYears)], initMonth = initMonth, leadMonth = leadMonth )$targetYear
# print(sprintf("targetmonth: %s, leadMonth: %s",targetMonth, leadMonth))
iPrefix <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_TAR%4d-%4d_%02d_LM%d",
inPath, variableName, locName,
iPrefix <- sprintf("%s/%s_forcing_seas15_%s_%s_E%02d-%02d_TAR%4d-%4d_%02d_LM%d",
inPath, variableName, locName, bcInfo,
members[1], members[length(members)],
targetSYear, targetEYear,
targetMonth, leadMonth)
print(iPrefix)
# load(sprintf("%s.RData",iPrefix))
#load(sprintf("%s.RData",iPrefix))
RData<-Netcdf2R(sprintf("%s.nc4",iPrefix),variableName)
## Apply mask
print("Apply mask")
for (iMember in 1:members) {
for (iTime in 1:dim(RData$Data)[2]) {
RData$Data[iMember,iTime,,]<-RData$Data[iMember,iTime,,]*mask$Data[1,,]
}
}
## Convert Units
RData<-convert(RData, toUnit = variableInfo[[variableName]]$units)
......@@ -117,7 +130,7 @@ for (initMonth in initMonths) {
RData$InitializationDates<-finalList[[iLM]]$InitializationDates[which(initYears==initYear)]
## Save to file...
outFile <- sprintf("%s/%s_forcing_seas15_%s_noBC_E%02d_%04d_%02d", outPath, variableName, locName, iMember, initYear, initMonth)
outFile <- sprintf("%s/%s_forcing_seas15_%s_%s_E%02d_%04d_%02d", outPath, variableName, locName, bcInfo, iMember, initYear, initMonth)
#print(outFile)
R2Netcdf(outFile = sprintf("%s.nc4",outFile), RData)
}
......
#!/bin/bash
#SBATCH --account=5120867-01
#SBATCH --time=5000
#SBATCH --mem=32024
#SBATCH --ntasks=1
#SBATCH --output=./log/log_doReorder_sepYears_sepMembers_combLeadmonths_<location>_initMonth<initMonth>_%j.txt
#SBATCH --job-name=Reformat2
#SBATCH --partition=ESG_Std
#SBATCH --mail-type=FAIL
#SBATCH --mail-user=wietse.franssen@wur.nl
# print date and time
date
#
# print the working directory
pwd
module load R/3.2.0
#
# run current job
echo '******** start Rscript...'
Rscript ./tmpScripts/doReorder_sepYears_sepMembers_combLeadmonths_<location>_initMonth<initMonth>.R
date
#!/bin/bash
tmpScripts="./tmpScripts"
#location="GHA"
location="EU"
mkdir -p $tmpScripts
for iInitMonth in $(seq -f "%02g" 1 12); do
echo "leadMonth: $iInitMonth"
sed -e "s|<initMonth>|$iInitMonth|g" \
-e "s|<location>|$location|g" \
jobScriptReorder_sepYears_sepMembers_combLeadmonths > $tmpScripts"/jobScriptReorder_sepYears_sepMembers_combLeadmonths_"$location"_initMonth"$iInitMonth
sed -e "s|submitscript <- FALSE|submitscript <- TRUE|g" \
-e "s|initMonths <- c(X:X)|initMonths <- c($iInitMonth:$iInitMonth)|g" \
-e "s|locName <- 'X'|locName <- '$location'|g" \
doReorder_sepYears_sepMembers_combLeadmonths.R > $tmpScripts"/doReorder_sepYears_sepMembers_combLeadmonths_"$location"_initMonth"$iInitMonth".R"
sbatch "$tmpScripts/jobScriptReorder_sepYears_sepMembers_combLeadmonths_"$location"_initMonth"$iInitMonth
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