Skip to main content

io utilities for reading in .asc and .zmap grids

Project description

pygridsio

Introduction

This is a python submodule containing IO functionality for reading and writing .asc, .zmap and .nc grids.

Usage

from pygridsio.pygridsio import * The standard grid class used throughout this project is an Xarray DataArray (see: https://xarray.dev/) with 2 dimensions: x and y.

To read a grid file to this class use: grid = read_grid(filename)

When writing out grids, you can write out grids to a netcdf raster (.nc) which can be read easily by xarray, or QGIS or ArcGIS, .asc and .zmap are also supported: write_grid(grid,filename) The code will discern which filetype to write out to by the file extension in filename.

There is some plotting functionality built into pygridsio using the pygridsio.grid_plotting module: The method pygridsio.grid_plotting.plot_grid allows you to plot a custom Grid class, or xr.DataArray with multiple options. See the description of the method for more detail. The method pygridsio.grid_plotting.plot_grid_comparison Creates a plot comparing two grids values against eachother. See the description of the method for more detail. The method pygridsio.grid_plotting.make_interactive_plot Creates a interactive .html plot using plotly The method pygridsio.grid_plotting.make_interactive_plot_with_map Creates a interactive .html plot using plotly with a mapbox map underneath (not suitable for really large datasets)

Installation to Develop the code further

Anaconda

Create/update anaconda environment

The file environment.yml can be used to create a working development python environment with the needed packages. For this open an Anaconda Prompt and:

conda env create -f environment.yml

Or to update the existing anaconda environment (with an updated version of theenvironment.ymlfile :

conda env update -n pygridsio -f environment.yml

Export (updated) anaconda environment

The environment.yml file needs to be updated when new packages are added:

conda env export --from-history -n pygridsio > environment.yml

Use anaconda environment in PyCharm

To connect the anaconda environment to Pycharm you can go to File , Settings, Project, Python Interpreter, add interpreter, add local interpreter, conda environment and then select the environment you created using the above steps.

Poetry

Poetry is becoming the new way to manage your python projects and dependencies. Install poetry here: https://python-poetry.org/docs/ (note: if you can't run poetry from your terminal, ensure that the poetry.exe is in your environment variables).

Then after cloning this repo to your local machine, run: poetry install

Which will install a virtual environment in the gitlab repo. This can also be done using the Pycharm Python Interpreter interface.

Verify Installation

You can verify the installation of the different python packages by running the tests stored in tests. In pycharm: Right-click on the folder marked tests and click on Run python tests in test

publishing the project to gitlab

To publish an updated version of the project to the pygridsio package registry I recommend using poetry.

First configure the connection between poetry and the gitlab package registry: poetry config repositories.gitlab_pygridsio https://YOURGITLABLOCATION/gitlab/api/v4/projects/17422/packages/pypi

Add your own personal access token details (https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html): poetry publish --repository gitlab_pygridsio -u"token name" -p "token value"

Then you can build and publish the project as a new deployment in the package registry: poetry build poetry publish (make sure the version number you publish is unique)

How to import pygridsio into other python projects

Pip

You can use pip to get the most up-to-date version of pygridsio: pip install pygridsio

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygridsio-0.3.9.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygridsio-0.3.9-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file pygridsio-0.3.9.tar.gz.

File metadata

  • Download URL: pygridsio-0.3.9.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.1 Windows/10

File hashes

Hashes for pygridsio-0.3.9.tar.gz
Algorithm Hash digest
SHA256 38078b7280601e66751fc0eab6c9b84e5a77db287f793a40b40833b3b3244c07
MD5 d67a766a05720b0bb4308985e465a41d
BLAKE2b-256 6626b18c5d36dd378c84e6c25e7fc7ad1bc17a83256fac0dcc713de0631aeeb9

See more details on using hashes here.

File details

Details for the file pygridsio-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: pygridsio-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.1 Windows/10

File hashes

Hashes for pygridsio-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 dff5b184b6bf63f722351e1b29b590975d1fab40752fdcf8b3dc31fa4bbabc98
MD5 3e991ea4be0ebbffd9aca86514c303ff
BLAKE2b-256 6537b26e002e15083e7ff5c2b56922b8010c3e98750b73e3c02ece02a0146a9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page