-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle model-specific docstrings and hide their classes from public a…
…pi (#98) * Bundle model-specific docstrings and hide their classes from public api * Formatting * Mock fiona to test rtd build * comma * mock dateutil * mock shapely * Change order of forcing constructors * Add that model-specific stuff should be in a dict * Automatically detect new models in docs * fix init statements * Add pathparser to util and fix formatting issues * remove marrmot defaults * Try conda install on readthedocs * Revert "Try conda install on readthedocs" This reverts commit 17addd6. * Revert "Automatically detect new models in docs" This reverts commit 6580cd3. * Fix imports * Small fixes of rendering of API docs * Move input parsing to its own branch * fix small issues * Keep shape argument optional in init * Add __eq__ method to default forcing; this makes it possible to compare whether 2 forcing objects share the same properties. It broke when we removed the dataclasses, which implements a default method * Revert removing marrmot default name and fix remaining tests * fix sphinx warnings * fix mypy * does this fix mypy? Co-authored-by: Stefan Verhoeven <[email protected]>
- Loading branch information
1 parent
955499d
commit a7c8d3a
Showing
20 changed files
with
636 additions
and
536 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Forcing related functionality for default models""" | ||
|
||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from ruamel.yaml import YAML | ||
|
||
|
||
class DefaultForcing: | ||
"""Container for forcing data. | ||
Args: | ||
dataset: Name of the source dataset. See :py:data:`.DATASETS`. | ||
start_time: Start time of forcing in UTC and ISO format string e.g. | ||
'YYYY-MM-DDTHH:MM:SSZ'. | ||
end_time: End time of forcing in UTC and ISO format string e.g. | ||
'YYYY-MM-DDTHH:MM:SSZ'. | ||
shape: Path to a shape file. Used for spatial selection. | ||
""" | ||
def __init__(self, | ||
start_time: str, | ||
end_time: str, | ||
directory: str, | ||
shape: Optional[str] = None): | ||
self.start_time = start_time | ||
self.end_time = end_time | ||
self.directory = directory | ||
self.shape = shape | ||
|
||
@classmethod | ||
def generate( | ||
cls, | ||
dataset: str, | ||
start_time: str, | ||
end_time: str, | ||
shape: str, | ||
**model_specific_options, | ||
) -> 'DefaultForcing': | ||
"""Generate forcing data with ESMValTool.""" | ||
raise NotImplementedError("No default forcing generator available.") | ||
|
||
def save(self): | ||
"""Export forcing data for later use.""" | ||
yaml = YAML() | ||
yaml.register_class(self.__class__) | ||
target = Path(self.directory) / 'ewatercycle_forcing.yaml' | ||
# TODO remove directory or set to . | ||
with open(target, 'w') as f: | ||
yaml.dump(self, f) | ||
return target | ||
|
||
def plot(self): | ||
raise NotImplementedError("No generic plotting method available.") | ||
|
||
def __eq__(self, other): | ||
return self.__dict__ == other.__dict__ |
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
Oops, something went wrong.