diff --git a/typhon/collocations/collocator.py b/typhon/collocations/collocator.py index d5da6f44..7945bda7 100644 --- a/typhon/collocations/collocator.py +++ b/typhon/collocations/collocator.py @@ -1014,7 +1014,7 @@ def _flat_to_main_coord(data): data["collocation"] = shared_dims[0], np.arange( data[shared_dims[0]].size) data = data.swap_dims({shared_dims[0]: "collocation"}) - data.reset_coords(shared_dims[0], inplace=True) + data = data.reset_coords(shared_dims[0]) # So far, collocation is a coordinate. We want to make it to a # dimension, so drop its values: @@ -1046,7 +1046,7 @@ def _flat_to_main_coord(data): # for dim in dims: # new_dim = f"__replacement_{dim}" # data[new_dim] = dim, np.arange(data.dims[dim]) - # data.swap_dims({dim: new_dim}, inplace=True) + # data = data.swap_dims({dim: new_dim}) # new_dims.append(new_dim) return data.stack(collocation=dims) diff --git a/typhon/collocations/common.py b/typhon/collocations/common.py index 60d4ebc3..cf49273e 100644 --- a/typhon/collocations/common.py +++ b/typhon/collocations/common.py @@ -462,16 +462,13 @@ def expand(dataset): for i in range(2): expanded["collocation"] = groups[i] + "/collocation", \ np.arange(pairs[i].size) - expanded.swap_dims( - {groups[i] + "/collocation": "collocation"}, inplace=True + expanded = expanded.swap_dims( + {groups[i] + "/collocation": "collocation"} ) # The variable pairs is useless now: expanded = expanded.drop("Collocations/pairs") - expanded.rename( - {"Collocations/collocation": "collocation"}, - inplace=True - ) + expanded = expanded.rename({"Collocations/collocation": "collocation"}) return expanded diff --git a/typhon/files/handlers/cloudsat.py b/typhon/files/handlers/cloudsat.py index 93585ec9..5b70089c 100644 --- a/typhon/files/handlers/cloudsat.py +++ b/typhon/files/handlers/cloudsat.py @@ -105,7 +105,7 @@ def read(self, file_info, **kwargs): ) if user_mapping is not None: - dataset.rename(user_mapping, inplace=True) + dataset = dataset.rename(user_mapping) return dataset diff --git a/typhon/files/handlers/common.py b/typhon/files/handlers/common.py index 2f728c7d..d728fb87 100644 --- a/typhon/files/handlers/common.py +++ b/typhon/files/handlers/common.py @@ -124,7 +124,7 @@ def _xarray_rename_fields(dataset, mapping): if old_name in names } - dataset.rename(mapping, inplace=True) + dataset = dataset.rename(mapping) return dataset @@ -786,12 +786,12 @@ def write(self, data, filename, **kwargs): full: NetCDF4._split_path(full)[1] for full in ds.data_vars } - ds.rename(mapping, inplace=True) + ds = ds.rename(mapping) mapping = { dim: NetCDF4._split_path(dim)[1] for dim in ds.dims } - ds.rename(mapping, inplace=True) + ds = ds.rename(mapping) ds.to_netcdf( filename.path, group=group, diff --git a/typhon/files/handlers/meteosat.py b/typhon/files/handlers/meteosat.py index b43535ce..f65dfcdb 100644 --- a/typhon/files/handlers/meteosat.py +++ b/typhon/files/handlers/meteosat.py @@ -208,7 +208,7 @@ def read(self, file_info, fields=None, calibration=True, **kwargs): for old, new in self.channel_names.items() if old in dataset.variables } - dataset.rename(mapping, inplace=True) + dataset = dataset.rename(mapping) return dataset @staticmethod diff --git a/typhon/files/handlers/tovs.py b/typhon/files/handlers/tovs.py index 4652f4d6..f2fd2359 100644 --- a/typhon/files/handlers/tovs.py +++ b/typhon/files/handlers/tovs.py @@ -184,7 +184,7 @@ def read(self, file_info, mask_and_scale=True, **kwargs): check_lat_lon(dataset) if user_mapping is not None: - dataset.rename(user_mapping, inplace=True) + dataset = dataset.rename(user_mapping) return dataset @@ -289,7 +289,7 @@ def read(self, file_info, mask_and_scale=True, interpolate_packed_pixels=True, check_lat_lon(dataset) if user_mapping is not None: - dataset.rename(user_mapping, inplace=True) + dataset = dataset.rename(user_mapping) return dataset