Page 1 of 1

Exporting Operative Temperature to Match VistaPro

Posted: Sat Jul 06, 2024 9:19 am
by RossThompson87
Hi,

I am working on a script to extract hourly figures for the variable "Operative temperature (TM 52/CIBSE)" from an APS file so it matches the output from VistaPro.

The first obstacle I hit was that VistaPro seems to post process the impact of the air speed. So in the APS file "Dry Resultant Temperature", "Operative Temperature (ASHRAE)" and "Operative Temperature (TM52/CIBSE)" are identical, is this correct?
However for this project the air speed is low so this isn't a problem.

The script I have developed below works perfectly in Winter, but there is a Mismatch with the VistaPro figures between May and September. Does the Operative temperature get post processed differently in Summer? Could daylight saving also be causing an issue?

As general feedback could overheating comfort settings not get fixed into the APS files?

Thanks in advance for the help!
import sys
import iesve
from ies_file_picker import IesFilePicker
import pandas as pd
import os
from datetime import datetime

# Pick an aps file name
aps_name = IesFilePicker.pick_vista_file([("APS files", "*.aps")], "Select an APS file")
# Open the aps file for reading
aps_file = iesve.ResultsReader.open(aps_name)

# Get a list of real model bodies
project = iesve.VEProject.get_current_project()
realmodel = project.models[0]
bodies = realmodel.get_bodies(False)

# Initialize a list to store the results
results = []

# Iterate through the bodies
for body in bodies:
# Setup a list of body types we do not want to query
unwanted_subtypes = [iesve.VEBody_subtype.void, iesve.VEBody_subtype.ra_plenum, iesve.VEBody_subtype.sa_plenum]
# Now avoid the body types we do not want
if (body.type != iesve.VEBody_type.room or body.subtype in unwanted_subtypes):
continue

# Get the body data object
bodydata = body.get_room_data(0)

# Get room data
room_data = bodydata.get_general()
room_name = room_data['name']
room_id = room_data['id']

# Get operative temperature data using room id
try:
operative_temp_data = aps_file.get_room_results(room_id, 'Room air temperature&Room radiant temperature', 'Operative temperature (TM 52/CIBSE)', 'z', start_day=-1, end_day=-1)
except Exception as e:
print(f"No data returned for room: {room_name} (ID: {room_id}) - {str(e)}")
continue

if operative_temp_data is None:
print(f"No data returned for room: {room_name} (ID: {room_id})")
continue

# Store the results
for hour, temp in enumerate(operative_temp_data, start=1):
results.append({"Hour": hour, "Room Name": room_name, "Operative Temperature (C)": temp})

# Close results file
aps_file.close()

# Create a DataFrame
df = pd.DataFrame(results)

# Pivot the DataFrame
pivot_df = df.pivot(index="Hour", columns="Room Name", values="Operative Temperature (C)")

# Extract the base name of the aps file without extension
aps_base_name = os.path.splitext(os.path.basename(aps_name))[0]

# Get the current time
current_time = datetime.now().strftime("%H%M")

# Construct the output file name
output_file_name = f"{aps_base_name}_{current_time}.xlsx"

# Save to an Excel file
pivot_df.to_excel(output_file_name)

print(f"Hourly operative temperature data extracted and saved to {output_file_name}")