Skip to content
Snippets Groups Projects
Commit 35c45f5e authored by lkugler's avatar lkugler
Browse files

posterior

parent fae50795
Branches
No related tags found
No related merge requests found
...@@ -226,20 +226,29 @@ class ObsSeq(object): ...@@ -226,20 +226,29 @@ class ObsSeq(object):
list_of_obsdict = obs_list_to_dict(obs_list) list_of_obsdict = obs_list_to_dict(obs_list)
return list_of_obsdict return list_of_obsdict
def get_prior_Hx_matrix(self): def _get_model_Hx(self, what):
"""Return prior Hx array (n_obs, n_ens)""" if what not in ['prior', 'posterior']:
raise ValueError
# which columns do we need? # which columns do we need?
keys = self.df.columns keys = self.df.columns
keys_bool = np.array(['prior ensemble member' in a for a in keys]) keys_bool = np.array([what+' ensemble member' in a for a in keys])
# select columns in DataFrame # select columns in DataFrame
prior_Hx = self.df.iloc[:, keys_bool] Hx = self.df.iloc[:, keys_bool]
# consistency check: compute mean over ens - compare with value from file # consistency check: compute mean over ens - compare with value from file
assert np.allclose(prior_Hx.mean(axis=1), self.df['prior ensemble mean']) assert np.allclose(Hx.mean(axis=1), self.df[what+' ensemble mean'])
return Hx.values
return prior_Hx.values def get_prior_Hx(self):
"""Return prior Hx array (n_obs, n_ens)"""
return self._get_model_Hx('prior')
def get_posterior_Hx(self):
"""Return posterior Hx array (n_obs, n_ens)"""
return self._get_model_Hx('posterior')
def get_truth_Hx(self): def get_truth_Hx(self):
return self.df['truth'].values return self.df['truth'].values
...@@ -416,6 +425,7 @@ class ObsSeq(object): ...@@ -416,6 +425,7 @@ class ObsSeq(object):
def write_obs(i, obs, next_i_obs=None, prev_i_obs=None): def write_obs(i, obs, next_i_obs=None, prev_i_obs=None):
"""Write the observation section of a obs_seq.out file """Write the observation section of a obs_seq.out file
Args: Args:
i (int): index of observation i (int): index of observation
obs (dict): observation data obs (dict): observation data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment