64 lines
3.1 KiB
Python
64 lines
3.1 KiB
Python
import pandas as pd
|
|
|
|
# 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)'])
|
|
|
|
# Calculate the time difference between consecutive points in minutes
|
|
data['Time Diff (min)'] = data['Date/Time (--4:0:0)'].diff().dt.total_seconds() / 60
|
|
|
|
# Set flow rate and specific heat capacity
|
|
flow_rate_gpm = 10
|
|
density_water = 62.4 # lbm/ft^3
|
|
flow_rate_lbm_min = flow_rate_gpm * 0.133681 * density_water # Convert GPM to lbm/min
|
|
|
|
# Calculate Q (BTU)
|
|
cp_water = 1 # BTU/lbm°F
|
|
data['Delta T (F)'] = data['Sewer Water Out'] - data['Sewer Water In']
|
|
data['Q (BTU)'] = flow_rate_lbm_min * cp_water * data['Delta T (F)'] * data['Time Diff (min)']
|
|
|
|
# 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)'].rolling(window=window_size, center=True).mean()
|
|
|
|
# Plotting the data
|
|
import plotly.graph_objects as go
|
|
from plotly.subplots import make_subplots
|
|
|
|
fig = make_subplots(rows=1, cols=1, shared_xaxes=True, vertical_spacing=0.1,
|
|
subplot_titles=('Temperature Variations and Transferred Heat from 25/06/2024-08/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=2, 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=2, 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=2, 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=2, 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)',
|
|
line=dict(shape='spline', color='purple', width=2, dash='solid')), secondary_y=True)
|
|
|
|
# Update layout with secondary y-axis title
|
|
fig.update_layout(
|
|
xaxis_title='Date/Time',
|
|
yaxis_title='Temperature (F)',
|
|
yaxis2_title='Transferred Heat (BTU)',
|
|
legend_title_text='Legend',
|
|
font=dict(size=14),
|
|
width=1400,
|
|
height=800
|
|
)
|
|
|
|
# Save the plot (requires kaleido package)
|
|
fig.write_image('temperature_variations_with_q.png')
|
|
|
|
# Display the plot
|
|
fig.show() |