@@ -40,7 +40,11 @@ def __init__(self, keys_da, keys_en, sim):
4040
4141 # At the moment, the iterative loop is threated as an iterative smoother an thus we check if assim. indices
4242 # are given as in the Simultaneous loop.
43- self .check_assimindex_sequential ()
43+ self .check_assimindex_simultaneous ()
44+
45+ self .assim_index = [self .keys_da ['obsname' ], self .keys_da ['assimindex' ][0 ]]
46+ self .list_datatypes , self .list_act_datatypes = at .get_list_data_types (self .obs_data , self .assim_index )
47+
4448
4549 # Extract no. assimilation steps from MDA keyword in DATAASSIM part of init. file and set this equal to
4650 # the number of iterations pluss one. Need one additional because the iter=0 is the prior run.
@@ -56,11 +60,11 @@ def __init__(self, keys_da, keys_en, sim):
5660 else :
5761 self .trunc_energy = 0.98
5862
59- self . state_scaling = at . calc_scaling (
60- self .prior_enX ,
61- self .list_states ,
62- self . prior_info
63- )
63+ # Get the perturbed observations and observation scaling
64+ self . vecObs , self . enObs = self .set_observations ()
65+ self . enObs_conv = deepcopy ( self .enObs )
66+
67+ self . _ext_scaling ( )
6468
6569 def calc_analysis (self ):
6670 """
@@ -74,32 +78,32 @@ def calc_analysis(self):
7478 np .concatenate (self .keys_da ['assimindex' ]))]
7579 list_datatypes , list_active_dataypes = at .get_list_data_types (
7680 self .obs_data , assim_index )
77- if not hasattr (self , 'cov_data' ):
78- self .full_cov_data = at .gen_covdata (
79- self .datavar , assim_index , list_datatypes )
80- else :
81- self .full_cov_data = self .cov_data
82-
83- #obs_data_vector, pred_data = at.aug_obs_pred_data(
84- # self.obs_data, self.pred_data, assim_index, list_datatypes)
81+ # if not hasattr(self, 'cov_data'):
82+ # self.full_cov_data = at.gen_covdata(
83+ # self.datavar, assim_index, list_datatypes)
84+ # else:
85+ # self.full_cov_data = self.cov_data
86+
87+ # # obs_data_vector, pred_data = at.aug_obs_pred_data(
88+ # # self.obs_data, self.pred_data, assim_index, list_datatypes)
8589
86- vecObs , enPred = at .aug_obs_pred_data (
90+ _ , enPred = at .aug_obs_pred_data (
8791 self .obs_data ,
8892 self .pred_data ,
8993 assim_index ,
9094 list_datatypes
9195 )
9296
93- # Generate realizations of the observed data
94- generator = Cholesky () # Initialize GeoStat class for generating realizations
95- self .enObs = generator .gen_real (
96- vecObs ,
97- self .full_cov_data ,
98- self .ne
99- )
97+ # # Generate realizations of the observed data
98+ # generator = Cholesky() # Initialize GeoStat class for generating realizations
99+ # self.enObs = generator.gen_real(
100+ # vecObs,
101+ # self.full_cov_data,
102+ # self.ne
103+ # )
100104
101105 # Calc. misfit for the initial iteration
102- data_misfit = at .calc_objectivefun (self .enObs , enPred , self .full_cov_data )
106+ data_misfit = at .calc_objectivefun (self .enObs , enPred , self .scale_data )
103107
104108 # Store the (mean) data misfit (also for conv. check)
105109 self .data_misfit = np .mean (data_misfit )
@@ -119,27 +123,36 @@ def calc_analysis(self):
119123 self .obs_data , self .assim_index )
120124
121125 # Augment observed and predicted data
122- self .vecObs , self .enPred = at .aug_obs_pred_data (
123- self .obs_data ,
124- self .pred_data ,
125- self .assim_index ,
126- self .list_datatypes
127- )
128-
129- self .cov_data = at .gen_covdata (
130- self .datavar ,
131- self .assim_index ,
132- self .list_datatypes
133- )
134-
135- generator = Cholesky () # Initialize GeoStat class for generating realizations
136- self .data_random_state = deepcopy (np .random .get_state ())
137- self .enObs , self .scale_data = generator .gen_real (
138- self .vecObs ,
139- self .cov_data ,
140- self .ne ,
141- return_chol = True
142- )
126+ if ('emp_cov' in self .keys_da ) and (self .keys_da ['emp_cov' ] == 'yes' ):
127+ _ , self .enPred = at .aug_obs_pred_data (
128+ self .obs_data ,
129+ self .pred_data ,
130+ self .assim_index ,
131+ self .list_datatypes
132+ )
133+ else :
134+ self .vecObs , self .enPred = at .aug_obs_pred_data (
135+ self .obs_data ,
136+ self .pred_data ,
137+ self .assim_index ,
138+ self .list_datatypes
139+ )
140+
141+ self .cov_data = at .gen_covdata (
142+ self .datavar ,
143+ self .assim_index ,
144+ self .list_datatypes
145+ )
146+
147+ generator = Cholesky () # Initialize GeoStat class for generating realizations
148+ self .data_random_state = deepcopy (np .random .get_state ())
149+ self .enObs , self .scale_data = generator .gen_real (
150+ self .vecObs ,
151+ self .cov_data ,
152+ self .ne ,
153+ return_chol = True
154+ )
155+
143156 self .E = np .dot (self .enObs , self .proj )
144157
145158 if 'localanalysis' in self .keys_da :
0 commit comments