Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check feasibility of PCRaster import alternatives #9

Closed
soaressgabriel opened this issue Jun 14, 2021 · 4 comments
Closed

Check feasibility of PCRaster import alternatives #9

soaressgabriel opened this issue Jun 14, 2021 · 4 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@soaressgabriel
Copy link
Collaborator

soaressgabriel commented Jun 14, 2021

PCRaster Info

Installing PCRaster

PCRaster is available on conda-forge and can be installed using conda. Supported platforms are Linux, macOS and Windows.

We recommend to download and install Miniconda. The user guide and short reference on conda can be found here. After install you can check which Python versions are supported by PCRaster:

conda search -c conda-forge pcraster

Afterwards you can create a new environment and install PCRaster, e.g. with the following steps:

conda create --name pcraster -c conda-forge python

conda activate pcraster

conda install -c conda-forge pcraster
@soaressgabriel soaressgabriel added the help wanted Extra attention is needed label Jun 14, 2021
@soaressgabriel soaressgabriel self-assigned this Jun 14, 2021
@soaressgabriel
Copy link
Collaborator Author

soaressgabriel commented Jun 20, 2021

@soaressgabriel
Copy link
Collaborator Author

soaressgabriel commented Jun 20, 2021

Solutions from other packages that use PCRaster

  • wflow

    wflow consists of a set of Python programs that can be run on the command line and perform hydrological simulations. The models are based on the PCRaster Python framework. In wflow this framework is extended (the wf_DynamicFramework) so that models build using the framework can be controlled using the API. Links to BMI, OpenMI and OpenDAP have been made.

    A link to the latest version can always be found at https://github.com/openstreams/wflow

    Reference documentation

    • Installing pcraster

    • Install as a conda environment

    • Install using pip

      [...]

      If you want to avoid using conda, an example of a PCRaster build and pip install on Ubuntu Linux can be found in issue #36 Installing wflow on Ubuntu 18.04

      [...]

      For my specific application, I want the Python distribution to be as lean as possible. Therefore, I was not going for the Anaconda environment solution.

      Compile PCRaster from source:

      sudo apt install cmake gcc g++ git qtbase5-dev libncurses5-dev libqwt-qt5-dev libxerces-c-dev libboost-all-dev libgdal-dev python3-numpy python3-docopt
      wget http://pcraster.geo.uu.nl/pcraster/4.2.1/pcraster-4.2.1.tar.bz2
      tar xf pcraster-4.2.1.tar.bz2 && cd pcraster-4.2.1
      mkdir build && cd build
      cmake -DFERN_BUILD_ALGORITHM:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=$HOME/pcraster -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 ..
      cmake --build .
      make install
      export PATH=$PATH:$HOME/pcraster/bin
      export PYTHONPATH=$PYTHONPATH:$HOME/pcraster/python

      Since the automatic installation of the required Python packages did not work for me, I installed them manually using pip

      sudo apt install python3-pip
      pip3 install numpy
      pip3 install scipy
      pip3 install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}') --global-option=build_ext --global-option="-I/usr/include/gdal"
      pip3 install netcdf4
      pip3 install pyproj
      sudo apt-get install libllvm-9-ocaml-dev libllvm9 llvm-9 llvm-9-dev llvm-9-doc llvm-9-examples llvm-9-runtime
      export LLVM_CONFIG='/usr/bin/llvm-config-9'
      pip3 install numba
      pip3 install python-dateutil

      Afterwards I was cloning the git repository to my $Home directory

      cd $HOME
      git clone https://github.com/openstreams/wflow.git

      I had to excluded the required packages in the setup.py file, which is located in $HOME/wflow/setup.py

      install_requires=[
      	#   "numpy",
      	#   "scipy",
          #   "gdal",
          #   "netCDF4",
          #   "xarray",
      	#   "cftime",
          #   "numba",
          #   "pyproj",
      	#   "python-dateutil",
      ], 

      At last wflow can be installed by using pip

      cd wflow
      pip3 install -e .

@soaressgabriel
Copy link
Collaborator Author

Python Wrapping

  • exec-wrappers

    Wrappers for running commands that need some initial setup. exec-wrappers is useful whenever you need a single executable file, but have to do some setup before executing it.

    If you develop using some kind of environment isolation like conda, schroot, virtualenv you probably wanted to configure a GUI application like an IDE to use the executables available inside these environments.

    [...]

    Creating conda wrappers:

    $ create-wrappers  -t conda --bin-dir ~/miniconda/envs/test/bin --dest-dir /tmp/conda_wrappers --conda-env-dir ~/miniconda/envs/test

    This will create in /tmp/conda_wrappers a wrapper for each executable found in ~/miniconda/envs/test/bin. So if you run the python wrapper:

    $ /tmp/conda_wrappers/python -c "import sys; print(sys.executable)"
    /home/username/miniconda/envs/test/bin/python

    It will actually activate the conda environment and set necessary variables, and then execute the real python interpreter. So you can use the wrapper to configure you IDE, for example.

    Features

    • automatically detect executables in a given directory
    • wrappers written in plain shell and batch scripts
    • low overhead (as low as possible)
    • built-in wrappers for common tools

    Requirements

    python is the only dependency to create wrappers. To properly use the generated wrappers you need the tool used by the wrapper (conda, schroot, etc.).

@soaressgabriel
Copy link
Collaborator Author

O Hans van der Kwast anunciou o PCRaster Tools plugin para o QGIS mais recente e agora é possível instalar o PCRaster (somente Windows por enquanto) através do instalador OSGeo4W no ambiente Python do QGIS.

@soaressgabriel soaressgabriel changed the title Verificar a viabilidade de alternativas de importação do PCRaster Check feasibility of PCRaster import alternatives Mar 23, 2022
@soaressgabriel soaressgabriel modified the milestone: v0.1.0-alpha Mar 23, 2022
@soaressgabriel soaressgabriel moved this from Todo to Done in RUBEM (model & plugin) May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Development

No branches or pull requests

1 participant