Skip to content

Commit

Permalink
Support Omega time in mfd_sln viz step
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Nov 28, 2024
1 parent c7103de commit 51be5cb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions polaris/ocean/tasks/manufactured_solution/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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)))

Expand Down

0 comments on commit 51be5cb

Please sign in to comment.