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
874cf064
Commit
874cf064
authored
Feb 23, 2016
by
Franssen, Wietse
Browse files
minor updates
parent
4bf3add7
Changes
4
Hide whitespace changes
Inline
Side-by-side
SCRIPTS/tryDownload.R
deleted
100644 → 0
View file @
4bf3add7
rm
(
list
=
ls
())
#setwd("/home/wietse/TODO/SCRIPTS")
source
(
file
=
"./functionDownload.R"
)
source
(
file
=
"./functionConvert.R"
)
members
<-
c
(
1
:
15
)
members
<-
c
(
1
)
initMonths
<-
c
(
1
:
12
)
initMonths
<-
c
(
1
)
initYears
<-
c
(
1981
:
2010
)
initYears
<-
c
(
1981
)
variables
<-
names
(
variableInfo
)
variables
<-
c
(
"pr"
)
#variables<-c("tas")
#variables<-c( "rsds" ,"rlds" )
variables
<-
c
(
"rsds"
)
locName
<-
"GHA"
# locName<-"EU"
outPath
=
"./testData/noBC/"
dir.create
(
outPath
,
recursive
=
TRUE
,
showWarnings
=
FALSE
)
for
(
varName
in
variables
)
{
for
(
iMember
in
members
)
{
for
(
initYear
in
initYears
)
{
for
(
initMonth
in
initMonths
)
{
RData
<-
downloadSeas15
(
variableInfo
[
varName
],
locationInfo
[
locName
],
iMember
,
initYear
,
initMonth
)
RData
<-
convert
(
RData
=
RData
,
toUnit
=
variableInfo
[[
varName
]]
$
units
)
## Solve ECOMS stuff!
## Precip issue:
# if (varName == "pr") {
# ntime<-length(RData$Data[,1,1])
# dataTmp<-RData$Data[]
# dataTmp[1:ntime-1,,]<-RData$Data[2:ntime,,]
# dataTmp[ntime,,]<-RData$Data[ntime,,]
# RData$Data[]<-dataTmp[]
# }
## Radiation issue 1: (86400*86400)
## This is solved in the conversion with the help of infoGeneral.R
## Radiation issue 2:
## The downloaded radiation of leadmonth 0 has one extra day (firstday-1).
## This is solved in functionDownload.R because it affects only leadmonth 0
## NOTE!!! Is is not right in the current dataset!!!!
oFile
<-
sprintf
(
paste0
(
outPath
,
"/%s_forcing_seas15_%s_noBC_E%02d_%4d_%02d.nc4"
),
varName
,
locName
,
iMember
,
initYear
,
initMonth
)
R2Netcdf
(
oFile
,
RData
)
}
}
}
}
#TDOD: pr + 1day
SCRIPTS/tryNetcdf2R.R
deleted
100644 → 0
View file @
4bf3add7
rm
(
list
=
ls
())
source
(
file
=
"./functionNetcdf2R.R"
)
iFile
<-
"./testData/noBC/tas_forcing_seas15_GHA_noBC_E01_1981_01.nc4"
var
<-
"tas"
RData
<-
Netcdf2R
(
iFile
,
var
)
print
(
RData
)
SCRIPTS/tryR2Netcdf.R
deleted
100644 → 0
View file @
4bf3add7
rm
(
list
=
ls
())
source
(
file
=
"./functionR2Netcdf.R"
)
load
(
file
=
"./testData/RAW_originalDownload/tas_forcing_seas15_GHA_ref__E01_1981_01.RData"
)
load
(
file
=
"./testData/RAW_originalDownload/rsds_forcing_seas15_GHA_ref__E01_1981_01.RData"
)
load
(
file
=
"./testData/RAW_originalDownload/rsds_forcing_seas15_GHA_ref__E12_2005_10.RData"
)
load
(
file
=
"./testData/RAW_originalDownload/rsds_forcing_seas15_GHA_ref__E12_1984_01.RData"
)
outF
<-
(
"./testData/TestOutput.nc4"
)
sys4
$
xyCoords
$
x
[]
<-
round
(
sys4
$
xyCoords
$
x
[],
2
)
sys4
$
xyCoords
$
y
[]
<-
round
(
sys4
$
xyCoords
$
y
[],
2
)
R2Netcdf
(
outF
,
sys4
)
# ## Todo:
# # Check units
# RData$Variable$units<-"mm s-2"
# RData$Variable$longName<-"blaat"
SCRIPTS/tryReformat.R
deleted
100644 → 0
View file @
4bf3add7
rm
(
list
=
ls
())
library
(
fields
)
# e.g: using the fields library
library
(
abind
)
library
(
ncdf4
)
library
(
ecomsUDG.Raccess
)
source
(
file
=
"./infoGeneral.R"
)
source
(
file
=
"./functionReformat.R"
)
source
(
file
=
"./functionsGeneral.R"
)
source
(
file
=
"./functionR2Netcdf.R"
)
submitscript
<-
FALSE
if
(
submitscript
)
{
members
<-
c
(
1
:
15
)
# members <- c(1:1)
targetMonths
<-
c
(
1
:
12
)
# targetMonths <- c(1:2)
targetYears
<-
c
(
1981
:
2011
)
# targetYears <- c(1981:1982)
leadMonths
<-
c
(
X
:
X
)
locName
<-
'X'
outPath
<-
"./testData/reFormatted"
}
else
{
members
<-
c
(
1
,
2
)
targetMonths
<-
c
(
1
:
2
)
targetYears
<-
c
(
2009
:
2011
)
targetYears
<-
c
(
1981
:
1982
)
leadMonths
<-
c
(
0
:
1
)
#locName<-"GHA"
locName
<-
"EU"
outPath
<-
"./testData/noBC/"
outPath
<-
"./testData/reFormatted"
# outPath<-"/home/wietse/TODO/biascorrection/SCRIPTS/testData/newDownload"
}
variables
<-
names
(
variableInfo
)
variables
<-
c
(
"pr"
)
#variables<-c("tas")
dir.create
(
outPath
,
recursive
=
TRUE
,
showWarnings
=
FALSE
)
# print(getInitInfo(targetYear = 2010, targetMonth = 6, leadMonth = 6))
for
(
variableName
in
variables
)
{
for
(
targetMonth
in
targetMonths
)
{
for
(
leadMonth
in
leadMonths
)
{
## get the available target years for the current targetMonth and leadMonth
availableTargetYears
<-
getAvailableTargetYears
(
targetYears
=
targetYears
,
targetMonth
=
targetMonth
,
leadMonth
=
leadMonth
)
nYears
<-
length
(
availableTargetYears
)
if
(
'ecomsName'
%in%
names
(
variableInfo
[[
variableName
]]))
{
variableNameECOMS
<-
variableInfo
[[
variableName
]]
$
ecomsName
}
else
{
variableNameECOMS
<-
variableName
}
print
(
sprintf
(
"targetMonth: %s, leadMonth: %s, years: %d-%d"
,
month.name
[
targetMonth
],
leadMonth
,
availableTargetYears
[
1
],
availableTargetYears
[
nYears
]))
oPrefix
<-
sprintf
(
"%s/%s_forcing_seas15_%s_noBC_E%02d-%02d_%4d-%4d_%02d_LM%d"
,
outPath
,
variableName
,
locName
,
members
[
1
],
members
[
length
(
members
)],
availableTargetYears
[
1
],
availableTargetYears
[
nYears
],
targetMonth
,
leadMonth
)
print
(
oPrefix
)
}
}
}
#iFile = paste0("/home/WUR/frans004/L_BACKUP/PROJECTS/EUPORIAS/DATA_BIAS/DATA_OLD/DATA_RAW_R/",locName,"_", resolution, "/","tp/tp","_forcing_seas15_",locName, "_ref__E<MEMBERS>_<YEARS>_", initMonth, ".RData")
#RData <- reformat2Bias(members, initYears, initMonth, varName, locName, iFile = iFile)
#for (leadMonth in 0:6) {
# currMonth<-indexesOfDaysPerMonth(initMonth,7,0000)[leadMonth+1,"month"]
# print(sprintf("currmonth: %s, leadMonth: %s",currMonth,leadMonth))
# oPrefix <- sprintf("%s%s_forcing_seas15_%s_noBC_E%02d-%02d_initYears%4d-%4d_currMonth%02d_LeadMonth%d",
# oPath, varName, locName,
# members[1], members[length(members)],
# initYears[1], initYears[length(initYears)],
# currMonth, leadMonth)
# lmData<-RData[[paste0("LeadMonth_",leadMonth)]]
# #print(names(RData))
# #print(names(lmData))
# save(lmData, file = paste0(oPrefix, ".RData"))
# R2Netcdf(paste0(oPrefix, ".nc4"), lmData)
#}
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