From 98888f5b751b3816ecc7c587e9fa527c9703f127 Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Tue, 20 Jun 2023 10:59:32 +0200
Subject: [PATCH] just_posterior should override user input

---
 dartwrf/dart_nml.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/dartwrf/dart_nml.py b/dartwrf/dart_nml.py
index d38f144..bb03882 100644
--- a/dartwrf/dart_nml.py
+++ b/dartwrf/dart_nml.py
@@ -266,14 +266,7 @@ def write_namelist(just_prior_values=False):
         nml['&location_nml']['special_vert_normalization_levels'] = [[-1,]*n_obstypes]
         nml['&location_nml']['special_vert_normalization_pressures'] = [[-1,]*n_obstypes]
 
-    # dont compute posterior, just evaluate prior
-    if just_prior_values:  
-        nml['&filter_nml']['compute_posterior'] = [['.false.']]
-        nml['&filter_nml']['output_members'] = [['.false.']]
-        nml['&filter_nml']['output_mean'] = [['.false.']]
-        nml['&filter_nml']['output_sd'] = [['.false.']]
-        nml['&obs_kind_nml']['assimilate_these_obs_types'] = [[]]
-        nml['&obs_kind_nml']['evaluate_these_obs_types'] = [list_obstypes]
+
 
     # overwrite namelist parameters as defined in the experiment configuration
     for section, sdata in exp.dart_nml.items():
@@ -296,7 +289,21 @@ def write_namelist(just_prior_values=False):
             # overwrite entry in each dictionary
             nml[section][parameter] = value  # every entry in this list is one line
 
-    # final checks
+    # necessary options if we dont compute posterior but only evaluate prior
+    if just_prior_values:  
+        nml['&obs_kind_nml']['assimilate_these_obs_types'] = [[]]
+        nml['&obs_kind_nml']['evaluate_these_obs_types'] = [list_obstypes]
+
+        nml['&filter_nml']['compute_posterior'] = [['.false.']]
+        
+        # inf_flavor posterior must be 0 if posterior is not computed
+        # inf_flavor keyword exists, so we can just overwrite it
+        nml['&filter_nml']['inf_flavor'] = [['0', '0']]
+
+        nml['&filter_nml']['output_members'] = [['.false.']]
+        nml['&filter_nml']['output_mean'] = [['.false.']]
+        nml['&filter_nml']['output_sd'] = [['.false.']]
+
     # fail if horiz_dist_only == false but observations contain a satellite channel
     if nml['&location_nml']['horiz_dist_only'][0] == '.false.':
         for obscfg in exp.observations:
-- 
GitLab