Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

del bounds attr from coord in drop_attributes() #733

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,14 @@ def drop_attributes(self, xr_ds: xr.Dataset) -> xr.Dataset:
'average_T1',
'height',
'date']
# TODO: find a suitable answer to conflicts in xarray merging (i.e. nctoolkit)
for att in drop_atts:
if xr_ds.get(att, None) is not None:
xr_ds = xr_ds.drop_vars(att)
for coord in xr_ds.coords:
if 'bounds' in xr_ds[coord].attrs:
if xr_ds[coord].attrs['bounds'] == att:
del xr_ds[coord].attrs['bounds']
return xr_ds

def check_multichunk(self, group_df: pd.DataFrame, case_dr, log) -> pd.DataFrame:
Expand Down
2 changes: 1 addition & 1 deletion src/xr_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ def reconcile_coord_bounds(self, our_coord, ds, ds_coord_name):
expectations based on the model's convention (*our_var*), for the bounds
on the dimension coordinate *our_coord*.
"""
if len(ds.cf.bounds) > 0:
if len(ds.cf.bounds.get(ds_coord_name, [])) > 0:
jtmims marked this conversation as resolved.
Show resolved Hide resolved
bounds = ds.cf.get_bounds(ds_coord_name)
elif hasattr(ds[ds_coord_name], 'attrs'):
if ds[ds_coord_name].attrs.get('bounds', None):
Expand Down
Loading