In [1]:
import numpy as np
import pandas as pd
import datetime
import matplotlib.pyplot as plt
from numpy import diff
from numpy import genfromtxt
from statistics import *
In [2]:
# importing data and converting to celcius
sw42 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\sw4-2_9.19_4.22_2020.csv')
sw42.drop('Host Connect',axis=1,inplace=True)
sw42.drop('Button Down',axis=1,inplace=True)
sw42.drop('EOF',axis=1,inplace=True)
sw42['Date Time, GMT -0500'] = pd.to_datetime(sw42['Date Time, GMT -0500'])
sw42['Temp, (*F)'].astype('float')
sw4_2=sw42.resample('H',on='Date Time, GMT -0500').mean()
sw4_2['Temp, (*F)']=sw4_2.apply(lambda x:((x-32)*5/9))
sw4_2.columns=['Temp, (*C)']
datetime=pd.DataFrame(sw4_2.index)
sw41 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\sw4-1_9.19_11.5_2019.csv')
sw41.drop('Host Connect',axis=1,inplace=True)
sw41.drop('EOF',axis=1,inplace=True)
sw41['Date Time, GMT -0500'] = pd.to_datetime(sw41['Date Time, GMT -0500'])
sw41['Temp, (*F)'].astype('float')
sw4_1=sw41.resample('H',on='Date Time, GMT -0500').mean()
sw41.set_index('Date Time, GMT -0500', inplace=True)
sw4_1['Temp, (*F)']=sw4_1.apply(lambda x:((x-32)*5/9))
sw4_1.columns=['Temp, (*C)'] #sw41 only has data sep-nov
sw22 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\sw2-2_9.19_4.22_2020.csv')
sw22.drop('Host Connect',axis=1,inplace=True)
sw22.drop('EOF',axis=1,inplace=True)
sw22['Date Time, GMT -0500'] = pd.to_datetime(sw22['Date Time, GMT -0500'])
sw22['Temp, (*F)'].astype('float')
sw2_2=sw22.resample('H',on='Date Time, GMT -0500').mean()
sw22.set_index('Date Time, GMT -0500', inplace=True)
sw2_2['Temp, (*F)']=sw2_2.apply(lambda x:((x-32)*5/9))
sw2_2.columns=['Temp, (*C)']
sw21 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\sw2-1_9.19_4.22_2020.csv')
sw21.drop('Host Connect',axis=1,inplace=True)
sw21.drop('EOF',axis=1,inplace=True)
sw21['Date Time, GMT -0500'] = pd.to_datetime(sw21['Date Time, GMT -0500'])
sw21['Temp, (*F)'].astype('float')
sw2_1=sw21.resample('H',on='Date Time, GMT -0500').mean()
sw21.set_index('Date Time, GMT -0500', inplace=True)
sw2_1['Temp, (*F)']=sw2_1.apply(lambda x:((x-32)*5/9))
sw2_1.columns=['Temp, (*C)']
ne42 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\ne4-2_9.19_4.22_2020.csv')
ne42.drop('Host Connect',axis=1,inplace=True)
ne42.drop('EOF',axis=1,inplace=True)
ne42['Date Time, GMT -0500'] = pd.to_datetime(ne42['Date Time, GMT -0500'])
ne42['Temp, (*F)'].astype('float')
ne4_2=ne42.resample('H',on='Date Time, GMT -0500').mean()
ne42.set_index('Date Time, GMT -0500', inplace=True)
ne4_2['Temp, (*F)']=ne4_2.apply(lambda x:((x-32)*5/9))
ne4_2.columns=['Temp, (*C)']
ne41 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\ne4-1_9.19_4.22_2020.csv')
ne41.drop('Host Connect',axis=1,inplace=True)
ne41.drop('EOF',axis=1,inplace=True)
ne41['Date Time, GMT -0500'] = pd.to_datetime(ne41['Date Time, GMT -0500'])
ne41['Temp, (*F)'].astype('float')
ne4_1=ne41.resample('H',on='Date Time, GMT -0500').mean()
ne41.set_index('Date Time, GMT -0500', inplace=True)
ne4_1['Temp, (*F)']=ne4_1.apply(lambda x:((x-32)*5/9))
ne4_1.columns=['Temp, (*C)']
ne22 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\full datasets\ne2-2_9.19_4.22_2020.csv')
ne22.drop('Host Connect',axis=1,inplace=True)
ne22.drop('EOF',axis=1,inplace=True)
ne22.drop('Button Down',axis=1,inplace=True)
ne22['Date Time, GMT -0500'] = pd.to_datetime(ne22['Date Time, GMT -0500'])
ne22['Temp, (*F)'].astype('float')
ne2_2=ne22.resample('H',on='Date Time, GMT -0500').mean()
ne22.set_index('Date Time, GMT -0500', inplace=True)
ne2_2['Temp, (*F)']=ne2_2.apply(lambda x:((x-32)*5/9))
ne2_2.columns=['Temp, (*C)']
ne21 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\ne2-1_9.19_11.5_2019.csv')
ne21.drop('Host Connect',axis=1,inplace=True)
ne21.drop('EOF',axis=1,inplace=True)
ne21['Date Time, GMT -0500'] = pd.to_datetime(ne21['Date Time, GMT -0500'])
ne21['Temp, (*F)'].astype('float')
ne2_1=ne21.resample('H',on='Date Time, GMT -0500').mean()
ne21.set_index('Date Time, GMT -0500', inplace=True)
ne2_1['Temp, (*F)']=ne2_1.apply(lambda x:((x-32)*5/9))
ne2_1.columns=['Temp, (*C)'] #ne21 only has data sep-nov
In [3]:
# data sets with data missing from nov-jan
ne32 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\ne3-2_9.19_11.5_2019.csv')
ne32.drop('Host Connect',axis=1,inplace=True)
ne32.drop('EOF',axis=1,inplace=True)
ne32['Date Time, GMT -0500'] = pd.to_datetime(ne32['Date Time, GMT -0500'])
ne32['Temp, (*F)'].astype('float')
ne3_2=ne32.resample('H',on='Date Time, GMT -0500').mean()
ne32.set_index('Date Time, GMT -0500', inplace=True)
ne3_2['Temp, (*F)']=ne3_2.apply(lambda x:((x-32)*5/9))
ne3_2.columns=['Temp, (*C)']
ne32a = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\ne3-2_1.30_4.22_2020.csv')
ne32a.drop('Host Connect',axis=1,inplace=True)
ne32a.drop('EOF',axis=1,inplace=True)
ne32a['Date Time, GMT -0600'] = pd.to_datetime(ne32a['Date Time, GMT -0600'])
ne32a['Temp, (*F)'].astype('float')
ne3_2a=ne32a.resample('H',on='Date Time, GMT -0600').mean()
ne32a.set_index('Date Time, GMT -0600', inplace=True)
ne3_2a['Temp, (*F)']=ne3_2a.apply(lambda x:((x-32)*5/9))
ne3_2a.columns=['Temp, (*C)']
frames= [ne3_2,ne3_2a]
ne3_2x=pd.concat(frames)
ne31 = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\ne3-1_9.19_11.5_2019.csv')
ne31.drop('Host Connect',axis=1,inplace=True)
ne31.drop('EOF',axis=1,inplace=True)
ne31['Date Time, GMT -0500'] = pd.to_datetime(ne31['Date Time, GMT -0500'])
ne31['Temp, (*F)'].astype('float')
ne3_1=ne31.resample('H',on='Date Time, GMT -0500').mean()
ne31.set_index('Date Time, GMT -0500', inplace=True)
ne3_1['Temp, (*F)']=ne3_1.apply(lambda x:((x-32)*5/9))
ne3_1.columns=['Temp, (*C)']
ne31a = pd.read_csv (r'C:\Users\DanniJo\Documents\Cheesehead\cheesehead data\ne3-1_1.30_4.22_2020.csv')
ne31a.drop('Host Connect',axis=1,inplace=True)
ne31a.drop('EOF',axis=1,inplace=True)
ne31a['Date Time, GMT -0600'] = pd.to_datetime(ne31a['Date Time, GMT -0600'])
ne31a['Temp, (*F)'].astype('float')
ne3_1a=ne31a.resample('H',on='Date Time, GMT -0600').mean()
ne31a.set_index('Date Time, GMT -0600', inplace=True)
ne3_1a['Temp, (*F)']=ne3_1.apply(lambda x:((x-32)*5/9))
ne3_1a.columns=['Temp, (*C)']
frames2= [ne3_1,ne3_1a]
ne3_1x=pd.concat(frames)
#missing middle data
In [4]:
# data frame and plot of temperature data
df= sw4_2.filter(['index'], axis=0)
df.insert(0,'sw4_2',sw4_2['Temp, (*C)'],allow_duplicates=True)
df.insert(1,'sw4_1',sw4_1['Temp, (*C)'],allow_duplicates=True)
df.insert(2,'sw2_2',sw2_2['Temp, (*C)'],allow_duplicates=True)
df.insert(3,'sw2_1',sw2_1['Temp, (*C)'],allow_duplicates=True)
df.insert(4,'ne4_2',ne4_2['Temp, (*C)'],allow_duplicates=True)
df.insert(5,'ne4_1',ne4_1['Temp, (*C)'],allow_duplicates=True)
df.insert(6,'ne3_2',ne3_2x['Temp, (*C)'],allow_duplicates=True)
df.insert(7,'ne3_1',ne3_1x['Temp, (*C)'],allow_duplicates=True)
df.insert(8,'ne2_2',ne2_2['Temp, (*C)'],allow_duplicates=True)
df.insert(9,'ne2_1',ne2_1['Temp, (*C)'],allow_duplicates=True)
#plot of tree temp over time
temp = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw4_2['Temp, (*C)'],color='#8C571E',label='sw4_2',linewidth=1)
plt.plot(sw4_1['Temp, (*C)'],color='#7FD8CF',label='sw4_1',linewidth=1)
plt.plot(sw2_2['Temp, (*C)'],color='black',label='sw2_2',linewidth=1)
plt.plot(sw2_1['Temp, (*C)'],color='#F5A673',label='sw2_1',linewidth=1)
plt.plot(ne4_2['Temp, (*C)'],color='#818FD2',label='ne4_2',linewidth=1)
plt.plot(ne4_1['Temp, (*C)'],color='#93E320',label='ne4_1',linewidth=1)
plt.plot(ne3_2a['Temp, (*C)'],color='#69130e',label='ne3_2',linewidth=1)
plt.plot(ne3_2['Temp, (*C)'],color='#69130e',linewidth=1)
plt.plot(ne3_1a['Temp, (*C)'],color='#d43fcc',label='ne3_1',linewidth=1)
plt.plot(ne3_1['Temp, (*C)'],color='#d43fcc',linewidth=1)
plt.plot(ne2_2['Temp, (*C)'],color='#DE5331',label='ne2_2',linewidth=1)
plt.plot(ne2_1['Temp, (*C)'],color='#DCCB3F',label='ne2_1',linewidth=1)

