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
dadc24e9
Commit
dadc24e9
authored
14 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
private copy for CT, specifying its own needed rc-items
parent
1798750e
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/ct/dasystem.py
+80
-0
80 additions, 0 deletions
da/ct/dasystem.py
with
80 additions
and
0 deletions
da/ct/dasystem.py
0 → 100755
+
80
−
0
View file @
dadc24e9
#!/usr/bin/env python
# control.py
"""
Author : peters
Revision History:
File created on 26 Aug 2010.
"""
import
os
import
sys
import
logging
import
datetime
################### Begin Class DaSystem ###################
class
DaSystem
(
object
):
"""
Information on the data assimilation system used. This is normally an rc-file with settings.
"""
def
__init__
(
self
,
rcfilename
):
"""
Initialization occurs from passed rc-file name
"""
self
.
LoadRc
(
rcfilename
)
def
__str__
(
self
):
"""
String representation of a DaInfo object
"""
msg
=
"
===============================================================
"
;
print
msg
msg
=
"
DA System Info rc-file is %s
"
%
self
.
RcFileName
;
print
msg
msg
=
"
===============================================================
"
;
print
msg
return
""
def
LoadRc
(
self
,
RcFileName
):
"""
This method loads a DA System Info rc-file with settings for this simulation
"""
import
da.tools.rc
as
rc
self
.
da_settings
=
rc
.
read
(
RcFileName
)
self
.
RcFileName
=
RcFileName
self
.
DaRcLoaded
=
True
msg
=
'
DA System Info rc-file (%s) loaded successfully
'
%
self
.
RcFileName
;
logging
.
info
(
msg
)
return
True
def
Validate
(
self
,
needed_rc_items
):
"""
Validate the contents of the rc-file given a dictionary of required keys
"""
for
k
,
v
in
self
.
da_settings
.
iteritems
():
if
v
==
'
True
'
:
self
.
da_settings
[
k
]
=
True
if
v
==
'
False
'
:
self
.
da_settings
[
k
]
=
False
for
key
in
needed_rc_items
:
if
not
self
.
da_settings
.
has_key
(
key
):
status
,
msg
=
(
False
,
'
Missing a required value in rc-file : %s
'
%
key
)
logging
.
error
(
msg
)
raise
IOError
,
msg
status
,
msg
=
(
True
,
'
DA System Info settings have been validated succesfully
'
)
;
logging
.
debug
(
msg
)
return
None
################### End Class DaSystem ###################
if
__name__
==
"
__main__
"
:
pass
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