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
4bf3add7
Commit
4bf3add7
authored
Feb 23, 2016
by
Franssen, Wietse
Browse files
minor updates in reorder functions
parent
82dcccd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
SCRIPTS/doReorder_sepYears_sepMembers_combLeadmonths.R
View file @
4bf3add7
...
...
@@ -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.
7
5"
#
locName<-"GHA"
locName
<-
"EU"
resolution
<-
"0.5
0
"
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
)
}
...
...
SCRIPTS/jobScriptReorder_sepYears_sepMembers_combLeadmonths
0 → 100644
View file @
4bf3add7
#!/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
SCRIPTS/submit_reorder_sepYears_sepMembers_combLeadmonths.sh
0 → 100755
View file @
4bf3add7
#!/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
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