Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/precipitation_box_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/relative_humidity_box_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/satellite_burn_box_plots_capped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/temperature_box_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/wind_direction_box_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/wind_speed_box_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions satelliteBurnPlot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px

def load_and_prepare_burn_data(file_paths):
all_data = []

for file_path in file_paths:
group_number = int(file_path.split('_')[-1].split('.')[0])

year = 2017 + (group_number - 1) // 4
quarter = 'Q' + str(((group_number - 1) % 4) + 1)

df = pd.read_csv(file_path, header=None, names=['hectares_burned'])

df['year'] = year
df['quarter'] = quarter

all_data.append(df)

combined_data = pd.concat(all_data, ignore_index=True)

return combined_data

burn_file_paths = [f'data/training/quarterly-6-by-6/satellite-burn/group_{i}.csv' for i in range(1, 29)] # Files from group_1 to group_10
burn_data = load_and_prepare_burn_data(burn_file_paths)

def create_burn_box_plots(data):

sns.set_style("whitegrid")

plt.figure(figsize=(12, 6))

sns.boxplot(x='quarter', y='hectares_burned', hue='year', data=data, palette='pastel', showfliers=False)

plt.title('Hectares Burned vs Quarters', fontsize=16)
plt.xlabel('Quarter', fontsize=14)
plt.ylabel('Hectares Burned', fontsize=14)


plt.legend(title='Year', bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=12)


plt.ylim(0, 5000)
plt.tight_layout()
plt.savefig('data/satellite_burn_box_plots_capped.png')

# Show the plot
plt.show()


def create_burn_box_plots_interactive(data):
fig = px.box(data, x='quarter', y='hectares_burned', color='year',
labels={'hectares_burned': 'Hectares Burned', 'quarter': 'Quarter'},
title='Hectares Burned vs Quarters')
fig.update_traces(quartilemethod="inclusive") # Or "exclusive", depending on how you want to calculate quartiles
fig.update_layout(yaxis=dict(range=[0, 25000]))
fig.show()


#create_burn_box_plots_interactive(burn_data)
create_burn_box_plots(burn_data)
44 changes: 44 additions & 0 deletions weatherPlot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

def load_and_prepare_data(file_paths):
all_data = []

for file_path in file_paths:
group_number = int(file_path.split('_')[-1].split('.')[0])
year = 2017 + (group_number - 1) // 4
quarter = 'Q' + str(((group_number - 1) % 4) + 1)

df = pd.read_csv(file_path)
df['year'] = year
df['quarter'] = quarter

all_data.append(df)

combined_data = pd.concat(all_data, ignore_index=True)

return combined_data

file_paths = [f'data/training/quarterly-6-by-6/weather/group_{i}.csv' for i in range(1, 25)]
weather_data = load_and_prepare_data(file_paths)

def create_individual_plots(data, parameters):
sns.set_style("whitegrid")

for parameter in parameters:
plt.figure(figsize=(12, 6))
sns.boxplot(x='quarter', y=parameter, hue='year', data=data, palette='pastel')
plt.title(f'{parameter.replace("_", " ").capitalize()} vs Quarters', fontsize=16)
plt.xlabel('Quarter', fontsize=14)
plt.ylabel(parameter.replace("_", " ").capitalize(), fontsize=14)
plt.legend(title='Year', bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=12)
plt.tight_layout()

# Save each plot to a separate file
plt.savefig(f'data/{parameter}_box_plot.png')
plt.close() # Close the plot to free up memory

parameters = ['precipitation', 'temperature', 'relative_humidity', 'wind_direction', 'wind_speed']

create_individual_plots(weather_data, parameters)