-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Miggrate to selctor API * Add reusable subset examples * Add an exmaple for saving and loading selector with pickle * Add docstrings
- Loading branch information
1 parent
3f0b2d9
commit 2de3f6f
Showing
10 changed files
with
6,608 additions
and
2,438 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from abc import abstractmethod | ||
|
||
import xarray as xr | ||
|
||
|
||
class Selector: | ||
"""Selector class to subset datasets | ||
This is a base method that should be implemented by a subclass | ||
to perform selection on a given xarray dataset with whatever | ||
context or logic is desired by the implementation. | ||
select should return a new xarray dataset that is a subset of the input dataset | ||
and must be implemented by the subclass. | ||
""" | ||
|
||
@abstractmethod | ||
def select(self, ds: xr.Dataset) -> xr.Dataset: | ||
"""Perform the selection on the dataset""" | ||
return ds | ||
"""Perform the selection on the dataset | ||
For example, a selector could hold predifined masks to apply to the dataset, | ||
and the select method here would apply those masks to the dataset and return the result. | ||
This workflow is useful because computing the masks can be expensive, and | ||
we want to avoid recomputing them for every dataset that needs to be subsetted. It also | ||
allows datasets that are non standard to be subset using information from manually or | ||
otherwise standardized datasets.. | ||
""" | ||
raise NotImplementedError() |