Hello,
Do you have experience with Python? If not, you might need to do some general tutorials first.
If so, here are some code snippits that might help. Note these are from around one of my scripts and probably won't work on their own without a litte debugging, but I hope get you started:
Code: Select all
class LoadResultsData:
def __init__(self):
self.name = None
self.filetype = None
self.sens_total = None
self.sens_lighting = None
self.sens_equipment = None
self.sens_people = None
self.sens_external_conduction = None
self.sens_internal_conduction = None
self.sens_infiltration = None
self.sens_solar = None
self.sens_mass = None
self.lat_total = None
self.lat_equipment = None
self.lat_people = None
self.lat_infiltration = None
def get_room_load_results(rooms, results_file_reader, var_type):
#rooms = results_file_reader.get_room_list() # no need to pull room list from results file, because we're passing it from the model. might cause issues if the results file doesn't allign with the model'
if len(rooms) < 1:
raise_error("Looks like there aren't any rooms in your model.")
# Initialize dict with keys but no values
results = dict.fromkeys(rooms)
# Get unit conversions
units = results_file_reader.get_units()
if outputunits == 'ip':
units_display_name = units['Gain']['units_IP']['display_name']
units_divisor = units['Gain']['units_IP']['divisor']
elif outputunits == 'si':
units_display_name = units['Gain']['units_SI']['display_name']
units_divisor = units['Gain']['units_SI']['divisor']
else:
print("Select units at the top of the scripts. Options are: 'ip' or 'si'")
for room_id in rooms:
# Instantiate class for results data
results_data = LoadResultsData()
results_data.filetype = var_type # maybe do this and the filename in the main function, rather than looping and redoing here?
# Pull data for each variable and assign and divide to change units
results_data.sens_total = results_file_reader.get_room_results(room_id, 'System plant etc. gains','Space conditioning sensible','z')/units_divisor
results_data.sens_lighting = results_file_reader.get_room_results(room_id, 'Lighting gain','Lighting gain','z')/units_divisor
results_data.sens_equipment = results_file_reader.get_room_results(room_id, 'Equipment gain','Equipment gain','z')/units_divisor
results_data.sens_people = results_file_reader.get_room_results(room_id, 'People gain','People gain','z')/units_divisor
results_data.sens_external_conduction = results_file_reader.get_room_results(room_id, 'Conduction from ext elements','External conduction gain','z')/units_divisor
results_data.sens_internal_conduction = results_file_reader.get_room_results(room_id, 'Conduction from int surfaces','Internal conduction gain','z')/units_divisor
results_data.sens_infiltration = results_file_reader.get_room_results(room_id, 'Infiltration gain','Infiltration gain','z')/units_divisor
results_data.sens_solar = results_file_reader.get_room_results(room_id, 'Window solar gains','Solar gain','z')/units_divisor
results_data.sens_mass = results_file_reader.get_room_results(room_id, 'Air & furniture dynamics gain','Air & furniture dynamics gain','z')/units_divisor
results_data.lat_total = results_file_reader.get_room_results(room_id, 'Room latent load','Space conditioning latent','z')/units_divisor
results_data.lat_equipment = results_file_reader.get_room_results(room_id, 'Equipment latent gain','Equipment latent gain','z')/units_divisor
results_data.lat_people = results_file_reader.get_room_results(room_id, 'People latent gain','People latent gain','z')/units_divisor
results_data.lat_infiltration = results_file_reader.get_room_results(room_id, 'Infiltration lat gain','Infiltration lat gain','z')/units_divisor
# Assign class to overall dictionary with ID as key
results[room_id] = results_data
if room_id == 'L0000034':
print(results['L0000030'].sens_total)
print(results['L0000034'].sens_total)
elif room_id == 'L0000080':
print(results['L0000080'].sens_total)
return results, units_display_name
if __name__ == "__main__":
# import current (open) project
project = iesve.VEProject.get_current_project()
# create a list of VEModel objects
models = project.models
# The 'real building' model is always the first model in the 'models' list
model = models[0]
# create list of VEBody objects from VEModel object
bodies = model.get_bodies_and_ids(False) # get dictionary of VEBody objects, IDs as keys
# format body details into DFs for exporting to excel
room_data_simple, room_data_complex = get_room_details(bodies)
# get list of room IDs
room_ids = list(bodies.keys())
# Open results file (multiple types) (example just for heating file)
htg_file_name = IesFilePicker.pick_vista_file([("HTG files", "*.htg")], "Pick a heating room loads results file")
filetype_heating = htg_file_name.rsplit('.', 1)[1]
# read results data
with iesve.ResultsReader.open(htg_file_name) as results_file_reader_htg:
assert results_file_reader_htg is not None, "Results file appears empty or corrupted."
# get all (hourly) results data
space_heating_loads, units_display_name_htg = get_room_load_results(room_ids, results_file_reader_htg, filetype_heating)