API¶
FWF¶
Class to solve the Fire Weather Indices using output from a numerical weather model
-
class
utils.fwf.
FWF
(wrf_file_dir, domain, wrf_model, fbp_mode, initialize)¶ Class to solve the Fire Weather Indices using output from a numerical weather model
- Parameters
wrf_file_dir (str) –
File directory to (zarr) file of WRF met variables to calculate FWI
domain (str) –
the wrf domain tag, examples d03 or d02
wrf_model (str) –
the wrf version, this will be removed i n future version assuming WRFv4 is being used
fbp_mode (boolean) –
True, FBP will be resolved with FWI and both returned
False, Only FWI will be resolved and returned
initialize (boolean) –
True, initializing FWI iterations with default start-up values
False, will search and use yesterdays forecast to initialize the FWI iterations
- Returns
daily_ds (DataSet) – Writes a DataSet (zarr) of daily - FWI indices/codes - Associated Meterology
hourly_ds (DataSet) – Writes a DataSet (zarr) of hourly - FWI indices/codes - Associated Meterology - FBP products (if fbp_mode is True)
-
create_daily_ds
(wrf_ds)¶ Creates a dataset of forecast variables averaged from (1100-1300) local to act as the noon local conditions for daily index/codes calculations
- Parameters
wrf_ds (DataSet) –
- WRF dataset at 4-km spatial resolution and one hour tempolar resolution
- tzdict: dictionary
Dictionary of all times zones in North America and their respective offsets to UTC
- zone_id: in
ID of model domain with hours off set from UTC
- noon: int
1200 local index based on ID
- plus: int
1300 local index based on ID
- minus: int
1100 local index based on ID
- tzone_ds: dataset
Gridded 2D array of zone_id
- Returns
daily_ds – Dataset of daily variables at noon local averaged from (1100-1300) local the averageing was done as a buffer for any frontal passage.
- Return type
DataSet
-
daily
()¶ Writes daily_ds (.zarr) and adds the appropriate attributes to each variable
- Returns
make_dir –
File directory to (zarr) file of todays daily FWI codes
Needed for carry over to intilaze tomorrow’s model run
- Return type
str
-
daily_loop
()¶ Loops through each daily time step and solves daily fwi(s)
- Returns
daily_ds – A xarray DataSet with all the daily FWI codes/indices solved
- Return type
DataSet
-
hourly
()¶ Writes hourly_ds (.zarr) and adds the appropriate attributes to each variable
- Returns
make_dir –
File directory to (zarr) file of todays hourly FWI codes
Needed for carry over to intilaze tomorrow’s model run
- Return type
str
-
hourly_loop
()¶ Loops through each hourly time step and solves hourly fwi(s)
- Returns
daily_ds – A xarray DataSet with all the hourly FWI codes/indices solved
- Return type
DataSet
-
solve_bui
(daily_ds)¶ Calculates the Build up Index at noon local daily and outputs as an xarray
Notes
The dataset of daily variables at noon local are averaged from (1100-1300) local the averageing was done as a buffer for any frontal passage.
- Parameters
daily_ds (DataSet) –
- dataset of daily forecast variables
- P: DataArray
Duff moisture code
- D: DataArray
Drought code
- U: DataArray
Build up index
- Returns
U –
An DataArray of BUI
- Return type
DataArray
-
solve_dc
(daily_ds)¶ Calculates the Drought Code at noon local daily and outputs as an xarray
Notes
The dataset of daily variables at noon local are averaged from (1100-1300) local the averageing was done as a buffer for any frontal passage.
- Parameters
daily_ds (DataSet) –
- dataset of daily forecast variables
- Q_o: DataArray
Initial moisture equivalent of DC, units 0.254 mm
- Q: DataArray
Moisture equivalent of DC, units 0.254 mm
- Q_r: DataArray
Moisture equivalent of DC after rain, units 0.254 mm
- V: DataArray
Potential evapotranspiration, units of 0.254 mm water/day
- D_o: DataArray
Initial DC
- D_r: DataArray
DC after rain
- D: DataArray
Final DC
- H: DataArray
Noon local relative humidity, %
- W: DataArray
Noon local wind, km/hr
- T: DataArray
Noon local temperature, C
- r_o: DataArray
Noon local 24 hour accumulated precipitation
- r_d: DataArray
Effective rain
- L_f: DataArray
Day-length factor
- Returns
daily_ds –
Adds DC dataset
- Return type
DataSet
-
solve_dmc
(daily_ds)¶ Calculates the Duff Moisture Code at noon local daily and outputs as an xarray
Notes
The dataset of daily variables at noon local are averaged from (1100-1300) local the averageing was done as a buffer for any frontal passage.
- Parameters
daily_ds (DataSet) –
- dataset of daily forecast variables
- M_o: DataArray
Initial duff moisture content
- M_r: DataArray
Duff moisture content after rain
- M: DataArray
Final duff moisture content
- P_o: DataArray
Initial DMC
- P_r: DataArray
DMC after rain
- P: DataArray
Final DMC
- b: DataArray
Three coefficient with their own empirical equation for diff range of P_o
- K: DataArray
Log drying rate
- H: DataArray
Noon local relative humidity, %
- W: DataArray
Noon local wind, km/hr
- T: DataArray
Noon local temperature, C
- r_o: DataArray
Noon local 24 hour accumulated precipitation
- r_e: DataArray
Effective rain
- L_e: DataArray
Effective day-lengths
- Returns
daily_ds –
Adds DMC to DataSet
- Return type
DataSet
-
solve_fbp
(hourly_ds)¶ Calculates the hourly fire weather index and daily severity rating
- W: datarray
Wind speed, km/hr
- F: datarray
Fine fuel moisture code
- R: datarray
Initial spread index
- S: datarray
Fire weather index
- DSR: datarray
Daily severity rating
- Returns
S (datarray) –
An datarray of FWI
DSR datarray –
An datarray of DSR
-
solve_ffmc
(hourly_ds)¶ Calculates the Fine Fuel Moisture Code at a one-hour interval writes/outputs as an xarray
- Parameters
hourly_ds (DataSet) –
- Dataset of hourly forecast variables
- m_o: float
Initial fine fuel moisture content
- m: float
Final fine fuel moisture content
- F_o: float
Initial FFMC
- F: float
Final FFMC
- E_d: float
Equilibrium Moisture content for drying
- E_w: float
Equilibrium Moisture content for wetting
- k_a: float
Intermediate steps to k_d
- k_b:float
Intermediate steps to k_w
- k_d:float
Log drying rate for hourly computation, log to base 10
- k_w: float
Log wetting rate for hourly computation, log to base 10
- H: float
Relative humidity, %
- W: float
Wind speed km/hr
- T: float
Temperature, C
- Returns
hourly_ds –
Adds FFMC and m_o dataset
- Return type
DataSet
-
solve_fwi
()¶ Calculates the hourly fire weather index and daily severity rating
- W: datarray
Wind speed, km/hr
- F: datarray
Fine fuel moisture code
- R: datarray
Initial spread index
- S: datarray
Fire weather index
- DSR: datarray
Daily severity rating
- Returns
S (datarray) –
An datarray of FWI
DSR datarray –
An datarray of DSR
-
solve_isi
(hourly_ds, fbp=False)¶ Calculates the hourly initial spread index
- Parameters
hourly_ds (DataSet) –
- Dataset of hourly forecast variables
- W: DataArray
Wind speed, km/hr
- F: DataArray
Fine fuel moisture code
- R: DataArray
Initial spread index
- Returns
R –
Datarray of ISI
- Return type
DataArray
Read WRF NetCDF¶
-
utils.read_wrfout.
readwrf
(filein, domain, *args)¶ This function reads wrfout files and grabs required met variables for fire weather index calculations. Writes/outputs as a xarray
wind speed (km h-1)
temp (degC)
rh (%)
qpf (mm)
snw (mm)
- Parameters
files (str) –
File directory to NetCDF files
- Returns
ds_wrf – xarray DataSet
- Return type
DataSet
Geoutils¶
-
utils.geoutils.
mask
(ds_unmasked, wrf_file_dir)¶ This masks out all lakes, oceans, and snow cover from model domain.
- Parameters
ds_unmasked (DataSet) –
either daily_ds or houlry_ds
wrf_file_dir (str) –
file directory to wrf NetCDF files
/nfs/kitsault/archives/forecasts/WAN00CP-04/YYMMDD00/
- Returns
ds –
masked daily_ds or houlry_ds
- Return type
DataSet
-
utils.geoutils.
mycontourf_to_geojson
(cmaps, var, ds, index, folderdate, colornumber, domain, nested_index)¶ This makes a geojson file from a matplot lib countourf
- Parameters
cmaps (dictionary) –
- contains variable attributes from
colormaps.json
variable name
variable title
contour levels/range
color palette
- contains variable attributes from
var (str) –
variable name
ds (DataSet) –
either daily_ds or houlry_ds
index (int) –
time index
folderdate (str) –
file directory to geojson files
../fwf/data/geojson/YYYYMMDDHH
colornumber (str) –
colors30 or colors15
will provide either 30 or 15 contour levels
- Returns
file –
../fwf/data/geojson/YYYYMMDDHH
- Return type
geojson