gval


Namegval JSON
Version 0.2.5 PyPI version JSON
download
home_page
SummaryFlexible, portable, and efficient geospatial evaluations for a variety of data.
upload_time2024-01-02 18:39:19
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords geospatial evaluations
VCS
bugtrack_url
requirements rioxarray dask xarray-spatial pandera shapely geocube pandas odc-geo pydantic rio-cogeo matplotlib contextily flox xskillscore pyogrio pystac-client stackstac
Travis-CI No Travis.
coveralls test coverage
             ![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)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "gval",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "geospatial,evaluations",
    "author": "",
    "author_email": "Fernando Aristizabal <fernando.aristizabal@noaa.gov>, Gregory Petrochenkov <gregory.petrochenkov@noaa.gov>",
    "download_url": "https://files.pythonhosted.org/packages/cd/7d/f59b933f04d7f61aee03442f3f74d939204e009de611deda70151f0ecb4b/gval-0.2.5.tar.gz",
    "platform": null,
    "description": " ![alt\ntext](https://github.com/NOAA-OWP/gval/raw/main/docs/images/gval_light_mode.png#gh-light-mode-only)\n\n![Build and\nTest](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\nversion](https://badge.fury.io/py/gval.svg)](https://badge.fury.io/py/gval)\n\nGVAL (pronounced \"g-val\") is a high-level Python framework to evaluate\nthe skill of geospatial datasets by comparing candidates to benchmark\nmaps producing agreement maps and metrics.\n\nGVAL is intended to work on raster and vector files as xarray and\ngeopandas objects, respectively. Abilities to prepare or homogenize maps\nfor comparison are included. The comparisons are based on scoring\nphilosophies for three statistical data types including categorical,\ncontinuous, and probabilistic.\n\nSee the full [documentation](https://noaa-owp.github.io/gval/).\n\nWARNING:\n\n- Our current public API and output formats are likely to change in the\n  future.\n- Software is provided \"AS-IS\" without any guarantees. Please QA/QC your\n  metrics carefully until this project matures.\n\n# Installation\n\n## General Use\n\nTo use this package:\n\n`pip install gval`\n\nOr for bleeding edge updates install from the repository:\n\n`pip install 'git+https://github.com/NOAA-OWP/gval'`\n\n# Using GVAL\n\n### Categorical Example\n\nAn example of running the entire process for two-class categorical\nrasters with one function using minimal arguments is demonstrated below:\n\n``` python\nimport gval\nimport rioxarray as rxr\n\ncandidate = rxr.open_rasterio('candidate_map_two_class_categorical.tif', mask_and_scale=True)\nbenchmark = rxr.open_rasterio('benchmark_map_two_class_categorical.tif', mask_and_scale=True)\n\n(agreement_map,\n crosstab_table,\n metric_table) = candidate.gval.categorical_compare(benchmark,\n                                                   positive_categories=[2],\n                                                   negative_categories=[0, 1])\n```\n\n#### Categorical Outputs\n\n`agreement_map`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/agreement_map.png)\n\n`crosstab_table`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/cross_table.png)\n\n`metric_table`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/metric_table.png)\n\n### Continuous Example\n\nThe same can be done for rasters with continuous valued statistical data\ntypes as shown below (in this case only a subset of the default\nstatistics will be run):\n\n``` python\nimport gval\nimport rioxarray as rxr\n\ncandidate = rxr.open_rasterio('livneh_2011_precip.tif', mask_and_scale=True) # VIC\nbenchmark = rxr.open_rasterio('prism_2011_precip.tif', mask_and_scale=True) # PRISM\n\nagreement, metric_table = candidate.gval.continuous_compare(\n    benchmark,\n    metrics=[\n        \"coefficient_of_determination\",\n        \"mean_percentage_error\",\n        \"mean_absolute_percentage_error\",\n        \"mean_normalized_mean_absolute_error\"\n    ]\n)\n```\n\n#### Continuous Outputs\n\n`agreement_map`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/continuous_agreement_map.png)\n\n`metric_table`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/continuous_metric_table.png)\n\n### Catalog Example\n\nEntire catalogs can be compared in GVAL, which are represented by\ndataframes of maps. The following is a candidate and benchmark catalog\nfor continuous datasets:\n\n`candidate_catalog`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/candidate_catalog.png)\n\n`benchmark_catalog`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/benchmark_catalog.png)\n\nWith the following code a comparison of each pair of maps can be run\nwith the following code. Since the parameter `agreement_map_field` is\nprovided the column `agreement_maps` found in the candidate catalog will\nbe used to export the agreement map to that location. (Note the first\npair of candidate and benchmark maps are single band rasters while the\nsecond pair are multiband rasters):\n\n``` python\nimport pandas as pd\n\nfrom gval.catalogs.catalogs import catalog_compare\n\ncandidate_continuous_catalog = pd.read_csv('candidate_catalog_0.csv')\nbenchmark_continuous_catalog = pd.read_csv('benchmark_catalog_0.csv')\n\narguments = {\n    \"candidate_catalog\": candidate_continuous_catalog,\n    \"benchmark_catalog\": benchmark_continuous_catalog,\n    \"on\": \"compare_id\",\n    \"agreement_map_field\": \"agreement_maps\",\n    \"map_ids\": \"map_id\",\n    \"how\": \"inner\",\n    \"compare_type\": \"continuous\",\n    \"compare_kwargs\": {\n        \"metrics\": (\n            \"coefficient_of_determination\",\n            \"mean_absolute_error\",\n            \"mean_absolute_percentage_error\",\n        ),\n        \"encode_nodata\": True,\n        \"nodata\": -9999,\n    },\n    \"open_kwargs\": {\n        \"mask_and_scale\": True,\n        \"masked\": True\n    }\n}\n\nagreement_continuous_catalog = catalog_compare(**arguments)\n```\n\n#### Catalog Outputs\n\n`agreement_map`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_agreement_map.png) ![alt\ntext](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_agreement_map2.png)\n\n`catalog_metrics`\n\n![alt text](https://github.com/NOAA-OWP/gval/raw/main/docs/images/catalog_metric_table.png)\n\n(Note that both catalog level attributes in the candidate and benchmark\ncatalogs are present in the catalog metrics table.)\n\nFor more detailed examples of how to use this software, check out these\n[notebook\ntutorials](https://github.com/NOAA-OWP/gval/blob/main/notebooks).\n\n# Contributing\n\nGuidelines for contributing to this repository can be found at\n[CONTRIBUTING](https://github.com/NOAA-OWP/gval/blob/main/CONTRIBUTING.MD).\n\n# Citation\n\nPlease cite our work if using this package. See 'cite this repository'\nin the about section on [GitHub](https://github.com/NOAA-OWP/gval/) or\nrefer to\n[CITATION.cff](https://github.com/NOAA-OWP/gval/blob/main/CITATION.cff)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flexible, portable, and efficient geospatial evaluations for a variety of data.",
    "version": "0.2.5",
    "project_urls": {
        "Homepage": "https://noaa-owp.github.io/gval/",
        "Repository": "https://github.com/NOAA-OWP/gval"
    },
    "split_keywords": [
        "geospatial",
        "evaluations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6df5a2b866864be42bbb5f5a6217c606fa8ca628a5c756656540b432f1c73c70",
                "md5": "4785615d18cda69ae6e4e60dfded1d63",
                "sha256": "7a03b9049c79470ec5e57a4d8e8a734225e2df31de319649b03023c74c7b0ed4"
            },
            "downloads": -1,
            "filename": "gval-0.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4785615d18cda69ae6e4e60dfded1d63",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 70824,
            "upload_time": "2024-01-02T18:39:17",
            "upload_time_iso_8601": "2024-01-02T18:39:17.968107Z",
            "url": "https://files.pythonhosted.org/packages/6d/f5/a2b866864be42bbb5f5a6217c606fa8ca628a5c756656540b432f1c73c70/gval-0.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd7df59b933f04d7f61aee03442f3f74d939204e009de611deda70151f0ecb4b",
                "md5": "6e86186a09303eff6779de2052c286cf",
                "sha256": "0ece91fc1dce49c7f5f45e39546f0e60dc565a2e26fa42b9d657017067f0457a"
            },
            "downloads": -1,
            "filename": "gval-0.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "6e86186a09303eff6779de2052c286cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 69738,
            "upload_time": "2024-01-02T18:39:19",
            "upload_time_iso_8601": "2024-01-02T18:39:19.285751Z",
            "url": "https://files.pythonhosted.org/packages/cd/7d/f59b933f04d7f61aee03442f3f74d939204e009de611deda70151f0ecb4b/gval-0.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-02 18:39:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NOAA-OWP",
    "github_project": "gval",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "rioxarray",
            "specs": [
                [
                    ">=",
                    "0.13.4"
                ]
            ]
        },
        {
            "name": "dask",
            "specs": [
                [
                    "==",
                    "2023.5.0"
                ]
            ]
        },
        {
            "name": "xarray-spatial",
            "specs": [
                [
                    "==",
                    "0.3.5"
                ]
            ]
        },
        {
            "name": "pandera",
            "specs": [
                [
                    "==",
                    "0.15.1"
                ]
            ]
        },
        {
            "name": "shapely",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "geocube",
            "specs": [
                [
                    ">=",
                    "0.3.3"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.0.2"
                ]
            ]
        },
        {
            "name": "odc-geo",
            "specs": [
                [
                    "==",
                    "0.4.1"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "1.10.10"
                ]
            ]
        },
        {
            "name": "rio-cogeo",
            "specs": [
                [
                    "==",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    "==",
                    "3.7.1"
                ]
            ]
        },
        {
            "name": "contextily",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "flox",
            "specs": [
                [
                    "==",
                    "0.7.2"
                ]
            ]
        },
        {
            "name": "xskillscore",
            "specs": [
                [
                    "==",
                    "0.0.24"
                ]
            ]
        },
        {
            "name": "pyogrio",
            "specs": [
                [
                    "==",
                    "0.7.2"
                ]
            ]
        },
        {
            "name": "pystac-client",
            "specs": [
                [
                    "==",
                    "0.7.5"
                ]
            ]
        },
        {
            "name": "stackstac",
            "specs": [
                [
                    "==",
                    "0.5.0"
                ]
            ]
        }
    ],
    "lcname": "gval"
}
        
Elapsed time: 0.15857s