Part 3 - Using Driver Data in a Test#
Generating a time-series functional test#
So far, we tested single-step behaviors of Fuel methods. In this chapter, we’ll examine how fuel properties evolve over time when subjected to changing environmental conditions, like temperature, humidity, and wind.
This simulates a small slice of a fire model without running a full CESM/FATES simulation.
Goals#
Test
Fuelmethods over multiple timesteps using input weather data.Observe trends over time
Exercise 3.1: Read in driver data and initialize FireWeather class#
We will read in some weather data that can help us drive our test. By using this data, we have known conditions that we can test, rather than relying on the overal Earth system model to produce this weather data.
from fire_model.testing.testing_shr import read_weather_data
# read in data
temp, precip, RH, wind = read_weather_data("../data/weather_data.csv")
We will use this data to drive our functional test using the FireWeather class.
from fire_model import NesterovFireWeather
fire_weather = NesterovFireWeather()
Exercise 3.2: Initialize some fuel objects#
As before, we will set up a handful of fuels objects using our synthetic fuel array.
from fire_model import FireParams
from fire_model.testing import FuelModelsArray
# get fire parameters
params = FireParams.from_yaml("../parameter_files/fire_parameters.yaml")
# get synthetic fuel model array
all_synthetic_fuels = FuelModelsArray()
# use these fuel models
fuel_models = [102, 183, 164, 104, 163]
fuel_model_names = ["low load dry climate grass", "moderate load conifer litter",
"dwarf conifer with understory", "moderate load dry climate grass",
"moderate load humid climate timber-grass-shrub"]
Use what you learned in the previous code to set up the fuel models:
Initialize each fuel object.
Use the
initialize_from_syntheticmethod to populate the correct attributes for each fuel object.
from fire_model.testing import initialize_from_synthetic
from fire_model import Fuel
fuels = []
for fuel_model in fuel_models:
# TODO: set up fuel objects
Cell In[4], line 6
# TODO: set up fuel objects
^
SyntaxError: incomplete input
Exercise 3.3: Calculate fuel moisture#
Next use the fire_weather.update_index method to calculate the Nesterov Index
for each day in the weather data. Save the Nesterov Index (fire_weather.fire_weather_index)
so we can plot it. Additionally, use the fuel.update_fuel_moisture method to calculate fuel moisture.
Save the average_moisture_notrunks attribute for plotting later.
import numpy as np
n_days = len(temp)
nesterov_index = []
moisture = {fmodel: [] for fmodel in fuel_models}
# TODO: calculate Nesterov Index and fuel moisture for each day in weather data
# for i in range(n_days):
Now plot the output. Plot both the Nesterov Index and the different fuel moisture values each fuel object.
import matplotlib.pyplot as plt
# TODO: plot output
Exercise 3.4: Compute additional attributes#
Now let’s calculate potential fraction burnt and fire residence time based on the moisture.
Loop through the weather data again as before and calculate Nesterov Index and fuel moisture,
as well as implementing the calculate_fraction_burnt and calculate_residence_time methods. Save the residence time output.
# TODO: calculate fraction burnt and residence time (tau_l)
Again plot the residence time output alongside your moisture and Nesterov Index plots. What patterns do you see?
Additional exercises#
Humidity spike: Add a day with very high RH (90%). How do frac_burnt and residence time respond?
Long dry spell: Set RH = 0% for several days. How does moisture and residence time respond?
What We Just Did#
Time-series functional tests help to understand patterns over time without having to run the entire model.
The approach can scale to multiple fuels, multiple timesteps, or even partial integration tests without running a full simulation.
Looking Ahead#
Next we will:
Use a functional test to identify and diagnose a potential error in our code.