Skip to content

24spiders/wisejobbuilder

Repository files navigation

W.I.S.E. Job Builder

(Unofficial) pythonic utilities for creating W.I.S.E. jobs. The code in this package is research-grade, meaning users are encouraged to verify completeness and correctness themselves.

Description

Ever wanted to simulate thousands of wildfires, but need a Pythonic tool to initialize and create thousands of W.I.S.E. jobs?

This package:

  1. ✅ Allows the user to set a variety of W.I.S.E. parameters in Python
  2. ✅ Generates a JavaScript file with the instructions W.I.S.E. uses to generate a job file (.FGMJ)
  3. ✅ Calls W.I.S.E. Builder (passes the generated JavaScript file) to generate a .FGMJ

The resulting .FGMJ files should be usable in both Prometheus and W.I.S.E. for wildfire simulation. This process can be easily looped in this package, allowing for the creation of many .FGMJ files (with different inputs and settings) for later simulation.

Notes

  • This package does not take any credit for or have any official affiliation with W.I.S.E.; it is a simple interface to generate W.I.S.E. jobs pythonically
  • This package is incomplete and does not provide an interface for every aspect / option of W.I.S.E. If you need it, you might have to add it
  • This is research-grade code: correctness, support, robustness, maintenance not guaranteed
  • I am open to any contributions or collaborations

Requirements

Installation

First, you need W.I.S.E. and its components installed and working. Specifically, this package relies on WISE_Builder, WISE_Manager, WISE_JS_API, and WISE.

To install W.I.S.E.:

  1. Download and unzip the latest WISE_Builder release

  2. Download and unzip the latest WISE_Manager release

  3. Download and unzip the latest WISE_JS_API release

    i. Install Node.js

    ii. Navigate to the unzipped WISE_JS_API directory in a command prompt

    iii. npm install

  4. Download and install the latest WISE release

    i. Don't forget, you need all the components the installer lists

You should now be able to start WISE_Builder (needs to be running as this package calls it) by navigating to its directory and calling it with java -jar wise_builder.jar

To install this package:

  1. Clone this repository
  2. Navigate to the directory where it is cloned
  3. Install (in development mode if desired): pip install -e .

Useful Datasets

  • Global Fire Weather Indices - Zenodo
  • ERA5-Land Hourly Weather - CDS
  • National FBP Fuel Type Map - NRCan
  • Medium Resolution DEM (MRDEM) - NRCan

Example

fire_dir must contain the following. example_data.zip in this package contains example files. Unzip first.

  1. a Canadian FBP fuel map (fuelmap.tif)
  2. a DEM (elevation.tif) (NOTE: the fuel map and DEM must be correctly aligned; in the same CRS (preferrably UTM), with matching grids).
  3. an ignition shapefile (ignition.shp)
  4. at least one weather stream: daily_wx_#.csv, where # is a numerical weather station ID that the weather stream belongs to. This file has columns [Daily, Min_Temp, Max_Temp, Min_RH, Min_WS, Max_WS, WD, Precip, FFMC, DMC, DC, ISI, BUI, FWI]. Each row corresponds to one days weather. An example file is included.
  5. a weather stream location file: ws.csv, the # described above is used to look up the weather station location in this file. This file has columns [ws_id, latitude, longitude]. An example file is included.
  6. [optional] fuel patches can be included as .shp files
from wise_job_builder.option_dicts import (
    StartingFWIOptions,
    BurnConditions,
    HFFMCOptions,
    FBPOptions,
    FWIOptions,
    FGMOptions,
    ProbabilisticOptions,
    FMCOptions,
    OutputOptions,
    FuelPatches,
)

from wise_job_builder.utils import make_fuel_patches

from wise_job_builder.make_wise_inputs import make_params, make_wise_job

# %% --- Initialization ---
fire_dir = './example_data/'  # Path to folder containing example data
dates = ('2021-07-30', '2021-07-30')  # Start and end date of the fire, YYYY-MM-DD
wise_jobs_dir = r'D:\Programs\WISE\Jobs'  # Path to your WISE jobs directory
wise_js_api_dir = r'D:\Programs\WISE_JS_API'  # Path to WISE JS API directory
scen_name = 'Scenario0'  # Name of scenario
ignition_buffer = 0  # Can buffer the ignition polygon by this many metres
scenario_times = ('10:00:00', '20:00:00')  # Start fire at 10 AM local time, burn until 8 pm

# %% --- Options ---
fuel_patch_geoms = make_fuel_patches(['./example_data/non_fuel_patch.shp',
                                      './example_data/c2_fuel_patch.shp'])

fuel_patches = FuelPatches(geoms=fuel_patch_geoms,
                           fromFuels=['Mature Jack or Lodgepole Pine',
                                      'ALL_FUELS'],
                           toFuels=['Non-fuel',
                                    'Boreal Spruce'])

# Weather Stations
# # One element in the list for each weather station (otherwise it will use defaults)
hffmc_options_list = [HFFMCOptions(hffmc_value=85,
                                   hffmc_hour=16,
                                   hffmc_method='LAWSON'),
                      HFFMCOptions(hffmc_value=85,
                                   hffmc_hour=16,
                                   hffmc_method='LAWSON'),]

# # One element in the list for each weather station (otherwise it will use defaults)
starting_fwi_list = [StartingFWIOptions(startingFFMC=85,
                                        startingDMC=25,
                                        startingDC=200,
                                        startingPrecip=0),
                     StartingFWIOptions(startingFFMC=85,
                                        startingDMC=25,
                                        startingDC=200,
                                        startingPrecip=0)]

# Burn Conditions
burn_conditions = BurnConditions(startTime=0,
                                 endTime=24,
                                 fwiGreater=0,
                                 wsGreater=0,
                                 rhLess=100,
                                 isiGreater=0)

# FGM Options
fgm_options = FGMOptions(maxAccTS=(0, 2, 0, False),
                         distRes=1,
                         perimRes=1,
                         minimumSpreadingRos=0.1,
                         stopAtGridEnd=False,
                         breaching=False,
                         dynamicSpatialThreshold=False,
                         spotting=False,
                         purgeNonDisplayable=True,
                         growthPercentileApplied=False,
                         growthPercentile=0.1)

# Probabilistic Options
probabilistic_options = ProbabilisticOptions(dx=0,
                                             dy=0,
                                             dt=(0, 0, 0, False))

# FBP Options
fbp_options = FBPOptions(terrainEffect=False,
                         windEffect=True)

# FMC Options
fmc_options = FMCOptions(perOverrideVal=0.5,
                         nodataElev=3000,
                         terrain=False,
                         accurateLocation=False)

# FWI Options
fwi_options = FWIOptions(fwiSpacInterp=True,
                         fwiFromSpacWeather=True,
                         historyOnEffectedFWI=False,
                         burningConditionsOn=False,
                         fwiTemporalInterp=False)

# Output Options
output_options = OutputOptions(mergeContact=False,
                               multPerim=True,
                               removeIslands=False,
                               perimActive=False,
                               outputApplication=True,
                               outputFBP=True,
                               outputFBPPatches=True,
                               outputGeoData=True,
                               outputIgnitions=True,
                               outputInputs=True,
                               outputLandscape=True,
                               outputScenario=True,
                               outputScenarioComments=True,
                               outputWxPatches=True,
                               outputWxStreams=True)


# %% --- Make Parameters ---
params = make_params(fire_dir,
                     dates,
                     wise_jobs_dir,
                     wise_js_api_dir,
                     scen_name=scen_name,
                     ignition_buffer=ignition_buffer,
                     scenario_times=scenario_times,
                     fuel_patches=fuel_patches,
                     hffmc_options_list=hffmc_options_list,
                     starting_fwi_list=starting_fwi_list,
                     burn_conditions=burn_conditions,
                     fgm_options=fgm_options,
                     probabilistic_options=probabilistic_options,
                     fbp_options=fbp_options,
                     fmc_options=fmc_options,
                     fwi_options=fwi_options,
                     output_options=output_options,
                     )

# %% --- Make WISE Job ---
make_wise_job(wise_jobs_dir, params, overwrite=True)  # Must have WISE Builder running!

References

Credit for W.I.S.E. to the W.I.S.E. team

About

Pythonic utilities for creating WISE jobs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages