Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ avaframe/**/**/Inputs/remeshedRasters
avaframe/com1DFA/*.c

avaframe/com1DFA/*.so
/pixi.lock
34 changes: 14 additions & 20 deletions docs/developinstall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,25 @@ guide is described for **Linux**. For *Windows*, see :ref:`developinstallwin:Adv
Requirements
^^^^^^^^^^^^

Install `git <https://github.com/git-guides/install-git>`_ and python, we
suggest to work with miniconda/anaconda. For installation see `miniconda
<https://docs.conda.io/en/latest/miniconda.html>`_ or
`anaconda <https://docs.anaconda.com/anaconda/install/linux/>`_.
Install `git <https://github.com/git-guides/install-git>`_, python and `pixi <https://pixi.sh/latest/#installation>`_.
Some operating systems might require the python headers (e.g python-dev on ubuntu) or other supporting
libraries/packages (e.g. Visual Studio on Windows needs the c++ compiler components).


Setup AvaFrame
^^^^^^^^^^^^^^

Create a new `conda environment
<https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html>`_
for AvaFrame, activate it and install pip, numpy and cython in this environment::

conda create --name avaframe_env
conda activate avaframe_env
conda install pip numpy cython

Clone the AvaFrame repository (in a directory of your choice: [YOURDIR]) and change into it::

cd [YOURDIR]
git clone https://github.com/avaframe/AvaFrame.git
cd AvaFrame


Comment thread
fso42 marked this conversation as resolved.
Run pixi::
Comment thread
fso42 marked this conversation as resolved.

pixi shell

Comment thread
PaulaSp3 marked this conversation as resolved.
Compile the cython com1DFA part. You might also have to install a c-compiler (gcc or similar) through your systems
package manager::

Expand All @@ -44,18 +38,18 @@ package manager::
You will have to do this compilation every time something changes in the cython code. We also suggest
to do this everytime updates from the repositories are pulled.

Install avaframe and its requirements by **either** doing::

pip install -e .

or if this fails (see `github issue 986 <https://github.com/avaframe/AvaFrame/issues/986>`_), do::
All this installs avaframe in editable mode, so every time you import avaframe the
current (local) version will be used.

python setup.py develop
If you want to have the lastet stable release instead, run::

This installs avaframe in editable mode, so every time you import avaframe the
current (local) version will be used.
pixi shell --environment prod

Test it by starting ``python`` and do an ``import avaframe``. If no error comes
up, you are good to go.

To see the current version, you can use::

pixi list avaframe

Head over to :ref:`gettingstarted:First run` for the next steps.
100 changes: 24 additions & 76 deletions docs/developinstallwin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ Advanced Installation (Windows)

This is a quick guide on how to install AvaFrame
and the required dependencies on your machine. AvaFrame is developed on **Linux
machines** (Ubuntu/Manjaro/Arch) with recent Python versions > 3.8. Caution: currently unavailable for Version 3.13
machines** (Ubuntu/Manjaro/Arch) with recent Python versions > 3.8.
These instructions assume you are familiar with working in a terminal. This
guide is described for **Windows**. For *Linux*, see :ref:`developinstall:Advanced Installation (Linux)`.

Requirements
^^^^^^^^^^^^

Install `git <https://github.com/git-guides/install-git>`_ and python, we
suggest to work with miniconda/anaconda. For installation see `miniconda
<https://docs.conda.io/en/latest/miniconda.html>`_ or
`anaconda <https://docs.anaconda.com/anaconda/install/linux/>`_.
Install `git <https://github.com/git-guides/install-git>`_, python and `pixi <https://pixi.sh/latest/#installation>`_.

Install `Microsoft C++ compiler <https://wiki.python.org/moin/WindowsCompilers>`_.
Follow the installation steps for the version corresponding to the installed python version.

Setup AvaFrame
^^^^^^^^^^^^^^

Open conda shell and create a new `conda environment
<https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html>`_
for AvaFrame, activate it and install pip, numpy and cython in this environment::

conda create --name avaframe_env
conda activate avaframe_env
conda install pip numpy cython

Clone the AvaFrame repository (in a directory of your choice: [YOURDIR]) and change into it::

cd [YOURDIR]
git clone https://github.com/avaframe/AvaFrame.git
cd AvaFrame



Run pixi::

pixi shell

.. Note::
If you get some access denied error in Powershell, you might need to run the command

``Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser``

Compile the cython com1DFA part::

python setup.py build_ext --inplace
Expand All @@ -46,84 +46,32 @@ Compile the cython com1DFA part::
**Before** compilation in Windows, make sure to delete ``AvaFrame/build`` directory, in addition to any .pyd, .c, and
.pycache files in ``AvaFrame/avaframe/com1DFA``

Install avaframe and its requirements by **either** doing::

pip install -e .
This installs avaframe in editable mode, so every time you import avaframe the
current (local) version will be used.

or if this fails (see `github issue 986 <https://github.com/avaframe/AvaFrame/issues/986>`_), do::
If you want to have the lastet stable release instead, run::

python setup.py develop
pixi shell --environment prod

This installs avaframe in editable mode, so every time you import avaframe the
current (local) version will be used.

Test it by starting ``python`` and do an ``import avaframe``. If no error comes
up, you are good to go.

If wanted: Integrate conda environment into editor of your choice (i.e. PyCharm, Spyder or any other)

Head over to :ref:`gettingstarted:First run` for the next steps.

Using QGIS from Conda
Using QGIS from with an advanced installation
^^^^^^^^^^^^^^
It is possible to have the script installation and the plugin installed on your machine at the same time.
However, be aware: Depending on your mode of QGis installation (direct installer, conda, OSGeo4W...) your script AvaFrame installation might be overruled.

The steps below install QGis and the Connector plugin in a separate *conda* environment. If the steps above have been followed, this method will result in two script installations where one will be used by QGis and the other can be worked on separately, preventing any overlap.
Assuming you followed the steps above, you should get a working QGis installation by running (it will take a while)::

If you have another QGis installation somewhere, make sure that the AvaFrame plugin is not installed.
To create and activate a new environment, which will contain your installation of QGis open your conda terminal and run::

conda create -n qgis_latest
conda activate qgis_latest

To **install the latest QGIS version**, use::

conda install qgis --channel conda-forge

.. Note::
Conda will always try to install the latest version. If you want to use another version, you need to specify it, e.g.:
pixi shell --environment qgis

``conda install qgis=3.34.11 --channel conda-forge``

Now install the avaframe requirements::

conda install pip numpy cython

Now find the directory where your environment is located. The path should be something like:
``C:\Users\USER\miniconda3\envs\qgis_latest``. Change into it::

cd \miniconda3\envs\qgis_latest

Clone the AvaFrame repository and change into it::

git clone https://github.com/avaframe/AvaFrame.git
cd AvaFrame

.. Note::
This will pull the latest developer version of AvaFrame, if you want the current release version for the plugin,
you need to specify the version, e.g.:

``https://github.com/avaframe/AvaFrame/tree/1.8.3``

Compile the cython com1DFA part and create an editable avaframe version in your environment::

python setup.py build_ext --inplace
pip install -e .

Run QGIS::
An to run QGIS::

qgis

Now you can **install the AvaFrameConnector plugin** via QGIS as per usual (:ref:`installation:Operational Installation`).

AvaFrame should now be installed, and both installations should work and be editable separately. To display the installed version and installation location, use
``pip show avaframe`` in the respective environment, or use the *getVersion* function in the plugin. Note that the script
versions are separate, and changes in one installation will not affect the other.

**Updating QGIS**

To update QGIS to the most recent version, you need to run the following command with the respective environment active::

conda update qgis -c conda-forge
Depending on your mode of QGis installation (direct installer, conda, OSGeo4W...) your script AvaFrame installation
might be overruled...

Now you can **install the AvaFrameConnector plugin** via QGIS as per usual (:ref:`installation:Operational Installation`).
3 changes: 2 additions & 1 deletion docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
First run
---------

Follow these steps to run your first simulation:
Follow these steps to run your first simulation (assuming you finished the advanced installation steps; if you come
back later, make sure to run ``pixi shell`` again to activate the environment):

* change into your ``AvaFrame`` directory (replace [YOURDIR]
with your path from the installation steps)::
Expand Down
29 changes: 4 additions & 25 deletions docs/moduleCom4FlowPy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,12 @@ The motivational background and concepts behind the model, as well as a list of
:ref:`theoryCom4FlowPy:com4FlowPy theory`.


Additional installation requirements and running the code
Running the code
----------------

In order to run :py:mod:`com4FlowPy` you need to separately install the ``rasterio`` package, which is not included in the general AvaFrame requirements.
On Linux distributions inside the ``avaframe_env`` `conda environment
<https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html>`_ it should usually work with:

::

pip install rasterio


Running ``pip install rasterio`` inside the newly created ``avaframe_env`` `conda environment
<https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html>`_
is now (status: December 2024) also the recommended way to install ``rasterio`` on Windows.

If this does not work, alternatively you can try installing ``rasterio`` via ``conda`` from the ``conda-forge`` channel.

Additional (albeit not straight-forward) information can be found on:
- https://rasterio.readthedocs.io/en/stable/installation.html
- https://github.com/conda-forge/rasterio-feedstock

Once the rasterio package is installed you can test :py:mod:`com4FlowPy` by:
1. setting ``avalancheDir = data/avaFlowPy`` inside ``local_avaframeCfg.ini`` in the ``avaframe`` directory (if you don't already hava a ``local_avaFrameCfg.ini`` create it by copying and renaming the ``avaframeCfg.ini`` -- also see :ref:`moduleCom4FlowPy:Configuration`.)
2. running within the ``avaframe`` directory:

::
Generate an environment as described in :ref:`developinstall:Advanced Installation (Linux)` or
:ref:`developinstallwin:Advanced Installation (Windows)`. Once you have a working ``pixi shell``, you can run the
model via::

python runCom4FlowPy.py

Expand Down
84 changes: 82 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
[build-system]
# Cython dependency is optional, see setup.py for details.
# For the package (run-time) dependencies, see setup.cfg.
requires = ["setuptools", "wheel", "numpy", "Cython"]
build-backend = "setuptools.build_meta"
#requires = ["setuptools", "wheel", "numpy", "Cython"]
#build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "avaframe"
description = "The Open Avalanche Framework"
readme = "README.md"
dynamic = ["version"]
license = { text = "EUPL" }
authors = [
{ name = "AvaFrame Contributors", email = "felix@avaframe.org" }
]
urls = { Homepage = "http://avaframe.org" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
requires-python = ">=3.8"
dependencies = [
"numpy",
"matplotlib",
"pyshp",
"scipy",
"cmcrameri",
"seaborn",
"cython",
"pandas",
"shapely",
"configUpdater",
"tabulate",
"deepdiff",
"deepmerge",
"psutil",
"rasterio",
"contextily",
"geopandas",
"fiona"
]

[tool.flake8]
max-line-length = 109
Expand All @@ -11,3 +56,38 @@ extend-ignore = ['E203', 'E501']

[tool.black]
line-length = 109

[tool.hatch.version]
source = "vcs"

[tool.hatch.version.raw-options]
version_scheme = "no-guess-dev"
local_scheme = "node-and-date"

[tool.pixi.workspace]
channels = ["conda-forge/label/qgis_ltr", "https://prefix.dev/conda-forge"]
platforms = ["linux-64", "win-64", "osx-64"]

[tool.pixi.dependencies]
pytest = "*"
setuptools = "*"

[tool.pixi.pypi-dependencies]
#avaframe = { path = "./", editable = true }
# avaframe = "==1.11"

[tool.pixi.feature.dev.pypi-dependencies]
avaframe = { path = "./", editable = true }

[tool.pixi.feature.prod.pypi-dependencies]
avaframe = "*"

[tool.pixi.feature.qgis.dependencies]
qgis = "*"

[tool.pixi.environments]
default = { features = ["dev"], solve-group = "default" }
dev = ["dev"]
prod = ["prod"]
qgis = ["qgis", "dev"]

Loading
Loading