diff --git a/README.md b/README.md index 5575d84..2c58e4e 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,16 @@ python3 -m pip install cgeniepy ```bash python3 -m pip install git+https://github.com/ruiying-ocean/cgeniepy.git@master ``` +## Quickstart -## How to use +```python +import cgeniepy + +model = cgeniepy.sample_model() +model.get_var('ocn_sur_temp').isel(time=-1).plot(colorbar=True) +``` + +## Full documentation [Here is the documentation with examples](https://cgeniepy.readthedocs.io/en/latest/) diff --git a/src/cgeniepy/__init__.py b/src/cgeniepy/__init__.py index 8f77873..b661f4a 100644 --- a/src/cgeniepy/__init__.py +++ b/src/cgeniepy/__init__.py @@ -6,3 +6,21 @@ # Q_ = ureg.Quantity # file_path = pathlib.Path(__file__).parent.parent / "data/context.txt" # ureg.load_definitions(file_path) + + +from importlib.resources import files +from cgeniepy.model import GenieModel +from cgeniepy.ecology import EcoModel + +def sample_model(model_type='GenieModel', *args, **kwargs): + file_path=str(files('data').joinpath('sample_model')) + + if model_type == 'GenieModel': + model = GenieModel(file_path,*args, **kwargs) + elif model_type == 'EcoModel': + model = EcoModel(file_path,*args, **kwargs) + else: + raise ValueError('model_type must be either GenieModel or EcoModel') + + return model +