From 16f410b37cf9d0788fe534bfd332cbd113944872 Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 3 Mar 2020 12:12:28 +0100 Subject: [PATCH] Replace xarray.Dataset.drop with drop_vars xarray.Dataset.drop is deprecated. --- typhon/collocations/collocator.py | 6 +++--- typhon/collocations/common.py | 2 +- typhon/datasets/tovs.py | 2 +- typhon/files/handlers/cloudsat.py | 2 +- typhon/files/handlers/common.py | 2 +- typhon/files/handlers/meteosat.py | 2 +- typhon/files/handlers/tovs.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/typhon/collocations/collocator.py b/typhon/collocations/collocator.py index db425bd7..9fb6fc3c 100644 --- a/typhon/collocations/collocator.py +++ b/typhon/collocations/collocator.py @@ -1018,7 +1018,7 @@ def _flat_to_main_coord(data): # So far, collocation is a coordinate. We want to make it to a # dimension, so drop its values: - return data.drop("collocation") + return data.drop_vars("collocation") return data.rename({ shared_dims[0]: "collocation" @@ -1127,7 +1127,7 @@ def _create_return( if var.startswith("__replacement_") ] - output[name] = output[name].drop([ + output[name] = output[name].drop_vars([ f"collocation", *vars_to_drop ]) @@ -1452,7 +1452,7 @@ def concat_collocations(collocations): # Correct the indices: data["Collocations/pairs"][0, :] += primary_size data["Collocations/pairs"][1, :] += secondary_size - data = data.drop("Collocations/group") + data = data.drop_vars("Collocations/group") groups[group].append(data) primary_size += obj.dims[f"{primary}/collocation"] diff --git a/typhon/collocations/common.py b/typhon/collocations/common.py index 476c4bda..c72ee123 100644 --- a/typhon/collocations/common.py +++ b/typhon/collocations/common.py @@ -465,7 +465,7 @@ def expand(dataset): ) # The variable pairs is useless now: - expanded = expanded.drop("Collocations/pairs") + expanded = expanded.drop_vars("Collocations/pairs") expanded = expanded.rename({"Collocations/collocation": "collocation"}) diff --git a/typhon/datasets/tovs.py b/typhon/datasets/tovs.py index 044d206b..62e9e391 100644 --- a/typhon/datasets/tovs.py +++ b/typhon/datasets/tovs.py @@ -1897,7 +1897,7 @@ def combine(self, M, other_obj, *args, col_field, # first or xarray will complain that "the new name # 'matchup_count' conflicts" timedims = utils.get_time_dimensions(MM) - MM = MM.drop(timedims).rename(dict.fromkeys(timedims, self.colloc_dim) + MM = MM.drop_vars(timedims).rename(dict.fromkeys(timedims, self.colloc_dim) ).assign_coords( **{d: (self.colloc_dim, MM.coords[d].values) for d in utils.get_time_dimensions(MM)}, diff --git a/typhon/files/handlers/cloudsat.py b/typhon/files/handlers/cloudsat.py index 5b70089c..bd92c29c 100644 --- a/typhon/files/handlers/cloudsat.py +++ b/typhon/files/handlers/cloudsat.py @@ -100,7 +100,7 @@ def read(self, file_info, **kwargs): # Remove fields that we do not need any longer (expect the user asked # for them explicitly) - dataset = dataset.drop( + dataset = dataset.drop_vars( {"UTC_start", "Profile_time"} - set(user_fields), ) diff --git a/typhon/files/handlers/common.py b/typhon/files/handlers/common.py index 796b1641..4265aec1 100644 --- a/typhon/files/handlers/common.py +++ b/typhon/files/handlers/common.py @@ -785,7 +785,7 @@ def write(self, data, filename, **kwargs): for coord in ds.coords.keys() if NetCDF4._split_path(coord)[0] != group ] - ds = ds.drop(coords_to_drop) + ds = ds.drop_vars(coords_to_drop) # Remove the group name from all variables (incl. dimensions): mapping = { diff --git a/typhon/files/handlers/meteosat.py b/typhon/files/handlers/meteosat.py index f65dfcdb..f57fe10c 100644 --- a/typhon/files/handlers/meteosat.py +++ b/typhon/files/handlers/meteosat.py @@ -255,4 +255,4 @@ def counts_to_bt(dataset): ) # Drop the conversion variable: - return dataset.drop("counts_to_rad") + return dataset.drop_vars("counts_to_rad") diff --git a/typhon/files/handlers/tovs.py b/typhon/files/handlers/tovs.py index f2fd2359..d84bb9de 100644 --- a/typhon/files/handlers/tovs.py +++ b/typhon/files/handlers/tovs.py @@ -65,7 +65,7 @@ def _get_time_field(dataset, user_fields): # Remove the time fields that we do not need any longer (expect the # user asked for them explicitly) - dataset = dataset.drop( + dataset = dataset.drop_vars( {"Data/scnlinyr", "Data/scnlindy", "Data/scnlintime"} - set(user_fields), )