From 51be5cbd35f8c3c333900243872cad73dcfb908d Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 28 Nov 2024 11:09:19 -0600 Subject: [PATCH] Support Omega time in mfd_sln viz step --- .../ocean/tasks/manufactured_solution/viz.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/viz.py b/polaris/ocean/tasks/manufactured_solution/viz.py index 3fe4b8ef1..fd23d18ab 100644 --- a/polaris/ocean/tasks/manufactured_solution/viz.py +++ b/polaris/ocean/tasks/manufactured_solution/viz.py @@ -66,6 +66,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 = [] @@ -74,14 +76,21 @@ def run(self): mesh_name = resolution_to_subdir(res) ds_mesh = self.open_model_dataset(f'mesh_{mesh_name}.nc') ds_init = self.open_model_dataset(f'init_{mesh_name}.nc') - ds = self.open_model_dataset(f'output_{mesh_name}.nc') + ds = self.open_model_dataset(f'output_{mesh_name}.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)))