Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hydroPSO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Senoner Samuel
hydroPSO
Commits
27e00176
Commit
27e00176
authored
12 years ago
by
Mauricio Zambrano-Bigiarini
Browse files
Options
Downloads
Patches
Plain Diff
hydroPSO.R: sub-daily writing of obsrvations
parent
c04a9d73
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NEWS
+1
-0
1 addition, 0 deletions
NEWS
R/PSO_v2012.R
+20
-4
20 additions, 4 deletions
R/PSO_v2012.R
with
21 additions
and
4 deletions
NEWS
+
1
−
0
View file @
27e00176
...
@@ -42,6 +42,7 @@ NEWS/ChangeLog for hydroPSO
...
@@ -42,6 +42,7 @@ NEWS/ChangeLog for hydroPSO
v[t+1] : v[t] -> -v[t] (when x[t+1] > x_max | x[t+1] < x_min )
v[t+1] : v[t] -> -v[t] (when x[t+1] > x_max | x[t+1] < x_min )
-) when the control argument 'out.with.fit.iter' (not used so far) is set to TRUE, the number of iterations returned
-) when the control argument 'out.with.fit.iter' (not used so far) is set to TRUE, the number of iterations returned
correspond to the effective number of iterations carried out, not the maximum defined by 'maxit'
correspond to the effective number of iterations carried out, not the maximum defined by 'maxit'
-) now it is able to correctly write the observed values for sub-daily models
o Running 'hydroPSO' >= 0.1-59 with default settings will produce DIFFERENT RESULTS from those obtained with 'hydroPSO' <= 0.1-58, due to the
o Running 'hydroPSO' >= 0.1-59 with default settings will produce DIFFERENT RESULTS from those obtained with 'hydroPSO' <= 0.1-58, due to the
...
...
This diff is collapsed.
Click to expand it.
R/PSO_v2012.R
+
20
−
4
View file @
27e00176
...
@@ -1290,7 +1290,7 @@ hydromod.eval <- function(part, Particles, iter, npart, maxit,
...
@@ -1290,7 +1290,7 @@ hydromod.eval <- function(part, Particles, iter, npart, maxit,
# 15-Jan-2012 ; 23-Jan-2012 ; 30-Jan-2012 ; 23-Feb-2012 ; 23-Mar-2012 #
# 15-Jan-2012 ; 23-Jan-2012 ; 30-Jan-2012 ; 23-Feb-2012 ; 23-Mar-2012 #
# 14-Jun-2012 ; 15-Jun-2012 ; 03-Jul-2012 ; 06-Jul-2012 #
# 14-Jun-2012 ; 15-Jun-2012 ; 03-Jul-2012 ; 06-Jul-2012 #
# 11-Jul-2012 ; 17-Jul-2012 ; 18-Jul-2012 ; 13-Sep-2012; 14-Sep-2012 #
# 11-Jul-2012 ; 17-Jul-2012 ; 18-Jul-2012 ; 13-Sep-2012; 14-Sep-2012 #
# 17-Sep-2012 ; 23-Sep-2012
#
# 17-Sep-2012 ; 23-Sep-2012
; 15-Oct-2012
#
################################################################################
################################################################################
# 'lower' : minimum possible value for each parameter
# 'lower' : minimum possible value for each parameter
# 'upper' : maximum possible value for each parameter
# 'upper' : maximum possible value for each parameter
...
@@ -1690,6 +1690,7 @@ hydroPSO <- function(
...
@@ -1690,6 +1690,7 @@ hydroPSO <- function(
ifelse
(
(
"gof.Ini"
%in%
names
(
model.FUN.args
)),
gof.Ini.exists
<-
TRUE
,
gof.Ini.exists
<-
FALSE
)
ifelse
(
(
"gof.Ini"
%in%
names
(
model.FUN.args
)),
gof.Ini.exists
<-
TRUE
,
gof.Ini.exists
<-
FALSE
)
ifelse
(
(
"gof.Fin"
%in%
names
(
model.FUN.args
)),
gof.Fin.exists
<-
TRUE
,
gof.Fin.exists
<-
FALSE
)
ifelse
(
(
"gof.Fin"
%in%
names
(
model.FUN.args
)),
gof.Fin.exists
<-
TRUE
,
gof.Fin.exists
<-
FALSE
)
ifelse
(
(
"date.fmt"
%in%
names
(
model.FUN.args
)),
date.fmt.exists
<-
TRUE
,
date.fmt.exists
<-
FALSE
)
############################################################################
############################################################################
# 1) Initialisation #
# 1) Initialisation #
...
@@ -2900,17 +2901,32 @@ hydroPSO <- function(
...
@@ -2900,17 +2901,32 @@ hydroPSO <- function(
)
)
hydromod.out
<-
do.call
(
model.FUN
,
as.list
(
model.FUN.args
))
hydromod.out
<-
do.call
(
model.FUN
,
as.list
(
model.FUN.args
))
if
(
"obs"
%in%
names
(
model.FUN.args
))
{
if
(
"obs"
%in%
names
(
model.FUN.args
))
{
ifelse
(
date.fmt.exists
,
date.fmt
<-
model.FUN.args
[[
"date.fmt"
]],
date.fmt
<-
"%Y-%m-%d"
)
if
(
gof.Ini.exists
|
gof.Fin.exists
)
ifelse
(
grepl
(
"%H"
,
date.fmt
,
fixed
=
TRUE
)
|
grepl
(
"%M"
,
date.fmt
,
fixed
=
TRUE
)
|
grepl
(
"%S"
,
date.fmt
,
fixed
=
TRUE
)
|
grepl
(
"%I"
,
date.fmt
,
fixed
=
TRUE
)
|
grepl
(
"%p"
,
date.fmt
,
fixed
=
TRUE
)
|
grepl
(
"%X"
,
date.fmt
,
fixed
=
TRUE
),
subdaily
<-
TRUE
,
subdaily
<-
FALSE
)
fname
<-
paste
(
file.path
(
drty.out
),
"/"
,
"Observations.txt"
,
sep
=
""
)
fname
<-
paste
(
file.path
(
drty.out
),
"/"
,
"Observations.txt"
,
sep
=
""
)
obs
<-
model.FUN.args
[[
"obs"
]]
obs
<-
model.FUN.args
[[
"obs"
]]
if
(
is.zoo
(
obs
))
{
if
(
is.zoo
(
obs
))
{
if
(
gof.Ini.exists
)
obs
<-
window
(
obs
,
start
=
as.Date
(
model.FUN.args
[[
"gof.Ini"
]])
)
if
(
gof.Ini.exists
)
{
if
(
gof.Fin.exists
)
obs
<-
window
(
obs
,
end
=
as.Date
(
model.FUN.args
[[
"gof.Fin"
]])
)
ifelse
(
subdaily
,
gof.Ini
<-
as.POSIXct
(
model.FUN.args
[[
"gof.Ini"
]],
format
=
date.fmt
),
gof.Ini
<-
as.Date
(
model.FUN.args
[[
"gof.Ini"
]],
format
=
date.fmt
)
)
obs
<-
window
(
obs
,
start
=
gof.Ini
)
}
# IF end
if
(
gof.Fin.exists
)
{
ifelse
(
subdaily
,
gof.Fin
<-
as.POSIXct
(
model.FUN.args
[[
"gof.Fin"
]],
format
=
date.fmt
),
gof.Fin
<-
as.Date
(
model.FUN.args
[[
"gof.Fin"
]],
format
=
date.fmt
)
)
obs
<-
window
(
obs
,
end
=
gof.Fin
)
}
# IF end
write.zoo
(
x
=
obs
,
file
=
fname
)
write.zoo
(
x
=
obs
,
file
=
fname
)
}
else
{
}
else
{
obs
<-
cbind
(
1
:
length
(
obs
),
obs
)
obs
<-
cbind
(
1
:
length
(
obs
),
obs
)
write.table
(
obs
,
file
=
fname
,
col.names
=
FALSE
,
row.names
=
FALSE
,
sep
=
" "
,
quote
=
FALSE
)
write.table
(
obs
,
file
=
fname
,
col.names
=
FALSE
,
row.names
=
FALSE
,
sep
=
" "
,
quote
=
FALSE
)
}
# ELSE end
}
# ELSE end
}
# IF end
}
# IF end
}
# IF end
}
# IF end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment