Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up pixi environment
uses: prefix-dev/setup-pixi@v0.9.1
uses: prefix-dev/setup-pixi@v0.9.6
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ contributors:
affiliation: University of Washington, Applied Physics Laboratory

contact:
- family-names: Sutterley
given-names: Tyler C.
orcid: "https://orcid.org/0000-0002-6964-1194"
- family-names: Sutterley
given-names: Tyler C.
orcid: "https://orcid.org/0000-0002-6964-1194"

identifiers:
- type: doi
Expand Down
21 changes: 12 additions & 9 deletions IS2view/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
api.py
Written by Tyler Sutterley (02/2026)
Written by Tyler Sutterley (06/2026)
Plotting tools for visualizing rioxarray variables on leaflet maps

PYTHON DEPENDENCIES:
Expand All @@ -28,6 +28,7 @@
https://xyzservices.readthedocs.io/en/stable/

UPDATE HISTORY:
Updated 06/2026: verify that area is conserved between calls if using option
Updated 02/2026: add conserve and all_touched options to extract function
Updated 01/2025: added more zoom levels and update max_zoom
deprecation update for writing the crs to the dataset object
Expand Down Expand Up @@ -1919,16 +1920,18 @@ def average(
clipped = self._ds_selected.sel(time=t).where(mask, drop=False)
# reduce cell area to time (for Release-02 and above)
if (ice_area.ndim == 3) and ("time" in ice_area.dims):
area = ice_area.sel(time=t)
area = ice_area.sel(time=t).where(mask, drop=False)
else:
area = ice_area.copy()
area = ice_area.where(mask, drop=False)
# multiply area by clipped mask
area *= np.isfinite(clipped).astype(float)
# calculate regional average
if self._variable in error_variables:
self._data[i] = np.sqrt(
np.sum(area * clipped**2) / np.sum(area)
np.nansum(area * clipped**2) / np.nansum(area)
)
else:
self._data[i] = np.sum(area * clipped) / np.sum(area)
self._data[i] = np.nansum(area * clipped) / np.nansum(area)
# output additional fields
for field_name in fields:
# reduce data to time and clip to geometry
Expand All @@ -1937,14 +1940,14 @@ def average(
)
if field_name in error_variables:
self._fields[field_name][i] = np.sqrt(
np.sum(area * clipped**2) / np.sum(area)
np.nansum(area * clipped**2) / np.nansum(area)
)
else:
self._fields[field_name][i] = np.sum(
self._fields[field_name][i] = np.nansum(
area * clipped
) / np.sum(area)
) / np.nansum(area)
# calculate total area for region
self._area[i] = np.sum(area)
self._area[i] = np.nansum(area)
# only create plot if valid
if np.all(np.isnan(self._data)):
return
Expand Down
12 changes: 12 additions & 0 deletions doc/source/api_reference/API-Reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=============
API Reference
=============

.. toctree::
:maxdepth: 1

./api.rst
./convert.rst
./io.rst
./tools.rst
./utilities.rst
6 changes: 3 additions & 3 deletions doc/source/api_reference/api.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===
api
===
=======
``api``
=======

Plotting tools for visualizing `rioxarray <https://corteva.github.io/rioxarray/stable/>`_ variables on `ipyleaflet <https://ipyleaflet.readthedocs.io/en/latest/>`_ maps

Expand Down
6 changes: 3 additions & 3 deletions doc/source/api_reference/convert.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=======
convert
=======
===========
``convert``
===========

Utilities for converting gridded ICESat-2 files from native netCDF4

Expand Down
6 changes: 3 additions & 3 deletions doc/source/api_reference/io.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
==
io
==
======
``io``
======

Utilities for reading gridded ICESat-2 files using rasterio and xarray

Expand Down
6 changes: 3 additions & 3 deletions doc/source/api_reference/tools.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=====
tools
=====
=========
``tools``
=========

`User interface <https://ipywidgets.readthedocs.io/en/latest/>`_ tools for `Jupyter notebook <https://jupyter.org/>`_

Expand Down
6 changes: 3 additions & 3 deletions doc/source/api_reference/utilities.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=========
utilities
=========
=============
``utilities``
=============

Download and management utilities

Expand Down
42 changes: 36 additions & 6 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
import os

# import sys
import logging
import datetime
import warnings

# sys.path.insert(0, os.path.abspath('.'))
import importlib.metadata


# -- Project information -----------------------------------------------------
on_rtd = os.environ.get('READTHEDOCS') == 'True'
on_github = os.environ.get('GITHUB_ACTIONS') == 'true'

# package metadata
metadata = importlib.metadata.metadata("IS2view")
Expand All @@ -32,6 +38,10 @@
# append "v" before the version
release = f"v{version}"

# suppress warnings in examples and documentation
if on_rtd:
warnings.filterwarnings('ignore')

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand All @@ -52,7 +62,21 @@
".rst": "restructuredtext",
".ipynb": "myst-nb",
}
nb_execution_mode = "off"
# execute notebooks on build
if on_rtd:
nb_execution_mode = 'auto'
nb_execution_excludepatterns = [
'notebooks/*.ipynb',
]
nb_output_stderr = 'remove-warn'
elif on_github:
nb_execution_mode = 'off'
else:
nb_execution_mode = 'auto'
nb_execution_excludepatterns = [
'notebooks/*.ipynb',
]
nb_output_stderr = 'remove-warn'

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -101,21 +125,27 @@
name, _, url = project_url.partition(', ')
project_urls[name.lower()] = url
# fetch the repository url
repository_url = project_urls.get('repository')
github_url = project_urls.get("repository")
*_, github_user, github_repo = github_url.split("/")
# add html context
html_context = {
"display_github": True,
"github_user": github_user,
"github_repo": github_repo,
"github_version": "main",
"conf_py_path": "/doc/source/",
"menu_links": [
(
'<i class="fa fa-github fa-fw"></i> Source Code',
repository_url,
github_url,
),
(
'<i class="fa fa-book fa-fw"></i> License',
f"{repository_url}/blob/main/LICENSE",
f"{github_url}/blob/main/LICENSE",
),
(
'<i class="fa fa-comment fa-fw"></i> Discussions',
f"{repository_url}/discussions",
f"{github_url}/discussions",
),
],
}
Expand Down
164 changes: 164 additions & 0 deletions doc/source/getting_started/Install.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "2e01086c",
"metadata": {},
"source": [
"# Setup and Installation\n",
"\n",
"## Dependencies\n",
"\n",
"`IS2view` is dependent on several open source programs that can be installed using OS-specific package management systems (e.g. `apt` or `homebrew`), `conda` or from source:\n",
"\n",
"- [PROJ](https://proj.org/)\n",
"- [HDF5](https://www.hdfgroup.org/)\n",
"- [libxml2](http://xmlsoft.org/)\n",
"- [libxslt](http://xmlsoft.org/XSLT/)\n",
"\n",
"## Installation\n",
"\n",
"`IS2view` is available for download from the [GitHub repository](https://github.com/tsutterley/IS2view), the [Python Package Index (pypi)](https://pypi.org/project/IS2view/), and from [conda-forge](https://anaconda.org/conda-forge/IS2view).\n",
"\n",
"\n",
"The simplest installation for most users will likely be using `conda` or `mamba`:\n",
"\n",
"```bash\n",
"conda install -c conda-forge is2view\n",
"```\n",
"\n",
"`conda` installed versions of `IS2view` can be upgraded to the latest stable release:\n",
"\n",
"```bash\n",
"conda update is2view\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "af65ece3",
"metadata": {},
"source": [
"## Development Install\n",
"\n",
"To use the development repository, please fork `IS2view` into your own account and then clone onto your system:\n",
"\n",
"```bash\n",
"git clone https://github.com/tsutterley/IS2view.git\n",
"```\n",
"\n",
"`IS2view` can then be installed within the package directory using `pip`:\n",
"\n",
"```bash\n",
"python3 -m pip install --user .\n",
"```\n",
"\n",
"To include all optional dependencies:\n",
"\n",
"```bash\n",
"python3 -m pip install --user .[all]\n",
"```\n",
"\n",
"The development version of `IS2view` can also be installed directly from GitHub using `pip`:\n",
"\n",
"```bash\n",
"python3 -m pip install --user git+https://github.com/tsutterley/IS2view.git\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "14ae498c",
"metadata": {},
"source": [
"## Package Management with ``pixi``\n",
"\n",
"Alternatively `pixi` can be used to create a [streamlined environment](https://pixi.sh/) after cloning the repository:\n",
"\n",
"```bash\n",
"pixi install\n",
"```\n",
"\n",
"`pixi` maintains isolated environments for each project, allowing for different versions of `IS2view` and its dependencies to be used without conflict.\n",
"The `pixi.lock` file within the repository defines the required packages and versions for the environment.\n",
"\n",
"`pixi` can also create shells for running programs within the environment:\n",
"\n",
"```bash\n",
"pixi shell\n",
"```\n",
"\n",
"To see the available tasks within the `IS2view` workspace:\n",
"\n",
"```bash\n",
"pixi task list\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "15f4d37e",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": [
"! pixi task list"
]
},
{
"cell_type": "markdown",
"id": "158990b9",
"metadata": {},
"source": [
"```{note}\n",
"`pixi` is under active development and may change in future releases\n",
"```\n"
]
},
{
"cell_type": "markdown",
"id": "286e9898",
"metadata": {},
"source": [
"## Verifying Installation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dbeee9a1",
"metadata": {},
"outputs": [],
"source": [
"import IS2view\n",
"\n",
"print(f\"IS2view version: {IS2view.__version__}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading