Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PE_CBL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefano Serafin
PE_CBL
Commits
3cf1b75b
Commit
3cf1b75b
authored
3 months ago
by
Stefano Serafin
Browse files
Options
Downloads
Patches
Plain Diff
minor changes to enable runs controlled by json files
parent
2a0741a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models.py
+42
-0
42 additions, 0 deletions
models.py
with
42 additions
and
0 deletions
models.py
+
42
−
0
View file @
3cf1b75b
...
...
@@ -2,13 +2,55 @@
# -*- coding: utf-8 -*-
import
numpy
as
np
from
scipy.interpolate
import
CubicSpline
from
scipy.special
import
erfinv
,
erf
verbose
=
True
def
transform_none
(
x
,
kind
):
if
kind
==
'
dir
'
:
return
x
if
kind
==
'
inv
'
:
return
x
def
transform_log
(
x
,
kind
):
if
kind
==
'
dir
'
:
return
np
.
log
(
x
)
if
kind
==
'
inv
'
:
return
np
.
exp
(
x
)
def
transform_pit
(
x
,
kind
):
# mu and sigma could be guessed from the data, but...
a
=
0.5
b
=
4.5
mu
=
0.5
*
(
a
+
b
)
sigma
=
(
b
-
a
)
/
12
**
0.5
# takes a uniform, returns a normal
if
kind
==
'
dir
'
:
p
=
(
x
-
a
)
/
(
b
-
a
)
xt
=
mu
+
sigma
*
2
**
0.5
*
erfinv
(
2
*
p
-
1
)
return
xt
# takes a normal), returns a uniform
if
kind
==
'
inv
'
:
p
=
0.5
*
(
1
+
erf
((
x
-
mu
)
/
sigma
/
2
**
0.5
))
xt
=
a
+
p
*
(
b
-
a
)
return
xt
class
CBL
:
def
__init__
(
self
,
settings
):
for
k
,
v
in
settings
.
items
():
setattr
(
self
,
k
,
v
)
self
.
parameter_true
=
np
.
array
([
self
.
parameter_true
])
self
.
parameter_ensemble_min
=
np
.
array
([
self
.
parameter_ensemble_min
])
self
.
parameter_ensemble_max
=
np
.
array
([
self
.
parameter_ensemble_max
])
self
.
parameter_inflation_rtps_alpha
=
np
.
array
([
self
.
parameter_inflation_rtps_alpha
])
if
self
.
parameter_transform
==
'
pit
'
:
self
.
parameter_transform
=
[
transform_pit
]
elif
self
.
parameter_transform
==
'
log
'
:
self
.
parameter_transform
=
[
transform_log
]
elif
self
.
parameter_transform
==
'
none
'
:
self
.
parameter_transform
=
[
transform_none
]
if
not
hasattr
(
self
,
'
do_parameter_estimation
'
):
self
.
do_parameter_estimation
==
False
def
initialize
(
self
,
argin
,
coordinates
=
None
):
...
...
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