Skip to content
Snippets Groups Projects
Commit 0cf47e0b authored by lkugler's avatar lkugler
Browse files

improved config

parent ca11b58a
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 107 deletions
...@@ -6,7 +6,8 @@ import os, sys, shutil ...@@ -6,7 +6,8 @@ import os, sys, shutil
import datetime as dt import datetime as dt
from dartwrf import utils from dartwrf import utils
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
log_dir = cluster.archivedir+'/logs/' log_dir = cluster.archivedir+'/logs/'
slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/' slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/'
......
from dartwrf import utils from dartwrf import utils
from config import clusters # from . = problem in archivedir
cluster = clusters.jet # change cluster configuration here
exp = utils.ExperimentConfiguration() exp = utils.ExperimentConfiguration()
exp.expname = "exp_v1.22_P2_rr_VIS+WV73_obs10_loc20_inf2" exp.expname = "exp_v1.22_P2_rr_WV62_obs10_loc20_oe2" #"exp_v1.22_P2_rr_VIS+WV73_obs10_loc20_inf5"
exp.model_dx = 2000 exp.model_dx = 2000
exp.n_ens = 40 exp.n_ens = 40
exp.filter_kind = 1 exp.filter_kind = 1
exp.prior_inflation = 2 exp.prior_inflation = 0
exp.post_inflation = 0 exp.post_inflation = 4
exp.sec = True exp.sec = True
exp.reject_smallFGD = False exp.reject_smallFGD = False
exp.cov_loc_vert_km_horiz_km = (3, 20) exp.cov_loc_vert_km_horiz_km = (3, 20)
...@@ -95,10 +93,7 @@ psfc = dict(plotname='SYNOP Pressure', plotunits='[Pa]', ...@@ -95,10 +93,7 @@ psfc = dict(plotname='SYNOP Pressure', plotunits='[Pa]',
error_generate=50., error_assimilate=100., error_generate=50., error_assimilate=100.,
cov_loc_radius_km=32) cov_loc_radius_km=32)
exp.observations = [wv62]
exp.observations = [vis,wv73]
exp.update_vars = ['U', 'V', 'W', 'THM', 'PH', 'MU', 'QVAPOR', 'QCLOUD', 'QICE', 'PSFC'] exp.update_vars = ['U', 'V', 'W', 'THM', 'PH', 'MU', 'QVAPOR', 'QCLOUD', 'QICE', 'PSFC']
#exp.update_vars = ['U', 'V', 'W', 'T', 'PH', 'MU', 'QVAPOR', 'PSFC'] #exp.update_vars = ['U', 'V', 'W', 'T', 'PH', 'MU', 'QVAPOR', 'PSFC']
# directory paths depend on the name of the experiment
cluster.expname = exp.expname
import os, sys import os, sys
import datetime as dt import datetime as dt
from dartwrf import utils from dartwrf import utils
from config.cfg import exp
"""Configuration name docs """Configuration name docs
...@@ -41,10 +42,7 @@ slurm_cfg python dictionary, containing options of SLURM ...@@ -41,10 +42,7 @@ slurm_cfg python dictionary, containing options of SLURM
'cfg_update = {"nodes": "2"}' 'cfg_update = {"nodes": "2"}'
""" """
vsc = utils.ClusterConfig(exp)
vsc = utils.ClusterConfig()
vsc.name = 'vsc' vsc.name = 'vsc'
vsc.max_nproc = 20 vsc.max_nproc = 20
vsc.size_jobarray = 10 # 10 jobs with each 4 WRF processes per node vsc.size_jobarray = 10 # 10 jobs with each 4 WRF processes per node
...@@ -77,7 +75,7 @@ vsc.slurm_cfg = {"account": "p71386", "partition": "skylake_0384", "qos": "p7138 ...@@ -77,7 +75,7 @@ vsc.slurm_cfg = {"account": "p71386", "partition": "skylake_0384", "qos": "p7138
"nodes": "1", "ntasks": "1", "ntasks-per-node": "48", "ntasks-per-core": "1", "nodes": "1", "ntasks": "1", "ntasks-per-node": "48", "ntasks-per-core": "1",
"mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"} "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
jet = utils.ClusterConfig() jet = utils.ClusterConfig(exp)
jet.name = 'jet' jet.name = 'jet'
jet.max_nproc = 12 jet.max_nproc = 12
jet.use_slurm = True jet.use_slurm = True
...@@ -113,7 +111,7 @@ jet.slurm_cfg = {"account": "lkugler", "partition": "compute", #"nodelist": "jet ...@@ -113,7 +111,7 @@ jet.slurm_cfg = {"account": "lkugler", "partition": "compute", #"nodelist": "jet
"mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"} "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
srvx1 = utils.ClusterConfig() srvx1 = utils.ClusterConfig(exp)
srvx1.name = 'srvx1' srvx1.name = 'srvx1'
srvx1.max_nproc = 6 srvx1.max_nproc = 6
srvx1.size_jobarray = 40 srvx1.size_jobarray = 40
...@@ -146,3 +144,7 @@ srvx1.run_WRF = srvx1.scriptsdir+'/run_ens.jet.sh' ...@@ -146,3 +144,7 @@ srvx1.run_WRF = srvx1.scriptsdir+'/run_ens.jet.sh'
srvx1.slurm_cfg = {"account": "lkugler", "partition": "compute", srvx1.slurm_cfg = {"account": "lkugler", "partition": "compute",
"ntasks": "1", "ntasks-per-core": "1", "mem": "50G", "ntasks": "1", "ntasks-per-core": "1", "mem": "50G",
"mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"} "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
########
# select cluster configuration here
cluster = jet
#!/usr/bin/python3 #!/usr/bin/python3
""" """
high level control script Run a cycled OSSE with WRF and DART.
submitting jobs into SLURM queue
""" """
import os, sys, shutil, glob, warnings import os, sys, shutil, glob, warnings
import datetime as dt import datetime as dt
from dartwrf.utils import script_to_str, symlink, copy, create_job from dartwrf.utils import script_to_str
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
log_dir = cluster.archivedir+'/logs/' log_dir = cluster.archivedir+'/logs/'
slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/' slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/'
...@@ -32,7 +32,7 @@ do ...@@ -32,7 +32,7 @@ do
mv $rundir/rsl.out.0000 $rundir/rsl.out.input mv $rundir/rsl.out.0000 $rundir/rsl.out.input
done done
""" """
s = create_job("ideal", cfg_update={"ntasks": str(exp.n_ens), s = cluster.create_job("ideal", cfg_update={"ntasks": str(exp.n_ens),
"time": "10", "mem": "100G"}) "time": "10", "mem": "100G"})
id = s.run(cmd, depends_on=[depends_on]) id = s.run(cmd, depends_on=[depends_on])
return id return id
...@@ -41,7 +41,7 @@ def wrfinput_insert_wbubble(perturb=True, depends_on=None): ...@@ -41,7 +41,7 @@ def wrfinput_insert_wbubble(perturb=True, depends_on=None):
"""Given that directories with wrfinput files exist, """Given that directories with wrfinput files exist,
update these wrfinput files with warm bubbles update these wrfinput files with warm bubbles
""" """
s = create_job("ins_wbubble", cfg_update={"time": "5"}) s = cluster.create_job("ins_wbubble", cfg_update={"time": "5"})
pstr = ' ' pstr = ' '
if perturb: if perturb:
pstr = ' perturb' pstr = ' perturb'
...@@ -64,7 +64,7 @@ def run_ENS(begin, end, depends_on=None, first_minute=True, ...@@ -64,7 +64,7 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
# hist_interval = 1 # hist_interval = 1
# radt = 1 # calc CFRAC also in first minute # radt = 1 # calc CFRAC also in first minute
# begin_plus1 = begin+dt.timedelta(minutes=1) # begin_plus1 = begin+dt.timedelta(minutes=1)
# s = create_job("preWRF1", cfg_update=dict(time="2")) # s = cluster.create_job("preWRF1", cfg_update=dict(time="2"))
# args = [cluster.python, cluster.scripts_rundir+'/prepare_namelist.py', # args = [cluster.python, cluster.scripts_rundir+'/prepare_namelist.py',
# begin.strftime('%Y-%m-%d_%H:%M'), # begin.strftime('%Y-%m-%d_%H:%M'),
# begin_plus1.strftime('%Y-%m-%d_%H:%M'), # begin_plus1.strftime('%Y-%m-%d_%H:%M'),
...@@ -73,13 +73,13 @@ def run_ENS(begin, end, depends_on=None, first_minute=True, ...@@ -73,13 +73,13 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
# '--restart='+restart_flag,] # '--restart='+restart_flag,]
# id = s.run(' '.join(args), depends_on=[id]) # id = s.run(' '.join(args), depends_on=[id])
# s = create_job("runWRF1", cfg_update={"nodes": "1", "array": "1-"+str(exp.n_nodes), # s = cluster.create_job("runWRF1", cfg_update={"nodes": "1", "array": "1-"+str(exp.n_nodes),
# "time": "2", "mem-per-cpu": "2G"}) # "time": "2", "mem-per-cpu": "2G"})
# cmd = script_to_str(cluster.run_WRF).replace('<expname>', exp.expname) # cmd = script_to_str(cluster.run_WRF).replace('<expname>', exp.expname)
# id = s.run(cmd, depends_on=[id]) # id = s.run(cmd, depends_on=[id])
# # apply forward operator (DART filter without assimilation) # # apply forward operator (DART filter without assimilation)
# s = create_job("fwOP-1m", cfg_update=dict(time="10", ntasks=48)) # s = cluster.create_job("fwOP-1m", cfg_update=dict(time="10", ntasks=48))
# id = s.run(cluster.python+' '+cluster.scripts_rundir+'/apply_obs_op_dart.py ' # id = s.run(cluster.python+' '+cluster.scripts_rundir+'/apply_obs_op_dart.py '
# + begin.strftime('%Y-%m-%d_%H:%M')+' ' # + begin.strftime('%Y-%m-%d_%H:%M')+' '
# + begin_plus1.strftime('%Y-%m-%d_%H:%M'), # + begin_plus1.strftime('%Y-%m-%d_%H:%M'),
...@@ -98,12 +98,12 @@ def run_ENS(begin, end, depends_on=None, first_minute=True, ...@@ -98,12 +98,12 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
if output_restart_interval: if output_restart_interval:
args.append('--restart_interval='+str(int(float(output_restart_interval)))) args.append('--restart_interval='+str(int(float(output_restart_interval))))
s = create_job("preWRF", cfg_update=dict(time="2")) s = cluster.create_job("preWRF", cfg_update=dict(time="2"))
id = s.run(' '.join(args), depends_on=[id]) id = s.run(' '.join(args), depends_on=[id])
time_in_simulation_hours = (end-begin).total_seconds()/3600 time_in_simulation_hours = (end-begin).total_seconds()/3600
runtime_wallclock_mins_expected = int(8+time_in_simulation_hours*9.5) # usually below 9 min/hour runtime_wallclock_mins_expected = int(8+time_in_simulation_hours*9.5) # usually below 9 min/hour
s = create_job("WRF", cfg_update={"array": "1-"+str(cluster.size_jobarray), "ntasks": "10", "nodes": "1", s = cluster.create_job("WRF", cfg_update={"array": "1-"+str(cluster.size_jobarray), "ntasks": "10", "nodes": "1",
"time": str(runtime_wallclock_mins_expected), "mem": "140G"}) "time": str(runtime_wallclock_mins_expected), "mem": "140G"})
cmd = script_to_str(cluster.run_WRF).replace('<exp.expname>', exp.expname cmd = script_to_str(cluster.run_WRF).replace('<exp.expname>', exp.expname
).replace('<cluster.wrf_rundir_base>', cluster.wrf_rundir_base) ).replace('<cluster.wrf_rundir_base>', cluster.wrf_rundir_base)
...@@ -123,7 +123,7 @@ def assimilate(assim_time, prior_init_time, prior_valid_time, prior_path_exp, ...@@ -123,7 +123,7 @@ def assimilate(assim_time, prior_init_time, prior_valid_time, prior_path_exp,
if not os.path.exists(prior_path_exp): if not os.path.exists(prior_path_exp):
raise IOError('prior_path_exp does not exist: '+prior_path_exp) raise IOError('prior_path_exp does not exist: '+prior_path_exp)
id = create_job("Assim", cfg_update={"ntasks": "12", "time": "60", id = cluster.create_job("Assim", cfg_update={"ntasks": "12", "time": "60",
"mem": "200G", "ntasks-per-node": "12", "ntasks-per-core": "2"} "mem": "200G", "ntasks-per-node": "12", "ntasks-per-core": "2"}
).run(cluster.python+' '+cluster.scripts_rundir+'/assim_synth_obs.py ' ).run(cluster.python+' '+cluster.scripts_rundir+'/assim_synth_obs.py '
+assim_time.strftime('%Y-%m-%d_%H:%M ') +assim_time.strftime('%Y-%m-%d_%H:%M ')
...@@ -140,7 +140,7 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new ...@@ -140,7 +140,7 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new
else: else:
tnew = '' tnew = ''
id = create_job("IC-prior", cfg_update=dict(time="8") id = cluster.create_job("IC-prior", cfg_update=dict(time="8")
).run(cluster.python+' '+cluster.scripts_rundir+'/prep_IC_prior.py ' ).run(cluster.python+' '+cluster.scripts_rundir+'/prep_IC_prior.py '
+prior_path_exp +prior_path_exp
+prior_init_time.strftime(' %Y-%m-%d_%H:%M') +prior_init_time.strftime(' %Y-%m-%d_%H:%M')
...@@ -150,14 +150,14 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new ...@@ -150,14 +150,14 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new
def update_IC_from_DA(assim_time, depends_on=None): def update_IC_from_DA(assim_time, depends_on=None):
id = create_job("IC-update", cfg_update=dict(time="8") id = cluster.create_job("IC-update", cfg_update=dict(time="8")
).run(cluster.python+' '+cluster.scripts_rundir+'/update_IC.py ' ).run(cluster.python+' '+cluster.scripts_rundir+'/update_IC.py '
+assim_time.strftime('%Y-%m-%d_%H:%M'), depends_on=[depends_on]) +assim_time.strftime('%Y-%m-%d_%H:%M'), depends_on=[depends_on])
return id return id
def create_satimages(init_time, depends_on=None): def create_satimages(init_time, depends_on=None):
s = create_job("RTTOV", cfg_update={"ntasks": "12", "time": "80", "mem": "200G"}) s = cluster.create_job("RTTOV", cfg_update={"ntasks": "12", "time": "80", "mem": "200G"})
id = s.run(cluster.python_verif+' ~/RTTOV-WRF/run_init.py '+cluster.archivedir id = s.run(cluster.python_verif+' ~/RTTOV-WRF/run_init.py '+cluster.archivedir
+init_time.strftime('/%Y-%m-%d_%H:%M/'), +init_time.strftime('/%Y-%m-%d_%H:%M/'),
depends_on=[depends_on]) depends_on=[depends_on])
...@@ -166,31 +166,31 @@ def create_satimages(init_time, depends_on=None): ...@@ -166,31 +166,31 @@ def create_satimages(init_time, depends_on=None):
def mailme(depends_on=None): def mailme(depends_on=None):
if depends_on: if depends_on:
s = create_job("AllFinished", cfg_update={"time": "1", "mail-type": "BEGIN"}) s = cluster.create_job("AllFinished", cfg_update={"time": "1", "mail-type": "BEGIN"})
s.run('sleep 1', depends_on=[depends_on]) s.run('sleep 1', depends_on=[depends_on])
def gen_obsseq(depends_on=None): def gen_obsseq(depends_on=None):
s = create_job("obsseq_netcdf", cfg_update={"time": "10", "mail-type": "FAIL,END"}) s = cluster.create_job("obsseq_netcdf", cfg_update={"time": "10", "mail-type": "FAIL,END"})
id = s.run(cluster.python+' '+cluster.scripts_rundir+'/obsseq_to_netcdf.py', id = s.run(cluster.python+' '+cluster.scripts_rundir+'/obsseq_to_netcdf.py',
depends_on=[depends_on]) depends_on=[depends_on])
return id return id
def verify_sat(depends_on=None): def verify_sat(depends_on=None):
s = create_job("verif-SAT-"+exp.expname, cfg_update={"time": "60", "mail-type": "FAIL,END", "ntasks": "20", s = cluster.create_job("verif-SAT-"+exp.expname, cfg_update={"time": "60", "mail-type": "FAIL,END", "ntasks": "20",
"ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "100G",}) "ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "100G",})
cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node sat verif1d FSS BS' cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node sat verif1d FSS BS'
s.run(cmd, depends_on=[depends_on]) s.run(cmd, depends_on=[depends_on])
def verify_wrf(depends_on=None): def verify_wrf(depends_on=None):
s = create_job("verif-WRF-"+exp.expname, cfg_update={"time": "120", "mail-type": "FAIL,END", "ntasks": "20", s = cluster.create_job("verif-WRF-"+exp.expname, cfg_update={"time": "120", "mail-type": "FAIL,END", "ntasks": "20",
"ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "250G"}) "ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "250G"})
cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node wrf verif1d verif3d FSS BS' cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node wrf verif1d verif3d FSS BS'
s.run(cmd, depends_on=[depends_on]) s.run(cmd, depends_on=[depends_on])
def verify_fast(depends_on=None): def verify_fast(depends_on=None):
s = create_job("verif-fast-"+exp.expname, cfg_update={"time": "10", "mail-type": "FAIL", "ntasks": "1", s = cluster.create_job("verif-fast-"+exp.expname, cfg_update={"time": "10", "mail-type": "FAIL", "ntasks": "1",
"ntasks-per-node": "1", "ntasks-per-core": "1"}) "ntasks-per-node": "1", "ntasks-per-core": "1"})
cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_fast/plot_single_exp.py '+exp.expname cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_fast/plot_single_exp.py '+exp.expname
s.run(cmd, depends_on=[depends_on]) s.run(cmd, depends_on=[depends_on])
...@@ -202,10 +202,10 @@ if __name__ == "__main__": ...@@ -202,10 +202,10 @@ if __name__ == "__main__":
timedelta_integrate = dt.timedelta(minutes=15) timedelta_integrate = dt.timedelta(minutes=15)
timedelta_btw_assim = dt.timedelta(minutes=15) timedelta_btw_assim = dt.timedelta(minutes=15)
backup_scripts() cluster.backup_scripts()
id = None id = None
if True: # warm bubble if False: # warm bubble
prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P3_wbub7_noDA' prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P3_wbub7_noDA'
init_time = dt.datetime(2008, 7, 30, 12) init_time = dt.datetime(2008, 7, 30, 12)
...@@ -217,7 +217,7 @@ if __name__ == "__main__": ...@@ -217,7 +217,7 @@ if __name__ == "__main__":
# id = run_ideal(depends_on=id) # id = run_ideal(depends_on=id)
# id = wrfinput_insert_wbubble(depends_on=id) # id = wrfinput_insert_wbubble(depends_on=id)
if False: # random if True: # random
prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P2_noDA' prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P2_noDA'
init_time = dt.datetime(2008, 7, 30, 12) init_time = dt.datetime(2008, 7, 30, 12)
......
...@@ -3,7 +3,8 @@ import time as time_module ...@@ -3,7 +3,8 @@ import time as time_module
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
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
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
......
...@@ -4,7 +4,8 @@ import time as time_module ...@@ -4,7 +4,8 @@ import time as time_module
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from dartwrf.utils import copy, print from dartwrf.utils import copy, print
import dartwrf.create_obsseq as osq import dartwrf.create_obsseq as osq
from dartwrf import obsseq from dartwrf import obsseq
......
...@@ -7,7 +7,8 @@ import numpy as np ...@@ -7,7 +7,8 @@ import numpy as np
import datetime as dt import datetime as dt
from pysolar.solar import get_altitude, get_azimuth from pysolar.solar import get_altitude, get_azimuth
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from dartwrf.obs import calculate_obs_locations as col from dartwrf.obs import calculate_obs_locations as col
def obskind_read(): def obskind_read():
......
...@@ -3,7 +3,8 @@ from re import U ...@@ -3,7 +3,8 @@ from re import U
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
import netCDF4 as nc import netCDF4 as nc
dx_km = 2 dx_km = 2
......
...@@ -3,7 +3,8 @@ import time as time_module ...@@ -3,7 +3,8 @@ import time as time_module
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from dartwrf import assim_synth_obs as aso from dartwrf import assim_synth_obs as aso
......
...@@ -3,7 +3,8 @@ import time as time_module ...@@ -3,7 +3,8 @@ import time as time_module
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
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
from dartwrf import assim_synth_obs as aso from dartwrf import assim_synth_obs as aso
......
import os import os
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from utils import symlink, copy_scp_srvx8, copy, sed_inplace from utils import symlink, copy_scp_srvx8, copy, sed_inplace
joinp = os.path.join joinp = os.path.join
......
...@@ -7,7 +7,8 @@ import os, sys, shutil, warnings ...@@ -7,7 +7,8 @@ import os, sys, shutil, warnings
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove
......
...@@ -8,7 +8,8 @@ import time as time_module ...@@ -8,7 +8,8 @@ import time as time_module
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from dartwrf import assim_synth_obs as aso from dartwrf import assim_synth_obs as aso
from dartwrf import obsseq from dartwrf import obsseq
......
import os, sys, glob, warnings import os, sys, glob, warnings
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
import run_obs_diag as rod import run_obs_diag as rod
def listdir_dirs(path): def listdir_dirs(path):
......
...@@ -2,7 +2,8 @@ import os, sys, warnings, glob ...@@ -2,7 +2,8 @@ import os, sys, warnings, glob
import datetime as dt import datetime as dt
import numpy as np import numpy as np
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from utils import copy, clean_wrfdir, try_remove from utils import copy, clean_wrfdir, try_remove
""" """
......
...@@ -12,7 +12,8 @@ import os, sys, shutil, warnings ...@@ -12,7 +12,8 @@ import os, sys, shutil, warnings
import datetime as dt import datetime as dt
from docopt import docopt from docopt import docopt
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from utils import sed_inplace, copy, symlink, mkdir from utils import sed_inplace, copy, symlink, mkdir
def run(iens, begin, end, hist_interval=5, radt=5, archive=True, def run(iens, begin, end, hist_interval=5, radt=5, archive=True,
......
import os, sys, shutil import os, sys, shutil
import datetime as dt import datetime as dt
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from utils import symlink, copy, link_contents from utils import symlink, copy, link_contents
import prepare_namelist import prepare_namelist
......
import os, sys, shutil, glob import os, sys, shutil, glob
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
from utils import symlink, copy, sed_inplace, append_file, shell from utils import symlink, copy, sed_inplace, append_file, shell
rundir_program = '/home/fs71386/lkugler/data/run_DART/' rundir_program = '/home/fs71386/lkugler/data/run_DART/'
......
...@@ -2,7 +2,8 @@ import os, sys, warnings ...@@ -2,7 +2,8 @@ import os, sys, warnings
import datetime as dt import datetime as dt
import netCDF4 as nc import netCDF4 as nc
from config.cfg import exp, cluster from config.cfg import exp
from config.clusters import cluster
def update_initials_in_WRF_rundir(time): def update_initials_in_WRF_rundir(time):
"""Updates wrfrst-files in `/run_WRF/` directory """Updates wrfrst-files in `/run_WRF/` directory
......
...@@ -3,74 +3,69 @@ import builtins as __builtin__ ...@@ -3,74 +3,69 @@ import builtins as __builtin__
import subprocess import subprocess
import datetime as dt import datetime as dt
from slurmpy import Slurm from slurmpy import Slurm
from config.cfg import cluster
class ExperimentConfiguration(object): class ExperimentConfiguration(object):
"""Collection of variables to use in code later on""" """Collection of variables to use in code later on"""
def __init__(self): def __init__(self):
pass pass
class Shellslurm():
"""Like Slurmpy class, but runs locally"""
def __init__(self, *args, **kwargs):
pass
def run(self, *args, **kwargs):
print(args[0])
os.system(args[0])
class ClusterConfig(object): class ClusterConfig(object):
"""Collection of variables to use in code later on""" """Collection of variables to use in code later on"""
def __init__(self): def __init__(self, exp):
pass self.exp = exp
@property
def archivedir(self): def archivedir(self):
return self.archive_base+'/'+self.expname return self.archive_base+'/'+self.exp.expname
def wrf_rundir(self, iens): def wrf_rundir(self, iens):
return self.wrf_rundir_base+'/'+self.expname+'/'+str(iens) return self.wrf_rundir_base+'/'+self.exp.expname+'/'+str(iens)
@property
def scripts_rundir(self): def scripts_rundir(self):
return self.archivedir+'/DART-WRF/' return self.archivedir+'/DART-WRF/'
@property
def dartrundir(self): def dartrundir(self):
return self.dart_rundir_base+'/'+self.expname+'/' return self.dart_rundir_base+'/'+self.exp.expname+'/'
class Shellslurm(): def create_job(self, *args, cfg_update=dict(), **kwargs):
"""Like Slurmpy class, but runs locally"""
def __init__(self, *args, **kwargs):
pass
def run(self, *args, **kwargs):
print(args[0])
os.system(args[0])
def create_job(*args, cfg_update=dict(), **kwargs):
"""Shortcut to slurmpy's class; keep certain default kwargs """Shortcut to slurmpy's class; keep certain default kwargs
and only update some with kwarg `cfg_update` and only update some with kwarg `cfg_update`
see https://github.com/brentp/slurmpy see https://github.com/brentp/slurmpy
with_slurm (bool) : if True, use SLURM, else run locally depending on cluster config : run either locally or via SLURM
""" """
if cluster.use_slurm: if self.use_slurm:
return Slurm(*args, slurm_kwargs=dict(cluster.slurm_cfg, **cfg_update), return Slurm(*args, slurm_kwargs=dict(self.slurm_cfg, **cfg_update),
log_dir=log_dir, scripts_dir=slurm_scripts_dir, **kwargs) log_dir=log_dir, scripts_dir=slurm_scripts_dir, **kwargs)
else: else:
return Shellslurm(*args) return Shellslurm(*args)
def backup_scripts(): def backup_scripts():
"""Copies scripts and configuration to archive dir output folder""" """Copies scripts and configuration to archive dir output folder"""
os.makedirs(cluster.archivedir, exist_ok=True) os.makedirs(self.archivedir, exist_ok=True)
try: try:
shutil.copytree(cluster.scriptsdir, cluster.scripts_rundir) shutil.copytree(self.scriptsdir, self.scripts_rundir)
except FileExistsError: except FileExistsError:
pass pass
except: except:
raise raise
try: try:
copy(os.path.basename(__file__), cluster.scripts_rundir+'/') copy(os.path.basename(__file__), self.scripts_rundir+'/')
except Exception as e: except Exception as e:
warnings.warn(str(e)) warnings.warn(str(e))
def prepare_WRFrundir(init_time): def prepare_WRFrundir(init_time):
"""Create WRF/run directories and wrfinput files """Create WRF/run directories and wrfinput files
""" """
cmd = cluster.python+' '+cluster.scripts_rundir+'/prepare_wrfrundir.py '+init_time.strftime('%Y-%m-%d_%H:%M') cmd = self.python+' '+self.scripts_rundir+'/prepare_wrfrundir.py '+init_time.strftime('%Y-%m-%d_%H:%M')
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment