Skip to content

Commit

Permalink
Support Omega time in convergence analysis step
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Nov 28, 2024
1 parent 28e5f4a commit c7103de
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions polaris/ocean/convergence/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,18 @@ def get_output_field(self, refinement_factor, field_name, time, zidx=None):
field_mpas : xarray.DataArray
model output field
"""
ds_out = self.open_model_dataset(f'output_r{refinement_factor:02g}.nc')
config = self.config
ds_out = self.open_model_dataset(f'output_r{refinement_factor:02g}.nc',
decode_times=False)

tidx = time_index_from_xtime(ds_out.xtime.values, time)
ds_out = ds_out.isel(Time=tidx)
model = config.get('ocean', 'model')
if model == 'mpas-o':
tidx = time_index_from_xtime(ds_out.xtime.values, time)
ds_out = ds_out.isel(Time=tidx)
else:
# time is seconds since the start of the simulation in Omega
tidx = np.argmin(np.abs(ds_out.time.values - time))
ds_out = ds_out.isel(time=tidx)

field_mpas = ds_out[field_name]
if zidx is not None:
Expand Down

0 comments on commit c7103de

Please sign in to comment.