My last question “promise” @mostapha
If I want to get the actual x and y coordinates of a test grid and its lux value. How to do that ?
I know that I can use
room.analysis_points() to get me all the test points generated in that room.
Say for the first test grid First = room.analysis_points()[0] I want to find what lux value exits there. How to do that?
@fhalawa1 , I broke down the previous questions into 3. Please open a new topic for each question so it is both easier to reply and easier to find in the future.
To answer your question, analysis_points is an AnalysisGrid
object. You can access each AnalysisPoint
using it’s index. AnalysisPoint
has several methods to get the results based on the type of the study (e.g. recipe).
https://www.ladybug.tools/apidoc/honeybee/honeybee.radiance.html#module-honeybee.radiance.analysispoint
I would refer to post-processing components for code sample on how to use these methods.
1 Like
Awesome, thanks! i could access the location now. How to access the lux vlaue ?
Say using rp = GridBased( …
All the lux values are saved inside ( rp.results()[0]) , but how to access the value?
rp.results()[0]
returns an AnalysisGrid
. You can get the values from an analysis grid like this. This component returns the hourly results for an analysis grid.
try:
states = eval(blind_state_)
except Exception as e:
if blind_state_:
raise TypeError('Failed to read blind_state_:\n{}'.format(e))
states = None
if _mode_ < 2:
values = (v[_mode_] for v in _analysis_grid.combined_value_by_id(hoy_, states))
if _mode_ != 0 and not _analysis_grid.has_direct_values:
print('Direct values are not available. Results will be 0.')
else:
cValues = tuple(_analysis_grid.combined_value_by_id(hoy_, states))
if _analysis_grid.has_direct_values:
print('Loading {} values for {}.'.format(_modes[_mode_],
DateTime.from_hoy(hoy_)))
values = (v[0] - v[1] for v in cValues)
else:
print('Loading total values for {}.'.format(DateTime.from_hoy(hoy_)))
If you want to get this results for a single sensor then see this:
_mode_ = _mode_ or 0
hoys_ = hoys_ or _sensor.hoys
assert _mode_ < 3, '_mode_ can only be 0: total, 1: direct or 2: sky.'
states = _sensor.parse_blind_states(blind_states_)
print('Loading {} values for several hours.'.format(_modes[_mode_]))
if _mode_ < 2:
values = (v[_mode_] for v in
_sensor.combined_values_by_id(hoys_, blinds_state_ids=states))
else:
cValues = _sensor.combined_values_by_id(hoys_, blinds_state_ids=states)
values = (v[0] - v[1] for v in cValues)
In both cases you can just pass an empty list for states since you are not modeling dynamic blinds.
Thanks, but I am not getting what is the attribute I should add to
rp.results()[0] to access the lux values? Sorry I could not understand the two examples.
@mostapha I reckon these questions warrant setting up a few hacktoberfest issues around writing code tutorials for folk to run basic python tasks no?
1 Like
See this example for a room with a single grid:
from ladybug.wea import Wea
from honeybee.room import Room
from honeybee.radiance.sky.climatebased import ClimateBased
from honeybee.radiance.recipe.pointintime.gridbased import GridBased
epw_file = 'USA_MN_Duluth.727450_TMY2.epw' # change this!
wea = Wea.from_epw_file(epw_file)
sky = ClimateBased.from_wea(wea, month=6, day=21, hour=12.0)
room = Room(origin=(0, 0, 0), width=4.2, depth=6.0, height=3.0, rotation_angle=0)
room.add_fenestration_surface(wall_name='back', width=4, height=1.6, sill_height=1.2)
analysis_grid = room.generate_test_points(grid_size=0.5, height=0.75)
rp = GridBased(
sky=sky,
analysis_grids=(analysis_grid,),
simulation_type=0,
hb_objects=(room,)
)
# run the simulation
batch_file = rp.write(target_folder=r'c:\ladybug', project_name='room')
rp.run(batch_file, debug=False)
# get the result grid and calculate the values
result_grid = rp.results()[0]
results = result_grid.combined_value_by_id()
print('location, illuminance value')
for sensor, value in zip(result_grid, results):
print(sensor.location, '=> %d lux' % value[0])
It should print out the location and the value for each sensor
location, illuminance value
0.250 0.250 0.750 => 20220 lux
0.775 0.250 0.750 => 20718 lux
1.300 0.250 0.750 => 20842 lux
1.825 0.250 0.750 => 20775 lux
2.350 0.250 0.750 => 20905 lux
2.875 0.250 0.750 => 20819 lux
3.400 0.250 0.750 => 20641 lux
3.925 0.250 0.750 => 19858 lux
0.250 0.750 0.750 => 3466 lux
0.775 0.750 0.750 => 4265 lux
1.300 0.750 0.750 => 4691 lux
1.825 0.750 0.750 => 4846 lux
2.350 0.750 0.750 => 4839 lux
2.875 0.750 0.750 => 4897 lux
3.400 0.750 0.750 => 4312 lux
3.925 0.750 0.750 => 3289 lux
0.250 1.250 0.750 => 2599 lux
0.775 1.250 0.750 => 3192 lux
1.300 1.250 0.750 => 3430 lux
1.825 1.250 0.750 => 3414 lux
2.350 1.250 0.750 => 3502 lux
2.875 1.250 0.750 => 3550 lux
3.400 1.250 0.750 => 3139 lux
3.925 1.250 0.750 => 2473 lux
0.250 1.750 0.750 => 1885 lux
0.775 1.750 0.750 => 2261 lux
1.300 1.750 0.750 => 2316 lux
1.825 1.750 0.750 => 2495 lux
2.350 1.750 0.750 => 2451 lux
2.875 1.750 0.750 => 2319 lux
3.400 1.750 0.750 => 2041 lux
3.925 1.750 0.750 => 1764 lux
0.250 2.250 0.750 => 1464 lux
0.775 2.250 0.750 => 1643 lux
1.300 2.250 0.750 => 1764 lux
1.825 2.250 0.750 => 1765 lux
2.350 2.250 0.750 => 1811 lux
2.875 2.250 0.750 => 1705 lux
3.400 2.250 0.750 => 1562 lux
3.925 2.250 0.750 => 1349 lux
0.250 2.750 0.750 => 1047 lux
0.775 2.750 0.750 => 1174 lux
1.300 2.750 0.750 => 1347 lux
1.825 2.750 0.750 => 1361 lux
2.350 2.750 0.750 => 1295 lux
2.875 2.750 0.750 => 1306 lux
3.400 2.750 0.750 => 1230 lux
3.925 2.750 0.750 => 1090 lux
0.250 3.250 0.750 => 763 lux
0.775 3.250 0.750 => 925 lux
1.300 3.250 0.750 => 1000 lux
1.825 3.250 0.750 => 998 lux
2.350 3.250 0.750 => 1016 lux
2.875 3.250 0.750 => 917 lux
3.400 3.250 0.750 => 887 lux
3.925 3.250 0.750 => 827 lux
0.250 3.750 0.750 => 689 lux
0.775 3.750 0.750 => 753 lux
1.300 3.750 0.750 => 754 lux
1.825 3.750 0.750 => 783 lux
2.350 3.750 0.750 => 725 lux
2.875 3.750 0.750 => 745 lux
3.400 3.750 0.750 => 697 lux
3.925 3.750 0.750 => 615 lux
0.250 4.250 0.750 => 537 lux
0.775 4.250 0.750 => 529 lux
1.300 4.250 0.750 => 580 lux
1.825 4.250 0.750 => 617 lux
2.350 4.250 0.750 => 623 lux
2.875 4.250 0.750 => 585 lux
3.400 4.250 0.750 => 562 lux
3.925 4.250 0.750 => 475 lux
0.250 4.750 0.750 => 423 lux
0.775 4.750 0.750 => 485 lux
1.300 4.750 0.750 => 482 lux
1.825 4.750 0.750 => 490 lux
2.350 4.750 0.750 => 487 lux
2.875 4.750 0.750 => 468 lux
3.400 4.750 0.750 => 465 lux
3.925 4.750 0.750 => 432 lux
0.250 5.250 0.750 => 355 lux
0.775 5.250 0.750 => 400 lux
1.300 5.250 0.750 => 407 lux
1.825 5.250 0.750 => 460 lux
2.350 5.250 0.750 => 418 lux
2.875 5.250 0.750 => 419 lux
3.400 5.250 0.750 => 435 lux
3.925 5.250 0.750 => 351 lux
0.250 5.750 0.750 => 328 lux
0.775 5.750 0.750 => 377 lux
1.300 5.750 0.750 => 395 lux
1.825 5.750 0.750 => 429 lux
2.350 5.750 0.750 => 411 lux
2.875 5.750 0.750 => 403 lux
3.400 5.750 0.750 => 403 lux
3.925 5.750 0.750 => 307 lux
1 Like
YES! I think even collecting a full list of what people would like to have will be very helpful in the future.
1 Like