Skip to content

Commit

Permalink
added dynamic temperatures and dewpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Paytonco committed Jan 29, 2022
1 parent 69574b0 commit 93bd4ed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
16 changes: 11 additions & 5 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
'''


#initialState: initial fire state matrix
#tempHigh: vector of high temperatures over the next 14 days
#tempLow: vector of low temperatures over the next 14 days
Expand Down Expand Up @@ -45,18 +43,26 @@ def __init__(self, initialState, tempHigh, tempLow, precip, wind, humid, density
self.precip = precip[0]
self.mask = np.ones(initialState.shape)
def fireSpread(self):
kernel = util.findKernel(self.state, self.wind, self.humid, self.precip) #calculate kernel for convolution
kernel = util.findKernel(self.state, self.wind, self.humid, self.precip, self.temp) #calculate kernel for convolution
self.state = util.maskConvolve(self.state, kernel, self.mask) #convolve but skipping burnt out cells
self.burnout() #check if any regions are over 100% burned

#need to add sensitivity to wind, humidity, and preciptiation

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.mask[i,j] = 0

def updateTemp(self):
day, hour = util.dayTime(self.t)
highT = self.tempHighs[day]
lowT = self.tempLows[day]
lowT_new = self.tempLows[day+1]
if hour < 8:
self.temp = lowT + hour * (highT - lowT)/8
else:
self.temp = highT + (hour - 8) * (lowT_new - highT)/16

def timeStep(self):
self.fireSpread()
Expand Down
6 changes: 3 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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

'''plt.figure(1)
plt.figure(1)
plt.imshow(testModel.visualize(), cmap=plt.get_cmap('inferno'))
plt.show
for i in range(7):
Expand All @@ -22,9 +22,9 @@

plt.figure(i+2)
plt.imshow(testModel.visualize(), cmap=plt.get_cmap('inferno'))
plt.show'''
plt.show

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

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

def findKernel(state,wind,humidity,precip):
def dayTime(time):
day = math.floor(time/24)
hour = time % 24
return (day, hour)

def findKernel(state,wind,humidity,precip,temp):
kernel = np.zeros((3,3))
if temp <= 51.61:
kernel[1,1] = 1
return kernel
kernel[0,0] = wind/20
kernel[0,1] = wind/40
kernel[1,0] = wind/40
Expand Down

0 comments on commit 93bd4ed

Please sign in to comment.