diff --git a/polaris/ocean/tasks/manufactured_solution/viz.py b/polaris/ocean/tasks/manufactured_solution/viz.py index 86d287b27..2de17ece8 100644 --- a/polaris/ocean/tasks/manufactured_solution/viz.py +++ b/polaris/ocean/tasks/manufactured_solution/viz.py @@ -135,6 +135,8 @@ def run(self): section = config['manufactured_solution'] eta0 = section.getfloat('ssh_amplitude') + model = config.get('ocean', 'model') + use_mplstyle() fig, axes = plt.subplots(nrows=nres, ncols=3, figsize=(12, 2 * nres)) rmse = [] @@ -146,14 +148,20 @@ def run(self): ds_init = self.open_model_dataset( f'init_r{refinement_factor:02g}.nc') ds = self.open_model_dataset( - f'output_r{refinement_factor:02g}.nc') + f'output_r{refinement_factor:02g}.nc', decode_times=False) exact = ExactSolution(config, ds_init) - t0 = datetime.datetime.strptime(ds.xtime.values[0].decode(), - '%Y-%m-%d_%H:%M:%S') - tf = datetime.datetime.strptime(ds.xtime.values[-1].decode(), - '%Y-%m-%d_%H:%M:%S') - t = (tf - t0).total_seconds() + if model == 'mpas-o': + t0 = datetime.datetime.strptime(ds.xtime.values[0].decode(), + '%Y-%m-%d_%H:%M:%S') + tf = datetime.datetime.strptime(ds.xtime.values[-1].decode(), + '%Y-%m-%d_%H:%M:%S') + t = (tf - t0).total_seconds() + + else: + # time is seconds since the start of the simulation in Omega + t = ds.Time[-1].values + ssh_model = ds.ssh.values[-1, :] rmse.append(np.sqrt(np.mean((ssh_model - exact.ssh(t).values)**2)))