From 4af099b3fa6a53c902e1be94175409b246abb303 Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Tue, 18 Oct 2022 11:05:11 +0200
Subject: [PATCH] .

---
 config/cfg.py      | 33 ++++++++++++++++++++++-----------
 config/clusters.py |  7 ++++---
 dartwrf/utils.py   | 18 ++++++++++--------
 scheduler.py       | 19 +++++++++----------
 4 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/config/cfg.py b/config/cfg.py
index 75314c9..b045eb1 100755
--- a/config/cfg.py
+++ b/config/cfg.py
@@ -7,15 +7,22 @@ class ExperimentConfiguration(object):
         pass
 
 exp = ExperimentConfiguration()
-exp.expname = "exp_v1.21_P3_wbub7_VIS_obs10_loc20"
+exp.expname = "exp_v1.22_P3_wbub7_WV73_obs10_loc20"
 exp.model_dx = 2000
 exp.n_ens = 40
 exp.n_nodes = 10
+
+exp.filter_kind = 1
 exp.inflation = True
 exp.sec = True
 exp.reject_smallFGD = False
-exp.cov_loc_vert_km_horiz_km = (3, 20)
-exp.superob_km = False
+exp.cov_loc_vert_km_horiz_km = False  # (3, 20)
+exp.superob_km = False  # False or int (spatial averaging of observations)
+
+exp.use_existing_obsseq = False  # False or pathname (use precomputed obs_seq.out files)
+#exp.use_existing_obsseq = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.21_P2_rr_REFL_obs10_loc20_oe1/obs_seq_out/2008-07-30_%H:%M_obs_seq.out'  
+#exp.use_existing_obsseq = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.21_P3_wbub7_REFL2D_obs10_loc20_oe5/obs_seq_out/2008-07-30_%H:%M_obs_seq.out'
+#exp.use_existing_obsseq = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.21_P2_rr_VIS_obs20_loc4/obs_seq_out/2008-07-30_%H:%M_obs_seq.out'
 
 
 #exp.nature_wrfout = '/home/fs71386/lkugler/data/sim_archive/exp_v1.19_P5+su_nat2/2008-07-30_07:00/1/wrfout_d01_%Y-%m-%d_%H:%M:%S'
@@ -30,7 +37,6 @@ exp.nature_wrfout = '/home/fs71386/lkugler/data/sim_archive/exp_v1.19_P3_wbub7_n
 #exp.input_profile = '/home/fs71386/lkugler/data/initial_profiles/wrf/ens/large_mean_error/raso.nat.<iens>.wrfprof'
 exp.input_profile = '/gpfs/data/fs71386/lkugler/initial_profiles/wrf/ens/2022-03-31/raso.fc.<iens>.wrfprof'
 #exp.input_profile = '/gpfs/data/fs71386/lkugler/initial_profiles/wrf/ens/2022-03-31/raso.nat.<iens>.wrfprof'
-#exp.input_profile = '/gpfs/data/fs71386/lkugler/initial_profiles/wrf/ens/2022-05-18_nopert/raso.nat.<iens>.wrfprof'
 #exp.input_profile = '/gpfs/data/fs71386/lkugler/initial_profiles/wrf/ens/2022-05-18/raso.fc.<iens>.wrfprof'
 
 
@@ -40,12 +46,17 @@ exp.input_profile = '/gpfs/data/fs71386/lkugler/initial_profiles/wrf/ens/2022-03
 
 n_obs = 961  # 22500: 2km, 5776: 4km, 121: 30km, 256:16x16 (20km); 961: 10km resoltn # radar: n_obs for each observation height level
 
-vis = dict(plotname='VIS 0.6µm',  plotunits='[1]',
+vis = dict(plotname='VIS 0.6µm', plotunits='[1]',
            kind='MSG_4_SEVIRI_BDRF', sat_channel=1, n_obs=n_obs, 
            error_generate=0.03, error_assimilate=0.06,
            cov_loc_radius_km=20)
 
-wv73 = dict(plotname='Brightness temperature WV 7.3µm',  plotunits='[K]',
+wv62 = dict(plotname='Brightness temperature WV 6.2µm', plotunits='[K]',
+            kind='MSG_4_SEVIRI_TB', sat_channel=5, n_obs=n_obs, 
+            error_generate=1., error_assimilate=False, 
+            cov_loc_radius_km=20)
+
+wv73 = dict(plotname='Brightness temperature WV 7.3µm', plotunits='[K]',
             kind='MSG_4_SEVIRI_TB', sat_channel=6, n_obs=n_obs, 
             error_generate=1., error_assimilate=False, 
             cov_loc_radius_km=20)
@@ -57,8 +68,8 @@ ir108 = dict(plotname='Brightness temperature IR 10.8µm', plotunits='[K]',
 
 radar = dict(plotname='Radar reflectivity', plotunits='[dBz]',
              kind='RADAR_REFLECTIVITY', n_obs=n_obs, 
-             error_generate=2.5, error_assimilate=2.5,
-             heights=np.arange(2000, 14001, 2000),
+             error_generate=2.5, error_assimilate=5,
+             heights=[2000,], #np.arange(2000, 14001, 2000),
              cov_loc_radius_km=20)
 
 t = dict(plotname='Temperature', plotunits='[K]',
@@ -69,7 +80,7 @@ t = dict(plotname='Temperature', plotunits='[K]',
 
 q = dict(plotname='Specific humidity', plotunits='[kg/kg]',
          kind='RADIOSONDE_SPECIFIC_HUMIDITY', n_obs=n_obs,
-         error_generate=0., error_assimilate=0.001,
+         error_generate=0., error_assimilate=5*1e-5,
          heights=[1000], #np.arange(1000, 17001, 2000),
          cov_loc_radius_km=0.1)
 
@@ -78,13 +89,13 @@ t2m = dict(plotname='SYNOP Temperature', plotunits='[K]',
            error_generate=0.1, error_assimilate=1.,
            cov_loc_radius_km=20)
 
-psfc = dict(plotname='SYNOP Pressure', plotunits='[dBz]',
+psfc = dict(plotname='SYNOP Pressure', plotunits='[Pa]',
             kind='SYNOP_SURFACE_PRESSURE', n_obs=n_obs, 
             error_generate=50., error_assimilate=100.,
             cov_loc_radius_km=32)
 
 
-exp.observations = [vis]
+exp.observations = [wv73]
 exp.update_vars = ['U', 'V', 'W', 'THM', 'PH', 'MU', 'QVAPOR', 'QCLOUD', 'QICE', 'PSFC']
 #exp.update_vars = ['U', 'V', 'W', 'T', 'PH', 'MU', 'QVAPOR', 'PSFC']
 
diff --git a/config/clusters.py b/config/clusters.py
index 5b84038..349ed19 100755
--- a/config/clusters.py
+++ b/config/clusters.py
@@ -67,8 +67,9 @@ vsc.name = 'vsc'
 vsc.python = '/home/fs71386/lkugler/miniconda3/envs/DART/bin/python'
 vsc.python_enstools = '/home/fs71386/lkugler/miniconda3/envs/enstools/bin/python'
 vsc.ncks = '/home/fs71386/lkugler/miniconda3/envs/DART/bin/ncks'
-vsc.ideal = '/home/fs71386/lkugler/compile/bin/ideal-v4.2.2_v1.16.exe'
-vsc.wrfexe = '/home/fs71386/lkugler/compile/bin/wrf-v4.3_v1.19.exe'
+vsc.ideal = '/home/fs71386/lkugler/compile/bin/ideal-v4.2.2_v1.22.exe'
+vsc.wrfexe = '/home/fs71386/lkugler/compile/bin/wrf-v4.3_v1.22.exe'
+vsc.container = '/home/fs71386/lkugler/run_container.sh python.gcc9.5.0.vsc4.sif'
 
 # paths for data output
 vsc.wrf_rundir_base = '/gpfs/data/fs71386/lkugler/run_WRF/'  # path for temporary files
@@ -85,7 +86,7 @@ vsc.scriptsdir = '/home/fs71386/lkugler/DART-WRF/dartwrf/'
 vsc.namelist = vsc.scriptsdir+'/../templates/namelist.input'
 vsc.run_WRF = '/home/fs71386/lkugler/DART-WRF/dartwrf/run_ens.vsc.sh'
 
-vsc.slurm_cfg = {"account": "p71386", "partition": "mem_0384", "qos": "p71386_0384",
+vsc.slurm_cfg = {"account": "p71386", "partition": "skylake_0384", "qos": "p71386_0384",
                  "nodes": "1", "ntasks": "1", "ntasks-per-node": "48", "ntasks-per-core": "1",
                  "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
 
diff --git a/dartwrf/utils.py b/dartwrf/utils.py
index 10ddd91..85286a6 100755
--- a/dartwrf/utils.py
+++ b/dartwrf/utils.py
@@ -3,18 +3,20 @@ import builtins as __builtin__
 #copy = shutil.copy
 import subprocess
 
-def shell(cmd):
-    # subprocess.check_output(cmd.split(' '), shell=True)
-    os.system(cmd)
+def shell(args):
+    print(args)
+    subprocess.run(args.split(' ')) #, shell=True) #, stderr=subprocess.STDOUT) 
+    #os.system(args)
 
 def print(*args):
     __builtin__.print(*args, flush=True)
 
-def copy(src, dst):
-    try:
-        os.remove(dst)
-    except:
-        pass
+def copy(src, dst, remove_if_exists=True):
+    if remove_if_exists:
+        try:
+            os.remove(dst)
+        except:
+            pass
     shutil.copy(src, dst)
 
 def try_remove(f):
diff --git a/scheduler.py b/scheduler.py
index 9367f68..519e7f2 100755
--- a/scheduler.py
+++ b/scheduler.py
@@ -248,7 +248,7 @@ if __name__ == "__main__":
     backup_scripts()
     id = None
 
-    if False:  # warm bubble
+    if True:  # warm bubble
         prior_path_exp = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.19_P3_wbub7_noDA'
 
         init_time = dt.datetime(2008, 7, 30, 12)
@@ -257,10 +257,10 @@ if __name__ == "__main__":
         forecast_until = dt.datetime(2008, 7, 30, 18)
     
         prepare_WRFrundir(init_time)
-        id = run_ideal(depends_on=id)
-        id = wrfinput_insert_wbubble(depends_on=id)    
+        # id = run_ideal(depends_on=id)
+        # id = wrfinput_insert_wbubble(depends_on=id)    
 
-    if True:  # random
+    if False:  # random
         prior_path_exp = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.19_P2_noDA'
 
         init_time = dt.datetime(2008, 7, 30, 12)
@@ -269,11 +269,10 @@ if __name__ == "__main__":
         forecast_until = dt.datetime(2008, 7, 30, 18)
 
         prepare_WRFrundir(init_time)
-        id = run_ideal(depends_on=id)
+        # id = run_ideal(depends_on=id)
 
-
-    #prior_path_exp = cluster.archivedir  # 
-    #prior_path_exp = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.19_P5+su_noDA'
+    # prior_path_exp = cluster.archivedir
+    # prior_path_exp = '/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.19_P5+su_noDA'
     
     prior_init_time = init_time
     prior_valid_time = time
@@ -286,7 +285,7 @@ if __name__ == "__main__":
         prior_valid_time = time
 
         id = assimilate(time, prior_init_time, prior_valid_time, prior_path_exp, depends_on=id)
-        
+
         # 1) Set posterior = prior
         id = prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id)
 
@@ -298,7 +297,7 @@ if __name__ == "__main__":
         output_restart_interval = timedelta_btw_assim.total_seconds()/60
         if time == last_assim_time: #this_forecast_init.minute in [0,]:  # longer forecast every full hour
             timedelta_integrate = forecast_until - last_assim_time  # dt.timedelta(hours=4)
-            output_restart_interval = 9999 #timedelta_btw_assim.total_seconds()/60 # 9999
+            output_restart_interval = 9999  # timedelta_btw_assim.total_seconds()/60 # 9999
 
         # 3) Run WRF ensemble
         id = run_ENS(begin=time,  # start integration from here
-- 
GitLab