Wildfire Histograms

Wildfire rates for each of the 54 weeks of the year.

In [92]:
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

sns.set_theme(style='darkgrid')
In [93]:
# Wildland Fire Incident Locations data acquired from the National Interagency Fire Center
# https://data-nifc.opendata.arcgis.com/datasets/nifc::wildland-fire-incident-locations/about
gdf = gpd.read_file("../Data/Wildland_Fire_Incident_Locations.geojson")
gdf.head()
Out[93]:
OBJECTID SourceOID ABCDMisc ADSPermissionState ContainmentDateTime ControlDateTime CreatedBySystem IncidentSize DiscoveryAcres DispatchCenterID ... OrganizationalAssessment StrategicDecisionPublishDate CreatedOnDateTime_dt ModifiedOnDateTime_dt IsCpxChild CpxName CpxID SourceGlobalID GlobalID geometry
0 1 7747595 None DEFAULT None None lacocad NaN 0.10 CALACC ... None NaT 2020-02-28 20:52:36+00:00 2020-02-28 20:52:36+00:00 0 None None {6A311ABB-DF4F-4947-B8DD-3900BDA784F6} {48D2C0E2-5E38-4D40-9D5E-066B076C7D98} POINT (-118.18071 33.80898)
1 2 6384391 None DEFAULT None None firecode NaN NaN CAMVIC ... None NaT 2019-07-01 20:10:12+00:00 2019-07-01 20:10:12+00:00 0 None None {1AF2C949-B159-4D8F-8D39-90CB58BC5DD5} {17D2D66A-D451-4592-A172-7B2C860A2CC9} POINT (-117.15390 33.17639)
2 3 1383752 None DEFAULT None None firecode NaN NaN None ... None NaT 2016-06-20 22:39:02+00:00 2016-06-20 22:39:02+00:00 0 None None {1B179EA1-97CE-4699-915B-374754BCBC5B} {60C471FF-3C85-41B4-9135-E7338D7EC90B} POINT (-121.10418 38.83473)
3 4 22499589 None DEFAULT None None cfcad NaN 0.10 CARRCC ... None NaT 2021-11-25 15:24:53+00:00 2021-11-25 15:24:53+00:00 0 None None {E61E387B-4ED7-4971-9604-C5D7391FAF77} {149237EC-A42E-43D6-9318-22207A705DD9} POINT (-117.22859 33.78244)
4 5 23869477 None DEFAULT None None lacocad NaN 0.01 CALACC ... None NaT 2022-11-21 11:28:49+00:00 2022-11-21 11:28:49+00:00 0 None None {AEB6F7A3-A109-4132-9FEB-FB1EE1DF3193} {EF7675E3-D5BE-412A-A6C1-0D63FC7153C8} POINT (-118.30903 33.94181)

5 rows × 95 columns

In [94]:
%%capture --no-stdout
# suppresses pandas warnings

df = pd.DataFrame()
df['Timestamp'] = gdf['FireDiscoveryDateTime']
df['Week/Year'] = df['Timestamp'].apply(lambda x: "%d/%d" % (x.week, x.year))
In [95]:
countdf = df.groupby(['Week/Year']).count()
count_dict = countdf.to_dict()['Timestamp']
week_count = {'2014': [0]*54,
              '2015': [0]*54,
              '2016': [0]*54,
              '2017': [0]*54,
              '2018': [0]*54,
              '2019': [0]*54,
              '2020': [0]*54,
              '2021': [0]*54,
              '2022': [0]*54}

for key, val in countdf.to_dict()['Timestamp'].items():
    year = key[-4:]
    if year in week_count:
        week = int(key[:-5])
        week_count[year][week - 1] = count_dict[key]
In [96]:
fig, ax = plt.subplots(1)
ax.stackplot(list(range(1,55)), *week_count.values(), labels=week_count.keys())
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles[::-1], labels[::-1], title='Year', loc='upper right')

month_ticks = [x * 4.345 - 4.345/2 for x in range(1,13)]
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
plt.xticks(month_ticks, months, rotation=40)
plt.ylabel('Number of Incidents Reported')
plt.tight_layout()
plt.savefig('Incidents_Stacked.png', dpi=300)
In [97]:
mean_year = pd.DataFrame(week_count).mean(axis=1)
for key, val in week_count.items():
    plt.plot(val, color='maroon', alpha=0.2)
plt.plot(mean_year, label='Mean')
plt.legend()
plt.xticks(month_ticks, months, rotation=40)
plt.ylabel('Number of Incidents Reported')
plt.tight_layout()
plt.savefig('Incidents_Mean.png', dpi=300)