Dry-bulb temperature mis-match between API and VistaPro

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
Post Reply
ohensby
VE Newbie
VE Newbie
Posts: 8
Joined: Thu Feb 24, 2022 4:29 pm

Dry-bulb temperature mis-match between API and VistaPro

Post by ohensby »

I've noticed a discrepancy between the dry-bulb temperature obtained from VistaPro and the dry-bulb temperature obtained through the Python API.

From vista, the first few values are (in list format):

Code: Select all

[16. , -1.6, -2. , -3.2, -3.2, -2.6, -2. , -1.9, -1.8, -2. , -1.4, -0.5,  0.1,  0.4,  0.6, ...]  (1)
whereas, from the API, we obtain this:

Code: Select all

[-1.6, -2. , -3.2, -3.2, -2.6, -2. , -1.9, -1.8, -2. , -1.4, -0.5, 0.1,  0.4,  0.6,  0.8, ...]  (2)
The first noticeable difference is that the dry-bulb temperature (1) from vista starts with 16.

Now, the next thing I noticed is that (1) and (2) are just one element out-of-sync, so if I removed the 16 value from (1) then all would be good, however, from the 2160th index, they are one element out-of-sync again:

From vista:

Code: Select all

[ ..., 6.4,  6.4,  6.5,  6.2,  6. ,  6.5,  6.4,  6.4,  6.6,  7.3,  7.9, 8.5,  9.4, 10.1, 10. , ...]
From API:

Code: Select all

[ ..., 6.4,  6.5,  6.2,  6. ,  6.5,  6.4,  6.4,  6.6,  7.3,  7.9,  8.5, 9.4, 10.1, 10. , 10.6, ...]
To re-create the problem:

1. Obtain the dry-bulb temperature using the python script below. This needs to be run in VEScript in IES. It will save the numpy array obtaining the dry-bulb temperatures hourly.

Code: Select all

import numpy as np 
import pandas as pd 
import iesve 
from ies_file_picker import IesFilePicker 

file_name = IesFilePicker.pick_aps_file() 
results_file_reader = iesve.ResultsReader.open(file_name) 

weather_file_name = results_file_reader.weather_file 
weather_file = iesve.WeatherFileReader() 
open_weather_file = weather_file.open_weather_file(weather_file_name) 
arr = weather_file.get_results( 
        3, # this is the dry-bulb temperature ID 
        1, # start day 
        365 # end day 
        )   
print(arr)
np.save("dry_bulb.npy", arr)
2. Then in VistaPro, open dry-bulb temperature in a table and then save it as a text file e.g. "dry_bulb_temperature_from_vista.txt".
Note: Make sure to have "dry_bulb.npy" and "dry_bulb_temperature_from_vista.txt" in the same location the python script is being run from.

3. Run the below python script (in jupyter or VEscript) to input data into a csv file which can then be opened in excel.

Code: Select all

import pandas as pd
import numpy as np

# Load dry-bulb from API and VistaPro
arr_from_api = np.load("arr_dry_bulb_temp.npy")
df = pd.read_csv("dry_bulb_temperature_from_vista.txt", delimiter="\t", encoding='latin1', header=2)
arr_from_vista = np.array(df.iloc[:, 2])

di = {
    "Dry-bulb Temp. Vista": arr_from_vista,
    "Dry-bulb Temp. API": arr_from_api
}
df = pd.DataFrame.from_dict(di)
df.to_csv('dry_bulb_test.csv')  # Save as csv
Any help with why these two dry-bulbs temps are different would be great!

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

Re: Dry-bulb temperature mis-match between API and VistaPro

Post by Rhind »

VEScript will give you the raw values from the weather file while Vista might do some minor adjustments e.g. for daylight savings time so they may not always match up exactly depending on the weather file.
ohensby
VE Newbie
VE Newbie
Posts: 8
Joined: Thu Feb 24, 2022 4:29 pm

Re: Dry-bulb temperature mis-match between API and VistaPro

Post by ohensby »

Hello Rhind, thank you for getting back to me.

Is there a way for the API to return the dry-bulb temperature where the day-light savings time is accounted for?
User avatar
Rhind
IES Staff
IES Staff
Posts: 87
Joined: Fri Mar 22, 2013 5:06 pm

Re: Dry-bulb temperature mis-match between API and VistaPro

Post by Rhind »

As far as I know there's no way of getting that automatically from the API, you would have to add your own post-process step to your script.
ohensby
VE Newbie
VE Newbie
Posts: 8
Joined: Thu Feb 24, 2022 4:29 pm

Re: Dry-bulb temperature mis-match between API and VistaPro

Post by ohensby »

Great - thanks for your help.
The following function did the conversion and we validated that the results from VistaPro and the API are now an exact match.

Code: Select all

def utc_to_bst(arr):
    """convert annual hourly from utc time to bst time

    Args:
        arr (np.array): array in UTC 

    Returns:
        np.array: array in BST 
    """
    arr_ = np.insert(arr, 2161, arr[2160])  # Accounting for clocks going forward end of March
    arr_ = np.delete(arr_, 7296) # Remove hour for clocks going back end of October
    return arr_
This was reviewed with the Max Fordham internal development team and they made the following comments:

- BST is not a scientific measure (i.e. an hour of physical readings (i.e. temperature) is not physically repeated in march or lost in October)
- It is not clear in the documentation of either VEscripts or VistaPro that BST is applied. As a simulation tool we'd suggest the typical working assumption would be to use UTC time.
- There should be consistency between the results in VistaPro and what is retrievable from the API, discrepancies (even minor ones) lead to confusion and undermine the results obtained from the API.
- We suggest that there should be a key word argument within the API retrieval that allows the developer to retrieve the data as either BST or as UTC (/GMT). This would allow us to retrieve data equivalent to what is accessible in the User Interface.
enerGwizz
VE Student
VE Student
Posts: 46
Joined: Thu Mar 01, 2012 6:36 pm
Location: Los Angeles

Re: Dry-bulb temperature mis-match between API and VistaPro

Post by enerGwizz »

I agree the results should be consistent between the VE interface and the API. However, adjusting for DST would affect the time stamp values - not the dry-bulb temps in the array. Weather files typically use local time with no DST adjustments. It seems very odd that you would reorder the array to match the interface.
--
Greg
Post Reply