Skip to content

Commit

Permalink
resolve #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ruiying-ocean committed Sep 17, 2024
1 parent 9ffaaee commit 0309fed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
18 changes: 18 additions & 0 deletions src/cgeniepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0309fed

Please sign in to comment.