feat: first commit

This commit is contained in:
Saeed Ranjbar 2024-07-07 18:53:08 -04:00
commit 6f4c89a756
6 changed files with 3736 additions and 0 deletions

3436
06-25_07-07.csv Normal file

File diff suppressed because it is too large Load Diff

65
daily_plots.py Normal file
View File

@ -0,0 +1,65 @@
import pandas as pd
import plotly.graph_objects as go
# Load the data (assuming you've already loaded and processed it as shown)
data = pd.read_csv('06-25_07-07.csv')
# Convert 'Date/Time (--4:0:0)' column to datetime
data['Date/Time (--4:0:0)'] = pd.to_datetime(data['Date/Time (--4:0:0)'])
# Set the datetime column as the index
data.set_index('Date/Time (--4:0:0)', inplace=True)
# Apply a smoothing function (moving average)
window_size = 10
data['Sewer Water In Smooth'] = data['Sewer Water In'].rolling(window=window_size, center=True).mean()
data['Sewer Water Out Smooth'] = data['Sewer Water Out'].rolling(window=window_size, center=True).mean()
data['Return Air Smooth'] = data['Return Air'].rolling(window=window_size, center=True).mean()
data['Supply Air Smooth'] = data['Supply Air'].rolling(window=window_size, center=True).mean()
# Ensure index is a datetime index for ease of filtering
data.index = pd.to_datetime(data.index)
# Loop through each calendar day and create separate plots
for day in pd.Index(data.index.date).unique():
# Filter data for the current day
day_data = data[data.index.date == day]
# Create the plot for the current day
fig = go.Figure()
fig.add_trace(go.Scatter(x=day_data.index, y=day_data['Sewer Water In Smooth'], mode='lines', name='Sewer Water In',
line=dict(shape='spline', color='blue', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=day_data.index, y=day_data['Sewer Water Out Smooth'], mode='lines', name='Sewer Water Out',
line=dict(shape='spline', color='red', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=day_data.index, y=day_data['Return Air Smooth'], mode='lines', name='Return Air',
line=dict(shape='spline', color='orange', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=day_data.index, y=day_data['Supply Air Smooth'], mode='lines', name='Supply Air',
line=dict(shape='spline', color='green', width=4, dash='solid')))
fig.update_layout(
title=dict(
text=f'Temperature at Inlets and Outlets of the Heat Exchanger - {day}',
font=dict(size=20, family='Arial', color='black', weight='bold')
),
xaxis_title=dict(
text='Date/Time',
font=dict(size=18, family='Arial', color='black', weight='bold')
),
yaxis_title=dict(
text='Temperature (F)',
font=dict(size=18, family='Arial', color='black', weight='bold'),
),
legend=dict(
title=dict(font=dict(size=15, family='Arial', color='black', weight='bold')),
font=dict(size=14, family='Arial', color='black', weight='bold')
),
font=dict(size=14),
width=1400,
height=800
)
# Save the plot (requires kaleido package)
fig.write_image(f'plotly_plot_{day}.png')

44
double_y.py Normal file
View File

@ -0,0 +1,44 @@
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
# Load the data (assuming you've already loaded and processed it as shown)
data = pd.read_csv('06-25_07-07.csv')
# Calculation of Q (BTU / lb)
data['Q (BTU/lb)'] = data['Sewer Water Out'] - data['Sewer Water In']
# Convert 'Date/Time (--4:0:0)' column to datetime
data['Date/Time (--4:0:0)'] = pd.to_datetime(data['Date/Time (--4:0:0)'])
# Apply a smoothing function (moving average)
window_size = 10
data['Sewer Water In Smooth'] = data['Sewer Water In'].rolling(window=window_size, center=True).mean()
data['Sewer Water Out Smooth'] = data['Sewer Water Out'].rolling(window=window_size, center=True).mean()
data['Return Air Smooth'] = data['Return Air'].rolling(window=window_size, center=True).mean()
data['Supply Air Smooth'] = data['Supply Air'].rolling(window=window_size, center=True).mean()
data['Q Smooth'] = data['Q (BTU/lb)'].rolling(window=window_size, center=True).mean()
fig = make_subplots(rows=1, cols=1, shared_xaxes=True, vertical_spacing=0.1,
subplot_titles=(f'Temperature Variations and Transferred Heat from 25/06/2024-07/07/2024',),
specs=[[{"secondary_y": True}]])
fig.add_trace(go.Scatter(x=data['Date/Time (--4:0:0)'], y=data['Sewer Water In Smooth'], mode='lines', name='Sewer Water In',
line=dict(shape='spline', color='blue', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=data['Date/Time (--4:0:0)'], y=data['Sewer Water Out Smooth'], mode='lines', name='Sewer Water Out',
line=dict(shape='spline', color='red', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=data['Date/Time (--4:0:0)'], y=data['Return Air Smooth'], mode='lines', name='Return Air',
line=dict(shape='spline', color='orange', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=data['Date/Time (--4:0:0)'], y=data['Supply Air Smooth'], mode='lines', name='Supply Air',
line=dict(shape='spline', color='green', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=data['Date/Time (--4:0:0)'], y=data['Q Smooth'], mode='lines', name='Transferred Heat (BTU/lb)',
line=dict(shape='spline', color='purple', width=4, dash='solid')), secondary_y=True)
# Update layout
fig.update_layout(
xaxis_title='Date/Time',
yaxis_title='Temperature (F)',
legend_title_text='Legend',
font=dict(size=14),
width=1400,
height=800
)
# Save the plot (requires kaleido package)
fig.write_image('plotly_plot_with_q.png')

55
double_y_daily.py Normal file
View File

@ -0,0 +1,55 @@
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
# Load the data (assuming you've already loaded and processed it as shown)
data = pd.read_csv('06-25_07-07.csv')
# Calculation of Q (BTU / lb)
data['Q (BTU/lb)'] = data['Sewer Water Out'] - data['Sewer Water In']
# Convert 'Date/Time (--4:0:0)' column to datetime
data['Date/Time (--4:0:0)'] = pd.to_datetime(data['Date/Time (--4:0:0)'])
# Apply a smoothing function (moving average)
window_size = 10
data['Sewer Water In Smooth'] = data['Sewer Water In'].rolling(window=window_size, center=True).mean()
data['Sewer Water Out Smooth'] = data['Sewer Water Out'].rolling(window=window_size, center=True).mean()
data['Return Air Smooth'] = data['Return Air'].rolling(window=window_size, center=True).mean()
data['Supply Air Smooth'] = data['Supply Air'].rolling(window=window_size, center=True).mean()
data['Q Smooth'] = data['Q (BTU/lb)'].rolling(window=window_size, center=True).mean()
# Iterate through each calendar day and create separate plots
for day in pd.Index(data['Date/Time (--4:0:0)'].dt.date).unique():
# Filter data for the current day
day_data = data[data['Date/Time (--4:0:0)'].dt.date == day]
# Create subplot figure with secondary y-axis
fig = make_subplots(rows=1, cols=1, shared_xaxes=True, vertical_spacing=0.1,
subplot_titles=(f'Temperature at Inlets and Outlets of the Heat Exchanger and Transferred Heat - {day}',),
specs=[[{"secondary_y": True}]])
# Add traces for each line with spline smoothing and increased visibility
fig.add_trace(go.Scatter(x=day_data['Date/Time (--4:0:0)'], y=day_data['Sewer Water In Smooth'], mode='lines', name='Sewer Water In',
line=dict(shape='spline', color='blue', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=day_data['Date/Time (--4:0:0)'], y=day_data['Sewer Water Out Smooth'], mode='lines', name='Sewer Water Out',
line=dict(shape='spline', color='red', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=day_data['Date/Time (--4:0:0)'], y=day_data['Return Air Smooth'], mode='lines', name='Return Air',
line=dict(shape='spline', color='orange', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=day_data['Date/Time (--4:0:0)'], y=day_data['Supply Air Smooth'], mode='lines', name='Supply Air',
line=dict(shape='spline', color='green', width=4, dash='solid')), secondary_y=False)
fig.add_trace(go.Scatter(x=day_data['Date/Time (--4:0:0)'], y=day_data['Q Smooth'], mode='lines', name='Transferred Heat (BTU/lb)',
line=dict(shape='spline', color='purple', width=4, dash='solid')), secondary_y=True)
# Update layout
fig.update_layout(
xaxis_title='Date/Time',
yaxis_title='Temperature (F)',
legend_title_text='Legend',
font=dict(size=14),
width=1400,
height=800
)
# Save the plot (requires kaleido package)
fig.write_image(f'plotly_plot_{day}.png')

70
main.py Normal file
View File

@ -0,0 +1,70 @@
import pandas as pd
import plotly.graph_objects as go
# Load the data
data = pd.read_csv('06-25_07-07.csv')
# Convert 'Date/Time (--4:0:0)' column to datetime
data['Date/Time (--4:0:0)'] = pd.to_datetime(data['Date/Time (--4:0:0)'])
# Set the datetime column as the index
data.set_index('Date/Time (--4:0:0)', inplace=True)
# Apply a smoothing function (moving average)
window_size = 10
data['Sewer Water In Smooth'] = data['Sewer Water In'].rolling(window=window_size, center=True).mean()
data['Sewer Water Out Smooth'] = data['Sewer Water Out'].rolling(window=window_size, center=True).mean()
data['Return Air Smooth'] = data['Return Air'].rolling(window=window_size, center=True).mean()
data['Supply Air Smooth'] = data['Supply Air'].rolling(window=window_size, center=True).mean()
# Create the plot
fig = go.Figure()
# Add traces for each line with spline smoothing and increased visibility
fig.add_trace(go.Scatter(x=data.index, y=data['Sewer Water In Smooth'], mode='lines', name='Sewer Water In',
line=dict(shape='spline', color='blue', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=data.index, y=data['Sewer Water Out Smooth'], mode='lines', name='Sewer Water Out',
line=dict(shape='spline', color='red', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=data.index, y=data['Return Air Smooth'], mode='lines', name='Return Air',
line=dict(shape='spline', color='orange', width=4, dash='solid')))
fig.add_trace(go.Scatter(x=data.index, y=data['Supply Air Smooth'], mode='lines', name='Supply Air',
line=dict(shape='spline', color='green', width=4, dash='solid')))
# Add shading to separate days
for i in range((data.index[-1] - data.index[0]).days + 1):
start = data.index[0] + pd.Timedelta(days=i)
end = start + pd.Timedelta(days=1)
fig.add_vrect(
x0=start, x1=end,
fillcolor='grey' if i % 2 == 0 else 'white',
opacity=0.1,
line_width=0
)
# Update layout for better styling and to set figure size
fig.update_layout(
title=dict(
text='Temperature Variations from 25/06/2024-07/07/2024',
font=dict(size=20, family='Arial', color='black', weight='bold')
),
xaxis_title=dict(
text='Date/Time',
font=dict(size=18, family='Arial', color='black', weight='bold')
),
yaxis_title=dict(
text='Temperature (F)',
font=dict(size=18, family='Arial', color='black', weight='bold')
),
legend=dict(
title=dict(font=dict(size=15, family='Arial', color='black', weight='bold')),
font=dict(size=14, family='Arial', color='black', weight='bold')
),
font=dict(size=14),
width=1400, # Set the width of the figure
height=800 # Set the height of the figure
)
# Save the plot (requires kaleido package)
fig.write_image('plotly_plot.png')
# Display the plot
fig.show()

66
q_calculation.py Normal file
View File

@ -0,0 +1,66 @@
import pandas as pd
import plotly.graph_objects as go
# Load the data (assuming you've already loaded and processed it as shown)
data = pd.read_csv('06-25_07-07.csv')
# Calculation of Q (BTU / lb)
t_sewer_in = data['Sewer Water In'].to_list()
t_sewer_out = data['Sewer Water Out'].to_list() # corrected column name
q = [t_sewer_out[i] - t_sewer_in[i] for i in range(len(t_sewer_out))]
data['Q (BTU/lb)'] = q
# Convert 'Date/Time (--4:0:0)' column to datetime
data['Date/Time (--4:0:0)'] = pd.to_datetime(data['Date/Time (--4:0:0)'])
# Set the datetime column as the index
data.set_index('Date/Time (--4:0:0)', inplace=True)
# Apply a smoothing function (moving average)
window_size = 10
data['Q Smooth'] = data['Q (BTU/lb)'].rolling(window=window_size, center=True).mean()
# Ensure index is a datetime index for ease of filtering
data.index = pd.to_datetime(data.index)
# Create the plot
fig = go.Figure()
# Add traces for each line with spline smoothing and increased visibility
fig.add_trace(go.Scatter(x=data.index, y=data['Q Smooth'], mode='lines', name='Transferred Heat (BTU/lb)',
line=dict(shape='spline', color='blue', width=4, dash='solid')))
# Add shading to separate days
for i in range((data.index[-1] - data.index[0]).days + 1):
start = data.index[0] + pd.Timedelta(days=i)
end = start + pd.Timedelta(days=1)
fig.add_vrect(
x0=start, x1=end,
fillcolor='grey' if i % 2 == 0 else 'white',
opacity=0.1,
line_width=0
)
# Update layout for better styling and to set figure size
fig.update_layout(
title=dict(
text='Transferred Heat',
font=dict(size=20, family='Arial', color='black', weight='bold')
),
xaxis_title=dict(
text='Date/Time',
font=dict(size=18, family='Arial', color='black', weight='bold')
),
yaxis_title=dict(
text='Energy (BTU/lb)',
font=dict(size=18, family='Arial', color='black', weight='bold')
),
legend=dict(
title=dict(font=dict(size=15, family='Arial', color='black', weight='bold')),
font=dict(size=14, family='Arial', color='black', weight='bold')
),
font=dict(size=14),
width=1400, # Set the width of the figure
height=800 # Set the height of the figure
)
# Save the plot (requires kaleido package)
fig.write_image('heat.png')
# Display the plot
fig.show()