Skip to content

Commit

Permalink
Merge pull request #62 from kthyng/add_test_data
Browse files Browse the repository at this point in the history
Tons of updates
  • Loading branch information
kthyng authored Oct 5, 2023
2 parents ef41d1e + 23c7e85 commit 287411a
Show file tree
Hide file tree
Showing 73 changed files with 4,166 additions and 3,377 deletions.
53 changes: 34 additions & 19 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,51 @@ jobs:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if ci/environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment-py${{ matrix.python-version }}.yml') }}
- uses: conda-incubator/setup-miniconda@v2
# - name: Cache conda
# uses: actions/cache@v3
# env:
# # Increase this value to reset cache if ci/environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment-py${{ matrix.python-version }}.yml') }}

- name: Setup Micromamba Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
# mamba-version: "*" # activate this to build with mamba.
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
channels: conda-forge, defaults # These need to be specified to use mamba
channel-priority: true
init-shell: bash
create-args: >-
python=${{ matrix.python-version }} --channel conda-forge
environment-file: ci/environment-py${{ matrix.python-version }}.yml
cache-environment: true
post-cleanup: 'all'


# - name: Set up conda environment
# uses: conda-incubator/setup-miniconda@v2
# with:
# # mamba-version: "*" # activate this to build with mamba.
# python-version: ${{ matrix.python-version }}
# miniforge-variant: Mambaforge
# use-mamba: true
# channels: conda-forge, defaults # These need to be specified to use mamba
# channel-priority: true
# environment-file: ci/environment-py${{ matrix.python-version }}.yml

# activate-environment: test_env_model_assessor
# use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!

activate-environment: test_env_model_assessor
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Set up conda environment
- name: Install package
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Run Tests
shell: bash -l {0}
run: |
pytest --cov=./ --cov-report=xml
pytest --mpl --cov=./ --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
16 changes: 9 additions & 7 deletions ci/environment-py3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ dependencies:
- pyproj
- scipy
- xarray
- xcmocean
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake>=0.7.0
- nested-lookup
- xroms # github actions won't find on conda-forge
##############
- pytest
- pip:
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake
- nested_lookup
- tqdm
- codecov
- pytest-cov
- pytest-mpl
- coverage[toml]
18 changes: 10 additions & 8 deletions ci/environment-py3.8.yml → ci/environment-py3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env_model_assessor
channels:
- conda-forge
dependencies:
- python=3.8
- python=3.11
############## These will have to be adjusted to your specific project
# - cf_pandas
- cf_xarray
Expand All @@ -18,16 +18,18 @@ dependencies:
- pyproj
- scipy
- xarray
- xcmocean
##############
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake>=0.7.0
- nested-lookup
- xroms # github actions won't find on conda-forge
- pytest
- pip:
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake
- nested_lookup
- tqdm
- codecov
- pytest-cov
- pytest-mpl
- coverage[toml]
16 changes: 9 additions & 7 deletions ci/environment-py3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ dependencies:
- pyproj
- scipy
- xarray
- xcmocean
##############
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake
- nested-lookup
- xroms # github actions won't find on conda-forge
- pytest
- pip:
- alphashape
- cf_pandas
- intake-axds
- intake-erddap
- intake
- nested_lookup
- tqdm
- codecov
- pytest-cov
- pytest-mpl
- coverage[toml]
36 changes: 28 additions & 8 deletions docs/add_vocab.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.4
jupytext_version: 1.15.2
kernelspec:
display_name: Python 3.10.8 ('omsa')
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# How to make and work with vocabularies
# How to make and work with vocabularies and vocab labels

This page demonstrates the workflow of making a new vocabulary, saving it to the user application cache, and reading it back in to use it. The vocabulary created is the exact same as the "general" vocabulary that is saved with the OMSA package, though here it is given another name to demonstrate that you could be making any new vocabulary you want.

Expand All @@ -31,6 +31,8 @@ Here is the list of variables of interest (with "nickname"), aimed at a physical
* sea ice velocity v "sea_ice_v"
* sea ice area fraction "sea_ice_area_fraction"

Vocab labels are used in model-data comparison plots to support nice labeling. They are a dictionary with the same keys as the vocabularies being used and the value is the string you want to use for that variable key's label in a plot.

```{code-cell} ipython3
import cf_pandas as cfp
import ocean_model_skill_assessor as omsa
Expand Down Expand Up @@ -100,19 +102,20 @@ vocab
This exact vocabulary was previously saved as "general" and is available under that name, but this page demonstrates saving a new vocabulary and so we use the name "general2" to differentiate.

```{code-cell} ipython3
vocab.save(omsa.VOCAB_PATH("general2"))
paths = omsa.paths.Paths()
vocab.save(paths.VOCAB_PATH("general2"))
```

```{code-cell} ipython3
omsa.VOCAB_PATH("general2")
paths.VOCAB_PATH("general2")
```

### Use it later

Read the saved vocabulary back in to use it:

```{code-cell} ipython3
vocab = cfp.Vocab(omsa.VOCAB_PATH("general2"))
vocab = cfp.Vocab(paths.VOCAB_PATH("general2"))
df = pd.DataFrame(columns=["sst", "time", "lon", "lat"], data={"sst": [1,2,3]})
with cfp.set_options(custom_criteria=vocab.vocab):
Expand All @@ -124,8 +127,8 @@ with cfp.set_options(custom_criteria=vocab.vocab):
A user can add together vocabularies. For example, here we combine the built-in "standard_names" and "general" vocabularies.

```{code-cell} ipython3
v1 = cfp.Vocab(omsa.VOCAB_PATH("standard_names"))
v2 = cfp.Vocab(omsa.VOCAB_PATH("general"))
v1 = cfp.Vocab(paths.VOCAB_PATH("standard_names"))
v2 = cfp.Vocab(paths.VOCAB_PATH("general"))
v = v1 + v2
v
Expand All @@ -137,3 +140,20 @@ v

.. raw:: html
<iframe src="vocab_widget.html" height="500px" width="100%"></iframe>

+++

## Vocab labels

There is a default set of labels in the repository available alongside the default vocabs, called "vocab_labels.json".

You can use `cf-pandas` to open up and look at `vocal_labels` like a vocabulary since they are both just dictionaries stored as json.

```{code-cell} ipython3
vocab_labels = cfp.Vocab(paths.VOCAB_PATH("vocab_labels"))
vocab_labels
```

```{code-cell} ipython3
```
4 changes: 2 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ API
main
utils
paths
accessor
stats
plot.map
plot.time_series
plot.line
plot.surface
6 changes: 4 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Make a catalog with known local or remote file(s). Also use a local catalog to r

##### Basic catalog for single dataset

omsa make_catalog --project_name test1 --catalog_type local --catalog_name example_local_catalog --description "Example local catalog description" --kwargs filenames="[https://erddap.sensors.axds.co/erddap/tabledap/aoos_204.csvp?time%2Clatitude%2Clongitude%2Cz%2Csea_water_temperature&time%3E=2022-01-01T00%3A00%3A00Z&time%3C=2022-01-06T00%3A00%3A00Z]" --kwargs_open blocksize=None
omsa make_catalog --project_name test1 --catalog_type local --catalog_name example_local_catalog --description "Example local catalog description" --kwargs filenames="[https://erddap.sensors.axds.co/erddap/tabledap/aoos_204.csvp?time%2Clatitude%2Clongitude%2Cz%2Csea_water_temperature&time%3E=2022-01-01T00%3A00%3A00Z&time%3C=2022-01-06T00%3A00%3A00Z]"

##### Dataset with no lon/lat

Expand Down Expand Up @@ -175,7 +175,7 @@ The datasets need to all cover the same time periods.

### Available options

omsa run --project_name test1 --catalogs CATALOG_NAME1 CATALOG_NAME2 --vocab_names VOCAB1 VOCAB2 --key KEY --model_path PATH_TO_MODEL_OUTPUT --ndatasets NDATASETS --verbose --mode MODE
omsa run --project_name test1 --catalogs CATALOG_NAME1 CATALOG_NAME2 --vocab_names VOCAB1 VOCAB2 --key KEY --model_path PATH_TO_MODEL_OUTPUT --ndatasets NDATASETS --verbose --mode MODE --kwargs_map key_fig=value_fig --more_kwargs key=value key2=value2

* `project_name`: Subdirectory in cache dir to store files associated together.
* `catalog_names`: Catalog name(s). Datasets will be accessed from catalog entries.
Expand All @@ -185,6 +185,8 @@ The datasets need to all cover the same time periods.
* `ndatasets`: Max number of datasets from each input catalog to use.
* `verbose` Print useful runtime commands to stdout if True as well as save in log, otherwise silently save in log. Log is located in the project directory, which can be checked on the command line with `omsa proj_path --project_name PROJECT_NAME`. Default is True, to turn off use `--no-verbose`.
* `mode` mode for logging file. Default is to overwrite an existing logfile, but can be changed to other modes, e.g. "a" to instead append to an existing log file.
* `kwargs_map` are sent to `omsa.plot.map`
* `more_kwargs` are sent to `omsa.run`

### Example

Expand Down
118 changes: 0 additions & 118 deletions docs/cli_tutorial.md

This file was deleted.

Loading

0 comments on commit 287411a

Please sign in to comment.