plt.title('Tree Temperature over Time')
plt.ylabel('Tree Temperature (°C)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.46, 0.64), ncol= 2,prop={"size":9})
plt.rcParams["font.family"] = "serif"
#plt.xlim(left=737320,right=737380)
plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')
plt.show()
In [5]:
# dT/dt temperature tendency calculation: rate of change
sw4_2.index= pd.RangeIndex(stop=5188,name='Index')
A=sw4_2['Temp, (*C)']
a=sw4_2.index
sw42_dTdt = pd.DataFrame(diff(A)/diff(a))
sw4_1.index= pd.RangeIndex(stop=1129,name='Index')
B=sw4_1['Temp, (*C)']
b=sw4_1.index
sw41_dTdt = pd.DataFrame(diff(B)/diff(b))
sw2_2.index= pd.RangeIndex(stop=5188,name='Index')
C=sw2_2['Temp, (*C)']
c=sw2_2.index
sw22_dTdt = pd.DataFrame(diff(C)/diff(c))
sw2_1.index= pd.RangeIndex(stop=5188,name='Index')
D=sw2_1['Temp, (*C)']
d=sw2_1.index
sw21_dTdt = pd.DataFrame(diff(D)/diff(d))
ne4_2.index= pd.RangeIndex(stop=5188,name='Index')
E=ne4_2['Temp, (*C)']
e=ne4_2.index
ne42_dTdt = pd.DataFrame(diff(E)/diff(e))
ne4_1.index= pd.RangeIndex(stop=5188,name='Index')
F=ne4_1['Temp, (*C)']
f=ne4_1.index
ne41_dTdt = pd.DataFrame(diff(F)/diff(f))
ne3_2.index= pd.RangeIndex(stop=1126,name='Index')
G=ne3_2['Temp, (*C)']
g=ne3_2.index
ne32_dTdt = pd.DataFrame(diff(G)/diff(g))
ne3_2a.index= pd.RangeIndex(start=3195,stop=5188,name='Index')
Z=ne3_2a['Temp, (*C)']
z=ne3_2a.index
ne32a_dTdt = pd.DataFrame(diff(Z)/diff(z))
ne3_2x.index= pd.RangeIndex(stop=3119,name='Index')
W=ne3_2x['Temp, (*C)']
w=ne3_2x.index
ne32x_dTdt = pd.DataFrame(diff(W)/diff(w))
ne3_1.index= pd.RangeIndex(stop=1129,name='Index')
H=ne3_1['Temp, (*C)']
h=ne3_1.index
ne31_dTdt = pd.DataFrame(diff(H)/diff(h))
ne3_1a.index= pd.RangeIndex(start=3195,stop=5188,name='Index')
Y=ne3_1a['Temp, (*C)']
y=ne3_1a.index
ne31a_dTdt = pd.DataFrame(diff(Y)/diff(y))
ne3_1x.index= pd.RangeIndex(stop=3119,name='Index')
V=ne3_1x['Temp, (*C)']
v=ne3_1x.index
ne31x_dTdt = pd.DataFrame(diff(V)/diff(v))
ne2_2.index= pd.RangeIndex(stop=5188,name='Index')
I=ne2_2['Temp, (*C)']
i=ne2_2.index
ne22_dTdt = pd.DataFrame(diff(I)/diff(i))
ne2_1.index= pd.RangeIndex(stop=1129,name='Index')
J=ne2_1['Temp, (*C)']
j=ne2_1.index
ne21_dTdt = pd.DataFrame(diff(J)/diff(j))
In [6]:
#dataframe and plot of rate of temperature change
df_roc= sw42.filter(['index'], axis=1)
df_roc.insert(0,'sw4_2',sw42_dTdt,allow_duplicates=True)
df_roc.insert(1,'sw4_1',sw41_dTdt,allow_duplicates=True)
df_roc.insert(2,'sw2_2',sw22_dTdt,allow_duplicates=True)
df_roc.insert(3,'sw2_1',sw21_dTdt,allow_duplicates=True)
df_roc.insert(4,'ne4_2',ne42_dTdt,allow_duplicates=True)
df_roc.insert(5,'ne4_1',ne41_dTdt,allow_duplicates=True)
df_roc.insert(6,'ne3_2',ne32x_dTdt,allow_duplicates=True)
df_roc.insert(7,'ne3_1',ne31x_dTdt,allow_duplicates=True)
df_roc.insert(8,'ne2_2',ne22_dTdt,allow_duplicates=True)
df_roc.insert(9,'ne2_1',ne21_dTdt,allow_duplicates=True)
#plot of rate of temperature change
roc = plt.plot(df=sw42.filter(['index'], axis=0))
plt.plot(sw42_dTdt,color='#8C571E',label='sw4_2',linewidth=1)
plt.plot(sw41_dTdt,color='#7FD8CF',label='sw4_1',linewidth=1)
plt.plot(sw22_dTdt,color='black',label='sw2_2',linewidth=1)
plt.plot(sw21_dTdt,color='#F5A673',label='sw2_1',linewidth=1)
plt.plot(ne42_dTdt,color='#818FD2',label='ne4_2',linewidth=1)
plt.plot(ne41_dTdt,color='#93E320',label='ne4_1',linewidth=1)
plt.plot(ne32a_dTdt,color='#69130e',label='ne3_2',linewidth=1)
plt.plot(ne32_dTdt,color='#69130e',linewidth=1)
plt.plot(ne31a_dTdt,color='#d43fcc',label='ne3_1',linewidth=1)
plt.plot(ne31_dTdt,color='#d43fcc',linewidth=1)
plt.plot(ne22_dTdt,color='#DE5331',label='ne2_2',linewidth=1)
plt.plot(ne21_dTdt,color='#DCCB3F',label='ne2_1',linewidth=1)
plt.title('Rate of Tree Temperature Change over Time')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('September 2019-April 2020')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.52,0),ncol=5,prop={"size":9})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
#plt.xlim(left=100,right=196)
plt.ylim(bottom=-7)
plt.show()
In [7]:
# mean dTdt per tree
meandTdt= [-sw42_dTdt.mean(axis=0),-sw41_dTdt.mean(axis=0),-sw22_dTdt.mean(axis=0),-sw21_dTdt.mean(axis=0),-ne42_dTdt.mean(axis=0),-ne41_dTdt.mean(axis=0),-ne32x_dTdt.mean(axis=0),-ne31x_dTdt.mean(axis=0),-ne22_dTdt.mean(axis=0),-ne21_dTdt.mean(axis=0)]
names=['sw4_2','sw4_1','sw2_2','sw2_1','ne4_2','ne4_1','ne3_2','ne3_1','ne2_2','ne2_1']
mean_dTdt=pd.DataFrame(meandTdt)
mean_dTdt.columns=['dTdt (*C)']
mean_dTdt.index=names
mean_dTdt
Out[7]:
dTdt (*C)
sw4_2 0.002193
sw4_1 0.018465
sw2_2 0.003109
sw2_1 0.001976
ne4_2 0.002832
ne4_1 0.002957
ne3_2 0.005725
ne3_1 0.005725
ne2_2 0.003587
ne2_1 0.022871
In [8]:
# mean dTdt per area
dTdtsw4=-(((sw42_dTdt.mean(axis=0))+(sw41_dTdt.mean(axis=0)))/2)
dTdtsw2=-(((sw22_dTdt.mean(axis=0))+(sw21_dTdt.mean(axis=0)))/2)
dTdtne4=-(((ne42_dTdt.mean(axis=0))+(ne41_dTdt.mean(axis=0)))/2)
dTdtne3=-(((ne32x_dTdt.mean(axis=0))+(ne31x_dTdt.mean(axis=0)))/2)
dTdtne2=-(((ne22_dTdt.mean(axis=0))+(ne21_dTdt.mean(axis=0)))/2)
areameandTdt=[dTdtsw4,dTdtsw2,dTdtne4,dTdtne3,dTdtne2]
areamean_dTdt=pd.DataFrame(areameandTdt)
names2=['sw4','sw2','ne4','ne3','ne2']
areamean_dTdt.index=names2
areamean_dTdt.columns=['dTdt (*C)']
areamean_dTdt
Out[8]:
dTdt (*C)
sw4 0.010329
sw2 0.002543
ne4 0.002895
ne3 0.005725
ne2 0.013229
In [9]:
# sw4 - hardwood deciduous
sw4 = genfromtxt(r'C:\Users\DanniJo\Documents\Cheesehead\canopy\canopy_sw4.csv',delimiter=',')
sw4 = sw4.astype('float64') 
sw4=sw4.reshape(10201, )
sw4=sw4.tolist()
#now the average height
sw4_totalheight=0
sw4_heightcount=0
for height in (sw4):
        if float(height)>2:
            sw4_totalheight=sw4_totalheight+height
            sw4_heightcount=sw4_heightcount+1  
