There are some bugs in fix_ocean_restarts.py:
output_files are based on template_files, not old_files, and then filled in with data from old_files only for fields of shape (1, 75, 2700, 3600), so there are many fields it should fix but doesn't, e.g.
- eta_t with shape (1, 2700, 3600)
- t_surf with shape (1, 2700, 3600)
- advectionu with shape (2, 75, 2700, 3600)
- dswt with shape (1, 76, 2700, 3600)
- etc
Since output_files are based on template_files these variables would then contain values from template_files, not old_files, and so would be inconsistent with fields with shape (1, 75, 2700, 3600) that were replaced with values from old_files.
- something like
out_fp.variables[var][..., level, :, :] = out_data needs to be added to actually write the changes to the file.
I've made a variant of this script called fix_ocean_restarts_cpumask.py which could be used as a starting point, but is designed for cpu mask changes rather than topography changes. fix_ocean_restarts_cpumask.py has different logic:
output_files is based on old_files, not template_files
- all >1-d fields are processed
- replaces
output_files cpu mask with that from template_files
- replaces newly-unmasked values with values from
template_files (this should be fine, since we assume the topography has not changed so the newly-unmasked values will still be in the land mask)
- leaves
old_files data intact everywhere else in output_files
Something different will be needed for fix_ocean_restarts.py, since this is for topography changes rather than cpu mask changes. I think what we want here is to locate the points that are wet with the new bathymetry but were dry with the old one, and replace their values with a nearest-neighbour horizontal extrapolation from old_files, like what we do with initial conditions.
There are some bugs in fix_ocean_restarts.py:
output_filesare based ontemplate_files, notold_files, and then filled in with data fromold_filesonly for fields of shape (1, 75, 2700, 3600), so there are many fields it should fix but doesn't, e.g.Since
output_filesare based ontemplate_filesthese variables would then contain values fromtemplate_files, notold_files, and so would be inconsistent with fields with shape (1, 75, 2700, 3600) that were replaced with values fromold_files.out_fp.variables[var][..., level, :, :] = out_dataneeds to be added to actually write the changes to the file.I've made a variant of this script called fix_ocean_restarts_cpumask.py which could be used as a starting point, but is designed for cpu mask changes rather than topography changes.
fix_ocean_restarts_cpumask.pyhas different logic:output_filesis based onold_files, nottemplate_filesoutput_filescpu mask with that fromtemplate_filestemplate_files(this should be fine, since we assume the topography has not changed so the newly-unmasked values will still be in the land mask)old_filesdata intact everywhere else inoutput_filesSomething different will be needed for
fix_ocean_restarts.py, since this is for topography changes rather than cpu mask changes. I think what we want here is to locate the points that are wet with the new bathymetry but were dry with the old one, and replace their values with a nearest-neighbour horizontal extrapolation fromold_files, like what we do with initial conditions.