From 93bd4edbe9f6308054a548067a4260cc8405f282 Mon Sep 17 00:00:00 2001 From: Payton Thomas Date: Fri, 28 Jan 2022 23:21:07 -0700 Subject: [PATCH] added dynamic temperatures and dewpoint --- model.py | 16 +++++++++++----- test.py | 6 +++--- util.py | 11 ++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/model.py b/model.py index 29f029c..95daaeb 100644 --- a/model.py +++ b/model.py @@ -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 @@ -45,11 +43,9 @@ 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]): @@ -57,6 +53,16 @@ def burnout(self): 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() diff --git a/test.py b/test.py index ed758e8..654565f 100644 --- a/test.py +++ b/test.py @@ -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): @@ -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')) \ No newline at end of file +#plt.imshow(testModel.visualize(),cmap=plt.get_cmap('inferno')) \ No newline at end of file diff --git a/util.py b/util.py index aa6a31d..aa27868 100644 --- a/util.py +++ b/util.py @@ -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