sw4meanheight = (sw4_totalheight/sw4_heightcount)
#height to biomass
d_b1Ht=4.183
d_b2Ht=0.4558
d_b1Bs=0.1987
d_b2Bs=2.2044
sw4DBH = (sw4meanheight/d_b1Ht)**(1/d_b2Ht)
sw4biomass = d_b1Bs*(sw4DBH**(d_b2Bs))
#biomass to heat storage per area
cp=1500  #specific heat in J/kg*C
sw4dTdt= (dTdtsw4/3600) # *C per hour --> seconds
sw4heatstorage = sw4biomass*cp*sw4dTdt
#heatstorage units = watts per m^2
In [10]:
# sw2 - hardwood deciduous
sw2 = genfromtxt(r'C:\Users\DanniJo\Documents\Cheesehead\canopy\canopy_sw2.csv',delimiter=',')
sw2 = sw2.astype('float64') 
sw2=sw2.reshape(10201, )
sw2=sw2.tolist()
#now the average height
sw2_totalheight=0
sw2_heightcount=0
for height in (sw2):
        if float(height)>2:
            sw2_totalheight=sw2_totalheight+height
            sw2_heightcount=sw2_heightcount+1  
sw2meanheight = (sw2_totalheight/sw2_heightcount)
#height to biomass
d_b1Ht=4.183
d_b2Ht=0.4558
d_b1Bs=0.1987
d_b2Bs=2.2044
sw2DBH = (sw2meanheight/d_b1Ht)**(1/d_b2Ht)
sw2biomass = d_b1Bs*(sw2DBH**(d_b2Bs))
#biomass to heat storage per area
cp=1500  #specific heat
sw2dTdt= (dTdtsw2/3600) # *C per hour --> seconds
sw2heatstorage = sw2biomass*cp*sw2dTdt
#watts per m^2
In [11]:
# ne4 - conifer
ne4 = genfromtxt(r'C:\Users\DanniJo\Documents\Cheesehead\canopy\canopy_ne4.csv',delimiter=',')
ne4 = ne4.astype('float64') 
ne4=ne4.reshape(10201, )
ne4=ne4.tolist()
#now the average height
ne4_totalheight=0
ne4_heightcount=0
for height in (ne4):
        if float(height)>2:
            ne4_totalheight=ne4_totalheight+height
            ne4_heightcount=ne4_heightcount+1  
