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 Dec 4, 2024
1 parent 5444602 commit bdd5ae4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions polaris/ocean/tasks/manufactured_solution/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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)))

Expand Down

0 comments on commit bdd5ae4

Please sign in to comment.