Skip to content

Commit

Permalink
[WIP] Refactoring Ocean Tools (#58)
Browse files Browse the repository at this point in the history
* added Ocean tools.
Removed all traces of oceanbench.
Added new ocn-tools dependency.

* Removed more ocean tools.

* Removed rogue add units.

* Slimmed down the test environment.yaml

* refactored mamba test environment.

* fixed yaml. further refactor.

* Try poetry test framework.

* updated pyproject. removed cmake.

* update.

* fix again.

* added linux dist this time.

* added dummy test data.

* Updated environment with ocn-tools.
  • Loading branch information
jejjohnson authored Oct 9, 2023
1 parent d2d9deb commit 5d3de4c
Show file tree
Hide file tree
Showing 50 changed files with 3,988 additions and 5,285 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
defaults:
run:
shell: bash -l {0}
name: PyTest
on: [pull_request]
name: Run Tests
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
- name: Check out the code
uses: actions/[email protected]
- name: Install Micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "1.4.5-0"
environment-file: environments/linux.yaml

init-shell: bash
cache-environment: true
post-cleanup: "all"
- name: install xarray-dataclasses
run: pip install --no-deps xarray-dataclasses
shell: micromamba-shell {0}
- name: pytest
run: pytest oceanbench/_src
shell: micromamba-shell {0}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@ notebooks/*.gif
.DS_Store
.vscode/settings.json
\jbook/_build/

\oceanbench-data-registry/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Some highlighted tutorials are listed in the next section.
We have an open data registry located at the [oceanbench-data-registry](https://github.com/quentinf00/oceanbench-data-registry) GitHub repository.
You can find some more meta-data about the available datasets as well as how to download them yourself.

**Ocean-Tools** [![Open In GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/jejjohnson/ocn-tools)

We have our utility functions which make up the backbone of the preprocessing, postprocessing, and some plotting.
This is what we piece together to use for creating recipes, pipelines and tasks.
This repo is located at [jejjohnson/ocn-tools](https://github.com/jejjohnson/ocn-tools).
See the docs (**TODO**) for more information.

**Machine Learning Datasets** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://jejjohnson.github.io/oceanbench/content/getting_started/TaskToPatcher.html)

We have a set of tasks related to sea surface height interpolation and they come readily integrated into a digestable ML-ready format.
Expand Down
4 changes: 2 additions & 2 deletions config/dataset/components/patcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ strides: null
ref_grid_var: null

cfg:
_target_: oceanbench._src.datasets.base.XRDAPatcher
_target_: xrpatcher._src.base.XRDAPatcher
da:
_target_: oceanbench._src.utils.data.interpstack_dataarrays
_target_: ocn_tools._src.utils.data.interpstack_dataarrays
dataarrays: '${...das}'
ref_grid_var: '${...ref_grid_var}'
domain_limits:
Expand Down
4 changes: 2 additions & 2 deletions config/leaderboard/ose_gf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ method: duacs

outputs:
eval_ds:
_target_: oceanbench._src.utils.data.stack_dataarrays
_target_: ocn_tools._src.utils.data.stack_dataarrays
_partial_: true
dataarrays:
ref: '${results.outputs.eval.ref}'
Expand All @@ -21,7 +21,7 @@ outputs:

plot_ds:
maps:
_target_: oceanbench._src.utils.data.stack_dataarrays
_target_: ocn_tools._src.utils.data.stack_dataarrays
_partial_: true
dataarrays:
ref: '${results.outputs.plots.maps.ref}'
Expand Down
4 changes: 2 additions & 2 deletions config/leaderboard/osse_gf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ method: bfn

outputs:
eval_ds:
_target_: oceanbench._src.utils.data.stack_dataarrays
_target_: ocn_tools._src.utils.data.stack_dataarrays
_partial_: true
dataarrays:
ref: '${results.outputs.eval.ref}'
Expand All @@ -21,7 +21,7 @@ outputs:

plot_ds:
maps:
_target_: oceanbench._src.utils.data.stack_dataarrays
_target_: ocn_tools._src.utils.data.stack_dataarrays
_partial_: true
dataarrays:
ref: '${results.outputs.plots.maps.ref}'
Expand Down
4 changes: 2 additions & 2 deletions config/metrics/components/alongtrack_psd_score.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

alongtrack_segments:
_target_: "oceanbench._src.preprocessing.alongtrack.select_track_segments"
_target_: "ocn_tools._src.preprocessing.alongtrack.select_track_segments"
_partial_: True
variable: "ref"
variable_interp: "study"
Expand All @@ -10,7 +10,7 @@ alongtrack_segments:
segment_overlapping: 0.25

psd_welch_score:
_target_: "oceanbench._src.metrics.power_spectrum.psd_welch_score"
_target_: "ocn_tools._src.metrics.power_spectrum.psd_welch_score"
_partial_: True
variable: "study"
variable_ref: "ref"
Expand Down
2 changes: 1 addition & 1 deletion config/metrics/components/nrmse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
dim: ["lat", "lon", "time"]

cfg:
_target_: "oceanbench._src.metrics.stats.nrmse_ds"
_target_: "ocn_tools._src.metrics.stats.nrmse_ds"
_partial_: True
target: study
reference: ref
Expand Down
4 changes: 2 additions & 2 deletions config/metrics/lib.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#@package _global_

psd_isotropic_score:
_target_: "oceanbench._src.metrics.power_spectrum.psd_isotropic_score"
_target_: "ocn_tools._src.metrics.power_spectrum.psd_isotropic_score"
_partial_: True
ref_variable: ref
study_variable: study
Expand All @@ -15,7 +15,7 @@ psd_isotropic_score:
truncate: True

psd_spacetime_score:
_target_: "oceanbench._src.metrics.power_spectrum.psd_spacetime_score"
_target_: "ocn_tools._src.metrics.power_spectrum.psd_spacetime_score"
_partial_: True
ref_variable: ref
study_variable: study
Expand Down
2 changes: 1 addition & 1 deletion config/plots/gfmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cmaps:
- {_target_: operator.attrgetter, _args_: [speed]}
- {_target_: holoviews.plotting.util.process_cmap, _partial_: True}

geocalc: oceanbench._src.geoprocessing.geostrophic_v2
geocalc: ocn_tools._src.geoprocessing.geostrophic_v2

attrs:
ke: {units: 'm$^{2}$s$^{-2}$', standard_name: kinetic_energy, long_name: Kinetic Energy}
Expand Down
4 changes: 2 additions & 2 deletions config/plots/lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ hook:
_target_: oceanbench._src.utils.hydra.const_fn
const:
inp:
- {_target_: oceanbench._src.viz.ygrid_major, _partial_: True}
- {_target_: oceanbench._src.viz.xformatter, _partial_: True}
- {_target_: ocn_tools._src.viz.ygrid_major, _partial_: True}
- {_target_: ocn_tools._src.viz.xformatter, _partial_: True}
_partial_: false
fns: [{_target_: builtins.list, _partial_: true}]

Expand Down
10 changes: 5 additions & 5 deletions config/processing/lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ resample_method: {target_: "xarray.Dataset.resample", _partial_: True, indexer:
resample_aggregate: {_target_: "xarray.core.resample.DatasetResample.mean", _partial_: True}

fill_nans:
_target_: "oceanbench._src.geoprocessing.interpolate.fillnan_gauss_seidel"
_target_: "ocn_tools._src.geoprocessing.interpolate.fillnan_gauss_seidel"
_partial_: True
variable: "ssh"

rescale_space:
_target_: "oceanbench._src.geoprocessing.spatial.latlon_deg2m"
_target_: "ocn_tools._src.geoprocessing.spatial.latlon_deg2m"
_partial_: True
mean: True

Expand All @@ -19,12 +19,12 @@ to_dataset:
name: 'ssh'

add_units:
_target_: oceanbench._src.data.add_units
_target_: ocn_tools._src.data.add_units
_partial_: true
units: {ssh: meter, lon: degrees_east, lat: degrees_north, time: seconds}

psd_spacetime:
_target_: "oceanbench._src.metrics.power_spectrum.psd_spacetime"
_target_: "ocn_tools._src.metrics.power_spectrum.psd_spacetime"
_partial_: True
variable: "ssh"
dims: ["time", "lon"]
Expand All @@ -36,7 +36,7 @@ psd_spacetime:
truncate: True

psd_isotropic:
_target_: "oceanbench._src.metrics.power_spectrum.psd_isotropic"
_target_: "ocn_tools._src.metrics.power_spectrum.psd_isotropic"
_partial_: True
variable: "ssh"
dims: ["lon", "lat"]
Expand Down
2 changes: 1 addition & 1 deletion config/processing/ose_gf_results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ select:
lon: '${task.outputs.domain.lon}'

degrid:
_target_: oceanbench._src.geoprocessing.gridding.grid_to_coord_based
_target_: ocn_tools._src.geoprocessing.gridding.grid_to_coord_based
_partial_: true
tgt_coord_based_ds: {inp: '${...outputs.eval.ref}', fns: ['${F.call}'], _partial_: false}

Expand Down
1 change: 1 addition & 0 deletions environments/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
- jupyter-book
- ghp-import
- pip:
- git+https://github.com/jejjohnson/ocn-tools.git
- hydra-core
- pyrootutils
- loguru
Expand Down
31 changes: 0 additions & 31 deletions environments/macos.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions environments/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: oceanbench
channels:
- conda-forge
- pyviz
dependencies:
- python=3.10
- xesmf
- pip
- pytest
- pip:
- git+https://github.com/jejjohnson/ocn-tools.git
- hydra-core
- pyrootutils
- loguru
- xrpatcher
- autoroot
Loading

0 comments on commit 5d3de4c

Please sign in to comment.