Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
euporias
biascorrection
Commits
fe847531
Commit
fe847531
authored
Feb 18, 2016
by
Franssen, Wietse
Browse files
changed reformat into reorder
parent
ddf9dc2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
SCRIPTS/doReorder_combYears_combMembers_sepLeadmonths.R
0 → 100644
View file @
fe847531
rm
(
list
=
ls
())
library
(
fields
)
# e.g: using the fields library
library
(
abind
)
library
(
ncdf4
)
library
(
ecomsUDG.Raccess
)
source
(
file
=
"./functions/functionsGeneral.R"
)
source
(
file
=
"./functions/functionReformat.R"
)
source
(
file
=
"./functions/functionR2Netcdf.R"
)
source
(
file
=
"./functions/infoGeneral.R"
)
submitscript
<-
FALSE
if
(
submitscript
)
{
members
<-
c
(
1
:
15
)
initYears
<-
c
(
1981
:
2010
)
initMonths
<-
c
(
X
:
X
)
locName
<-
'X'
resolution
<-
"0.75"
inPath
<-
sprintf
(
"../DATA/System4_seasonal_15_rev1.0/%s_%s"
,
locName
,
resolution
)
outPath
<-
sprintf
(
"../DATA/System4_seasonal_15_rev1.1REF2/%sdeg/%s_noBC"
,
resolution
,
locName
)
}
else
{
members
<-
c
(
1
:
2
)
initYears
<-
c
(
1981
:
1982
)
initMonths
<
-1
#locName<-"GHA"
locName
<-
"EU"
resolution
<-
"0.75"
inPath
<-
sprintf
(
"../DATA/System4_seasonal_15_rev1.0/%s_%s"
,
locName
,
resolution
)
outPath
<-
sprintf
(
"../DATA/System4_seasonal_15_rev1.x/%sdeg/%s_noBC"
,
resolution
,
locName
)
}
variables
<-
names
(
variableInfo
)
#variables<-c( "pr" , "psl" , "rsds" , "rlds" , "tasmin","tasmax", "huss" , "sfcWind")
dir.create
(
outPath
,
recursive
=
TRUE
,
showWarnings
=
FALSE
)
leadMonths
<-
c
(
0
:
6
)
print
(
"start"
)
for
(
initMonth
in
initMonths
)
{
for
(
variableName
in
variables
)
{
if
(
'ecomsName'
%in%
names
(
variableInfo
[[
variableName
]]))
{
variableNameECOMS
<-
variableInfo
[[
variableName
]]
$
ecomsName
}
else
{
variableNameECOMS
<-
variableName
}
inFile
<-
sprintf
(
"%s/%s/%s_forcing_seas15_%s_noBC_E<MEMBERS>_<YEARS>_%02d.RData"
,
inPath
,
variableNameECOMS
,
variableNameECOMS
,
locName
,
initMonth
)
print
(
inFile
)
RDataAllLeadMonths
<-
reformat2Bias
(
members
,
initYears
,
initMonth
,
variableNameECOMS
,
locName
,
iFile
=
inFile
)
for
(
leadMonth
in
leadMonths
)
{
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_TAR%4d-%4d_%02d_LM%d"
,
outPath
,
variableName
,
locName
,
members
[
1
],
members
[
length
(
members
)],
targetSYear
,
targetEYear
,
targetMonth
,
leadMonth
)
print
(
oPrefix
)
RData
<-
RDataAllLeadMonths
[[
paste0
(
"LeadMonth_"
,
leadMonth
)]]
# print(RData$InitializationDates)
# print(RData$Dates$start)
## set all negative precipitation values 0
if
(
variableName
==
"pr"
)
{
RData
$
Data
[
RData
$
Data
<
0
]
<-
0
}
RData
$
xyCoords
$
x
[]
<-
round
(
RData
$
xyCoords
$
x
[],
2
)
RData
$
xyCoords
$
y
[]
<-
round
(
RData
$
xyCoords
$
y
[],
2
)
# Check units
RData
$
Variable
$
varName
<-
variableName
attr
(
RData
$
Variable
,
"standard_name"
)
<-
variableInfo
[[
variableName
]]
$
standardName
attr
(
RData
$
Variable
,
"long_name"
)
<-
variableInfo
[[
variableName
]]
$
longName
attr
(
RData
$
Variable
,
"units"
)
<-
variableInfo
[[
variableName
]]
$
unitsEcoms
## add some extra attributes
attr
(
RData
,
"contact"
)
<-
"Wietse Franssen (wietse.franssen@wur.nl)"
save
(
RData
,
file
=
paste0
(
oPrefix
,
".RData"
))
#R2Netcdf(paste0(oPrefix, ".nc4"), RData)
}
}
}
SCRIPTS/doRe
f
or
mat
.R
→
SCRIPTS/doReor
der_sepYears_sepMembers_combLeadmonths
.R
View file @
fe847531
File moved
SCRIPTS/jobScriptRe
f
or
mat
→
SCRIPTS/jobScriptReor
der_combYears_combMembers_sepLeadmonths
View file @
fe847531
...
...
@@ -3,7 +3,7 @@
#SBATCH --time=5000
#SBATCH --mem=32024
#SBATCH --ntasks=1
#SBATCH --output=./log/log_
reformat
_<location>_initMonth<initMonth>_%j.txt
#SBATCH --output=./log/log_
doReorder_combYears_combMembers_sepLeadmonths
_<location>_initMonth<initMonth>_%j.txt
#SBATCH --job-name=Reformat
#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/doRe
f
or
mat
_<location>_initMonth<initMonth>.R
Rscript ./tmpScripts/doReor
der_combYears_combMembers_sepLeadmonths
_<location>_initMonth<initMonth>.R
date
SCRIPTS/submit_re
f
or
mat
.sh
→
SCRIPTS/submit_reor
der_combYears_combMembers_sepLeadmonths
.sh
View file @
fe847531
...
...
@@ -8,10 +8,10 @@ for iInitMonth in $(seq -f "%02g" 1 12); do
echo
"leadMonth:
$iInitMonth
"
sed
-e
"s|<initMonth>|
$iInitMonth
|g"
\
-e
"s|<location>|
$location
|g"
\
jobScriptRe
f
or
mat
>
$tmpScripts
"/jobScriptRe
f
or
mat
_"
$location
"_initMonth"
$iInitMonth
jobScriptReor
der_combYears_combMembers_sepLeadmonths
>
$tmpScripts
"/jobScriptReor
der_combYears_combMembers_sepLeadmonths
_"
$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"
\
doRe
f
or
mat
.R
>
$tmpScripts
"/doRe
f
or
mat
_"
$location
"_initMonth"
$iInitMonth
".R"
sbatch
"
$tmpScripts
/jobScriptRe
f
or
mat
_"
$location
"_initMonth"
$iInitMonth
doReor
der_combYears_combMembers_sepLeadmonths
.R
>
$tmpScripts
"/doReor
der_combYears_combMembers_sepLeadmonths
_"
$location
"_initMonth"
$iInitMonth
".R"
sbatch
"
$tmpScripts
/jobScriptReor
der_combYears_combMembers_sepLeadmonths
_"
$location
"_initMonth"
$iInitMonth
done
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment