Results reader fails in recent (post 2018 hotfix 2?) versions

The VE Python API allows users create simple programs using the Python Programming Language, to interact with a VE Model and/or Vista Results File
jgill
VE Newbie
VE Newbie
Posts: 1
Joined: Tue Mar 20, 2018 10:22 am

Results reader fails in recent (post 2018 hotfix 2?) versions

Post by jgill »

The results reader get_variables() call is failing in the most recent VE version.

This can be easily replicated by opening any project with a results file and running the 'read_aps_energy.py' script, giving the output:

>>> Run start, Fri Sep 28 14:26:06 2018
Traceback (most recent call last):
File "C:\Program Files (x86)\IES\VE 2018\apps\Scripts\api_examples\resultsreader\read_aps_energy.py", line 118, in <module>
aps_variables = results_file_reader.get_variables()
AttributeError: type object 'Error' has no attribute 'values'
>>> Runtime: 2.83 seconds

Not sure if there's some undocumented (or documented somewhere I haven't seen yet) change related to accessing vista generated variables in the python environment.

Has anyone seen anything similar? any suggestions?
LeightonSS55
VE Beginner
VE Beginner
Posts: 10
Joined: Mon Aug 22, 2016 1:50 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by LeightonSS55 »

jgill,

Just going to say that the same is happening for me.

It seems the .get functions which access the C++ data do not match the IES-VE user documentation.

Boost.Python.ArgumentError: Python argument types in
ResultsReader.get_room_results(ResultsReader, str, str, str, int, int)
did not match C++ signature:
get_room_results(class ResultsReader {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, char, int start_day=-1, int end_day=-1)

Can someone from IES clarify ASAP please?

Thanks,
User avatar
Rhind
IES Staff
IES Staff
Posts: 87
Joined: Fri Mar 22, 2013 5:06 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by Rhind »

Hi,

This is what's needed for get_room_results:

Code: Select all

get_room_results(room_id, aps_var, vista_var, var_level, start_day, end_day)
start_day and end_day can be omitted, in which case the full date range is used.

There's also the related function get_all_room_results which may be of use:

Code: Select all

get_all_room_results(room_id, aps_var, var_level, start_day, end_day)
Hope that helps.
LeightonSS55
VE Beginner
VE Beginner
Posts: 10
Joined: Mon Aug 22, 2016 1:50 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by LeightonSS55 »

Hi Rhind,

Thanks for getting back and the code makes sense for use in VE2018.

I note that between the VE2017 version and VE2018 (Hotfix 2), the method for get_room_results changed?

In VE2017, when running the example 'overheating_test.py' script; the method for accessing results is stipulated as below:

Code: Select all

np_room_temp = results_reader_file.get_room_results(room_id, 'Comfort temperature', 'z', 1, 365)
In VE 2018, when running the example 'overheating_test.py' script; the method for accessing results is as below (and aligns with the VE Python Script User Guide)

Code: Select all

np_room_temp = results_reader_file.get_room_results(room_id, 'Comfort temperature', 'Dry resultant temperature', 'z', 1, 365)
This explains why i was getting the above error - both the aps_var & the vista_var were required, whereas in VE2017 it seems it wasn't required.
-----------------------------------------------------------------

Now, linked to jgill's original comment; the 'get_variables()' isn't working in VE2018.

The below script is what I have used to access the dictionary of .aps variables and print it out to excel. I did this so I can see name of both the vista_var AND the aps_var, because as far as I can tell there is no documentation of the aps_var, and hence needed a method to find this out so i can access the correct results in any future scripts.

Code: Select all

'''Importing modules'''
import iesve
import xlsxwriter
import os
from ies_file_picker import IesFilePicker

'''Accessing Results via Results Reader'''
aps_file_name = IesFilePicker.pick_aps_file()
results_reader_file = iesve.ResultsReader.open(aps_file_name)
variables = results_reader_file.get_variables()

# # # print(variables)
# here we can print the function 'variables' which reads into the .aps file variables and prints out a LIST of DICTIONARIES

# Here we can just print the first variable - which has an .aps variable name of Lights & SP elec, but a display name of Equip Elec. CE
# print(variables[0])

# Here we can find out the length of the list of variables
# print(len(variables))

# Create an Excel worksheet and name it
workbook = xlsxwriter.Workbook('Results_Variables.xlsx')
worksheet = workbook.add_worksheet('Sheet1')

# Specify the Row and Column index to start at 0 
row = 0
col = 0

# Loop through the dictionaries and write to columns using the index method
for dict in variables[1:718]:
    worksheet.write(row, col, dict['units_type'])
    worksheet.write(row, col + 1, dict['post_process_spec'])
    worksheet.write(row, col + 2, dict['aps_varname'])
    worksheet.write(row, col + 3, dict['source'])
    worksheet.write(row, col + 4, dict['subtype'])
    worksheet.write(row, col + 5, dict['model_level'])
    worksheet.write(row, col + 6, dict['custom_type'])
    worksheet.write(row, col + 7, dict['display_name'])
    row += 1
    
# Close the workbook and use OS to open the Excel file
workbook.close()
os.startfile('Results_Variables.xlsx')
I get the same error message as Jgill, from running the code above in VE2018, but it runs fine in VE2017.

Please can you review and explain what has changed and/or what is required in the code? Hopefully this will answer jgill's question also.

Many thanks for your help so far,

Leighton
User avatar
Rhind
IES Staff
IES Staff
Posts: 87
Joined: Fri Mar 22, 2013 5:06 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by Rhind »

Nothing has changed with the usage of get_variables() and the example script you've posted is correct. I've run it in a copy of VE 2018 and it worked as expected. I used the small office starter model, are you able to run your script with this?

MIght be worth getting in touch with support, who can investigate further.
bbrannon4
VE Professor
VE Professor
Posts: 111
Joined: Wed Feb 12, 2014 6:56 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by bbrannon4 »

Did anyone ever figure out the issue with get_variables? I have some code that actually worked fine, then I must have dome something which broke it. In both cases it's in VE 2018 FP1, and I've sent this into support.

Here is my code up until the error:

Code: Select all

import iesve
from ies_file_picker import IesFilePicker
import pandas as pd
import pickle
import json

#### Select results file to use ####
aps_filename = IesFilePicker.pick_aps_file()
results = iesve.ResultsReader.open(aps_filename)

#### Check available rooms ####
rooms = pd.DataFrame(results.get_room_list()) # (name,ID,Area,Volume)
rooms.to_csv(r'C:\Users\ben.brannon\Desktop\rooms_out.csv')    #save to file if needed

#### Check available variables ####
var_names = results.get_variables()
And the resulting error:

Code: Select all

Traceback (most recent call last):
  File "C:\git\IESVE_Scripts\RoomConditionsExtract.py", line 20, in <module>
    var_names = results.get_variables()
AttributeError: type object 'NullImporter' has no attribute 'values'
get_room_list works fine, so at least it's accessing the results file in some manner.
User avatar
Terence
Site Admin
Site Admin
Posts: 411
Joined: Mon Aug 25, 2008 12:58 pm
Location: Glasgow, UK
Contact:

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by Terence »

bbrannon4, sorry to see you are having trouble with this... Our developers looked at the example you posted above and confirmed they were able to get the exception in this instance and they have logged it for investigation.

If they find a way around it then they will post back here with the information.
Terence McMahon
IES Technical Support
Linkedin
bbrannon4
VE Professor
VE Professor
Posts: 111
Joined: Wed Feb 12, 2014 6:56 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by bbrannon4 »

Thanks Terence. In the meantime, is it possible for you to provide a full list of all available variables (vista name and aps name, plus the model level and units type)? I don't see a full list in the documentation and I'm not sure another way to verify the names. Specifically I'm trying to get the plant profiles and heating/cooling set-points out of the results, but it would be great to get a full list, similar to what I would get if my code above worked.
User avatar
Rhind
IES Staff
IES Staff
Posts: 87
Joined: Fri Mar 22, 2013 5:06 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by Rhind »

bbrannon4, support will be in touch with some more information while we address this issue.
LeightonSS55
VE Beginner
VE Beginner
Posts: 10
Joined: Mon Aug 22, 2016 1:50 pm

Re: Results reader fails in recent (post 2018 hotfix 2?) versions

Post by LeightonSS55 »

Hi Rhind / bbrannon4,

Appreciate the support.

I still am having the same issue - when this is resolved please may you post the solution in this thread please?

I also second bbrannon4's request to formalise the vista names and corresponding aps names (outside the python dictionary), as accessing the data is not the problem here - it's the method to find out the naming convention which is not working - Like the internet with no search engine :roll:

Thanks,
Post Reply