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
Package registry
Container registry
Model registry
Operate
Terraform modules
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
NearRealTimeCTDAS
CTDAS
Commits
bb3b2820
Commit
bb3b2820
authored
10 years ago
by
weihe
Browse files
Options
Downloads
Patches
Plain Diff
May 21 New observationoperator for WRF-STILT
parent
6dba86ae
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/stilt/observationoperator.py
+32
-18
32 additions, 18 deletions
da/stilt/observationoperator.py
with
32 additions
and
18 deletions
da/stilt/observationoperator.py
+
32
−
18
View file @
bb3b2820
...
...
@@ -27,12 +27,12 @@ import subprocess #use to get info from running status
import
numpy
as
np
from
string
import
join
import
glob
sys
.
path
.
append
(
os
.
getcwd
())
sys
.
path
.
append
(
"
../../
"
)
#
sys.path.append(os.getcwd())
#
sys.path.append("../../")
import
da.tools.rc
as
rc
from
da.tools.general
import
create_dirs
,
to_datetime
from
da.baseclasses.observationoperator
import
ObservationOperator
#
import da.tools.rc as rc
#
from da.tools.general import create_dirs, to_datetime
#
from da.baseclasses.observationoperator import ObservationOperator
# global constants, which will be used in the following classes
identifier
=
'
WRF-STILT
'
...
...
@@ -45,44 +45,57 @@ version = '1.0'
class
STILTObservationOperator
(
ObservationOperator
):
class
STILTObservationOperator
(
object
):
def
__init__
(
self
,
filenam
e
):
#only the filename used to specify the location of the stavector file for wrf-stilt runs
def
__init__
(
self
,
dacycle
=
Non
e
):
#only the filename used to specify the location of the stavector file for wrf-stilt runs
"""
The instance of an STILTObservationOperator is application dependent
"""
self
.
ID
=
identifier
# the identifier gives the model name
self
.
version
=
version
# the model version used
self
.
restart_filelist
=
[]
self
.
output_filelist
=
[]
self
.
outputdir
=
None
# Needed for opening the samples.nc files created
#self.load_rc(filename) # load the specified rc-file
#self.validate_rc() # validate the contents
#self.update_rc(filename)
self
.
simulated_file
=
None
self
.
forecast_nmembers
=
None
#self.simulated_file = None
#self.forecast_nmembers = None
# we need the folder of the input statevector and the path of the excecutable STILT procedure
self
.
rc
=
filename
#
self.rc=filename
logging
.
info
(
'
Observation Operator initialized: %s (%s)
'
%
(
self
.
ID
,
self
.
version
))
if
dacycle
!=
None
:
self
.
dacycle
=
dacycle
else
:
self
.
dacycle
=
{}
self
.
startdate
=
None
def
get_initial_data
(
self
):
"""
This method places all initial data needed by an ObservationOperator in the proper folder for the model
"""
def
setup
(
self
,
dacycle
):
"""
Execute all steps needed to prepare the ObsOperator for use inside CTDAS, only done at the very first cycle normally
"""
self
.
dacycle
=
dacycle
self
.
outputdir
=
dacycle
[
'
dir.output
'
]
self
.
rc
=
dacycle
[
'
da.obsoperator.rc
'
]
print
"
XXX%s
"
%
(
self
.
outputdir
)
#print "XXX%s" %(self.rc)
def
prepare_run
(
self
):
"""
Prepare the running of the actual forecast model, for example compile code
"""
import
os
self
.
update_rc
(
self
.
rc
)
ss
=
self
.
startdate
.
strftime
(
"
%Y%m%d
"
)
print
"
XXX%s
"
%
(
ss
)
self
.
outputdir
=
(
self
.
outputdir
)[
0
:(
len
(
self
.
outputdir
)
-
8
)]
+
ss
print
"
XXX%s
"
%
(
self
.
outputdir
)
# Define the name of the file that will contain the modeled output of each observation
self
.
simulated_file
=
os
.
path
.
join
(
self
.
outputdir
,
'
samples_simulated.%s.nc
'
%
self
.
dacycle
[
'
time.sample.stamp
'
])
self
.
forecast_nmembers
=
int
(
self
.
dacycle
[
'
da.optimizer.nmembers
'
])
def
update_rc
(
self
,
name
):
def
update_rc
(
self
,
name
):
self
.
rc_filename
=
name
with
open
(
name
)
as
f
:
...
...
@@ -95,6 +108,7 @@ class STILTObservationOperator(ObservationOperator):
starttime
=
datetime
.
date
(
starttime
.
year
,
starttime
.
month
,
starttime
.
day
)
#YYYY-MM-DD
print
"
XXX%s
"
%
(
starttime
)
data
[
26
]
=
starttime
self
.
startdate
=
starttime
t
=
data
.
reshape
((
9
,
3
))
output
=
open
(
name
,
'
w
'
)
...
...
@@ -107,7 +121,7 @@ class STILTObservationOperator(ObservationOperator):
def
run_forecast_model
(
self
):
#extral interface
self
.
prepare_run
()
#self.validate_input()
self
.
update_rc
(
self
.
rc
)
#
self.update_rc(self.rc)
self
.
run
()
#self.save_data()
...
...
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