Skip to content

Commit

Permalink
Merge pull request #355 from olemke/fix-deprecated-drop
Browse files Browse the repository at this point in the history
Replace xarray.Dataset.drop with drop_vars
  • Loading branch information
lkluft authored Mar 4, 2020
2 parents be6f751 + 16f410b commit 64f20ba
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions typhon/collocations/collocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
])

Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion typhon/collocations/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})

Expand Down
2 changes: 1 addition & 1 deletion typhon/datasets/tovs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
2 changes: 1 addition & 1 deletion typhon/files/handlers/cloudsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down
2 changes: 1 addition & 1 deletion typhon/files/handlers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion typhon/files/handlers/meteosat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion typhon/files/handlers/tovs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down

0 comments on commit 64f20ba

Please sign in to comment.