Skip to content

Commit

Permalink
Merge branch 'main' into feat_to_odc_geobox
Browse files Browse the repository at this point in the history
  • Loading branch information
BENR0 committed Dec 11, 2023
2 parents 09c35fd + e82bf47 commit e560f1c
Show file tree
Hide file tree
Showing 82 changed files with 1,400 additions and 1,000 deletions.
3 changes: 3 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[bandit]
skips: B506
exclude: pyresample/test,pyresample/version.py,versioneer.py
36 changes: 0 additions & 36 deletions .bumpversion.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```
#### Problem description

[this should also explain **why** the current behaviour is a problem and why the
[this should also explain **why** the current behaviour is a problem and why the
expected output is a better solution.]

#### Expected Output
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
fail-fast: true
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.11", "3.12"]
experimental: [false]
include:
- python-version: "3.11"
- python-version: "3.12"
os: "ubuntu-latest"
experimental: true

Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
Expand Down Expand Up @@ -101,4 +101,3 @@ jobs:
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true

6 changes: 3 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.1
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *i686 *-musllinux* cp312-*"
CIBW_ARCHS: "${{ matrix.cibw_archs }}"
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
path: dist
- name: Publish package to PyPI
if: github.event.action != 'published'
uses: pypa/gh-action-pypi-publish@v1.8.10
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
Expand All @@ -115,7 +115,7 @@ jobs:
path: dist
- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.8.10
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
39 changes: 33 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
exclude: '^$'
fail_fast: false
repos:
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-debugger, flake8-bugbear]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.6'
hooks:
- id: ruff
# once https://github.com/astral-sh/ruff/issues/2402 is fully resolved then we can get rid of flake8:
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- repo: https://github.com/PyCQA/bandit
rev: '1.7.5' # Update me!
hooks:
- id: bandit
args: [--ini, .bandit]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.7.1' # Use the sha / tag you want to point at
hooks:
- id: mypy
additional_dependencies:
- types-docutils
- types-pkg-resources
- types-PyYAML
- types-requests
- type_extensions
args: ["--python-version", "3.9", "--ignore-missing-imports"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
Expand All @@ -14,4 +41,4 @@ repos:
ci:
# To trigger manually, comment on a pull request with "pre-commit.ci autofix"
autofix_prs: false

skip: [bandit]
2 changes: 1 addition & 1 deletion CITATION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
To find out how to reference pyresample, go to https://doi.org/10.5281/zenodo.3372769 and choose your favourite citation format on the bottom of the right hand side-bar.
To find out how to reference pyresample, go to https://doi.org/10.5281/zenodo.3372769 and choose your favourite citation format on the bottom of the right hand side-bar.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ recursive-include docs/source *
include pyresample/test/test_files/*
include LICENSE.txt
include pyresample/ewa/_fornav_templates.*
include pyresample/py.typed
include versioneer.py
include pyresample/version.py
include README.md
recursive-include pyresample *.pyx
recursive-include pyresample *.pyx
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pyresample offers multiple resampling algorithms including:
- Bilinear

For nearest neighbor and bilinear interpolation pyresample uses a kd-tree
approach by using the fast KDTree implementation provided by the
approach by using the fast KDTree implementation provided by the
[pykdtree](https://github.com/storpipfugl/pykdtree) library.
Pyresample works with numpy arrays and numpy masked arrays. Interfaces to
XArray objects (including dask array support) are provided in separate
Expand All @@ -38,4 +38,3 @@ PyTroll group and related packages.
Citation
----------
Hoese, D., Raspaud, M., Lahtinen, P., Roberts, W., Lavergne, et al. (2020). pytroll/pyresample: Version 1.16.0. Zenodo. [https://doi.org/10.5281/zenodo.3372769](https://doi.org/10.5281/zenodo.3372769)

3 changes: 0 additions & 3 deletions changelog_pre1.9.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,3 @@ Other
- No commit message. [StorPipfugl]
- Moved to Google Code under GPLv3 license. [StorPipfugl]
- moved to Google Code. [StorPipfugl]



2 changes: 0 additions & 2 deletions continuous_integration/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ dependencies:
- pillow
- platformdirs
- pyyaml
# 9.3.1 includes bug fix
- proj !=9.3.0
- pyproj
- pykdtree
- rasterio
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Pyresample's API has changed (new functions, modules, classes, etc) then the
API documentation should be regenerated before running the above make
command.

sphinx-apidoc -f -T -o source/api ../pyresample ../pyresample/test
sphinx-apidoc -f -T -o source/api ../pyresample ../pyresample/test
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
"""Sphinx documentation configuration."""
from __future__ import annotations

import os
import sys
Expand Down Expand Up @@ -111,7 +112,7 @@

# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = []
exclude_trees: list[str] = []

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dev_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ The documentation is split into 4 main groups:
Put another way, the user knows what they want to do, the how-to shows them
how to do it. How-tos should still not go into any more detail than
necessary and try to depend on :doc:`../concepts/index`.
4. Reference: API docs and other low-level information.
4. Reference: API docs and other low-level information.
61 changes: 61 additions & 0 deletions docs/source/howtos/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,67 @@ Or for specific blocks of code:
Similarly, if you need to access one of the values you can
use the ``pyresample.config.get`` method.
Cache Directory
^^^^^^^^^^^^^^^
* **Environment variable**: ``PYRESAMPLE_CACHE_DIR``
* **YAML/Config Key**: ``cache_dir``
* **Default**: See below
Directory where any files cached by Pyresample will be stored. This
directory is not necessarily cleared out by Pyresample, but is rarely used
without explicitly being enabled by the user. This
defaults to a different path depending on your operating system following
the `platformdirs <https://github.com/platformdirs/platformdirs#example-output>`_
"user cache dir".
.. note::
Some resampling algorithms provide caching functionality when the user
provides a directory to cache to. These resamplers do not currently use this
configuration option.
.. _config_cache_sensor_angles_setting:
Cache Geometry Slices
^^^^^^^^^^^^^^^^^^^^^
* **Environment variable**: ``PYRESAMPLE_CACHE_GEOMETRY_SLICES``
* **YAML/Config Key**: ``cache_geometry_slices``
* **Default**: ``False``
Whether or not generated slices for geometry objects are cached to disk.
These slices are used in various parts of Pyresample like
cropping or overlap calculations including those performed in some resampling
algorithms. At the time of writing this is only performed on
``AreaDefinition`` objects through their
:meth:`~pyresample.geometry.AreaDefinition.get_area_slices` method.
Slices are stored in ``cache_dir`` (see above).
Unlike other caching performed in Pyresample where potentially large arrays
are cached, this option saves a pair of ``slice`` objects that consist of
only 3 integers each. This makes the amount of space used in the cache very
small for many cached results.
The slicing operations in Pyresample typically involve finding the intersection
between two geometries. This requires generating bounding polygons for the
geometries and doing polygon intersection calculations that can handle
projection anti-meridians. At the time of writing these calculations can take
as long as 15 seconds depending on number of vertices used in the bounding
polygons. One use case for these slices is reducing input data to only the
overlap of the target area. This can be done before or during resampling as
part of the algorithm or as part of a third-party resampling interface
(ex. Satpy). In the future as optimizations are made to the polygon
intersection logic this caching option should hopefully not be needed.
When setting this as an environment variable, this should be set with the
string equivalent of the Python boolean values ``="True"`` or ``="False"``.
.. warning::
This caching does not limit the number of entries nor does it expire old
entries. It is up to the user to manage the contents of the cache
directory.
Feature Flags
-------------
Expand Down
23 changes: 11 additions & 12 deletions docs/source/howtos/data_reduce.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Reduction of swath data
=======================
Given a swath and a cartesian grid or grid lons and lats, pyresample can reduce the swath data
to only the relevant part covering the grid area. The reduction is coarse in order not to risk removing
to only the relevant part covering the grid area. The reduction is coarse in order not to risk removing
relevant data.