ne4meanheight = (ne4_totalheight/ne4_heightcount)
#height to biomass
c_b1Ht=3.6337
c_b2Ht=0.5213
c_b1Bs=0.0775
c_b2Bs=2.3233
ne4DBH = (ne4meanheight/c_b1Ht)**(1/c_b2Ht)
ne4biomass = c_b1Bs*(ne4DBH**(c_b2Bs))
#biomass to heat storage per area
cp=1500  #specific heat
ne4dTdt= (dTdtne4/3600) # *C per hour --> seconds
ne4heatstorage = ne4biomass*cp*ne4dTdt
#watts per m^2
In [12]:
# ne3 - hardwood deciduous
ne3 = genfromtxt(r'C:\Users\DanniJo\Documents\Cheesehead\canopy\canopy_ne3.csv',delimiter=',')
ne3 = ne3.astype('float64') 
ne3=ne3.reshape(10201, )
ne3=ne3.tolist()
#now the average height
ne3_totalheight=0
ne3_heightcount=0
for height in (ne3):
        if float(height)>2:
            ne3_totalheight=ne3_totalheight+height
            ne3_heightcount=ne3_heightcount+1  
#ne3_meanheight = (ne3_totalheight/ne3_heightcount)
ne3meanheight = (ne3_totalheight/ne3_heightcount)
ne3meanheight
#height to biomass
d_b1Ht=4.183
d_b2Ht=0.4558
d_b1Bs=0.1987
d_b2Bs=2.2044
ne3DBH = (ne3meanheight/d_b1Ht)**(1/d_b2Ht)
ne3biomass = d_b1Bs*(ne3DBH**(d_b2Bs))
#biomass to heat storage per area
cp=1500  #specific heat
ne3dTdt= (dTdtne3/3600) # *C per hour --> seconds
ne3heatstorage = ne3biomass*cp*ne3dTdt
 #watts per m^2
