Skip to main content

Algorithms and tools python package for Forest Fire Research, Management and Analytics

Project description

Friendly graphical user interface click here

PyPI workflow auto pdoc workflow PyPI Version Python Versions License Downloads Code Style

fire2a-lib python package

Fire Advanced Analyitics research group scriptable knowledge base

  • Novel Algorithms related to landscape risk metrics, spatial decision optimization models, etc.
  • (Cell2) Fire (W) Simulator integration algorithms to facilitating placing firebreaks, measuring forest fire impacts, etc.
  • (Q)GIS algorithms to common tasks related to rasters, polygons, spatial clustering, etc.

Quickstart

Simplest: Use within QGIS

  1. Install QGIS
  2. Open QGIS Python Console
  3. To install, type :
!pip install fire2a-lib
  1. Visit fire2a-lib documentation, example:
from fire2a.downstream_protection_value import digraph_from_messages
digraph = digraph_from_messages('messages01.csv')

Command line usage

  1. Install QGIS
  • 1.A. Simple
  • 1.B. Docker users check qgis container
  • Optional but worth it for Windows: Make QGIS's bundled python folder writable by your user
    • Three alternatives:
    • A. Open File Explorer, go to C:\Program Files\QGIS 3.38.3\apps, right-click Python312 folder [Show more options]\Properties\Security\Edit\Allow Full control\OK
    • B. Open cmd administrator terminal, type:
      icacls "C:\Program Files\QGIS 3.38.3\apps\Python312" /grant %username%:F /T
      
  1. Locate python, prepare environment
  • 2.A. Windows
    • Open OsGeo4W Shell application,
    • Run bin\python-qgis.bat once to configure all environment variables in the current session.
    • Also you could: bin\python-qgis.bat your_script.py
    • Recommended persistent integration
  • 2.B. macOS
    • Open terminal application,
    • Use this python: /Applications/QGIS.app/Contents/MacOS/bin/python (see creating an alias below)
    • TODO: are all environment variables right?
  • 2.C. Linux
    python3 -m venv --system-site-packages qgis_venv
    source qgis_venv/bin/activate
    
  1. Install
python -m pip install fire2a-lib
# also recommended for development: ipython qtconsole jupyterlab
  1. Visit fire2a-lib documentation, example for getting the burn probability from a simulator results directory:
python -m fire2a.cell2fire -vvv --base-raster ../fuels.asc --authid EPSG:25831 --scar-sample Grids/Grids2/ForestGrid03.csv --scar-poly propagation_scars.shp --burn-prob burn_probability.tif

Scripting/Developing tips

  • Check standalone scripting for more info on initializing a headless QGIS environment
  • Usage examples
  • macOS users add a permanent alias, on the terminal app
    echo "alias pythonq='/Applications/QGIS.app/Contents/MacOS/bin/python'" >> ~/.zshrc
    

Interactive

  1. Interactive sessions in IPython, qtconsole, jupyter-lab, or IPyConsole (QGIS plugin) compatible
# Press tab to auto-complete of available modules from IPython
In [1]: from fire2a.<press-tab>
  1. Stop here interactive (colored terminal able):
from IPython.terminal.embed import InteractiveShellEmbed
InteractiveShellEmbed()()
  1. Stop here interactive (no colors):
from IPython import embed
embed()

c. QGIS debugging:

from qgis.PyQt.QtCore import pyqtRemoveInputHook
pyqtRemoveInputHook()
import pdb
pdb.set_trace()
from IPython.terminal.embed import InteractiveShellEmbed
InteractiveShellEmbed()()
  1. Copy and paste the code interactive:
# Select and Copy a whole module from line 1 up -but not included- to 'def main def main(argv=None):' line 
In [2]: %paste

# Choose your args 
In [3]: args = arg_parser.parse_args(['-vvv', '--base-raster', ...

# Skip (reading args from sys.argv o main)
    if argv is sys.argv:
        argv = sys.argv[1:]
    args = arg_parser(argv)

# Ready to run the main interactively (args object ready)

Contributing

Building

Code of Conduct

Everyone interacting in the project's codebases, issue trackers, chat rooms, and fora is expected to follow the PSF Code of Conduct.

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

fire2a_lib-0.3.4.tar.gz (768.8 kB view details)

Uploaded Source

Built Distribution

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

fire2a_lib-0.3.4-py3-none-any.whl (789.1 kB view details)

Uploaded Python 3

File details

Details for the file fire2a_lib-0.3.4.tar.gz.

File metadata

  • Download URL: fire2a_lib-0.3.4.tar.gz
  • Upload date:
  • Size: 768.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for fire2a_lib-0.3.4.tar.gz
Algorithm Hash digest
SHA256 0a7860d4302f364f188784048ca910076b7a1fb071fa3cb6b1af82b399659bb3
MD5 8891abbda2387743b740255e2f1e7d5d
BLAKE2b-256 6b8fb11a82978868593738b07ac28d7a4d68cd87c7bf82b059cac31cf3632318

See more details on using hashes here.

File details

Details for the file fire2a_lib-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: fire2a_lib-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 789.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for fire2a_lib-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0339e9e83fa5bdfa920cc64e837b2abe4469a85a37419a18dc415076e5680721
MD5 bcd8c0bf9d8eab5db709738b57a3f0fb
BLAKE2b-256 4734237368390b3e9d9ae2b78e0a5a7fe11a266241ed353ef47928f08e724dcf

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