Skip to main content

Python tools for MesoNH-Blaze model

Project description

GitHub tag (latest by date) GitHub issues GitHub license

pyrolib

pyrolib is a tool library for Méso-NH/Blaze model. pyrolib provides python tools for the following purposes:

  • Generation of the FuelMap.nc file by using a Méso-NH namelist and the initialisation file of a Méso-NH/Blaze run.
  • FireFlux I exeprimental fire data processing.
  • Development of numerical methods for the Blaze fire model.

Installation

Install pyrolib from PyPI's:

pip install pyrolib

Usage

pyrolib is separated into several sub-libraries for each of the objectives mentioned above, respectively:

  • pyrolib.fuels
  • pyrolib.firefluxpost
  • pyrolib.blaze

How to

FuelMap.nc file generation

The objective of this part is to easily create a fuel file for a Méso-NH/Blaze run. This file is always named FuelMap.nc. It needs to contain a 2D map on the fire grid for the following fields :

  • fuel type,
  • every fuel property that are compliant with the selected rate of spead parameterization in the Méso-NH/Blaze namelist,
  • ignition time,
  • walking ignition time.

pyrolib.fuels provides tools for the generation of every Fuelmap.nc component. Some Méso-NH files are needed to complete the process. A typical Méso-NH run directory should look like

run_MNH/
├─ EXSEG1.nam
├─ Init_file.des
├─ Init_file.nc

Some Méso-NH files are included in the example directory to run examples.

simplecase.py example provides basic steps to create a fuel map using pyrolib tools. Some operations can be accelerated with numba. pyrolib can check if numba is installed in your environment. If not, pyrolib will show a warning message. In this example, the Méso-NH domain is $(Nx, Ny) = (20, 20)$ with $\Delta_x = \Delta_y = 25$m. The fire mesh is refined with $\Gamma_x = \Gamma_y = 5$. The goal of this example is to set:

  • a rectangle burnable area defined by $50 \leqslant x \leqslant 450$ and $50 \leqslant y \leqslant 450$,
  • an ignition patch is set at $t = 10$s with $100 \leqslant x \leqslant 105$ and $245 \leqslant y \leqslant 255$.

As the rate of spread model defined in the Méso-NH namelist, the BalbiFuel class shall be used to define the fuel properties.

"""simplecase.py
"""
import pyrolib.fuels as pl

# create default Balbi fuel
fuel1 = pl.BalbiFuel()

# create a scenario to store fuel
scenario = pl.Scenario(
    name='test',
    longname='test scenario',
    infos='This is a test scenario',
    )
scenario.add_fuel(fuel1)

# Create FuelMap
fuelmap = pl.FuelMap(scenario=scenario)

# add fuel patch and ignition patch
fuelmap.addRectanglePatch(xpos=[50, 450], ypos=[50, 450], fuelindex=1)
fuelmap.addRectanglePatch(xpos=[100, 105], ypos=[245, 255], ignitiontime=10)

# write FuelMap.nc file and create FuelMap.des
fuelmap.write(save2dfile=True)

After running the script, the directory should contains:

example/
├─ EXSEG1.nam
├─ FuelMap.des
├─ FuelMap.nc
├─ FuelMap2d.nc
├─ Init_file.des
├─ Init_file.nc
├─ simplecase.py

FuelMap2d.nc is an optional file that is easier for human to chack if the generated fuel map respects the requirements.

Create a fuel object

pyrolib contains several fuel objects that represent a fuel description as fuel properties. To show the list of available fuel object, use show_fuel_classes. The following example shows several methods to create a BalbiFuel object. Properties can be either modified in the constructor or set as default.

import pyrolib.fuels as pl

# print fuel classes available and default property values
pl.show_fuel_classes()

# create default fuel
fuel1 = pl.BalbiFuel()

# create default fuel and changes some properties
fuel2 = pl.BalbiFuel(e=2., Md=0.15)

# copy fuel2 and changes some properties
fuel3 = fuel2.copy(DeltaH=20e7, LAI=2)

# change property value after creation
fuel1.Ml.set(0.9)

Manage scenario

pyrolib relies on a fuel container object called a scenario. It can contains several fuels type objects, that can be stored in .yml files and retrieved from .yml files. If no filepath is given to save method, it saves the scenario locally with its own name scenario.name. Several scenrio are already available in the library database. To show the list of available scenario, use show_default_scenario function.

Load a scenario file by using load argument with the filename in the constructor. The filename can be either a local file or a default file present in the pyrolib database.

import pyrolib.fuels as pl

# verbose level
# 0: only fuel name
# 1: name + ROS
# 2: name + ROS + every property value
verbose_level = 2

# create some fuels
fuel1 = pl.BalbiFuel()
fuel2 = pl.BalbiFuel(e=2., Md=0.15)

# create a scenario
scenario = pl.Scenario(
    name='scenario',
    longname='testscenario',
    infos='This is a test scenario'
    )

# add fuels to scenario
scenario.add_fuels(fuel1, fuel2)

# show fuels and no wind/no slope ROS contained in the scenario
scenario.show(verbose=verbose_level)

# save scenario in yml file
scenario.save()

# Create a scenario from existing local file (scenario.yml)
new_scenario = pl.Scenario(load='scenario')
new_scenario.show(verbose=verbose_level)

# Show available default scenario
pl.show_default_scenario()

# Create a scenario from a default file
scenario_from_default = pl.Scenario(load='FireFluxI')
scenario_from_default.show(verbose=verbose_level)

Méso-NH compliance

The current version of pyrolib is compliant with Méso-NH from version 5.4.4 to version 5.5.0.

Acknowledgements

This library is part of the ANR FireCaster project (2017-2021, ANR-16-CE04-0006, FIRECASTER).

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

pyrolib-0.1.2.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

pyrolib-0.1.2-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file pyrolib-0.1.2.tar.gz.

File metadata

  • Download URL: pyrolib-0.1.2.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for pyrolib-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3338cdc3fd806b47bf8b5c6f04b054d95794dbf7aac8a7181466cd0fa4589338
MD5 368e7f6d9465850ffdac11905c6889ba
BLAKE2b-256 0925e6ece2b41faedd9b8d267b3b5b6e3dedbfb622de802fdd5ebec4376bcb41

See more details on using hashes here.

File details

Details for the file pyrolib-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyrolib-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for pyrolib-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 68e2c9c1fc76ccc754c137b94401fd4ad9e3828bd41ade4e769025cd853ec5c3
MD5 9bda435f9507ed0523e148b69af387b4
BLAKE2b-256 bf130c8c1111634ffa181525b21cfda4fda97f88a186847c5e93477bce29b30d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page