Skip to content

Latest commit

 

History

History
164 lines (114 loc) · 7.28 KB

installation.md

File metadata and controls

164 lines (114 loc) · 7.28 KB

Install MintPy

Tested on macOS and Linux, not sure about Windows.

Notes for Mac users

Install Xcode with command line tools, if you have not already done so.

  • Install Xcode from App store

  • Install command line tools within XCode and agree to the terms of license.

xcode-select --install -s /Applications/Xcode.app/Contents/Developer/
sudo xcodebuild -license
  • Install XQuartz, then restart the terminal.

Notes for Docker users

Docker allows one to run MintPy in a dedicated container (essentially an efficient virtual machine) and to be independent of platform OS. After installing docker, run the following to pull the MintPy container from DockerHub to your local machine, check more details at here.

docker pull andretheronsa/mintpy:latest

1. Download and setup MintPy

To use the package, you need to setup the environment a) by adding ${MINTPY_HOME} to your $PYTHONPATH to make mintpy importable in Python and b) by adding ${MINTPY_HOME}/mintpy to your $PATH to make application scripts executable in command line, as shown below.

Add to your ~/.bash_profile file for bash user. For tcsh user, check the example here. Source the file for the first time. It will be sourced automatically next time when you login.

if [ -z ${PYTHONPATH+x} ]; then export PYTHONPATH=""; fi

##--------- MintPy ------------------##
export MINTPY_HOME=~/python/MintPy
export PYTHONPATH=${PYTHONPATH}:${MINTPY_HOME}
export PATH=${PATH}:${MINTPY_HOME}/mintpy

##--------- PyAPS ------------------##
export PYAPS_HOME=~/python/PyAPS
export PYTHONPATH=${PYTHONPATH}:${PYAPS_HOME}

Run the following in your terminal to download the development version of MintPy and PyAPS:

# download MintPy and PyAPS
git clone https://github.com/insarlab/MintPy.git $MINTPY_HOME
git clone https://github.com/yunjunz/pyaps3.git $PYAPS_HOME/pyaps3

2. Install dependencies

MintPy is written in Python3 and relies on several Python modules, check the requirements.txt file for details. We recommend using conda or macports to install the python environment and the prerequisite packages, because of the convenient managenment and default performance setting with numpy/scipy and pyresample.

Installing via conda

Add to your ~/.bash_profile file:

export PYTHON3DIR=~/python/miniconda3
export PATH=${PATH}:${PYTHON3DIR}/bin

Run the following in your terminal to install miniconda:

# download and install miniconda
# use wget or curl to download in command line or from anaconda's web brower
# curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o Miniconda3-latest-MacOSX-x86_64.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
chmod +x Miniconda3-latest-MacOSX-x86_64.sh
./Miniconda3-latest-MacOSX-x86_64.sh -b -p $PYTHON3DIR

Run the following in your terminal to install the dependencies to the default environment base:

# install dependencies with conda
$PYTHON3DIR/bin/conda config --add channels conda-forge
$PYTHON3DIR/bin/conda install --yes --file $MINTPY_HOME/docs/conda.txt

# install dependencies not compatiable from conda: basemap, pykml
# run "conda uninstall basemap" if basemap was installed with conda
$PYTHON3DIR/bin/pip install git+https://github.com/matplotlib/basemap.git#egg=mpl_toolkits
$PYTHON3DIR/bin/pip install git+https://github.com/tylere/pykml.git

Or run the following in your terminal to install the dependencies to a new environment mintpy:

$PYTHON3DIR/bin/conda env create -f $MINTPY_HOME/docs/conda_env.yml
$PYTHON3DIR/bin/conda activate mintpy

Installing via MacPorts

Install macports if you have not done so. Add the following at the bottom of your ~/.bash_profile file:

# MacPorts Installer addition on 2017-09-02_at_01:27:12: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:${PATH}
export MANPATH=/opt/local/share/man:${MANPATH}
# Finished adapting your PATH environment variable for use with MacPorts.

#For py36-pyhdf in macports
export INCLUDE_DIRS=/opt/local/include
export LIBRARY_DIRS=/opt/local/lib

Update the port tree with the following command. If your network prevent the use of rsync or svn via http of port tree, try Portfile Sync via a Snapshot Tarball.

sudo port selfupdate

Run the following in your terminal in bash:

# install dependencies with macports
# use "port -N install" to use the safe default for prompt questions
sudo port install $(cat $MINTPY_HOME/docs/ports.txt)

# install dependencies not available on macports: pykml, pykdtree, pyresample, cdsapi, pyhdf
sudo /opt/local/bin/pip install git+https://github.com/tylere/pykml.git
sudo /opt/local/bin/pip install git+https://github.com/storpipfugl/pykdtree.git
sudo /opt/local/bin/pip install git+https://github.com/pytroll/pyresample.git
sudo /opt/local/bin/pip install git+https://github.com/ecmwf/cdsapi.git
sudo /opt/local/bin/pip install git+https://github.com/fhs/pyhdf.git

# install the basemap-dev version [remove after basemap-v1.2 release]
# run "sudo port uninstall py36-matplotlib-basemap" if basemap was installed with port
sudo /opt/local/bin/pip install git+https://github.com/matplotlib/basemap.git#egg=mpl_toolkits

Notes on PyAPS

  • We use PyAPS (Jolivet et al., 2011; 2014) for tropospheric delay correction calculated from Global Atmospheric Models (GAMs) such as ERA-5, ERA-Interim, HRES-ECMWF, MERRA and NARR.

  • Check Earthdef/PyAPS for accounts setup information for ERA-Interim and MERRA.

  • Check pyaps3 for account setup for ERA-5 and run pyaps3/examples/TestECMWF.ipynb to test.

  • If you defined an environment variable named WEATHER_DIR to contain the path to a directory, MintPy applications will download the GAM files into the indicated directory. Also MintPy application will look for the GAM files in the directory before downloading a new one to prevent downloading multiple copies if you work with different dataset that cover the same date/time.

Notes on parallel processing

We use Dask for parallel processing on High Performance Compute (HPC) cluster, it can be setup as below:

mkdir -p ~/.config/dask
cp $MINTPY_HOME/mintpy/defaults/dask_mintpy.yaml ~/.config/dask/dask_mintpy.yaml

Edit ~/.config/dask/dask_mintpy.yaml file according to your HPC settings. Currently, only LSFCluster job scheduler is tested, PBSCluster should also work after minor adjustment in ifgram_inversion.py.

Notes on vim

Here is some useful setup of Vim editor for general use and Python.