From 97242b469d706b3c9f5df3f940b725cc957347cc Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Sat, 19 Oct 2024 12:56:44 -0500 Subject: [PATCH] Fix renaming --- polaris/ocean/model/ocean_io_step.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/polaris/ocean/model/ocean_io_step.py b/polaris/ocean/model/ocean_io_step.py index 711fa31c5..733258c86 100644 --- a/polaris/ocean/model/ocean_io_step.py +++ b/polaris/ocean/model/ocean_io_step.py @@ -76,7 +76,9 @@ def map_to_native_model_vars(self, ds): model = config.get('ocean', 'model') if model == 'omega': assert self.mpaso_to_omega_var_map is not None - ds = ds.rename(self.mpaso_to_omega_var_map) + rename = {k: v for k, v in self.mpaso_to_omega_var_map.items() + if k in ds} + ds = ds.rename(rename) return ds def write_model_dataset(self, ds, filename): @@ -115,7 +117,9 @@ def map_from_native_model_vars(self, ds): model = config.get('ocean', 'model') if model == 'omega': assert self.omega_to_mpaso_var_map is not None - ds = ds.rename(self.omega_to_mpaso_var_map) + rename = {k: v for k, v in self.omega_to_mpaso_var_map.items() + if k in ds} + ds = ds.rename(rename) return ds def open_model_dataset(self, filename, **kwargs):