From **data_reduce** the function **swath_from_lonlat_grid** can be used to reduce the swath data set to the
From **data_reduce** the function **swath_from_lonlat_grid** can be used to reduce the swath data set to the
area covering the lon lat grid

.. doctest::
Expand All @@ -14,7 +14,7 @@ area covering the lon lat grid
>>> area_def = geometry.AreaDefinition('areaD', 'Europe (3km, HRV, VTC)', 'areaD',
... {'a': '6378144.0', 'b': '6356759.0',
... 'lat_0': '50.00', 'lat_ts': '50.00',
... 'lon_0': '8.00', 'proj': 'stere'},
... 'lon_0': '8.00', 'proj': 'stere'},
... 800, 800,
... [-1370912.72, -909968.64,
... 1029087.28, 1490031.36])
Expand All @@ -23,32 +23,31 @@ area covering the lon lat grid
>>> lats = np.fromfunction(lambda y, x: 75 - y, (50, 10))
>>> grid_lons, grid_lats = area_def.get_lonlats()
>>> reduced_lons, reduced_lats, reduced_data = \
... data_reduce.swath_from_lonlat_grid(grid_lons, grid_lats,
... lons, lats, data,
... data_reduce.swath_from_lonlat_grid(grid_lons, grid_lats,
... lons, lats, data,
... radius_of_influence=3000)

**radius_of_influence** is used to calculate a buffer zone around the grid where swath data points
are not reduced.

The function **get_valid_index_from_lonlat_grid** returns a boolean array of same size as the swath
indicating the relevant swath data points compared to the grid

.. doctest::

>>> import numpy as np
>>> from pyresample import geometry, data_reduce
>>> area_def = geometry.AreaDefinition('areaD', 'Europe (3km, HRV, VTC)', 'areaD',
... {'a': '6378144.0', 'b': '6356759.0',
... 'lat_0': '50.00', 'lat_ts': '50.00',
... 'lon_0': '8.00', 'proj': 'stere'},
... 'lon_0': '8.00', 'proj': 'stere'},
... 800, 800,
... [-1370912.72, -909968.64,
... 1029087.28, 1490031.36])
>>> data = np.fromfunction(lambda y, x: y*x, (50, 10))
>>> lons = np.fromfunction(lambda y, x: 3 + x, (50, 10))
>>> lats = np.fromfunction(lambda y, x: 75 - y, (50, 10))
>>> grid_lons, grid_lats = area_def.get_lonlats()
>>> valid_index = data_reduce.get_valid_index_from_lonlat_grid(grid_lons, grid_lats,
... lons, lats,
>>> valid_index = data_reduce.get_valid_index_from_lonlat_grid(grid_lons, grid_lats,
... lons, lats,
... radius_of_influence=3000)

1 change: 0 additions & 1 deletion docs/source/howtos/geo_def.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,3 @@ using the **projection_x_coord** or **projection_y_coords** property of a geogra
>>> area_def = AreaDefinition(area_id, description, proj_id, projection,
... width, height, area_extent)
>>> proj_x_range = area_def.projection_x_coords

8 changes: 4 additions & 4 deletions docs/source/howtos/geo_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ a full globe Plate Carrée projection using an 8x8 filter mask
>>> import numpy as np
>>> from pyresample import geometry, geo_filter
>>> lons = np.array([-170, -30, 30, 170])
>>> lats = np.array([20, -40, 50, -80])
>>> lats = np.array([20, -40, 50, -80])
>>> swath_def = geometry.SwathDefinition(lons, lats)
>>> data = np.array([1, 2, 3, 4])
>>> filter_area = geometry.AreaDefinition('test', 'test', 'test',
>>> filter_area = geometry.AreaDefinition('test', 'test', 'test',
... {'proj' : 'eqc', 'lon_0' : 0.0, 'lat_0' : 0.0},
... 8, 8,
... 8, 8,
... (-20037508.34, -10018754.17, 20037508.34, 10018754.17)
... )
>>> filter = np.array([[1, 1, 1, 1, 0, 0, 0, 0],
Expand All @@ -38,4 +38,4 @@ a full globe Plate Carrée projection using an 8x8 filter mask
Input swath_def and data must match as described in :ref:`swath`.

The returned data will always have a 1D geometry_def and if multiple channels are present the filtered
data will have the shape (number_of_points, channels).
data will have the shape (number_of_points, channels).
Loading

0 comments on commit e560f1c

Please sign in to comment.