Skip to content

Commit

Permalink
added environmental factors to fireSpread
Browse files Browse the repository at this point in the history
  • Loading branch information
Paytonco committed Jan 29, 2022
1 parent 6e23ab9 commit 69574b0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
15 changes: 13 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import util

'''features to add:
temperature dynamics/dewpoint
stochastic elements
-wind speed/direciton
-temperature
-precipitation
-humidity
'''

Expand Down Expand Up @@ -47,9 +55,12 @@ def burnout(self):
for i in range(self.state.shape[0]):
for j in range(self.state.shape[1]):
if self.state[i,j] >= 1:
self.state[i,j] = 0
self.state[i,j] = 0
self.mask[i,j] = 0

def timeStep(self):
self.fireSpread()
self.t += 1
self.t += 1

def visualize(self):
return self.state + (1-self.mask)
16 changes: 10 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import matplotlib.pyplot as plt
import model
import time

initialState = np.zeros((36,88))
initialState[18,44] = 0.1
Expand All @@ -10,17 +9,22 @@
tempLow = np.array([60,56,55,59,61,61,57,58,59,64,65,64,62,57])
precip = np.zeros((14))
wind = np.array([15,16,12,9,13,17,12,15,10,12,10,9,14,13])
humid = np.array([49.2,57.1,55.2,41.5,40.0,44.1,45.1,42.5,45.3,38.1,34.3,35.3,50.0,56.9])
humid = np.array([49.2,57.1,55.2,41.5,40.0,44.1,45.1,42.5,45.3,38.1,34.3,35.3,50.0,56.9])*0.01

testModel = model.firemodel(initialState, tempHigh, tempLow, precip, wind, humid)

plt.figure(1)
plt.imshow(testModel.state, cmap=plt.get_cmap('inferno'))
'''plt.figure(1)
plt.imshow(testModel.visualize(), cmap=plt.get_cmap('inferno'))
plt.show
for i in range(7):
testModel.timeStep()
#print(testModel.state)
plt.figure(i+2)
plt.imshow(testModel.state, cmap=plt.get_cmap('inferno'))
plt.show
plt.imshow(testModel.visualize(), cmap=plt.get_cmap('inferno'))
plt.show'''

for i in range(336):
testModel.timeStep()

plt.imshow(testModel.visualize(),cmap=plt.get_cmap('inferno'))
17 changes: 10 additions & 7 deletions util.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import numpy as np
from scipy.ndimage import convolve

def findKernel(state,wind,humidity,precip):
def findKernel(state,wind,humidity,precip):
kernel = np.zeros((3,3))
kernel[0,0] = wind/15
kernel[0,1] = 0.5
kernel[1,0] = 0.5
kernel[1,2] = 0.5
kernel[2,1] = 0.5

kernel[0,0] = wind/20
kernel[0,1] = wind/40
kernel[1,0] = wind/40
kernel[1,2] = 0.1
kernel[2,1] = 0.1
kernel[1,1] = 1
kernel[2,2] = 0.1
kernel *= humidity
kernel *= (1-precip)
return kernel

def maskConvolve(state,kernel,mask):
Expand Down

0 comments on commit 69574b0

Please sign in to comment.