Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NearRealTimeCTDAS
CTDAS
Commits
ab4590d0
Commit
ab4590d0
authored
Oct 30, 2012
by
karolina
Browse files
function names changes, some minor changes
parent
b0b1a255
Changes
14
Hide whitespace changes
Inline
Side-by-side
da/baseclasses/observationoperator.py
View file @
ab4590d0
...
...
@@ -58,11 +58,11 @@ class ObservationOperator(object):
def
Initialize
(
self
):
""" Perform all steps necessary to start the observation operator through a simple Run() call """
def
V
alidate
I
nput
(
self
):
def
v
alidate
_i
nput
(
self
):
""" Make sure that data needed for the ObservationOperator (such as observation input lists, or parameter files)
are present.
"""
def
S
ave
D
ata
(
self
):
def
s
ave
_d
ata
(
self
):
""" Write the data that is needed for a restart or recovery of the Observation Operator to the save directory """
...
...
da/baseclasses/optimizer.py
View file @
ab4590d0
...
...
@@ -42,8 +42,6 @@ class Optimizer(object):
self
.
nobs
=
dims
[
3
]
self
.
create_matrices
()
return
None
def
create_matrices
(
self
):
""" Create Matrix space needed in optimization routine """
import
numpy
as
np
...
...
da/baseclasses/platform.py
View file @
ab4590d0
...
...
@@ -54,7 +54,7 @@ class PlatForm(object):
def
ReturnQueueType
(
self
):
return
"foreground"
def
G
et
JobT
emplate
(
self
,
joboptions
=
{},
block
=
False
):
def
g
et
_job_t
emplate
(
self
,
joboptions
=
{},
block
=
False
):
"""
Returns the job template for a given computing system, and fill it with options from the dictionary provided as argument.
The job template should return the preamble of a job that can be submitted to a queue on your platform,
...
...
@@ -96,11 +96,11 @@ class PlatForm(object):
template
=
template
.
replace
(
k
,
v
)
return
template
def
G
et
MyID
(
self
):
def
g
et
_my_id
(
self
):
""" Return the process ID, or job ID of the current process or job"""
return
os
.
getpid
()
def
W
rite
J
ob
(
self
,
jobfile
,
template
,
jobid
):
def
w
rite
_j
ob
(
self
,
jobfile
,
template
,
jobid
):
"""
This method writes a jobfile to the exec dir and makes it executable (mod 477)
"""
...
...
@@ -113,7 +113,7 @@ class PlatForm(object):
os
.
chmod
(
jobfile
,
477
)
logging
.
debug
(
"A job file was created (%s)"
%
jobfile
)
def
S
ubmit
J
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
def
s
ubmit
_j
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
"""
:param jobfile: a string with the filename of a jobfile to run
:param joblog: a string with the filename of a logfile to write run output to
...
...
@@ -137,10 +137,10 @@ class PlatForm(object):
logging
.
info
(
' kill %i
\n
'
%
jobid
)
def
K
ill
J
ob
(
self
,
jobid
):
def
k
ill
_j
ob
(
self
,
jobid
):
""" This method kills a running job """
def
StatJob
(
self
,
jobid
):
def
job_stat
(
self
,
jobid
):
""" This method gets the status of a running job """
output
=
subprocess
.
Popen
([
'qstat'
,
jobid
],
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
;
logging
.
info
(
output
)
return
output
...
...
da/ct/obs.py
View file @
ab4590d0
...
...
@@ -70,7 +70,7 @@ class CtObservations(Observation):
idates
=
ncf
.
GetVariable
(
'date_components'
)
dates
=
array
([
dtm
.
datetime
(
*
d
)
for
d
in
idates
])
subselect
=
logical_and
(
dates
>=
self
.
startdate
,
dates
<=
self
.
enddate
).
nonzero
()[
0
]
subselect
=
logical_and
(
dates
>=
self
.
startdate
,
dates
<=
self
.
enddate
).
nonzero
()[
0
]
dates
=
dates
.
take
(
subselect
,
axis
=
0
)
...
...
@@ -484,13 +484,19 @@ class MixingRatioList(list):
return
result
.
squeeze
()
else
:
return
result
def
unflagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
==
0
])
l
=
[
o
for
o
in
self
if
o
.
flag
==
0
]
print
l
return
MixingRatioSample
(
l
)
def
flagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
!=
0
])
def
selectsite
(
self
,
site
=
'mlo'
):
l
=
[
o
for
o
in
self
if
o
.
code
==
site
]
return
MixingRatioSample
(
l
)
def
selecthours
(
self
,
hours
=
range
(
1
,
24
)):
l
=
[
o
for
o
in
self
if
o
.
xdate
.
hour
in
hours
]
return
MixingRatioSample
(
l
)
...
...
@@ -510,12 +516,23 @@ if __name__ == "__main__":
obs
=
CtObservations
()
DaCycle
=
JobStart
([
'-v'
],
{
'rc'
:
'da.rc'
})
DaCycle
[
'time.sample.start'
]
=
datetime
(
2000
,
1
,
1
)
DaCycle
[
'time.sample.end'
]
=
datetime
(
2000
,
1
,
2
)
obs
.
Initialize
()
obs
.
Validate
()
obs
.
add_observations
()
print
(
obs
.
Data
.
getvalues
(
'obs'
))
#DaCycle = JobStart(['-v'], {'rc':'da.rc'})
#DaCycle['time.sample.start'] = datetime(2000, 1, 1)
#DaCycle['time.sample.end'] = datetime(2000, 1, 2)
#obs.Initialize()
#obs.Validate()
#obs.add_observations()
#print(obs.Data.getvalues('obs'))
obs
.
Data
=
MixingRatioList
([])
obs
.
Data
.
append
(
MixingRatioSample
(
"10"
,
datetime
(
2000
,
1
,
1
)))
obs
.
Data
.
append
(
MixingRatioSample
(
"20"
,
datetime
(
2000
,
1
,
2
)))
obs
.
Data
.
append
(
MixingRatioSample
(
"30"
,
datetime
(
2000
,
1
,
3
)))
obs
.
Data
.
append
(
MixingRatioSample
(
"40"
,
datetime
(
2000
,
1
,
4
)))
for
d
in
obs
.
Data
:
print
d
new
=
obs
.
Data
.
unflagged
()
print
new
#new = obs.Data.selectsite("10")
#print new
\ No newline at end of file
da/ct/obspack.py
View file @
ab4590d0
...
...
@@ -501,13 +501,17 @@ class MixingRatioList(list):
return
result
.
squeeze
()
else
:
return
result
def
unflagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
==
0
])
def
flagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
!=
0
])
def
selectsite
(
self
,
site
=
'mlo'
):
l
=
[
o
for
o
in
self
if
o
.
code
==
site
]
return
MixingRatioSample
(
l
)
def
selecthours
(
self
,
hours
=
range
(
1
,
24
)):
l
=
[
o
for
o
in
self
if
o
.
xdate
.
hour
in
hours
]
return
MixingRatioSample
(
l
)
...
...
da/ct/obspack_geocarbon.py
View file @
ab4590d0
...
...
@@ -514,13 +514,17 @@ class MixingRatioList(list):
return
result
.
squeeze
()
else
:
return
result
def
unflagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
==
0
])
def
flagged
(
self
):
return
MixingRatioSample
([
o
for
o
in
self
if
o
.
flag
!=
0
])
def
selectsite
(
self
,
site
=
'mlo'
):
l
=
[
o
for
o
in
self
if
o
.
code
==
site
]
return
MixingRatioSample
(
l
)
def
selecthours
(
self
,
hours
=
range
(
1
,
24
)):
l
=
[
o
for
o
in
self
if
o
.
xdate
.
hour
in
hours
]
return
MixingRatioSample
(
l
)
...
...
da/ctgridded/dasystem.py
View file @
ab4590d0
...
...
@@ -29,7 +29,6 @@ class CtGriddedDaSystem(DaSystem):
"""
self
.
Identifier
=
'CarbonTracker Gridded CO2'
# the identifier gives the platform name
self
.
LoadRc
(
rcfilename
)
msg
=
'Data Assimilation System initialized: %s'
%
self
.
Identifier
;
logging
.
debug
(
msg
)
...
...
da/ctgridded/statevector.py
View file @
ab4590d0
...
...
@@ -16,8 +16,7 @@ sys.path.append('../../')
import
logging
import
datetime
from
da.baseclasses.statevector
import
EnsembleMember
,
StateVector
from
da.baseclasses.statevector
import
StateVector
import
numpy
as
np
identifier
=
'CarbonTracker Gridded Statevector '
...
...
@@ -202,13 +201,10 @@ class CtGriddedStateVector(StateVector):
if
__name__
==
"__main__"
:
import
os
import
sys
from
da.tools.initexit
import
StartLogger
,
ParseOptions
from
da.tools.pipeline
import
JobStart
from
da.tools.initexit
import
CycleControl
from
da.ctgridded.dasystem
import
CtGriddedDaSystem
import
numpy
as
np
sys
.
path
.
append
(
os
.
getcwd
())
sys
.
path
.
append
(
'../../'
)
...
...
da/platform/huygens.py
View file @
ab4590d0
...
...
@@ -52,7 +52,7 @@ class HuygensPlatForm(PlatForm):
def
G
et
JobT
emplate
(
self
,
joboptions
=
{},
block
=
False
):
def
g
et
_job_t
emplate
(
self
,
joboptions
=
{},
block
=
False
):
"""
Returns the job template for a given computing system, and fill it with options from the dictionary provided as argument.
The job template should return the preamble of a job that can be submitted to a queue on your platform,
...
...
@@ -136,7 +136,7 @@ class HuygensPlatForm(PlatForm):
# return os.getpid()
#
# def
S
ubmit
J
ob(self,jobfile,joblog=None,block=False):
# def
s
ubmit
_j
ob(self,jobfile,joblog=None,block=False):
# """ This method submits a jobfile to the queue, and returns the queue ID """
#
#
...
...
@@ -154,7 +154,7 @@ class HuygensPlatForm(PlatForm):
def
S
ubmit
J
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
def
s
ubmit
_j
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
""" This method submits a jobfile to the queue, and returns the queue ID """
...
...
da/platform/jet.py
View file @
ab4590d0
...
...
@@ -27,7 +27,7 @@ class JetPlatForm(PlatForm):
msg2
=
'%s version: %s'
%
(
self
.
Identifier
,
self
.
Version
)
;
logging
.
debug
(
msg2
)
def
G
et
JobT
emplate
(
self
,
joboptions
=
{},
block
=
False
):
def
g
et
_job_t
emplate
(
self
,
joboptions
=
{},
block
=
False
):
""" Return the job template for a given computing system, and fill it with options from the dictionary provided as argument"""
template
=
"""#$ -N jobname
\n
"""
+
\
...
...
@@ -59,13 +59,13 @@ class JetPlatForm(PlatForm):
return
template
def
G
et
MyID
(
self
):
def
g
et
_my_id
(
self
):
try
:
return
os
.
environ
[
'JOB_ID'
]
except
:
return
os
.
getpid
()
def
S
ubmit
J
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
def
s
ubmit
_j
ob
(
self
,
jobfile
,
joblog
=
None
,
block
=
False
):
""" This method submits a jobfile to the queue, and returns the queue ID """
...
...
@@ -77,14 +77,14 @@ class JetPlatForm(PlatForm):
return
retcode
def
K
ill
J
ob
(
self
,
jobid
):
def
k
ill
_j
ob
(
self
,
jobid
):
""" This method kills a running job """
output
=
subprocess
.
Popen
([
'qdel'
,
jobid
],
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
;
logging
.
info
(
output
)
return
output
def
StatJob
(
self
,
jobid
):
def
job_stat
(
self
,
jobid
):
""" This method gets the status of a running job """
import
subprocess
...
...
da/platform/maunaloa.py
View file @
ab4590d0
...
...
@@ -30,7 +30,7 @@ class MaunaloaPlatForm(PlatForm):
return
"foreground"
def
G
et
JobT
emplate
(
self
,
joboptions
=
{},
block
=
False
):
def
g
et
_job_t
emplate
(
self
,
joboptions
=
{},
block
=
False
):
"""
Returns the job template for a given computing system, and fill it with options from the dictionary provided as argument.
The job template should return the preamble of a job that can be submitted to a queue on your platform,
...
...
da/tm5/observationoperator.py
View file @
ab4590d0
...
...
@@ -357,7 +357,7 @@ class TM5ObservationOperator(ObservationOperator):
logging
.
debug
(
"Modified tm5_runtime.rc written (%s)"
%
tm5rcfilename
)
def
V
alidate
I
nput
(
self
):
def
v
alidate
_i
nput
(
self
):
"""
Make sure that parameter files are written to the TM5 inputdir, and that observation lists are present
"""
...
...
@@ -518,14 +518,14 @@ class TM5ObservationOperator(ObservationOperator):
jobfile
=
os
.
path
.
join
(
targetdir
,
'jb.%s.jb'
%
jobid
)
logfile
=
jobfile
.
replace
(
'.jb'
,
'.log'
)
template
=
DaPlatForm
.
G
et
JobT
emplate
(
jobparams
,
block
=
True
)
template
=
DaPlatForm
.
g
et
_job_t
emplate
(
jobparams
,
block
=
True
)
template
+=
'cd %s
\n
'
%
targetdir
template
+=
'mpirun -np %d %s ./tm5.x
\n
'
%
(
int
(
nthreads
),
mpi_shell_filename
,)
DaPlatForm
.
W
rite
J
ob
(
jobfile
,
template
,
jobid
)
DaPlatForm
.
w
rite
_j
ob
(
jobfile
,
template
,
jobid
)
logging
.
info
(
'Submitting job at %s'
%
datetime
.
datetime
.
now
())
code
=
DaPlatForm
.
S
ubmit
J
ob
(
jobfile
,
joblog
=
jobfile
)
code
=
DaPlatForm
.
s
ubmit
_j
ob
(
jobfile
,
joblog
=
jobfile
)
logging
.
info
(
'Resuming job at %s'
%
datetime
.
datetime
.
now
())
if
not
os
.
path
.
exists
(
okfile
):
...
...
@@ -577,7 +577,7 @@ class TM5ObservationOperator(ObservationOperator):
return
code
def
S
ave
D
ata
(
self
):
def
s
ave
_d
ata
(
self
):
""" Copy the TM5 recovery data from the outputdir to the TM5 savedir, also add the restart files to a list of names
that is used by the DaCycle object to collect restart data for the filter.
...
...
@@ -680,7 +680,7 @@ if __name__ == "__main__":
tm
.
Setup
()
tm
.
Initialize
()
tm
.
Run
()
tm
.
S
ave
D
ata
()
tm
.
s
ave
_d
ata
()
...
...
da/tools/initexit.py
View file @
ab4590d0
...
...
@@ -40,8 +40,8 @@ like this:::
The most important method of the CycleControl object are listed below:
.. autoclass:: da.tools.initexit.CycleControl
:members: Initialize, Finalize,
C
ollect
R
estart
D
ata,
M
ove
R
estart
D
ata,
S
ubmit
N
ext
Cycle, CleanUpC
ycle,
S
etup
F
ile
S
tructure,
R
ecover
R
un,
R
andom
S
eed
:members: Initialize, Finalize,
c
ollect
_r
estart
_d
ata,
m
ove
_r
estart
_d
ata,
s
ubmit
_n
ext
_c
ycle,
s
etup
_f
ile
_s
tructure,
r
ecover
_r
un,
r
andom
_s
eed
Two important attributes of the CycleControl object are:
(1) DaSystem, an instance of a :ref:`dasystem`
...
...
@@ -130,8 +130,6 @@ class CycleControl(dict):
logging
.
info
(
'DA Cycle rc-file (%s) loaded successfully'
%
self
.
RcFileName
)
return
True
def
ValidateRC
(
self
):
"""
...
...
@@ -203,7 +201,7 @@ class CycleControl(dict):
logging
.
info
(
"==============================================================="
)
def
S
et
S
ample
T
imes
(
self
,
lag
):
def
s
et
_s
ample
_t
imes
(
self
,
lag
):
"""
Set the times over which a sampling interval will loop, depending on
the lag. Note that lag falls in the interval [0,nlag-1]
...
...
@@ -217,10 +215,10 @@ class CycleControl(dict):
# Now advance depending on lag
for
l
in
range
(
lag
):
self
.
A
dvance
S
ample
T
imes
()
self
.
a
dvance
_s
ample
_t
imes
()
def
A
dvance
S
ample
T
imes
(
self
):
def
a
dvance
_s
ample
_t
imes
(
self
):
"""
Advance sampling start and end time by one cycle interval
"""
...
...
@@ -257,7 +255,7 @@ class CycleControl(dict):
self
[
'time.end'
]
=
enddate
def
R
andom
S
eed
(
self
,
action
=
'read'
):
def
r
andom
_s
eed
(
self
,
action
=
'read'
):
"""
Get the randomseed and save it, or read the random seed and set it. The seed is currently stored
in a python :mod:`pickle` file, residing in the ``exec`` directory
...
...
@@ -305,19 +303,19 @@ class CycleControl(dict):
# the ``time.restart : True`` option in the da.rc file
The latter is automatically set if the filter submits the next cycle at the end of the current one,
through method :meth:`~da.tools.initexit.CycleControl.
S
ubmit
N
ext
C
ycle`.
through method :meth:`~da.tools.initexit.CycleControl.
s
ubmit
_n
ext
_c
ycle`.
The specific call tree under each scenario is:
1. *Fresh Start*
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
S
etup
F
ile
S
tructure()` <- Create directory tree
* :meth:`~da.tools.initexit.CycleControl.
s
etup
_f
ile
_s
tructure()` <- Create directory tree
2. *Restart*
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
S
etup
F
ile
S
tructure()`
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
R
andom
S
eed` <- Read the random seed from file
* :meth:`~da.tools.initexit.CycleControl.
s
etup
_f
ile
_s
tructure()`
* :meth:`~da.tools.initexit.CycleControl.
r
andom
_s
eed` <- Read the random seed from file
3. *Recover*
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
S
etup
F
ile
S
tructure()`
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
R
ecover
R
un()` <- Recover files from restart/one-ago dir, reset ``time.start``
*
dummy =
:meth:`~da.tools.initexit.CycleControl.
R
andom
S
eed`
* :meth:`~da.tools.initexit.CycleControl.
s
etup
_f
ile
_s
tructure()`
* :meth:`~da.tools.initexit.CycleControl.
r
ecover
_r
un()` <- Recover files from restart/one-ago dir, reset ``time.start``
* :meth:`~da.tools.initexit.CycleControl.
r
andom
_s
eed`
And is always followed by a call to
...
...
@@ -329,24 +327,24 @@ class CycleControl(dict):
#
if
self
[
'da.crash.recover'
]:
logging
.
info
(
"Recovering simulation from data in: %s"
%
self
[
'dir.da_run'
])
self
.
S
etup
F
ile
S
tructure
()
self
.
R
ecover
R
un
()
self
.
R
andom
S
eed
(
'read'
)
self
.
s
etup
_f
ile
_s
tructure
()
self
.
r
ecover
_r
un
()
self
.
r
andom
_s
eed
(
'read'
)
#
# case 2: A continuation, this is signaled by rc-item time.restart = True
#
elif
self
[
'time.restart'
]:
logging
.
info
(
"Restarting filter from previous step"
)
self
.
S
etup
F
ile
S
tructure
()
self
.
s
etup
_f
ile
_s
tructure
()
strippedname
=
os
.
path
.
split
(
self
[
'jobrcfilename'
])[
-
1
]
self
[
'jobrcfilename'
]
=
os
.
path
.
join
(
self
[
'dir.exec'
],
strippedname
)
self
.
R
andom
S
eed
(
'read'
)
self
.
r
andom
_s
eed
(
'read'
)
#
# case 3: A fresh start, this is signaled by rc-item time.restart = False
#
elif
not
self
[
'time.restart'
]:
logging
.
info
(
"First time step in filter sequence"
)
self
.
S
etup
F
ile
S
tructure
()
self
.
s
etup
_f
ile
_s
tructure
()
# expand jobrcfilename to include exec dir from now on.
# First strip current leading path from filename
...
...
@@ -357,7 +355,7 @@ class CycleControl(dict):
self
.
ParseTimes
()
self
.
WriteRC
(
self
[
'jobrcfilename'
])
def
S
etup
F
ile
S
tructure
(
self
):
def
s
etup
_f
ile
_s
tructure
(
self
):
"""
Create file structure needed for data assimilation system.
In principle this looks like:
...
...
@@ -409,13 +407,13 @@ class CycleControl(dict):
logging
.
info
(
'Succesfully created the file structure for the assimilation job'
)
def
R
ecover
R
un
(
self
):
def
r
ecover
_r
un
(
self
):
"""
Prepare a recovery from a crashed run. This consists of:
- copying all data from the restart/one-ago folder (:meth:`~da.tools.initexit.CycleControl.
M
ove
R
estart
D
ata`),
- copying all data from the restart/one-ago folder (:meth:`~da.tools.initexit.CycleControl.
m
ove
_r
estart
_d
ata`),
- replacing all ``rc-file`` items with those from the ``da_runtime.rc`` in the restart/current dir
- resetting the seed of the random number generator to the value it had before the crash (:meth:`~da.tools.initexit.CycleControl.
R
andom
S
eed`)
- resetting the seed of the random number generator to the value it had before the crash (:meth:`~da.tools.initexit.CycleControl.
r
andom
_s
eed`)
- replacing the output dir name, since it has the sample time in it...
"""
...
...
@@ -459,14 +457,14 @@ class CycleControl(dict):
* Submit the next cycle
"""
self
.
R
andom
S
eed
(
'write'
)
self
.
W
rite
NewRC
file
()
self
.
M
ove
R
estart
D
ata
(
io_option
=
'store'
)
# Move restart data from current to one-ago
self
.
C
ollect
R
estart
D
ata
()
# Collect restart data for next cycle into a clean restart/current folder
self
.
C
ollect
O
utput
()
# Collect restart data for next cycle into a clean restart/current folder
self
.
S
ubmit
N
ext
C
ycle
()
def
C
ollect
O
utput
(
self
):
self
.
r
andom
_s
eed
(
'write'
)
self
.
w
rite
_new_rc_
file
()
self
.
m
ove
_r
estart
_d
ata
(
io_option
=
'store'
)
# Move restart data from current to one-ago
self
.
c
ollect
_r
estart
_d
ata
()
# Collect restart data for next cycle into a clean restart/current folder
self
.
c
ollect
_o
utput
()
# Collect restart data for next cycle into a clean restart/current folder
self
.
s
ubmit
_n
ext
_c
ycle
()
def
c
ollect
_o
utput
(
self
):
""" Collect files that are part of the requested output for this cycle. This function allows users to add files
to a list, and then the system will copy these to the current cycle's output directory.
The list of files included is read from the
...
...
@@ -495,7 +493,7 @@ class CycleControl(dict):
def
C
ollect
R
estart
D
ata
(
self
):
def
c
ollect
_r
estart
_d
ata
(
self
):
""" Collect files needed for the restart of this cycle in case of a crash, or for the continuation of the next cycle.
All files needed are written to the restart/current directory. The list of files included is read from the
attribute "RestartFileList" which is a simple list of files that can be appended by other objects/methods that
...
...
@@ -539,7 +537,7 @@ class CycleControl(dict):
shutil
.
copy
(
file
,
file
.
replace
(
os
.
path
.
split
(
file
)[
0
],
targetdir
))
def
M
ove
R
estart
D
ata
(
self
,
io_option
=
'restore'
):
def
m
ove
_r
estart
_d
ata
(
self
,
io_option
=
'restore'
):
"""
Store or restore model state to/from a restart directory.
...
...
@@ -587,7 +585,7 @@ class CycleControl(dict):
shutil
.
copy
(
file
,
file
.
replace
(
sourcedir
,
targetdir
))
#
def
W
rite
NewRC
file
(
self
):
def
w
rite
_new_rc_
file
(
self
):
""" Write the rc-file for the next DA cycle.
.. note:: The start time for the next cycle is the end time of this one, while
...
...
@@ -627,7 +625,7 @@ class CycleControl(dict):
logging
.
debug
(
'Wrote expanded rc-file (%s)'
%
(
fname
))
def
S
ubmit
N
ext
C
ycle
(
self
):
def
s
ubmit
_n
ext
_c
ycle
(
self
):
"""
Submit the next job of a DA cycle, this consists of
* Changing to the working directory from which the job was started initially
...
...
@@ -651,13 +649,13 @@ class CycleControl(dict):
# Template and commands for job
jobparams
=
{
'jobname'
:
"j.%s"
%
jobid
,
'jobtime'
:
'06:00:00'
,
'logfile'
:
logfile
,
'errfile'
:
logfile
}
template
=
DaPlatForm
.
G
et
JobT
emplate
(
jobparams
)
template
=
DaPlatForm
.
g
et
_job_t
emplate
(
jobparams
)
execcommand
=
os
.
path
.
join
(
self
[
'dir.da_submit'
],
sys
.
argv
[
0
])
template
+=
'python %s rc=%s %s'
%
(
execcommand
,
self
[
'da.restart.fname'
],
join
(
self
.
opts
,
''
),)
# write and submit
DaPlatForm
.
W
rite
J
ob
(
jobfile
,
template
,
jobid
)
jobid
=
DaPlatForm
.
S
ubmit
J
ob
(
jobfile
,
joblog
=
logfile
)
DaPlatForm
.
w
rite
_j
ob
(
jobfile
,
template
,
jobid
)
jobid
=
DaPlatForm
.
s
ubmit
_j
ob
(
jobfile
,
joblog
=
logfile
)
else
:
logging
.
info
(
'Final date reached, no new cycle started'
)
...
...
@@ -665,10 +663,10 @@ class CycleControl(dict):
def
SubmitSubStep
(
self
,
stepname
):
"""
Submit the next substep of a DA cycle, this consists of
* getting a job template as returned by :meth:`~da.tools.baseclasses.platform.
G
et
JobT
emplate`
* getting a job template as returned by :meth:`~da.tools.baseclasses.platform.
g
et
_job_t
emplate`
* adding the lines needed to start a next run with a newly created rc-file
* Writing the jobfile as done by :meth:`~da.tools.baseclasses.platform.
W
rite
J
ob`
* Submitting the jobfile as done by :meth:`~da.tools.baseclasses.platform.
W
rite
J
ob`
* Writing the jobfile as done by :meth:`~da.tools.baseclasses.platform.
w
rite
_j
ob`
* Submitting the jobfile as done by :meth:`~da.tools.baseclasses.platform.
w
rite
_j
ob`
"""
from
string
import
join
...
...
@@ -676,16 +674,13 @@ class CycleControl(dict):
DaPlatForm
=
self
.
DaPlatForm
jobparams
=
{
'jobname'
:
'das.%s'
%
stepname
}
template
=
DaPlatForm
.
G
et
JobT
emplate
(
jobparams
)
template
=
DaPlatForm
.
g
et
_job_t
emplate
(
jobparams
)
template
+=
'cd %s
\n
'
%
os
.
getcwd
()
template
+=
'%s rc=%s process=%s %s'
%
(
sys
.
argv
[
0
],
self
[
'jobrcfilename'
],
stepname
,
join
(
self
.
opts
,
''
),)
jobfile
=
DaPlatForm
.
WriteJob
(
self
,
template
,
stepname
)
DaPlatForm
.
SubmitJob
(
jobfile
)
jobfile
=
DaPlatForm
.
write_job
(
self
,
template
,
stepname
)
DaPlatForm
.
submit_job
(
jobfile
)
def
CleanUpCycle
(
self
):
"""
Nothing to do for now anymore
"""
...
...
da/tools/pipeline.py
View file @
ab4590d0
...
...
@@ -158,7 +158,7 @@ def SampleOneCycle(DaCycle, Samples, StateVector, ObservationOperator, lag):
import
copy
# First set up the information for time start and time end of this sample
DaCycle
.
S
et
S
ample
T
imes
(
lag
)
DaCycle
.
s
et
_s
ample
_t
imes
(
lag
)
startdate
=
DaCycle
[
'time.sample.start'
]
enddate
=
DaCycle
[
'time.sample.end'
]
...
...
@@ -298,8 +298,8 @@ def RunForecastModel(DaCycle, ObsOperator):
"""
ObsOperator
.
PrepareRun
()
ObsOperator
.
V
alidate
I
nput
()
ObsOperator
.
v
alidate
_i
nput
()
ObsOperator
.
Run
()
ObsOperator
.
S
ave
D
ata
()
ObsOperator
.
s
ave
_d
ata
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment