sectionate 0.3.3__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {sectionate-0.3.3 → sectionate-0.3.4}/.github/workflows/ci.yml +6 -1
  2. sectionate-0.3.4/.github/workflows/publish-to-pypi.yml +44 -0
  3. {sectionate-0.3.3 → sectionate-0.3.4}/.gitignore +3 -0
  4. sectionate-0.3.4/.readthedocs.yaml +37 -0
  5. sectionate-0.3.4/PKG-INFO +83 -0
  6. sectionate-0.3.4/README.md +62 -0
  7. {sectionate-0.3.3 → sectionate-0.3.4}/ci/environment.yml +1 -0
  8. sectionate-0.3.4/conda/meta.yaml +54 -0
  9. sectionate-0.3.4/docs/Makefile +20 -0
  10. {sectionate-0.3.3 → sectionate-0.3.4}/docs/environment.yml +4 -0
  11. sectionate-0.3.4/docs/make.bat +35 -0
  12. sectionate-0.3.4/docs/source/_static/.gitkeep +0 -0
  13. sectionate-0.3.4/docs/source/_static/custom.css +39 -0
  14. sectionate-0.3.4/docs/source/_templates/.gitkeep +0 -0
  15. sectionate-0.3.4/docs/source/conf.py +78 -0
  16. sectionate-0.3.4/docs/source/index.rst +13 -0
  17. sectionate-0.3.4/docs/source/installation.rst +44 -0
  18. sectionate-0.3.4/pyproject.toml +55 -0
  19. sectionate-0.3.4/sectionate/_version.py +24 -0
  20. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/gridutils.py +7 -3
  21. sectionate-0.3.4/sectionate/tests/test_utils.py +42 -0
  22. sectionate-0.3.4/sectionate/version.py +18 -0
  23. sectionate-0.3.3/.github/workflows/publish-to-pypi.yml +0 -26
  24. sectionate-0.3.3/PKG-INFO +0 -44
  25. sectionate-0.3.3/README.md +0 -23
  26. sectionate-0.3.3/pyproject.toml +0 -38
  27. sectionate-0.3.3/sectionate/tests/test_utils.py +0 -4
  28. sectionate-0.3.3/sectionate/version.py +0 -3
  29. {sectionate-0.3.3 → sectionate-0.3.4}/LICENSE +0 -0
  30. {sectionate-0.3.3 → sectionate-0.3.4}/binder/environment.yml +0 -0
  31. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/__init__.py +0 -0
  32. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/catalog/Atlantic_transport_arrays.json +0 -0
  33. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/section.py +0 -0
  34. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/tests/test_convergent_transport.py +0 -0
  35. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/tests/test_section.py +0 -0
  36. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/tests/test_section_class.py +0 -0
  37. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/tests/test_section_cornercases.py +0 -0
  38. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/tracers.py +0 -0
  39. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/transports.py +0 -0
  40. {sectionate-0.3.3 → sectionate-0.3.4}/sectionate/utils.py +0 -0
@@ -26,7 +26,12 @@ jobs:
26
26
  with:
27
27
  access_token: ${{ github.token }}
28
28
  - name: Checkout source
29
- uses: actions/checkout@v2
29
+ uses: actions/checkout@v4
30
+ with:
31
+ # `pip install -e .` resolves the version from the git tag via
32
+ # hatch-vcs; a shallow clone has no tag, so the installed package
33
+ # would report `0.1.devN` instead of the release line.
34
+ fetch-depth: 0
30
35
 
31
36
  - name: Conda setup
32
37
  uses: conda-incubator/setup-miniconda@v2
@@ -0,0 +1,44 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build-and-publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ with:
13
+ # hatch-vcs derives the version from the git tag, which a shallow clone
14
+ # does not have. Without this the build silently produces a
15
+ # `0.0.0.dev...` artifact instead of the release version.
16
+ fetch-depth: 0
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: '3.x'
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install build twine
25
+ - name: Build package
26
+ run: python -m build
27
+ # Deriving the version from the tag should make this unfalsifiable, but it
28
+ # is the last point at which a mismatch is cheap to see: the alternative
29
+ # symptom is a 400 from PyPI at the very end of the release, and only when
30
+ # that version already exists.
31
+ - name: Built version must match the release tag
32
+ run: |
33
+ built=$(ls dist/*.tar.gz | sed -E 's|.*/sectionate-(.*)\.tar\.gz|\1|')
34
+ tag="${GITHUB_REF_NAME#v}"
35
+ echo "tag=$tag built=$built"
36
+ if [ "$built" != "$tag" ]; then
37
+ echo "::error::Release tag $GITHUB_REF_NAME implies version '$tag', but the build produced '$built'."
38
+ exit 1
39
+ fi
40
+ - name: Publish package
41
+ env:
42
+ TWINE_USERNAME: __token__
43
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
44
+ run: twine upload dist/*
@@ -102,3 +102,6 @@ venv.bak/
102
102
 
103
103
  # mypy
104
104
  .mypy_cache/
105
+
106
+ # Version file generated from the git tag by hatch-vcs at build time.
107
+ sectionate/_version.py
@@ -0,0 +1,37 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "miniforge3-latest"
12
+ jobs:
13
+ post_checkout:
14
+ # RTD clones shallow, but installing sectionate resolves its version from
15
+ # the git tag via hatch-vcs, and the docs are titled with it
16
+ # (`docs/source/conf.py` reads it from the installed metadata). Without
17
+ # the tag they would say `.devN`. Tolerate failure: an already-complete
18
+ # clone makes `--unshallow` an error, which must not fail the build.
19
+ - git fetch --unshallow || true
20
+ - git fetch --tags || true
21
+
22
+ # Build documentation in the "docs/" directory with Sphinx
23
+ sphinx:
24
+ builder: html
25
+ configuration: docs/source/conf.py
26
+ fail_on_warning: true
27
+
28
+ # Don't build any extra output files
29
+ formats: []
30
+
31
+ python:
32
+ install:
33
+ - method: pip
34
+ path: .
35
+
36
+ conda:
37
+ environment: docs/environment.yml
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: sectionate
3
+ Version: 0.3.4
4
+ Summary: A package to sample grid-consistent sections from ocean model outputs
5
+ Project-URL: Homepage, https://github.com/MOM6-community/sectionate
6
+ Project-URL: Bugs/Issues/Features, https://github.com/MOM6-community/sectionate/issues
7
+ Project-URL: Sibling package, https://github.com/hdrake/regionate
8
+ Author-email: Raphael Dussin <raphael.dussin@gmail.com>, "Henri F. Drake" <hfdrake@uci.edu>
9
+ License-File: LICENSE
10
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.11
14
+ Requires-Dist: dask
15
+ Requires-Dist: numba
16
+ Requires-Dist: numpy
17
+ Requires-Dist: scipy
18
+ Requires-Dist: xarray
19
+ Requires-Dist: xgcm==0.9.*
20
+ Description-Content-Type: text/markdown
21
+
22
+ # sectionate
23
+ A package to sample grid-consistent sections from ocean model outputs
24
+
25
+ (Currently only supports structured grids.)
26
+
27
+ [![PyPI](https://badge.fury.io/py/sectionate.svg)](https://badge.fury.io/py/sectionate)
28
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/sectionate)](https://anaconda.org/conda-forge/sectionate)
29
+ [![Docs](https://readthedocs.org/projects/sectionate/badge/?version=latest)](https://sectionate.readthedocs.io/en/latest/)
30
+ [![License](https://img.shields.io/github/license/MOM6-Community/sectionate)](https://github.com/MOM6-Community/sectionate)
31
+
32
+ Quick Start Guide
33
+ -----------------
34
+
35
+ **For users: minimal installation within an existing environment**
36
+ ```bash
37
+ conda install -c conda-forge sectionate
38
+ ```
39
+
40
+ **For developers: installing dependencies from scratch using `conda`**
41
+ ```bash
42
+ git clone https://github.com/MOM6-community/sectionate.git
43
+ cd sectionate
44
+ conda env create -f docs/environment.yml
45
+ conda activate docs_env_sectionate
46
+ pip install -e .
47
+ python -m ipykernel install --user --name docs_env_sectionate --display-name "docs_env_sectionate"
48
+ jupyter-lab
49
+ ```
50
+
51
+ Releasing
52
+ ---------
53
+
54
+ **The git tag is the version.** `sectionate` has no version string checked into
55
+ the source tree: `hatch-vcs` derives it from the tag at build time and writes
56
+ `sectionate/_version.py` (gitignored, but shipped inside the sdist and wheel).
57
+ To cut a release you tag; there is no file to bump and nothing to keep in sync.
58
+
59
+ 1. Make sure `master` is green and has everything you want in the release.
60
+ 2. **Publish a GitHub Release** whose tag is `vX.Y.Z`, targeting the commit you
61
+ want to ship:
62
+ ```bash
63
+ gh release create vX.Y.Z --target "$(git rev-parse origin/master)" \
64
+ --title vX.Y.Z --generate-notes
65
+ ```
66
+ Publishing it (not merely pushing a tag) is what fires the workflow. Target
67
+ the commit you actually want: a tag placed *before* the commit you meant to
68
+ release builds the previous version, and PyPI rejects it as a duplicate.
69
+ 3. The **Publish to PyPI** workflow builds from that tag and uploads. It checks
70
+ out with `fetch-depth: 0` so the tag is visible to `hatch-vcs`, and asserts
71
+ that the built version matches the tag before publishing.
72
+ 4. Verify: <https://pypi.org/project/sectionate/>.
73
+ 5. conda-forge builds from the PyPI sdist and lags by design; the autotick bot
74
+ opens the version-bump PR. Its recipe must list `hatch-vcs` alongside
75
+ `hatchling` in `host`, since it builds with `--no-build-isolation`.
76
+
77
+ Two things follow from the tag being the version. Never add a version literal
78
+ back to the tree — `sectionate/version.py` is a shim over the generated file, and
79
+ a `0.0.0+unknown` from it means the package was imported without being built or
80
+ installed, not that a number is missing. And any checkout that installs the
81
+ package needs its tags: a shallow clone, or a fork that never fetched them,
82
+ resolves a `.devN` version instead of the release line. That is why CI checks out
83
+ with `fetch-depth: 0` and Read the Docs unshallows in `post_checkout`.
@@ -0,0 +1,62 @@
1
+ # sectionate
2
+ A package to sample grid-consistent sections from ocean model outputs
3
+
4
+ (Currently only supports structured grids.)
5
+
6
+ [![PyPI](https://badge.fury.io/py/sectionate.svg)](https://badge.fury.io/py/sectionate)
7
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/sectionate)](https://anaconda.org/conda-forge/sectionate)
8
+ [![Docs](https://readthedocs.org/projects/sectionate/badge/?version=latest)](https://sectionate.readthedocs.io/en/latest/)
9
+ [![License](https://img.shields.io/github/license/MOM6-Community/sectionate)](https://github.com/MOM6-Community/sectionate)
10
+
11
+ Quick Start Guide
12
+ -----------------
13
+
14
+ **For users: minimal installation within an existing environment**
15
+ ```bash
16
+ conda install -c conda-forge sectionate
17
+ ```
18
+
19
+ **For developers: installing dependencies from scratch using `conda`**
20
+ ```bash
21
+ git clone https://github.com/MOM6-community/sectionate.git
22
+ cd sectionate
23
+ conda env create -f docs/environment.yml
24
+ conda activate docs_env_sectionate
25
+ pip install -e .
26
+ python -m ipykernel install --user --name docs_env_sectionate --display-name "docs_env_sectionate"
27
+ jupyter-lab
28
+ ```
29
+
30
+ Releasing
31
+ ---------
32
+
33
+ **The git tag is the version.** `sectionate` has no version string checked into
34
+ the source tree: `hatch-vcs` derives it from the tag at build time and writes
35
+ `sectionate/_version.py` (gitignored, but shipped inside the sdist and wheel).
36
+ To cut a release you tag; there is no file to bump and nothing to keep in sync.
37
+
38
+ 1. Make sure `master` is green and has everything you want in the release.
39
+ 2. **Publish a GitHub Release** whose tag is `vX.Y.Z`, targeting the commit you
40
+ want to ship:
41
+ ```bash
42
+ gh release create vX.Y.Z --target "$(git rev-parse origin/master)" \
43
+ --title vX.Y.Z --generate-notes
44
+ ```
45
+ Publishing it (not merely pushing a tag) is what fires the workflow. Target
46
+ the commit you actually want: a tag placed *before* the commit you meant to
47
+ release builds the previous version, and PyPI rejects it as a duplicate.
48
+ 3. The **Publish to PyPI** workflow builds from that tag and uploads. It checks
49
+ out with `fetch-depth: 0` so the tag is visible to `hatch-vcs`, and asserts
50
+ that the built version matches the tag before publishing.
51
+ 4. Verify: <https://pypi.org/project/sectionate/>.
52
+ 5. conda-forge builds from the PyPI sdist and lags by design; the autotick bot
53
+ opens the version-bump PR. Its recipe must list `hatch-vcs` alongside
54
+ `hatchling` in `host`, since it builds with `--no-build-isolation`.
55
+
56
+ Two things follow from the tag being the version. Never add a version literal
57
+ back to the tree — `sectionate/version.py` is a shim over the generated file, and
58
+ a `0.0.0+unknown` from it means the package was imported without being built or
59
+ installed, not that a number is missing. And any checkout that installs the
60
+ package needs its tags: a shallow clone, or a fork that never fetched them,
61
+ resolves a `.devN` version instead of the release line. That is why CI checks out
62
+ with `fetch-depth: 0` and Read the Docs unshallows in `post_checkout`.
@@ -1,6 +1,7 @@
1
1
  name: test_env_sectionate
2
2
  channels:
3
3
  - conda-forge
4
+ - nodefaults
4
5
  dependencies:
5
6
  - python>=3.12
6
7
  - pytest
@@ -0,0 +1,54 @@
1
+ {% set name = "sectionate" %}
2
+ {% set version = "0.3.3" %}
3
+ {% set python_min = "3.11" %}
4
+
5
+ package:
6
+ name: {{ name|lower }}
7
+ version: {{ version }}
8
+
9
+ source:
10
+ url: https://pypi.org/packages/source/s/sectionate/sectionate-{{ version }}.tar.gz
11
+ sha256: b855b091e0c5ac56ab09ec96822ad46ee2ec89bf3b6b3aecb53cbe16dbc36ecb
12
+
13
+ build:
14
+ noarch: python
15
+ number: 0
16
+ script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
17
+
18
+ requirements:
19
+ host:
20
+ - python {{ python_min }}
21
+ - pip
22
+ - hatchling
23
+ # The build backend resolves the version through hatch-vcs. The build above
24
+ # is `--no-build-isolation`, so it has to be installed here or the wheel
25
+ # build fails outright; the sdist carries the generated `_version.py`, so
26
+ # git itself is not needed.
27
+ - hatch-vcs
28
+ run:
29
+ - python >={{ python_min }}
30
+ - dask
31
+ - numba
32
+ - numpy
33
+ - scipy
34
+ - xarray
35
+ - xgcm >=0.9.0
36
+
37
+ test:
38
+ requires:
39
+ - python {{ python_min }}
40
+ - pip
41
+ imports:
42
+ - sectionate
43
+ commands:
44
+ - pip check
45
+
46
+ about:
47
+ home: https://github.com/MOM6-community/sectionate
48
+ summary: A package to sample grid-consistent sections from ocean model outputs
49
+ license: GPL-3.0-only
50
+ license_file: LICENSE
51
+
52
+ extra:
53
+ recipe-maintainers:
54
+ - hdrake
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -11,3 +11,7 @@ dependencies:
11
11
  - netcdf4
12
12
  - pydap
13
13
  - pytest
14
+ - sphinx
15
+ - nbsphinx
16
+ - ipykernel
17
+ - pip
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
File without changes
@@ -0,0 +1,39 @@
1
+ /* Responsive layout widening for Alabaster
2
+ - On small screens: use full width (with padding)
3
+ - On typical laptops: ~1100–1250px content area
4
+ - On big screens: cap so lines don't get absurdly long
5
+ */
6
+
7
+ div.document {
8
+ /* Total doc block width (sidebar + content) */
9
+ width: min(96vw, 1400px);
10
+ margin: 0 auto;
11
+ }
12
+
13
+ /* Keep the main content comfortable: cap line length */
14
+ div.body {
15
+ /* body width within the document area */
16
+ max-width: 900px;
17
+ }
18
+
19
+ /* Give the sidebar a stable width; let it wrap below on small screens */
20
+ div.sphinxsidebar {
21
+ width: 270px;
22
+ }
23
+
24
+ /* On narrower screens, don't force sidebar + body side-by-side */
25
+ @media (max-width: 900px) {
26
+ div.document {
27
+ width: 96vw;
28
+ }
29
+ div.sphinxsidebar {
30
+ float: none;
31
+ width: auto;
32
+ }
33
+ div.bodywrapper {
34
+ margin: 0;
35
+ }
36
+ div.body {
37
+ max-width: none;
38
+ }
39
+ }
File without changes
@@ -0,0 +1,78 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ from importlib.metadata import version as get_version
7
+ from pathlib import Path
8
+ import shutil
9
+
10
+ # The master toctree document.
11
+ master_doc = "index"
12
+
13
+ # -- Project information -----------------------------------------------------
14
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
15
+
16
+
17
+ project = 'sectionate'
18
+ copyright = '2026, Henri Drake'
19
+ author = 'Henri Drake'
20
+
21
+ release = get_version(project)
22
+ version = ".".join(release.split(".")[:2])
23
+
24
+ # -- General configuration ---------------------------------------------------
25
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
26
+
27
+ extensions = [
28
+ "nbsphinx"
29
+ ]
30
+
31
+ templates_path = ['_templates']
32
+ exclude_patterns = []
33
+
34
+ # Don't execute notebooks on RTD unless you want that
35
+ nbsphinx_execute = "never"
36
+
37
+ # -- Copy notebooks from repo root/examples into docs/source/examples --------
38
+
39
+ HERE = Path(__file__).resolve()
40
+ DOCS_SOURCE = HERE.parent # docs/source
41
+ REPO_ROOT = HERE.parents[2] # up two levels from conf.py
42
+ EXAMPLES_SRC = REPO_ROOT / "examples"
43
+ EXAMPLES_DST = DOCS_SOURCE / "examples"
44
+
45
+ def _sync_examples():
46
+ if not EXAMPLES_SRC.exists():
47
+ return
48
+
49
+ # fresh copy so removed notebooks don't linger
50
+ if EXAMPLES_DST.exists():
51
+ shutil.rmtree(EXAMPLES_DST)
52
+ EXAMPLES_DST.mkdir(parents=True, exist_ok=True)
53
+
54
+ for nb in EXAMPLES_SRC.rglob("*.ipynb"):
55
+ rel = nb.relative_to(EXAMPLES_SRC)
56
+ out = EXAMPLES_DST / rel
57
+ out.parent.mkdir(parents=True, exist_ok=True)
58
+ shutil.copy2(nb, out)
59
+
60
+ _sync_examples()
61
+
62
+ # -- Options for HTML output -------------------------------------------------
63
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
64
+
65
+ html_title = f"{project} v{version} documentation"
66
+
67
+ html_theme = "alabaster"
68
+
69
+ html_theme_options = {
70
+ "sidebar_width": "270px",
71
+ }
72
+
73
+ html_static_path = ["_static"]
74
+ html_css_files = ["custom.css"]
75
+
76
+ latex_documents = [
77
+ ("index")
78
+ ]
@@ -0,0 +1,13 @@
1
+ sectionate: a package to sample grid-consistent sections from structured ocean model outputs
2
+ =============================================================================================
3
+
4
+ .. toctree::
5
+ :maxdepth: 2
6
+ :caption: Contents:
7
+
8
+ installation
9
+ examples/1_creating_an_OSNAP_section
10
+ examples/2_OSNAP_transports_CM4p25
11
+ examples/3_Labrador_convergence_CM4p25
12
+ examples/4_sections_on_global_tripolar_grid
13
+ examples/5_MOC_transports_CM4p25
@@ -0,0 +1,44 @@
1
+ Installation
2
+ ------------
3
+
4
+ Requirements
5
+ ^^^^^^^^^^^^
6
+
7
+ sectionate is compatible with python 3 (>= version 3.11). It requires xgcm
8
+ (>= version 0.9.0).
9
+
10
+ Installation from Conda Forge
11
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+
13
+ The easiest way to install sectionate along with its dependencies is via conda
14
+ forge::
15
+
16
+ conda install -c conda-forge sectionate
17
+
18
+
19
+ Installation from Pip
20
+ ^^^^^^^^^^^^^^^^^^^^^
21
+
22
+ An alternative is to use pip::
23
+
24
+ pip install sectionate
25
+
26
+ This will install the latest release from
27
+ `pypi <https://pypi.python.org/pypi>`_.
28
+
29
+ Installation from GitHub
30
+ ^^^^^^^^^^^^^^^^^^^^^^^^
31
+
32
+ sectionate is under active development. To obtain the latest development version,
33
+ you may clone the `source repository <https://github.com/MOM6-Community/sectionate>`_
34
+ and install it using pip::
35
+
36
+ pip install git+https://github.com/MOM6-Community/sectionate.git
37
+
38
+ More comprehensive instructions for installing a development environment can be found in the Contributor Guide (coming soon).
39
+
40
+ Users are encouraged to `fork <https://help.github.com/articles/fork-a-repo/>`_
41
+ sectionate and submit issues_ and `pull requests`_.
42
+
43
+ .. _issues: https://github.com/MOM6-Community/sectionate/issues
44
+ .. _`pull requests`: https://github.com/MOM6-Community/sectionate/pulls
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "sectionate"
3
+ dynamic = ["version"]
4
+ authors = [
5
+ {name="Raphael Dussin", email="raphael.dussin@gmail.com"},
6
+ {name="Henri F. Drake", email="hfdrake@uci.edu"}
7
+ ]
8
+ description = "A package to sample grid-consistent sections from ocean model outputs"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
14
+ "Operating System :: OS Independent",
15
+ ]
16
+ dependencies = [
17
+ "dask",
18
+ "numba",
19
+ "numpy",
20
+ "scipy",
21
+ "xarray",
22
+ "xgcm == 0.9.*",
23
+ ]
24
+
25
+ [project.urls]
26
+ "Homepage" = "https://github.com/MOM6-community/sectionate"
27
+ "Bugs/Issues/Features" = "https://github.com/MOM6-community/sectionate/issues"
28
+ "Sibling package" = "https://github.com/hdrake/regionate"
29
+
30
+ [build-system]
31
+ requires = ["hatchling", "hatch-vcs"]
32
+ build-backend = "hatchling.build"
33
+
34
+ # The version comes from the git tag, not from a file in the tree. Releasing is
35
+ # then a single act -- tag `vX.Y.Z` and publish the GitHub Release -- with no
36
+ # second commit to remember, and no way for the tag and the built artifact to
37
+ # disagree about which version they are.
38
+ [tool.hatch.version]
39
+ source = "vcs"
40
+
41
+ # Drop the `+g<sha>` local segment. On a clean tag the version is exactly X.Y.Z
42
+ # either way, but an untagged build would otherwise carry a PEP 440 *local*
43
+ # version, which package indexes refuse outright. Untagged builds are
44
+ # `X.Y.Z.devN` instead, which an index will accept.
45
+ [tool.hatch.version.raw-options]
46
+ local_scheme = "no-local-version"
47
+
48
+ # Building writes the resolved version to `sectionate/_version.py`, which is
49
+ # gitignored but *is* included in the sdist -- so `pip install` from the sdist,
50
+ # and conda-forge's build from the PyPI sdist, both work without git present.
51
+ [tool.hatch.build.hooks.vcs]
52
+ version-file = "sectionate/_version.py"
53
+
54
+ [tool.hatch.build]
55
+ exclude = ["examples/**", "data/**"]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.3.4'
22
+ __version_tuple__ = version_tuple = (0, 3, 4)
23
+
24
+ __commit_id__ = commit_id = None
@@ -25,17 +25,21 @@ def get_geo_corners(grid):
25
25
  vorticity coordinates at 'outer' and 'right' positions, respectively.")
26
26
 
27
27
  coords = grid._ds.coords
28
- return {
28
+
29
+ geo_coord_dict = {
29
30
  axis: [
30
31
  coords[c] for c in coords
31
32
  if (
32
- (geoc in c) and
33
+ (geoc in c.lower()) and
33
34
  (dims["X"] in coords[c].dims) and
34
35
  (dims["Y"] in coords[c].dims)
35
36
  )
36
- ][0]
37
+ ]
37
38
  for axis, geoc in zip(["X", "Y"], ["lon", "lat"])
38
39
  }
40
+ if any([len(v) == 0 for (k,v) in geo_coord_dict.items()]):
41
+ raise ValueError("""grid._ds must contain two-dimensional ("X", "Y") coordinates including the strings "lon" and "lat", consistent with grid.coords.""")
42
+ return {k:v[0] for (k,v) in geo_coord_dict.items()}
39
43
 
40
44
  def coord_dict(grid):
41
45
  """
@@ -0,0 +1,42 @@
1
+ import pytest
2
+
3
+ def test_load_section():
4
+ from sectionate.utils import get_all_section_names, load_section
5
+ section_names = get_all_section_names()
6
+ load_section(section_names[0])
7
+
8
+ def test_get_geo_corners():
9
+ import numpy as np
10
+ import xarray as xr
11
+ import xgcm
12
+ coords = {
13
+ "xh": np.arange(0, 10),
14
+ "yh": np.arange(0, 10),
15
+ "xq": np.arange(0, 11),
16
+ "yq": np.arange(0, 11),
17
+ }
18
+
19
+ # Without coordinates
20
+ ds = xr.Dataset(coords=coords)
21
+ grid = xgcm.Grid(
22
+ ds = ds,
23
+ coords={
24
+ "X":{"center":"xh", "outer":"xq"},
25
+ "Y":{"center":"yh", "outer":"yq"}
26
+ },
27
+ boundary={"X":"periodic", "Y":"extend"},
28
+ autoparse_metadata=False
29
+ )
30
+
31
+ from sectionate.gridutils import get_geo_corners
32
+
33
+ # Fail when (lon, lat) coordinates are missing
34
+ with pytest.raises(ValueError):
35
+ get_geo_corners(grid)
36
+
37
+ # Pass when coordinates are there
38
+ grid._ds = grid._ds.assign_coords({
39
+ "lon_c": xr.DataArray(xr.broadcast(grid._ds.xq, grid._ds.yq)[0]),
40
+ "lat_c": xr.DataArray(xr.broadcast(grid._ds.xq, grid._ds.yq)[1])
41
+ })
42
+ get_geo_corners(grid)
@@ -0,0 +1,18 @@
1
+ """sectionate: version information.
2
+
3
+ The version is derived from the git tag at build time by ``hatch-vcs``, which
4
+ writes the resolved value to ``sectionate/_version.py``. That file is generated
5
+ rather than checked in: there is deliberately no version string in the source
6
+ tree that could drift out of step with the tag it is supposed to describe.
7
+
8
+ ``_version.py`` ships in every built artifact -- wheel, sdist, and editable
9
+ install -- so the fallback below only fires when ``sectionate`` is imported
10
+ straight from a source checkout that has never been built or installed.
11
+ """
12
+
13
+ try:
14
+ from sectionate._version import __version__
15
+ except ImportError: # pragma: no cover - un-built source checkout
16
+ __version__ = "0.0.0+unknown"
17
+
18
+ __all__ = ["__version__"]
@@ -1,26 +0,0 @@
1
- name: Publish to PyPI
2
-
3
- on:
4
- release:
5
- types: [published]
6
-
7
- jobs:
8
- build-and-publish:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - uses: actions/checkout@v2
12
- - name: Set up Python
13
- uses: actions/setup-python@v2
14
- with:
15
- python-version: '3.x'
16
- - name: Install dependencies
17
- run: |
18
- python -m pip install --upgrade pip
19
- pip install build twine
20
- - name: Build package
21
- run: python -m build
22
- - name: Publish package
23
- env:
24
- TWINE_USERNAME: __token__
25
- TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
26
- run: twine upload dist/*
sectionate-0.3.3/PKG-INFO DELETED
@@ -1,44 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: sectionate
3
- Version: 0.3.3
4
- Summary: A package to sample grid-consistent sections from ocean model outputs
5
- Project-URL: Homepage, https://github.com/MOM6-community/sectionate
6
- Project-URL: Bugs/Issues/Features, https://github.com/MOM6-community/sectionate/issues
7
- Project-URL: Sibling package, https://github.com/hdrake/regionate
8
- Author-email: Raphael Dussin <raphael.dussin@gmail.com>, "Henri F. Drake" <hfdrake@uci.edu>
9
- License-File: LICENSE
10
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
- Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3
13
- Requires-Python: >=3.11
14
- Requires-Dist: dask
15
- Requires-Dist: numba
16
- Requires-Dist: numpy
17
- Requires-Dist: scipy
18
- Requires-Dist: xarray
19
- Requires-Dist: xgcm>=0.9.0
20
- Description-Content-Type: text/markdown
21
-
22
- # sectionate
23
- A package to sample grid-consistent sections from ocean model outputs
24
-
25
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/raphaeldussin/sectionate/master)
26
-
27
- Quick Start Guide
28
- -----------------
29
-
30
- **For users: minimal installation within an existing environment**
31
- ```bash
32
- pip install sectionate
33
- ```
34
-
35
- **For developers: installing dependencies from scratch using `conda`**
36
- ```bash
37
- git clone https://github.com/MOM6-community/sectionate.git
38
- cd sectionate
39
- conda env create -f docs/environment.yml
40
- conda activate docs_env_sectionate
41
- pip install -e .
42
- python -m ipykernel install --user --name docs_env_sectionate --display-name "docs_env_sectionate"
43
- jupyter-lab
44
- ```
@@ -1,23 +0,0 @@
1
- # sectionate
2
- A package to sample grid-consistent sections from ocean model outputs
3
-
4
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/raphaeldussin/sectionate/master)
5
-
6
- Quick Start Guide
7
- -----------------
8
-
9
- **For users: minimal installation within an existing environment**
10
- ```bash
11
- pip install sectionate
12
- ```
13
-
14
- **For developers: installing dependencies from scratch using `conda`**
15
- ```bash
16
- git clone https://github.com/MOM6-community/sectionate.git
17
- cd sectionate
18
- conda env create -f docs/environment.yml
19
- conda activate docs_env_sectionate
20
- pip install -e .
21
- python -m ipykernel install --user --name docs_env_sectionate --display-name "docs_env_sectionate"
22
- jupyter-lab
23
- ```
@@ -1,38 +0,0 @@
1
- [project]
2
- name = "sectionate"
3
- dynamic = ["version"]
4
- authors = [
5
- {name="Raphael Dussin", email="raphael.dussin@gmail.com"},
6
- {name="Henri F. Drake", email="hfdrake@uci.edu"}
7
- ]
8
- description = "A package to sample grid-consistent sections from ocean model outputs"
9
- readme = "README.md"
10
- requires-python = ">=3.11"
11
- classifiers = [
12
- "Programming Language :: Python :: 3",
13
- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
14
- "Operating System :: OS Independent",
15
- ]
16
- dependencies = [
17
- "dask",
18
- "numba",
19
- "numpy",
20
- "scipy",
21
- "xarray",
22
- "xgcm >= 0.9.0",
23
- ]
24
-
25
- [project.urls]
26
- "Homepage" = "https://github.com/MOM6-community/sectionate"
27
- "Bugs/Issues/Features" = "https://github.com/MOM6-community/sectionate/issues"
28
- "Sibling package" = "https://github.com/hdrake/regionate"
29
-
30
- [build-system]
31
- requires = ["hatchling"]
32
- build-backend = "hatchling.build"
33
-
34
- [tool.hatch.version]
35
- path = "sectionate/version.py"
36
-
37
- [tool.hatch.build]
38
- exclude = ["examples/**", "data/**"]
@@ -1,4 +0,0 @@
1
- def test_load_section():
2
- from sectionate.utils import get_all_section_names, load_section
3
- section_names = get_all_section_names()
4
- load_section(section_names[0])
@@ -1,3 +0,0 @@
1
- """sectionate: version information"""
2
-
3
- __version__ = "0.3.3"
File without changes