How to load the results from a file into Grasshopper using Honeybee[+] API?

solar-access

#1

Hi @mostapha,

Is there a way to reload results for the ‘Solar Access’ recipe as well, as the component doesn’t have the option to reuse the matrices?
I have the resulting .ill files from a simulation I ran on another (Linux) machine, and I was now hoping to load the results back in grasshopper but couldn’t figure out how to do it properly…

Any hints would be appreciated (and apologies if I am missing something obvious)


Reloading results
#2

Hi @MohammadHamza,

You need both *.pts file and *.ill file.

from honeybee.radiance.analysisgrid import AnalysisGrid

pts_file = r'path_to_points_file.pts'
ill_file = r'path_to_ill_file.ill'
hoys = []  # list of hours of the year. You can get this from sun_path or recipe.

# first let's create an analysis grid from pts file
ag = AnalysisGrid.from_file(pts_file)

# now let's load the results
# mode is set to 1 to convert the results to 0-1
ag.set_values_from_file(ill_file, hoys, mode=1)

# output this ag and you can use the standard honeybee[+] components to get the values.

You can see recipe classes as a reference:


#3

Thanks for your swift reply Mostapha!

I gave it a try (with my very limited Python skills) but I am not sure if I got it right. I get the following Assertion error

What should I change to fix this?


#4

You should remove hoy = [] line from the script. That was a place holder for your input.


#5

Aha! Perfect! Now it works. Many thanks Mostapha.

For anyone else in need of the same, here’s the tiny component. I added some description to the component inputs too.

HBPlus_reloadAnalysisGrid.gh (4.4 KB)

Btw, Mostapha, I didn’t get mode = 2 in set_values_from_file

  • mode – 0 > load the values 1 > load values as binary. Any non-zero value will be 1. This is useful for studies such as sunlight hours. 2 > load the values divided by mode number. Use this mode for daylight factor or radiation analysis.

Why would we want to divide the values by the mode number i.e. division by 2?


#6

In mode 2 results will be divided by mode value which can be 2 or any other value larger than 2.

Imagine the case for daylight factor that we run an illuminance study under an overcast sky with total horizontal illuminance of 10000 lux. Now to get daylight factor we should divide the values by 100 ( 10000 / 100). In that case we can use mode = 100 to get the correct values.

Here is how it is used for daylight factor recipe:


#7

I see. Got it. Thanks!

Maybe it would help to change the description in the API documentation, as at least to me, it was not clear that I can set the mode to 100, or 1000 or to any other arbitrary number I like… I thought it maxed out at ‘2’


#8

Agreed! Why don’t you go ahead and get it fixed? :smiley:


#9

Sure! How do I do that? :sweat_smile:


#10

Edit the source code and send a pull request on GitHub. @PeterZatko has done one for the Grasshopper plugin recently so he know how.


#11

Cool! I’ll ask him about it on Monday then.