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
CTDAS
CTDAS
Commits
ef0e9b4a
Commit
ef0e9b4a
authored
2 years ago
by
Woude, Auke van der
Browse files
Options
Downloads
Patches
Plain Diff
Added flags to the statevector baseclass
parent
d8f86c47
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
da/statevectors/statevector_baseclass.py
+8
-12
8 additions, 12 deletions
da/statevectors/statevector_baseclass.py
with
8 additions
and
12 deletions
da/statevectors/statevector_baseclass.py
+
8
−
12
View file @
ef0e9b4a
...
...
@@ -338,7 +338,10 @@ class StateVector(object):
def
write_to_file
(
self
,
filename
,
qual
):
"""
:param filename: the full filename for the output NetCDF file
:type filename: str | path
:rtype: None
:param qual: the qualification of the file: prior or optimized
:type qual: str
Write the StateVector information to a NetCDF file for later use.
In principle the output file will have only one two datasets inside
...
...
@@ -350,17 +353,12 @@ class StateVector(object):
:meth:`~da.baseclasses.statevector.StateVector.read_from_file`
"""
#import da.tools.io4 as io
#import da.tools.io as io
if
qual
==
'
prior
'
:
f
=
io
.
CT_CDF
(
filename
,
method
=
'
create
'
)
logging
.
debug
(
'
Creating new StateVector output file (%s)
'
%
filename
)
#qual = 'prior'
else
:
f
=
io
.
CT_CDF
(
filename
,
method
=
'
write
'
)
logging
.
debug
(
'
Opening existing StateVector output file (%s)
'
%
filename
)
#qual = 'opt'
dimparams
=
f
.
add_params_dim
(
self
.
nparams
)
dimmembers
=
f
.
add_members_dim
(
self
.
nmembers
)
...
...
@@ -394,6 +392,7 @@ class StateVector(object):
def
interpolate_mean_ensemble
(
self
,
initdir
,
date
,
qual
=
'
opt
'
,
readensemble
=
True
):
#FLAG: add documentation
# deduce window length of source run:
all_dates
=
os
.
listdir
(
initdir
)
for
i
,
dstr
in
enumerate
(
all_dates
):
...
...
@@ -423,6 +422,7 @@ class StateVector(object):
logging
.
debug
(
'
Ensemble for %s will be interpolated from %s and %s
'
%
(
date
.
strftime
(
'
%Y-%m-%d
'
),
datemin
.
strftime
(
'
%Y-%m-%d
'
),
datemax
.
strftime
(
'
%Y-%m-%d
'
)))
# Read ensemble from both files
#FLAG add context manager
filename1
=
os
.
path
.
join
(
initdir
,
datemin
.
strftime
(
'
%Y%m%d
'
),
'
savestate_%s.nc
'
%
datemin
.
strftime
(
'
%Y%m%d
'
))
f
=
io
.
ct_read
(
filename1
,
'
read
'
)
meanstate1
=
f
.
get_variable
(
'
statevectormean_
'
+
qual
)
# [nlag x nparameters]
...
...
@@ -449,6 +449,7 @@ class StateVector(object):
def
read_mean_from_file
(
self
,
filename
,
lag
,
date
=
None
,
initdir
=
None
,
qual
=
'
opt
'
):
#FLAG: add documentation
if
date
is
None
:
f
=
io
.
ct_read
(
filename
,
'
read
'
)
meanstate
=
f
.
get_variable
(
'
statevectormean_
'
+
qual
)
# [nlag x nparameters]
...
...
@@ -463,6 +464,7 @@ class StateVector(object):
def
read_ensemble_member_from_file
(
self
,
filename
,
lag
,
date
=
None
,
initdir
=
None
,
qual
=
'
opt
'
,
read_lag
=
0
):
#FLAG: add documentation
# if date is None we can directly read mean and ensemble members. Else we will need to read 2 ensembles and interpolate
if
date
is
None
:
...
...
@@ -531,6 +533,7 @@ class StateVector(object):
:param: lag: Which lag step of the filter to write, must lie in range [1,...,nlag]
:param: outdir: Directory where to write files
:param: endswith: Optional label to add to the filename, default is simply .nc
:param: obsoperator: Currenlty unused: The observationoperator object. Defaults to None
:rtype: None
Write ensemble member information to a NetCDF file for later use. The standard output filename is
...
...
@@ -543,13 +546,6 @@ class StateVector(object):
can simply inherit from the StateVector baseclass and overwrite this write_members_to_file function.
"""
# These import statements caused a crash in netCDF4 on MacOSX. No problems on Jet though. Solution was
# to do the import already at the start of the module, not just in this method.
#import da.tools.io as io
#import da.tools.io4 as io
members
=
self
.
ensemble_members
[
lag
]
for
mem
in
members
:
...
...
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