Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor inputs to streamline API across functions #19

Merged
merged 14 commits into from
Oct 28, 2024
2 changes: 1 addition & 1 deletion .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
uv-version:
description: "uv version to use"
required: true
default: "0.4.18"
default: "0.4.27"

runs:
using: "composite"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
types: [opened, synchronize, reopened]

env:
EO_TIDES_TIDE_MODELS: ./tests/data/tide_models
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ build-and-publish: build publish ## Build and publish.
docs-test: ## Test if documentation can be built without warnings or errors
@uv run mkdocs build -s

# On Sandbox: uv run mkdocs serve -a localhost:8000
# https://app.sandbox.dea.ga.gov.au/user/[email protected]/proxy/8000/eo-tides/
.PHONY: docs
docs: ## Build and serve the documentation
@uv run mkdocs serve
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ For instructions on how to set up these models for use in `eo-tides`, refer to [

To get started with `eo-tides`, follow the [Installation](https://geoscienceaustralia.github.io/eo-tides/install/) and [Setting up tide models](https://geoscienceaustralia.github.io/eo-tides/setup/) guides.

## Jupyter Notebooks code examples

Interactive Jupyter Notebook usage examples and more complex coastal EO case studies can be found in the [`docs/notebooks/`](https://github.com/GeoscienceAustralia/eo-tides/tree/main/docs/notebooks) directory, or [rendered in the documentation here](https://geoscienceaustralia.github.io/eo-tides/notebooks/Model_tides/).

## Citing `eo-tides`

To cite `eo-tides` in your work, please use the following citation:
Expand Down
21 changes: 18 additions & 3 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ Renamed for consistency with `model_tides` and `pixel_tides`.

Update references to `tidal_tag` to `tag_tides`.

## `ds` param renamed to `data`, now accepts `GeoBox`

The `ds` param in all satellite data functions (`tag_tides`, `pixel_tides`, `tide_stats`, `pixel_tides`) has been updated to accept either `xarray.Dataset`, `xarray.DataArray` or a `odc.geo.geobox.GeoBox`. To account for this change, the `ds` param has been renamed to a more generic name `data`.

!!! tip "Action required"

Update:
```
tag_tides(ds=your_data)
```
To:
```
tag_tides(data=your_data)
```

### `tag_tides` now returns an array instead of updating data in-place

The `tag_tides` function now returns an `xarray.DataArray` output containing tide heights, rather than appending tide height data to the original input dataset in-place. This change provides better consistency with `pixel_tides`, which also returns an array of tide heights.
Expand All @@ -42,16 +57,16 @@ The `tag_tides` function now returns an `xarray.DataArray` output containing tid

Update:
```
ds = tag_tides(ds, ...)
data = tag_tides(data, ...)
```
To:
```
ds["tide_height"] = tag_tides(ds, ...)
data["tide_height"] = tag_tides(data, ...)
```

### `pixel_tides` only returns a single array

The `pixel_tides` function has been updated to only ever return a single array as an output: a high-resolution tide height array matching the resolution of the input `ds` by default, and a low-resolution tide height array if `resample=False`.
The `pixel_tides` function has been updated to only ever return a single array as an output: a high-resolution tide height array matching the resolution of the input `data` by default, and a low-resolution tide height array if `resample=False`.

!!! tip "Action required"

Expand Down
362 changes: 226 additions & 136 deletions docs/notebooks/Case_study_intertidal.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/notebooks/Satellite_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"from eo_tides.eo import tag_tides\n",
"\n",
"tides_da = tag_tides(\n",
" ds=ds,\n",
" data=ds,\n",
" directory=directory,\n",
")\n",
"\n",
Expand Down Expand Up @@ -554,7 +554,7 @@
"\n",
"# Model tides spatially\n",
"tides_lowres = pixel_tides(\n",
" ds=ds,\n",
" data=ds,\n",
" resample=False,\n",
" directory=directory,\n",
")\n",
Expand Down Expand Up @@ -665,7 +665,7 @@
"source": [
"# Model tides spatially\n",
"tides_highres = pixel_tides(\n",
" ds=ds,\n",
" data=ds,\n",
" resample=True,\n",
" directory=directory,\n",
")\n",
Expand Down Expand Up @@ -820,7 +820,7 @@
"source": [
"# Model tides spatially\n",
"tides_highres_quantiles = pixel_tides(\n",
" ds=ds,\n",
" data=ds,\n",
" calculate_quantiles=(0, 0.5, 1),\n",
" directory=directory,\n",
")\n",
Expand Down Expand Up @@ -897,7 +897,7 @@
"\n",
"# Model tides spatially\n",
"tides_highres = pixel_tides(\n",
" ds, \n",
" data=ds, \n",
" times=custom_times,\n",
" directory=directory,\n",
")\n",
Expand Down
48 changes: 24 additions & 24 deletions docs/notebooks/Tide_statistics.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions eo_tides/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
__all__ = [
"list_models",
"model_tides",
"phase_tides",
"tag_tides",
"pixel_tides",
"tide_stats",
"pixel_stats",
"idw",
"eval_metrics",
"load_gauge_gesla",
Expand Down
Loading