iconarray


Nameiconarray JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/C2SM/iconarray
SummaryA package of modules for processing and plotting ICON data.
upload_time2023-01-25 10:13:17
maintainer
docs_urlNone
authorMeteoSwiss, C2SM
requires_python>=3.7, <4
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # iconarray

[![Available on pypi](https://badge.fury.io/py/iconarray.svg)](https://pypi.python.org/pypi/iconarray/)
[![Docs](https://github.com/C2SM/iconarray/workflows/docs/badge.svg?branch=main)](https://c2sm.github.io/iconarray/)
[![Build Status](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/badge/icon?config=build)](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/)
[![Test Status](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/badge/icon?config=test)](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/)

## Introduction

The iconarray python package contains various modules to facilitate working with ICON data with xarray or other xarray based tools (such as [psyplot](https://psyplot.github.io/) - a plotting package). The package was developed together with [icon-vis](https://github.com/C2SM/icon-vis).

**API Documentation**: <https://c2sm.github.io/iconarray>

## Table of contents

1. [Introduction](#introduction)
2. [Installation and Setup](#installation-and-setup)
3. [Modules](#modules)
4. [Formatoptions](#formatoptions)
5. [Contacts](#contacts)

## Installation and Setup

Iconarray and the packages it depends on are installable with conda. Some of these dependencies, e.g. eccodes and cartopy are not easily installable with pip, but easily installable with conda.

First clone the iconarray repository and `cd` into its parent directory:

```bash
git clone git@github.com:C2SM/iconarray.git
cd iconarray
```

- If you are setting up a **new conda environment** for iconarray, carry out these two steps:

    1. Create a conda environment (e.g. called iconarray) and install iconarray and its requirements:

        ```bash
        conda env create -n iconarray -f env/environment.yml
        ```

    2. Activate environment:

        ```bash
        conda activate iconarray
        ```

- Alternatively if you are adding iconarray to your **existing conda environment**, carry out these two steps:

    1. Update your existing conda environment by executing this command. It will install all missing dependencies of iconarray into your existing conda environment:

        ```bash
        conda env update -n {YOUR_ENVIRONMENT} -f env/environment.yml
        ```

    2. You can then re-export an updated ``environment.yml`` file of your environment:

        ```bash
        conda activate {YOUR_ENVIRONMENT}
        conda env export | grep -v "^prefix: " > environment.yml
        ```

 - Alternatively, you can also update your own environment.yml file manually, according to [env/environment.yml](env/environment.yml).

### ICON GRIB Definitions

If you are using the conda setup and want to use GRIB data, you probably need to set the `GRIB_DEFINITION_PATH`. The GRIB_DEFINITION_PATH environment variable can be configured in order to use local definition files (text files defining the decoding rules) instead of the default definition files provided with eccodes. This can be done by sourcing the script setup-conda-env.sh. It only needs to be run a single time, as it will save the `GRIB_DEFINITION_PATH` environment variable to the conda environment. You will need to deactivate and reactivate the conda environment after doing this. You can check it has been correctly set by running `conda env config vars list`.

```bash
./env/setup-conda-env.sh
```

The above script also sets the Fieldextra installation path (`FIELDEXTRA_PATH`). Fieldextra is a tool which can be used for interpolating data to another grid (lon/lat or another ICON grid). The use of this specific installation of Fieldextra depends on your CSCS access rights, so you may need to change `FIELDEXTRA_PATH` if you have problems interpolating.

## Modules

There are a number of [modules](/iconarray) which are part of the `iconarray` package (installed by conda using [env/environment.yml](env/environment.yml)), which you can import like a normal python package into your scripts. To work with the modules from iconarray, you can add this code block to the start of your script / notebook. You will see many examples of the modules being used within the scripts in this repo.

```python
import iconarray # import iconarray modules
from iconarray.plot import formatoptions # import plotting formatoptions (for use with psyplot)
```

Then you can use the functions or modules as needed, eg:

```python
iconarray.get_example_data()
```

### Grid - [backend/grid.py](/iconarray/backend/grid.py)

**`combine_grid_information()`** This adds the required grid information from a provided grid file to your dataset if not present. It also adds coordinates encoding to each variable, which is needed to plot using psyplot.

**`check_grid_information()`** Checks whether or not the grid data needs to be added. eg:

```python
if check_grid_information(nc_file):
    print('The grid information is available')
    data = psy.open_dataset(nc_file)
else:
    print('The grid information is not available')
    data = combine_grid_information(nc_file,grid_file)
```

### Utilities - [core/utilities.py](/iconarray/core/utilities.py)

**`ind_from_latlon()`** Returns the nearest neighbouring index of lat-lon within given lats-lons.

**`add_coordinates()`** Returns the position of given coordinates on the plot (useful to add markers at a fixed location).

**`get_stats()`** Returns the mean of two given variables, the difference of the mean and the p values.

**`wilks()`** Returns a value for which differences are significant when data point dependencies are accounted for (based on [Wilks 2016](https://journals.ametsoc.org/view/journals/bams/97/12/bams-d-15-00267.1.xml)).

**`show_data_vars()`** Returns a table with variables in your data. The first column shows the variable name psyplot will need to plot that variable.
This is useful if you plot GRIB data, because if `GRIB_cfVarName` is defined, cfgrib will set this as the variable name, as opposed to `GRIB_shortName` which you might expect.

### Interpolate - [core/interpolate.py](/iconarray/core/interpolate.py)

The functions in interpolate.py are used to facilitate the interpolation of ICON vector data to a regular grid, or a coarser ICON grid, for the purpose of vectorplots, eg wind plots. For psyplot we recommend to plot wind data on the regular grid as you can then scale the density of arrows in a vector plot as desired.

**`remap_ICON_to_ICON()`** This calls the `_create_remap_nl()` function to create a fieldextra namelist with your datafile, and subsequently runs fieldextra with this namelist. The output file along with a LOG and the namelist are saved in a `tmp` folder. The function returns the file location of the output file.

**`remap_ICON_to_regulargrid()`** This calls the `_create_remap_nl()` function to create a fieldextra namelist with your datafile, and subsequently runs fieldextra with this namelist. The output file along with a LOG and the namelist are saved in a `tmp` folder. The function returns the file location of the output file.

## Formatoptions

Psyplot has a large number of ‘formatoptions’ which can be used to customize the look of visualizations. For example, the descriptions of the formatoptions associated with the MapPlotter class of psyplot can be found in the [psyplot documentation](https://psyplot.github.io/psy-maps/api/psy_maps.plotters.html#psy_maps.plotters.MapPlotter). The documentation for using formatoptions is also all on the psyplot documentation, or seen in the [examples](https://psyplot.github.io/examples/index.html).

Psyplot is designed in a way that is very modular and extensible, allowing users to easily create custom formatoptions and register them to plotters. Instructions for doing so are [here](https://psyplot.github.io/examples/general/example_extending_psyplot.html#3.-The-formatoption-approach).

This repository includes various custom formatoptions, that are not included in psyplot. For example:

- [Borders](/iconarray/plot/formatoptions/borders.py) - Adds internal land borders to mapplot, vectorplots, and combinedplots.
- [Rivers](/iconarray/plot/formatoptions/rivers.py) - Adds rivers to mapplot, vectorplots, and combinedplots.
- [Lakes](/iconarray/plot/formatoptions/lakes.py) - Adds lakes to mapplot, vectorplots, and combinedplots.
- [Standard Title](/iconarray/plot/formatoptions/standardtitle.py) - Adds a descriptive title based on your data to your mapplot.
- [Mean Max Wind](/iconarray/plot/formatoptions/meanmaxwind.py) - Work In Progress.
- [Custom Text](/iconarray/plot/formatoptions/customtext.py) - Work In Progress.

We encourage you to create your own formatoptions and contribute to this repository if they would be useful for others.

Once registered to a plotter class, the formatoptions can be used as seen in many of the icon-vis scripts, for example in [mapplot.py](https://github.com/C2SM/icon-vis/blob/master/mapplot/mapplot.py).

## Contacts

This repo has been developed by:

- Annika Lauber (C2SM) - annika.lauber@c2sm.ethz.ch
- Victoria Cherkas (MeteoSwiss) - victoria.cherkas@meteoswiss.ch

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/C2SM/iconarray",
    "name": "iconarray",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <4",
    "maintainer_email": "",
    "keywords": "",
    "author": "MeteoSwiss, C2SM",
    "author_email": "victoria.cherkas@meteoswiss.ch, annika.lauber@c2sm.ethz.ch",
    "download_url": "https://files.pythonhosted.org/packages/ac/57/425e4d638b60913e8375997cffc5292cc9b17c2cad99d4819426e3985814/iconarray-0.2.1.tar.gz",
    "platform": null,
    "description": "# iconarray\n\n[![Available on pypi](https://badge.fury.io/py/iconarray.svg)](https://pypi.python.org/pypi/iconarray/)\n[![Docs](https://github.com/C2SM/iconarray/workflows/docs/badge.svg?branch=main)](https://c2sm.github.io/iconarray/)\n[![Build Status](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/badge/icon?config=build)](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/)\n[![Test Status](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/badge/icon?config=test)](https://jenkins-mch.cscs.ch/job/iconarray_testsuite/)\n\n## Introduction\n\nThe iconarray python package contains various modules to facilitate working with ICON data with xarray or other xarray based tools (such as [psyplot](https://psyplot.github.io/) - a plotting package). The package was developed together with [icon-vis](https://github.com/C2SM/icon-vis).\n\n**API Documentation**: <https://c2sm.github.io/iconarray>\n\n## Table of contents\n\n1. [Introduction](#introduction)\n2. [Installation and Setup](#installation-and-setup)\n3. [Modules](#modules)\n4. [Formatoptions](#formatoptions)\n5. [Contacts](#contacts)\n\n## Installation and Setup\n\nIconarray and the packages it depends on are installable with conda. Some of these dependencies, e.g. eccodes and cartopy are not easily installable with pip, but easily installable with conda.\n\nFirst clone the iconarray repository and `cd` into its parent directory:\n\n```bash\ngit clone git@github.com:C2SM/iconarray.git\ncd iconarray\n```\n\n- If you are setting up a **new conda environment** for iconarray, carry out these two steps:\n\n    1. Create a conda environment (e.g. called iconarray) and install iconarray and its requirements:\n\n        ```bash\n        conda env create -n iconarray -f env/environment.yml\n        ```\n\n    2. Activate environment:\n\n        ```bash\n        conda activate iconarray\n        ```\n\n- Alternatively if you are adding iconarray to your **existing conda environment**, carry out these two steps:\n\n    1. Update your existing conda environment by executing this command. It will install all missing dependencies of iconarray into your existing conda environment:\n\n        ```bash\n        conda env update -n {YOUR_ENVIRONMENT} -f env/environment.yml\n        ```\n\n    2. You can then re-export an updated ``environment.yml`` file of your environment:\n\n        ```bash\n        conda activate {YOUR_ENVIRONMENT}\n        conda env export | grep -v \"^prefix: \" > environment.yml\n        ```\n\n - Alternatively, you can also update your own environment.yml file manually, according to [env/environment.yml](env/environment.yml).\n\n### ICON GRIB Definitions\n\nIf you are using the conda setup and want to use GRIB data, you probably need to set the `GRIB_DEFINITION_PATH`. The GRIB_DEFINITION_PATH environment variable can be configured in order to use local definition files (text files defining the decoding rules) instead of the default definition files provided with eccodes. This can be done by sourcing the script setup-conda-env.sh. It only needs to be run a single time, as it will save the `GRIB_DEFINITION_PATH` environment variable to the conda environment. You will need to deactivate and reactivate the conda environment after doing this. You can check it has been correctly set by running `conda env config vars list`.\n\n```bash\n./env/setup-conda-env.sh\n```\n\nThe above script also sets the Fieldextra installation path (`FIELDEXTRA_PATH`). Fieldextra is a tool which can be used for interpolating data to another grid (lon/lat or another ICON grid). The use of this specific installation of Fieldextra depends on your CSCS access rights, so you may need to change `FIELDEXTRA_PATH` if you have problems interpolating.\n\n## Modules\n\nThere are a number of [modules](/iconarray) which are part of the `iconarray` package (installed by conda using [env/environment.yml](env/environment.yml)), which you can import like a normal python package into your scripts. To work with the modules from iconarray, you can add this code block to the start of your script / notebook. You will see many examples of the modules being used within the scripts in this repo.\n\n```python\nimport iconarray # import iconarray modules\nfrom iconarray.plot import formatoptions # import plotting formatoptions (for use with psyplot)\n```\n\nThen you can use the functions or modules as needed, eg:\n\n```python\niconarray.get_example_data()\n```\n\n### Grid - [backend/grid.py](/iconarray/backend/grid.py)\n\n**`combine_grid_information()`** This adds the required grid information from a provided grid file to your dataset if not present. It also adds coordinates encoding to each variable, which is needed to plot using psyplot.\n\n**`check_grid_information()`** Checks whether or not the grid data needs to be added. eg:\n\n```python\nif check_grid_information(nc_file):\n    print('The grid information is available')\n    data = psy.open_dataset(nc_file)\nelse:\n    print('The grid information is not available')\n    data = combine_grid_information(nc_file,grid_file)\n```\n\n### Utilities - [core/utilities.py](/iconarray/core/utilities.py)\n\n**`ind_from_latlon()`** Returns the nearest neighbouring index of lat-lon within given lats-lons.\n\n**`add_coordinates()`** Returns the position of given coordinates on the plot (useful to add markers at a fixed location).\n\n**`get_stats()`** Returns the mean of two given variables, the difference of the mean and the p values.\n\n**`wilks()`** Returns a value for which differences are significant when data point dependencies are accounted for (based on [Wilks 2016](https://journals.ametsoc.org/view/journals/bams/97/12/bams-d-15-00267.1.xml)).\n\n**`show_data_vars()`** Returns a table with variables in your data. The first column shows the variable name psyplot will need to plot that variable.\nThis is useful if you plot GRIB data, because if `GRIB_cfVarName` is defined, cfgrib will set this as the variable name, as opposed to `GRIB_shortName` which you might expect.\n\n### Interpolate - [core/interpolate.py](/iconarray/core/interpolate.py)\n\nThe functions in interpolate.py are used to facilitate the interpolation of ICON vector data to a regular grid, or a coarser ICON grid, for the purpose of vectorplots, eg wind plots. For psyplot we recommend to plot wind data on the regular grid as you can then scale the density of arrows in a vector plot as desired.\n\n**`remap_ICON_to_ICON()`** This calls the `_create_remap_nl()` function to create a fieldextra namelist with your datafile, and subsequently runs fieldextra with this namelist. The output file along with a LOG and the namelist are saved in a `tmp` folder. The function returns the file location of the output file.\n\n**`remap_ICON_to_regulargrid()`** This calls the `_create_remap_nl()` function to create a fieldextra namelist with your datafile, and subsequently runs fieldextra with this namelist. The output file along with a LOG and the namelist are saved in a `tmp` folder. The function returns the file location of the output file.\n\n## Formatoptions\n\nPsyplot has a large number of \u2018formatoptions\u2019 which can be used to customize the look of visualizations. For example, the descriptions of the formatoptions associated with the MapPlotter class of psyplot can be found in the [psyplot documentation](https://psyplot.github.io/psy-maps/api/psy_maps.plotters.html#psy_maps.plotters.MapPlotter). The documentation for using formatoptions is also all on the psyplot documentation, or seen in the [examples](https://psyplot.github.io/examples/index.html).\n\nPsyplot is designed in a way that is very modular and extensible, allowing users to easily create custom formatoptions and register them to plotters. Instructions for doing so are [here](https://psyplot.github.io/examples/general/example_extending_psyplot.html#3.-The-formatoption-approach).\n\nThis repository includes various custom formatoptions, that are not included in psyplot. For example:\n\n- [Borders](/iconarray/plot/formatoptions/borders.py) - Adds internal land borders to mapplot, vectorplots, and combinedplots.\n- [Rivers](/iconarray/plot/formatoptions/rivers.py) - Adds rivers to mapplot, vectorplots, and combinedplots.\n- [Lakes](/iconarray/plot/formatoptions/lakes.py) - Adds lakes to mapplot, vectorplots, and combinedplots.\n- [Standard Title](/iconarray/plot/formatoptions/standardtitle.py) - Adds a descriptive title based on your data to your mapplot.\n- [Mean Max Wind](/iconarray/plot/formatoptions/meanmaxwind.py) - Work In Progress.\n- [Custom Text](/iconarray/plot/formatoptions/customtext.py) - Work In Progress.\n\nWe encourage you to create your own formatoptions and contribute to this repository if they would be useful for others.\n\nOnce registered to a plotter class, the formatoptions can be used as seen in many of the icon-vis scripts, for example in [mapplot.py](https://github.com/C2SM/icon-vis/blob/master/mapplot/mapplot.py).\n\n## Contacts\n\nThis repo has been developed by:\n\n- Annika Lauber (C2SM) - annika.lauber@c2sm.ethz.ch\n- Victoria Cherkas (MeteoSwiss) - victoria.cherkas@meteoswiss.ch\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A package of modules for processing and plotting ICON data.",
    "version": "0.2.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48ea10e34cc1593c17b60b957bac96973597a9c3d336e0a500f46c75057ebffc",
                "md5": "f2533ece18563afc2525aebc98c354bb",
                "sha256": "38d414ba958a3dd9e7567057ab71cb3594eed4c6979b1c4453e17fb7a0a105b7"
            },
            "downloads": -1,
            "filename": "iconarray-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f2533ece18563afc2525aebc98c354bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7, <4",
            "size": 31552,
            "upload_time": "2023-01-25T10:13:16",
            "upload_time_iso_8601": "2023-01-25T10:13:16.312475Z",
            "url": "https://files.pythonhosted.org/packages/48/ea/10e34cc1593c17b60b957bac96973597a9c3d336e0a500f46c75057ebffc/iconarray-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac57425e4d638b60913e8375997cffc5292cc9b17c2cad99d4819426e3985814",
                "md5": "d0f8c4bbc7da73a1a51bacb61f599ad3",
                "sha256": "4cf0ce8e0bb4c2af587d3db3f55241ebe774fb00deae549fcd3f36dbe5bccabb"
            },
            "downloads": -1,
            "filename": "iconarray-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d0f8c4bbc7da73a1a51bacb61f599ad3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <4",
            "size": 30057,
            "upload_time": "2023-01-25T10:13:17",
            "upload_time_iso_8601": "2023-01-25T10:13:17.535931Z",
            "url": "https://files.pythonhosted.org/packages/ac/57/425e4d638b60913e8375997cffc5292cc9b17c2cad99d4819426e3985814/iconarray-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-25 10:13:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "C2SM",
    "github_project": "iconarray",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "iconarray"
}
        
Elapsed time: 0.10583s