Metadata-Version: 2.4
Name: gval
Version: 0.2.12
Summary: Flexible, portable, and efficient geospatial evaluations for a variety of data.
Author-email: Fernando Aristizabal <fernando.aristizabal@noaa.gov>, Gregory Petrochenkov <gregory.petrochenkov@noaa.gov>
License: MIT
Project-URL: Repository, https://github.com/NOAA-OWP/gval
Project-URL: Homepage, https://noaa-owp.github.io/gval/
Keywords: geospatial,evaluations
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.MD
Requires-Dist: rioxarray>=0.13.4
Requires-Dist: dask>=2026.1.1
Requires-Dist: dask[dataframe]>=2026.1.1
Requires-Dist: pandera==0.29.0
Requires-Dist: shapely==2.1.2
Requires-Dist: geocube>=0.7.1
Requires-Dist: pandas==2.3.3
Requires-Dist: odc-geo==0.5.0
Requires-Dist: pydantic>=1.10.13
Requires-Dist: rio-cogeo==6.0.0
Requires-Dist: matplotlib==3.10.8
Requires-Dist: contextily==1.7.0
Requires-Dist: flox==0.10.4
Requires-Dist: xskillscore==0.0.28
Requires-Dist: pyogrio<=0.11.0,>=0.7.2
Requires-Dist: pystac-client==0.8.6
Requires-Dist: s3fs<=2025.5.0
Requires-Dist: numba==0.61.2
Requires-Dist: pyarrow==23.0.0
Provides-Extra: dev
Requires-Dist: flake8==6.0.0; extra == "dev"
Requires-Dist: flake8-black==0.3.6; extra == "dev"
Requires-Dist: pytest==7.2.2; extra == "dev"
Requires-Dist: pytest-benchmark==4.0.0; extra == "dev"
Requires-Dist: pytest-cov==4.1.0; extra == "dev"
Requires-Dist: pytest-cases==3.6.14; extra == "dev"
Requires-Dist: allure-pytest==2.13.2; extra == "dev"
Requires-Dist: pytest-memray==1.7.0; extra == "dev"
Requires-Dist: pytest-monitor==1.6.6; extra == "dev"
Requires-Dist: boto3==1.26.164; extra == "dev"
Requires-Dist: sqlalchemy==2.0.17; extra == "dev"
Requires-Dist: colorama==0.4.6; extra == "dev"
Requires-Dist: deepdiff==6.7.1; extra == "dev"
Requires-Dist: sphinx==6.2.1; extra == "dev"
Requires-Dist: sphinx-rtd-theme==1.2.2; extra == "dev"
Requires-Dist: myst_parser==2.0.0; extra == "dev"
Requires-Dist: nbsphinx==0.9.2; extra == "dev"
Requires-Dist: pypandoc==1.12; extra == "dev"
Requires-Dist: jupyter==1.0.0; extra == "dev"
Requires-Dist: nox==2023.04.22; extra == "dev"
Requires-Dist: pre-commit==3.3.3; extra == "dev"
Requires-Dist: build==0.10.0; extra == "dev"
Requires-Dist: twine==3.4.2; extra == "dev"
Provides-Extra: linting
Requires-Dist: flake8==6.0.0; extra == "linting"
Requires-Dist: flake8-black==0.3.6; extra == "linting"
Provides-Extra: testing
Requires-Dist: pytest==7.2.2; extra == "testing"
Requires-Dist: pytest-benchmark==4.0.0; extra == "testing"
Requires-Dist: pytest-cov==4.1.0; extra == "testing"
Requires-Dist: pytest-cases==3.6.14; extra == "testing"
Requires-Dist: allure-pytest==2.13.2; extra == "testing"
Requires-Dist: pytest-memray==1.4.1; extra == "testing"
Requires-Dist: pytest-monitor==1.6.6; extra == "testing"
Requires-Dist: boto3==1.26.164; extra == "testing"
Requires-Dist: sqlalchemy==2.0.17; extra == "testing"
Requires-Dist: colorama==0.4.6; extra == "testing"
Requires-Dist: deepdiff==6.7.1; extra == "testing"
Provides-Extra: docs
Requires-Dist: sphinx==6.2.1; extra == "docs"
Requires-Dist: sphinx-rtd-theme==1.2.2; extra == "docs"
Requires-Dist: myst_parser==2.0.0; extra == "docs"
Requires-Dist: nbsphinx==0.9.2; extra == "docs"
Requires-Dist: pypandoc==1.12; extra == "docs"
Requires-Dist: jupyter==1.0.0; extra == "docs"
Provides-Extra: ci-cd-automation
Requires-Dist: nox==2023.04.22; extra == "ci-cd-automation"
Requires-Dist: pre-commit==3.3.3; extra == "ci-cd-automation"
Provides-Extra: other
Requires-Dist: build==0.10.0; extra == "other"
Requires-Dist: twine==3.4.2; extra == "other"
Dynamic: license-file

 ![alt
text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/gval_light_mode.png#gh-light-mode-only)

![Build and
Test](https://github.com/NOAA-OWP/gval/actions/workflows/python-app.yml/badge.svg)![Coverage](https://github.com/NOAA-OWP/gval/raw/testing/docs/images/coverage.svg)[![PyPI
version](https://badge.fury.io/py/gval.svg)](https://badge.fury.io/py/gval)

GVAL (pronounced "g-val") is a high-level Python framework to evaluate
the skill of geospatial datasets by comparing candidates to benchmark
maps producing agreement maps and metrics.

GVAL is intended to work on raster and vector files as xarray and
geopandas objects, respectively. Abilities to prepare or homogenize maps
for comparison are included. The comparisons are based on scoring
philosophies for three statistical data types including categorical,
continuous, and probabilistic.

See the full [documentation](https://noaa-owp.github.io/gval/).

WARNING:

- Our current public API and output formats are likely to change in the
  future.
- Software is provided "AS-IS" without any guarantees. Please QA/QC your
  metrics carefully until this project matures.

# Installation

## General Use

To use this package:

`pip install gval`

Or for bleeding edge updates install from the repository:

`pip install 'git+https://github.com/NOAA-OWP/gval'`

# Using GVAL

### Categorical Example

An example of running the entire process for two-class categorical
rasters with one function using minimal arguments is demonstrated below:

``` python
import gval
import rioxarray as rxr

candidate = rxr.open_rasterio('candidate_map_two_class_categorical.tif', mask_and_scale=True)
benchmark = rxr.open_rasterio('benchmark_map_two_class_categorical.tif', mask_and_scale=True)

(agreement_map,
 crosstab_table,
 metric_table) = candidate.gval.categorical_compare(benchmark,
                                                   positive_categories=[2],
                                                   negative_categories=[0, 1])
```

#### Categorical Outputs

`agreement_map`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/agreement_map.png)

`crosstab_table`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/cross_table.png)

`metric_table`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/metric_table.png)

### Continuous Example

The same can be done for rasters with continuous valued statistical data
types as shown below (in this case only a subset of the default
statistics will be run):

``` python
import gval
import rioxarray as rxr

candidate = rxr.open_rasterio('livneh_2011_precip.tif', mask_and_scale=True) # VIC
benchmark = rxr.open_rasterio('prism_2011_precip.tif', mask_and_scale=True) # PRISM

agreement, metric_table = candidate.gval.continuous_compare(
    benchmark,
    metrics=[
        "coefficient_of_determination",
        "mean_percentage_error",
        "mean_absolute_percentage_error",
        "mean_normalized_mean_absolute_error"
    ]
)
```

#### Continuous Outputs

`agreement_map`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/continuous_agreement_map.png)

`metric_table`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/continuous_metric_table.png)

### Catalog Example

Entire catalogs can be compared in GVAL, which are represented by
dataframes of maps. The following is a candidate and benchmark catalog
for continuous datasets:

`candidate_catalog`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/candidate_catalog.png)

`benchmark_catalog`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/benchmark_catalog.png)

With the following code a comparison of each pair of maps can be run
with the following code. Since the parameter `agreement_map_field` is
provided the column `agreement_maps` found in the candidate catalog will
be used to export the agreement map to that location. (Note the first
pair of candidate and benchmark maps are single band rasters while the
second pair are multiband rasters):

``` python
import pandas as pd

from gval.catalogs.catalogs import catalog_compare

candidate_continuous_catalog = pd.read_csv('candidate_catalog_0.csv')
benchmark_continuous_catalog = pd.read_csv('benchmark_catalog_0.csv')

arguments = {
    "candidate_catalog": candidate_continuous_catalog,
    "benchmark_catalog": benchmark_continuous_catalog,
    "on": "compare_id",
    "agreement_map_field": "agreement_maps",
    "map_ids": "map_id",
    "how": "inner",
    "compare_type": "continuous",
    "compare_kwargs": {
        "metrics": (
            "coefficient_of_determination",
            "mean_absolute_error",
            "mean_absolute_percentage_error",
        ),
        "encode_nodata": True,
        "nodata": -9999,
    },
    "open_kwargs": {
        "mask_and_scale": True,
        "masked": True
    }
}

agreement_continuous_catalog = catalog_compare(**arguments)
```

#### Catalog Outputs

`agreement_map`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_agreement_map.png) ![alt
text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_agreement_map2.png)

`catalog_metrics`

![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_metric_table.png)

(Note that both catalog level attributes in the candidate and benchmark
catalogs are present in the catalog metrics table.)

For more detailed examples of how to use this software, check out these
[notebook
tutorials](https://github.com/NOAA-OWP/gval/blob/main/notebooks).

# Contributing

Guidelines for contributing to this repository can be found at
[CONTRIBUTING](https://github.com/NOAA-OWP/gval/blob/main/CONTRIBUTING.MD).

# Citation

Please cite our work if using this package. See 'cite this repository'
in the about section on [GitHub](https://github.com/NOAA-OWP/gval/) or
refer to
[CITATION.cff](https://github.com/NOAA-OWP/gval/blob/main/CITATION.cff)
