Skip to content

Latest commit

 

History

History
126 lines (92 loc) · 4.88 KB

INSTALL.md

File metadata and controls

126 lines (92 loc) · 4.88 KB

Installation

pyMETRIC is most easily installed by cloning the GitHub repository.

Most of the documentation and examples are written assuming you are running pyMETRIC on a Windows PC and that the pyMETRIC repository was cloned directly to the C: drive. If you are using a different operating system or cloned the repository to a different location, you will need adjust commands, drive letters, and paths accordingly.

Python

pyMETRIC has only been tested using Python 2.7 and 3.6, but may work with other versions.

Dependencies

The following external Python modules must be present to run pyMETRIC:

  • fiona (used to read and write multi-layered GIS file formats)
  • future (adds features from Python 3 to Python 2 installations)
  • gdal (version >2.2 and <3.0.0) (the Geospatial Data Abstraction Library is used to interact with raster and vector geospatial data)
  • matplotlib (necessary for creating plots of ET related data)
  • netcdf4 (for interacting with multi-dimensional scientific datasets, such as GRIDMET/DAYMET)
  • numpy
  • pandas (used to perform data processing)
  • requests (adds enhanced http functionality)
  • scipy (provides numerous packages required for the processing of data)
  • refet (for computing reference ET)
  • drigo (GDAL/OGR helper functions)

Please see the requirements file for details on the versioning requirements. The module version numbers listed in the file were tested and are known to work. Other combinations of versions may work but have not been tested.

Python 2

The following external Python modules must be present to run pyMETRIC on Python 2

  • configparser(Python 2 implementation of the Python 3 configparser module)

Anaconda/Miniconda

The easiest way of obtaining Python and all of the necessary external modules, is to install Miniconda or Anaconda.

TODO: Add more explanation about where to install Miniconda (ideally to the root on the C drive) and what options need to be selected when installing.

After installing Miniconda, make sure to add the conda-forge channel by entering the following in the command prompt or terminal:

conda config --add channels conda-forge

Conda Environment

The user is strongly encouraged to setup a dedicated conda environment for pyMETRIC:

conda create -n pymetric python=3.6

The environment must be "activated" before use:

conda activate pymetric

Most of the external modules can then be installed by calling:

conda install future matplotlib netcdf4 numpy pandas refet requests scipy requests-html
conda install gdal==3.3.2

The drigo modules must be installed separately with pip:

pip install drigo --no-deps

Environment Variables

Windows

PYTHONPATH

Many of the pyMETRIC scripts reference the "common" functions in the pymetric/code/support folder. To be able to access these functions, you will need to add/append this path to the PYTHONPATH environment variable.

The environment variable can be set at the command line. First check if PYTHONPATH is already set by typing:

echo %PYTHONPATH%

If PYTHONPATH is not set, type the following in the command prompt:

setx PYTHONPATH "C:\pymetric\code\support"

To append to an existing PYTHONPATH, type:

setx PYTHONPATH "C:\pymetric\code\support;%PYTHONPATH%"

GDAL_DATA

In order to execute pyMETRIC code, the GDAL_DATA environmental variable may need to be set (example: GDAL_DATA = C:\Miniconda3\envs\pymetric\Library\share\gdal). Depending on your specific installation of Python, you file path for GDAL_DATA may be different

On a Windows PC, the user environment variables can be set through the Control Panel (System -> Advanced system settings -> Environment Variables). Assuming that pyMETRIC was cloned/installed directly to the C: drive and Python 3 is used, the GDAL_DATA environmental variable may be set as:

C:\Miniconda3\envs\pymetric\Library\share\gdal

This environment variable can also be set at the command line. First check if GDAL_DATA is already set by typing:

echo %GDAL_DATA%

If GDAL_DATA is not set, type the following in the command prompt:

setx GDAL_DATA "C:\Miniconda3\envs\pymetric\Library\share\gdal"

Mac / Linux

PYTHONPATH

echo $PYTHONPATH
export PYTHONPATH=/Users/<USER>/pymetric/code/support

GDAL_DATA

echo $GDAL_DATA
export GDAL_DATA=/Users/<USER>/miniconda3/envs/python3/share/gdal