In [13]:
# ne2 - conifer
ne2 = genfromtxt(r'C:\Users\DanniJo\Documents\Cheesehead\canopy\canopy_ne2.csv',delimiter=',')
ne2 = ne2.astype('float64') 
ne2=ne2.reshape(10201, )
ne2=ne2.tolist()
#now the average height
ne2_totalheight=0
ne2_heightcount=0
for height in (ne2):
        if float(height)>2:
            ne2_totalheight=ne2_totalheight+height
            ne2_heightcount=ne2_heightcount+1  
#ne2_meanheight = (ne2_totalheight/ne2_heightcount)
ne2meanheight = (ne2_totalheight/ne2_heightcount)
ne2meanheight
#height to biomass
c_b1Ht=3.6337
c_b2Ht=0.5213
c_b1Bs=0.0775
c_b2Bs=2.3233
ne2DBH = (ne2meanheight/c_b1Ht)**(1/c_b2Ht)
ne2biomass = c_b1Bs*(ne2DBH**(c_b2Bs))
#biomass to heat storage per area
cp=1500  #specific heat
ne2dTdt= (dTdtne2/3600) # *C per hour --> seconds
ne2heatstorage = ne2biomass*cp*ne2dTdt
#watts per m^2
In [14]:
#dataframe of heat storage per m^2
hs= [sw4heatstorage,sw2heatstorage,ne4heatstorage,ne3heatstorage,ne2heatstorage]
hsdf=pd.DataFrame(hs)
names2=['sw4','sw2','ne4','ne3','ne2']
hsdf.index=names2
hsdf.columns=['Heat Storage (W/m^2)']
hsdf
Out[14]:
Heat Storage (W/m^2)
sw4 0.138972
sw2 0.008430
ne4 0.016051
ne3 0.097321
ne2 0.017279
In [15]:
sw4hs=(sw4biomass*cp*(((sw41_dTdt+sw42_dTdt)/2)/3600))
plt.plot(sw4hs,c='gray',linewidth=1)
plt.title('Heat Storage over Time- sw4')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('September-November 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(top=40,bottom=-20)
plt.xlim(left=0,right=1000)
plt.show()
In [16]:
sw2hs=(sw2biomass*cp*(((sw21_dTdt+sw22_dTdt)/2)/3600))
plt.plot(sw2hs,c='gray',linewidth=1)
plt.title('Heat Storage over Time- sw2')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('September-November 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(top=40,bottom=-20)
plt.xlim(left=0,right=1000)
plt.show()
In [17]:
ne4hs=(ne4biomass*cp*(((ne41_dTdt+ne42_dTdt)/2)/3600))
plt.plot(ne4hs,c='gray',linewidth=1)
plt.title('Heat Storage over Time- ne4')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('September-November 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(top=40,bottom=-20)
plt.xlim(left=0,right=1000)
plt.show()
In [18]:
ne3hs=(ne3biomass*cp*(((ne31_dTdt+ne32_dTdt)/2)/3600))
plt.plot(ne3hs,c='gray',linewidth=1)
plt.title('Heat Storage over Time- ne3')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('September-November 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(top=40,bottom=-20)
plt.xlim(left=0,right=1000)
plt.show()
In [19]:
ne2hs=(ne2biomass*cp*(((ne21_dTdt+ne22_dTdt)/2)/3600))
plt.plot(ne2hs,c='gray',linewidth=1)
plt.title('Heat Storage over Time- ne2')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('September-November 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(top=40,bottom=-20)
plt.xlim(left=0,right=1000)
plt.show()
In [20]:
hsplot=plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw4hs,c='#067BC2',linewidth=1,label='sw4',zorder=0)
plt.plot(sw2hs,c='#84BCDA',linewidth=1,label='sw2',zorder=15)
plt.plot(ne4hs,c='#ECC30B',linewidth=1,label='ne4',zorder=10)
plt.plot(ne3hs,c='#F37748',linewidth=1,label='ne3',zorder=5)
plt.plot(ne2hs,c='#D56062',linewidth=1,label='ne2',zorder=20)
plt.legend()
plt.legend(ncol=2,prop={"size":9})
plt.xlim(left=0,right=1000)
plt.title('Heat Storage over Time')
plt.ylabel('Heat Storage (W/m^2)')
plt.xlabel('Sep-Nov 2019')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.show()
In [21]:
# % of energy budget
maxs=[sw4hs.max(),sw2hs.max(),ne4hs.max(),ne3hs.max(),ne2hs.max()]
mins=[sw4hs.min(),sw2hs.min(),ne4hs.min(),ne3hs.min(),ne2hs.min()]
names7=['sw4','sw2','ne4','ne3','ne2']
pc=pd.DataFrame(maxs)
pc.insert(1,'min heat storage',mins)
pc.index=names7
perc=[(sw4hs.max()/2),(sw2hs.max()/2),(ne4hs.max()/2),(ne3hs.max()/2),(ne2hs.max()/2)]
pc.insert(2,'%oftot',perc)
pc
Out[21]:
0 min heat storage %oftot
sw4 42.813189 0 -18.65018 dtype: float64 0 21.406595 dtype: float64
sw2 19.014244 0 -8.162118 dtype: float64 0 9.507122 dtype: float64
ne4 30.580331 0 -8.526196 dtype: float64 0 15.290165 dtype: float64
ne3 24.278023 0 -20.874378 dtype: float64 0 12.139011 dtype: float64
ne2 2.311087 0 -1.813397 dtype: float64 0 1.155544 dtype: float64
In [22]:
dbhh= [sw4DBH,sw2DBH,ne4DBH,ne3DBH,ne2DBH]
dbhs= pd.DataFrame(dbhh)
dbhs
Out[22]:
0
0 10.068109
1 5.333147
2 9.160114
3 11.194492
4 4.916493
In [23]:
# everything after this is just experimenting and stuff
In [24]:
diamroc = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw42_dTdt,color='#69130e',label='sw4_2',linewidth=1,zorder=14)
plt.plot(sw41_dTdt,color='#69130e',label='sw4_1',linewidth=1,zorder=15)
plt.plot(sw22_dTdt,color='#F5A673',label='sw2_2',linewidth=1,zorder=20)
plt.plot(sw21_dTdt,color='#818FD2',label='sw2_1',linewidth=1,zorder=4)
plt.plot(ne42_dTdt,color='#818FD2',label='ne4_2',linewidth=1,zorder=0)
plt.plot(ne41_dTdt,color='#818FD2',label='ne4_1',linewidth=1,zorder=1)
plt.plot(ne32a_dTdt,color='#69130e',label='ne3_2',linewidth=1,zorder=16)
plt.plot(ne32_dTdt,color='#69130e',linewidth=1,zorder=17)
plt.plot(ne31a_dTdt,color='#818FD2',label='ne3_1',linewidth=1,zorder=2)
plt.plot(ne31_dTdt,color='#818FD2',linewidth=1,zorder=3)
plt.plot(ne22_dTdt,color='#DE5331',label='ne2_2',linewidth=1,zorder=22)
plt.plot(ne21_dTdt,color='#DE5331',label='ne2_1',linewidth=1,zorder=23)
plt.title('Rate of Tree Temperature Change over Time')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.xlim(left=100,right=600)
plt.show()
In [25]:
roc20_24 = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(ne42_dTdt,color='#ECC30B',label='ne4_2',linewidth=1,zorder=0)
plt.plot(ne41_dTdt,color='#F37748',label='ne4_1',linewidth=1,zorder=5)
plt.plot(ne31a_dTdt,color='#067BC2',label='ne3_1',linewidth=1,zorder=11)
plt.plot(ne31_dTdt,color='#067BC2',linewidth=1,zorder=10)

plt.title('Temperature ROC in 20-24" diameter Trees')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(bottom=-3,top=8)
plt.show()
In [26]:
roc8_10 = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw42_dTdt,color='#8C571E',label='sw4_2',linewidth=1)
plt.plot(sw41_dTdt,color='#7FD8CF',label='sw4_1',linewidth=1)
plt.plot(ne32_dTdt,color='#69130e',linewidth=1)
plt.plot(ne32a_dTdt,color='#69130e',label='ne3_2',linewidth=1)
plt.title('Tree Temperature ROC in 8-10 in diameter Trees')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(bottom=-3,top=8)
plt.show()
In [27]:
roc16_18 = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw22_dTdt,color='#8C571E',label='sw2_2',linewidth=1,zorder=10)
plt.plot(sw21_dTdt,color='#7FD8CF',label='sw2_1',linewidth=1,zorder=0)
plt.title('Tree Temperature ROC in 16-18 in diameter Trees')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
#plt.xticks([])
plt.ylim(bottom=-3,top=8)
plt.show()
In [28]:
roc5_6 = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(ne22_dTdt,color='#DE5331',label='ne2_2',linewidth=1)
plt.plot(ne21_dTdt,color='#DCCB3F',label='ne2_1',linewidth=1)
plt.title('Tree Temperature ROC in 5-6 in diameter Trees')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.ylim(bottom=-3,top=8)
plt.show()
In [29]:
ranges= np.array([((sw42_dTdt.max())-(sw42_dTdt.min())),((sw41_dTdt.max())-(sw41_dTdt.min())),((sw22_dTdt.max())-(sw22_dTdt.min())),((sw21_dTdt.max())-(sw21_dTdt.min())),((ne42_dTdt.max())-(ne42_dTdt.min())),((ne41_dTdt.max())-(ne41_dTdt.min())),((ne32_dTdt.max())-(ne32_dTdt.min())),((ne32a_dTdt.max())-(ne32a_dTdt.min())),((ne31_dTdt.max())-(ne31_dTdt.min())),((ne31a_dTdt.max())-(ne31a_dTdt.min())),((ne22_dTdt.max())-(ne22_dTdt.min())),((ne21_dTdt.max())-(ne21_dTdt.min()))])
stds= np.array([sw42_dTdt.std(),sw41_dTdt.std(),sw22_dTdt.std(),sw21_dTdt.std(),ne42_dTdt.std(),ne41_dTdt.std(),ne32_dTdt.std(),ne32a_dTdt.std(),ne31_dTdt.std(),ne31a_dTdt.std(),ne22_dTdt.std(),ne21_dTdt.std()])
ds= np.array([8,10,16,18,20,24,8,8,20,20,6,5])
plt.scatter(ds,ranges)
plt.title('Temperature Tendency Range vs Tree Diameter')
plt.ylabel('Range of Temperature ROC (°C/hour)')
plt.xlabel('Diameter (in)')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.rcParams["font.family"] = "serif"
ne21_dTdt.std()
Out[29]:
0    0.32387
dtype: float64
In [30]:
aspenroc = plt.plot(df=sw4_2.filter(['index'], axis=0))
plt.plot(sw22_dTdt,color='black',label='sw2_2',linewidth=1)
plt.plot(sw21_dTdt,color='#F5A673',label='sw2_1',linewidth=1)
plt.plot(ne32_dTdt,color='#69130e',linewidth=1)
plt.plot(ne32a_dTdt,color='#69130e',label='ne3_2',linewidth=1)
plt.plot(ne22_dTdt,color='#DE5331',label='ne2_2',linewidth=1)

plt.title('Tree Temperature ROC over Time in Aspen')
plt.ylabel('Rate of Temperature Change (°C/hour)')
plt.xlabel('Time')
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend()
plt.legend(loc="lower center", bbox_to_anchor=(0.5,0),ncol=5,prop={"size":8})
plt.rcParams["font.family"] = "serif"
plt.xticks([])
plt.show()