Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CTDAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tsurata, Aki
CTDAS
Commits
e5b81d14
Commit
e5b81d14
authored
13 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
species mask is introduced in code
parent
2e65e583
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
da/baseclasses/optimizer.py
+8
-1
8 additions, 1 deletion
da/baseclasses/optimizer.py
da/baseclasses/statevector.py
+32
-1
32 additions, 1 deletion
da/baseclasses/statevector.py
with
40 additions
and
2 deletions
da/baseclasses/optimizer.py
+
8
−
1
View file @
e5b81d14
...
...
@@ -72,6 +72,11 @@ class Optimizer(object):
self
.
may_reject
=
np
.
zeros
(
self
.
nobs
,
bool
)
# flags of obs
self
.
flags
=
np
.
zeros
(
self
.
nobs
,
int
)
# species type
self
.
species
=
np
.
zeros
(
self
.
nobs
,
str
)
# species mask
self
.
speciesmask
=
{}
# Total covariance of fluxes and obs in units of obs [H P H^t + R]
self
.
HPHR
=
np
.
zeros
(
(
self
.
nobs
,
self
.
nobs
,),
float
)
...
...
@@ -91,6 +96,7 @@ class Optimizer(object):
allreject
=
[]
# collect all model samples for n=1,..,nlag
alllocalize
=
[]
# collect all model samples for n=1,..,nlag
allflags
=
[]
# collect all model samples for n=1,..,nlag
allspecies
=
[]
# collect all model samples for n=1,..,nlag
allmemsamples
=
None
# collect all members model samples for n=1,..,nlag
for
n
in
range
(
self
.
nlag
):
...
...
@@ -106,7 +112,7 @@ class Optimizer(object):
allreject
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
may_reject
'
)
)
alllocalize
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
may_localize
'
)
)
allflags
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
flag
'
)
)
allspecies
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
species
'
)
)
allobs
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
obs
'
)
)
allsamples
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
simulated
'
)
)
allmdm
.
extend
(
members
[
0
].
ModelSample
.
Data
.
getvalues
(
'
mdm
'
)
)
...
...
@@ -129,6 +135,7 @@ class Optimizer(object):
self
.
may_reject
[:]
=
np
.
array
(
allreject
)
self
.
may_localize
[:]
=
np
.
array
(
alllocalize
)
self
.
flags
[:]
=
np
.
array
(
allflags
)
self
.
species
[:]
=
np
.
array
(
allspecies
)
self
.
X_prime
=
self
.
X_prime
-
self
.
x
[:,
np
.
newaxis
]
# make into a deviation matrix
...
...
This diff is collapsed.
Click to expand it.
da/baseclasses/statevector.py
+
32
−
1
View file @
e5b81d14
...
...
@@ -220,9 +220,41 @@ class StateVector(object):
msg
=
"
A matrix to map states to TransCom regions and vice versa was created
"
;
logging
.
debug
(
msg
)
# Create a mask for species/unknowns
dummy
=
self
.
MakeSpeciesMask
()
def
__str__
(
self
):
return
"
This is a base class derived state vector object
"
def
MakeSpeciesMask
(
self
):
"""
This method creates a dictionary with as key the name of a tracer, and as values an array of 0.0/1.0 values
specifying which StateVector elements are constrained by this tracer. This mask can be used in
the optimization to ensure that certain types of osbervations only update certain unknowns.
An example would be that the tracer
'
14CO2
'
can be allowed to only map onto fossil fuel emissions in the state
The form of the mask is:
{
'
co2
'
: np.ones(self.nparams),
'
co2c14
'
, np.zeros(self.nparams) }
so that
'
co2
'
maps onto all parameters, and
'
co2c14
'
on none at all. These arrays are used in the Class
optimizer when state updates are actually performed
"""
self
.
speciesdict
=
{
'
co2
'
:
np
.
ones
(
self
.
nparams
)}
msg
=
"
A species mask was created, only the following species are recognized in this system:
"
;
logging
.
debug
(
msg
)
for
k
in
self
.
speciesdict
.
keys
():
msg
=
"
-> %s
"
%
k
;
logging
.
debug
(
msg
)
return
None
def
MakeNewEnsemble
(
self
,
lag
,
covariancematrix
=
None
):
"""
:param lag: an integer indicating the time step in the lag order
...
...
@@ -409,7 +441,6 @@ class StateVector(object):
EnsembleMembers
=
f
.
GetVariable
(
'
statevectorensemble_
'
+
qual
)
dummy
=
f
.
close
()
for
n
in
range
(
self
.
nlag
):
if
not
self
.
EnsembleMembers
[
n
]
==
[]:
self
.
EnsembleMembers
[
n
]
=
[]
...
...
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