Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DART-WRF
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
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
f6ded4c6
Commit
f6ded4c6
authored
2 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
docs
parent
86151bf8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dartwrf/assim_synth_obs.py
+1
-8
1 addition, 8 deletions
dartwrf/assim_synth_obs.py
dartwrf/utils.py
+36
-5
36 additions, 5 deletions
dartwrf/utils.py
with
37 additions
and
13 deletions
dartwrf/assim_synth_obs.py
+
1
−
8
View file @
f6ded4c6
...
@@ -3,7 +3,7 @@ import time as time_module
...
@@ -3,7 +3,7 @@ import time as time_module
import
datetime
as
dt
import
datetime
as
dt
import
numpy
as
np
import
numpy
as
np
from
dartwrf.utils
import
symlink
,
copy
,
sed_inplace
,
append_file
,
mkdir
,
try_remove
,
print
,
shell
from
dartwrf.utils
import
symlink
,
copy
,
sed_inplace
,
append_file
,
mkdir
,
try_remove
,
print
,
shell
,
write_txt
from
dartwrf.obs
import
error_models
as
err
from
dartwrf.obs
import
error_models
as
err
import
dartwrf.create_obsseq
as
osq
import
dartwrf.create_obsseq
as
osq
from
dartwrf
import
wrfout_add_geo
from
dartwrf
import
wrfout_add_geo
...
@@ -141,13 +141,6 @@ def prepare_prior_ensemble(assim_time, prior_init_time, prior_valid_time, prior_
...
@@ -141,13 +141,6 @@ def prepare_prior_ensemble(assim_time, prior_init_time, prior_valid_time, prior_
os
.
system
(
"
rm -rf
"
+
cluster
.
dartrundir
+
"
/perfect_output_*
"
)
os
.
system
(
"
rm -rf
"
+
cluster
.
dartrundir
+
"
/perfect_output_*
"
)
os
.
system
(
"
rm -rf
"
+
cluster
.
dartrundir
+
"
/obs_seq.fina*
"
)
os
.
system
(
"
rm -rf
"
+
cluster
.
dartrundir
+
"
/obs_seq.fina*
"
)
def
write_txt
(
lines
,
fpath
):
try_remove
(
fpath
)
with
open
(
fpath
,
"
w
"
)
as
file
:
for
line
in
lines
:
file
.
write
(
line
+
'
\n
'
)
def
write_list_of_inputfiles_prior
():
def
write_list_of_inputfiles_prior
():
files
=
[]
files
=
[]
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
...
...
This diff is collapsed.
Click to expand it.
dartwrf/utils.py
+
36
−
5
View file @
f6ded4c6
...
@@ -109,7 +109,8 @@ def clean_wrfdir(dir):
...
@@ -109,7 +109,8 @@ def clean_wrfdir(dir):
os
.
remove
(
f
)
os
.
remove
(
f
)
def
symlink
(
src
,
dst
):
def
symlink
(
src
,
dst
):
# Create a symbolic link pointing to src named dst.
"""
Create a symbolic link from src to dst
"""
try
:
try
:
os
.
symlink
(
src
,
dst
)
os
.
symlink
(
src
,
dst
)
except
FileExistsError
:
except
FileExistsError
:
...
@@ -123,12 +124,18 @@ def symlink(src, dst):
...
@@ -123,12 +124,18 @@ def symlink(src, dst):
raise
e
raise
e
def
link_contents
(
src
,
dst
):
def
link_contents
(
src
,
dst
):
"""
Create symbolic links for all files in src to dst
Args:
src (str): Path to source directory
dst (str): Path to destination directory
Returns:
None
"""
for
f
in
os
.
listdir
(
src
):
for
f
in
os
.
listdir
(
src
):
symlink
(
src
+
'
/
'
+
f
,
dst
+
'
/
'
+
f
)
symlink
(
src
+
'
/
'
+
f
,
dst
+
'
/
'
+
f
)
def
copy_scp_srvx8
(
src
,
dst
):
os
.
system
(
'
scp
'
+
src
+
'
a1254888@srvx8.img.univie.ac.at:
'
+
dst
)
def
sed_inplace
(
filename
,
pattern
,
repl
):
def
sed_inplace
(
filename
,
pattern
,
repl
):
'''
Perform the pure-Python equivalent of in-place `sed` substitution
'''
Perform the pure-Python equivalent of in-place `sed` substitution
Like `sed -i -e
'
s/
'
${pattern}
'
/
'
${repl}
'
"
${filename}
"
`.
Like `sed -i -e
'
s/
'
${pattern}
'
/
'
${repl}
'
"
${filename}
"
`.
...
@@ -162,4 +169,28 @@ def sed_inplace(filename, pattern, repl):
...
@@ -162,4 +169,28 @@ def sed_inplace(filename, pattern, repl):
shutil
.
move
(
tmp_file
.
name
,
filename
)
shutil
.
move
(
tmp_file
.
name
,
filename
)
def
append_file
(
f_main
,
f_gets_appended
):
def
append_file
(
f_main
,
f_gets_appended
):
"""
Append the contents of one file to another
Args:
f_main (str): Path to file that will be appended
f_gets_appended (str): Path to file that will be appended to f_main
Returns:
None
"""
os
.
system
(
'
cat
'
+
f_gets_appended
+
'
>>
'
+
f_main
)
os
.
system
(
'
cat
'
+
f_gets_appended
+
'
>>
'
+
f_main
)
def
write_txt
(
lines
,
fpath
):
"""
Write a list of strings to a text file
Args:
lines (list): List of strings
fpath (str): Path to file
Returns:
None
"""
try_remove
(
fpath
)
with
open
(
fpath
,
"
w
"
)
as
file
:
for
line
in
lines
:
file
.
write
(
line
+
'
\n
'
)
\ No newline at end of file
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