honeybee-radiance-postprocess 0.4.404__py2.py3-none-any.whl → 0.4.405__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -235,7 +235,7 @@ def _ase_hourly_percentage(
235
235
  occupancy_hoys = schedule_to_hoys(results.schedule, results.sun_up_hours)
236
236
  # map states to 8760 values
237
237
  percentage_above = results.values_to_annual(
238
- occupancy_hoys, percentage_above, results.timestep, results.study_hours)
238
+ occupancy_hoys, percentage_above, results.timestep)
239
239
  header = Header(Fraction('Percentage above 1000 direct lux'), '%',
240
240
  AnalysisPeriod(results.timestep),
241
241
  metadata={'SensorGrid': grid_info['name']})
@@ -529,7 +529,7 @@ def leed_states_schedule(
529
529
  # map states to 8760 values
530
530
  for light_path, shd_trans in states_schedule.items():
531
531
  mapped_states = results.values_to_annual(
532
- occupancy_hoys, shd_trans, results.timestep, results.study_hours)
532
+ occupancy_hoys, shd_trans, results.timestep)
533
533
  states_schedule[light_path] = mapped_states
534
534
 
535
535
  return states_schedule, fail_to_comply, shd_trans_dict
@@ -2,6 +2,8 @@ import json
2
2
  from pathlib import Path
3
3
  from typing import Tuple, List
4
4
  import numpy as np
5
+ import itertools
6
+ from collections import defaultdict
5
7
 
6
8
  from ladybug.analysisperiod import AnalysisPeriod
7
9
  from ladybug.datacollection import HourlyContinuousCollection
@@ -16,7 +18,7 @@ from ..util import filter_array
16
18
  from ..annualdaylight import _annual_daylight_vis_metadata
17
19
  from ..electriclight import array_to_dimming_fraction
18
20
  from .. import type_hints
19
- from ..dynamic import DynamicSchedule
21
+ from ..dynamic import DynamicSchedule, ApertureGroupSchedule
20
22
  from .results import Results
21
23
 
22
24
 
@@ -682,3 +684,70 @@ class AnnualDaylight(Results):
682
684
 
683
685
  info_file = uniformity_ratio_folder.joinpath('grids_info.json')
684
686
  info_file.write_text(json.dumps(grids_info))
687
+
688
+ def dynamic_schedule_from_sensor_maximum(
689
+ self, sensor_index: dict, grids_filter: str = '*',
690
+ maximum: float = 3000, res_type: str = 'total') -> DynamicSchedule:
691
+ """Calculate a DynamicSchedule from a sensor and a maximum allowed
692
+ illuminance.
693
+
694
+ Args:
695
+ sensor_index: A dictionary with grids as keys and a list of sensor
696
+ indices as values. Defaults to None.
697
+ grids_filter: The name of a grid or a pattern to filter the grids.
698
+ Defaults to '*'.
699
+ maximum: A float value of the maximum illuminance allowed for the
700
+ sensor.
701
+ res_type: Type of results to load. Defaults to 'total'.
702
+
703
+ Returns:
704
+ DynamicSchedule object.
705
+ """
706
+ grids_info = self._filter_grids(grids_filter=grids_filter)
707
+
708
+ aperture_group_schedules = []
709
+ for grid_info in grids_info:
710
+ control_sensor = sensor_index.get(grid_info['full_id'], None)
711
+ if control_sensor is None:
712
+ continue
713
+ assert len(control_sensor) == 1, ('Expected one control sensor for '
714
+ f'grid {grid_info["name"]}. Received {len(control_sensor)} '
715
+ 'control sensors.')
716
+ control_sensor_index = control_sensor[0]
717
+ light_paths = [lp[0] for lp in grid_info['light_path']]
718
+ lp_states = {key: self.valid_states[key] for key in light_paths if key in self.valid_states}
719
+
720
+ keys, values = zip(*lp_states.items())
721
+ combinations = [dict(zip(keys, v)) for v in itertools.product(*values)]
722
+ array_list_combinations = []
723
+ for combination in combinations:
724
+ combination_arrays = []
725
+ for light_path, state_index in combination.items():
726
+ array = self._get_array(
727
+ grid_info, light_path, state=state_index, res_type=res_type)
728
+ sensor_array = array[control_sensor_index,:]
729
+ combination_arrays.append(sensor_array)
730
+ combination_array = sum(combination_arrays)
731
+ array_list_combinations.append(combination_array)
732
+ array_combinations = np.array(array_list_combinations)
733
+ array_combinations[array_combinations > maximum] = -np.inf
734
+ max_indices = array_combinations.argmax(axis=0)
735
+ combinations = [combinations[idx] for idx in max_indices]
736
+
737
+ states_schedule = defaultdict(list)
738
+ for combination in combinations:
739
+ for light_path, state_index in combination.items():
740
+ if light_path != '__static_apertures__':
741
+ states_schedule[light_path].append(state_index)
742
+
743
+ # map states to 8760 values
744
+ for light_path, state_indices in states_schedule.items():
745
+ mapped_states = self.values_to_annual(
746
+ self.sun_up_hours, state_indices, self.timestep)
747
+ mapped_states = mapped_states.astype(int)
748
+ aperture_group_schedules.append(
749
+ ApertureGroupSchedule(light_path, mapped_states.tolist()))
750
+
751
+ dyn_sch = DynamicSchedule.from_group_schedules(aperture_group_schedules)
752
+
753
+ return dyn_sch
@@ -882,7 +882,7 @@ class Results(_ResultsFolder):
882
882
  else:
883
883
  values = np.zeros(len(self.sun_up_hours))
884
884
  annual_array = Results.values_to_annual(
885
- self.sun_up_hours, values, self.timestep, self.study_hours)
885
+ self.sun_up_hours, values, self.timestep)
886
886
  header = Header(self.datatype, self.unit, analysis_period)
887
887
  header.metadata['sensor grid'] = grid_id
888
888
  header.metadata['sensor index'] = idx
@@ -931,7 +931,7 @@ class Results(_ResultsFolder):
931
931
  def values_to_annual(
932
932
  hours: Union[List[float], np.ndarray],
933
933
  values: Union[List[float], np.ndarray],
934
- timestep: int, study_hours: list, base_value: int = 0) -> np.ndarray:
934
+ timestep: int, base_value: int = 0) -> np.ndarray:
935
935
  """Map a 1D NumPy array based on a set of hours to an annual array.
936
936
 
937
937
  This method creates an array with a base value of length 8760 and
@@ -944,7 +944,6 @@ class Results(_ResultsFolder):
944
944
  values: A list of values to map to an annual array. This can be a
945
945
  regular list or a 1D NumPy array.
946
946
  timestep: Time step of the simulation.
947
- study_hours: Study hours of the simulation.
948
947
  base_value: A value that will be applied for all the base array.
949
948
 
950
949
  Returns:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: honeybee-radiance-postprocess
3
- Version: 0.4.404
3
+ Version: 0.4.405
4
4
  Summary: Postprocessing of Radiance results and matrices
5
5
  Home-page: https://github.com/ladybug-tools/honeybee-radiance-postprocess
6
6
  Author: Ladybug Tools
@@ -7,7 +7,7 @@ honeybee_radiance_postprocess/dynamic.py,sha256=RPJh2SsjASYJCsG5QRkazVCvzWjzMxm9
7
7
  honeybee_radiance_postprocess/electriclight.py,sha256=E7uhq7-YtZ02F9a1FbEdrXnxmYJNOFnfLF0Yw3JLQ-g,732
8
8
  honeybee_radiance_postprocess/en17037.py,sha256=5c5ahfzad12FqMwBL7c0sLOKHzLKSTXtlYFfaNhzA3w,10848
9
9
  honeybee_radiance_postprocess/helper.py,sha256=qz5kaJxzy1tGBfVYYXc2cEToOCoj0YLOtwjr3LVI3YU,9000
10
- honeybee_radiance_postprocess/leed.py,sha256=egdWC5nU81dlm7Xq_kKLqDWVeYdbghr2b7XZYmZ_YN0,35986
10
+ honeybee_radiance_postprocess/leed.py,sha256=Mx1fqNumEvLbQ1lb0HiFHVperbqtqBUjve-y4ZDdCJ4,35944
11
11
  honeybee_radiance_postprocess/metrics.py,sha256=6EHCuXf5jnhh6GglI9mTd0MFpfhfPFoKMf4b5gKRTMI,14038
12
12
  honeybee_radiance_postprocess/reader.py,sha256=6myKzfGC1pO8zPixg1kKrKjPihHabTKUh2t5BlJvij0,2367
13
13
  honeybee_radiance_postprocess/type_hints.py,sha256=4R0kZgacQrqzoh8Tq7f8MVzUDzynV-C_jlh80UV6GPE,1122
@@ -24,12 +24,12 @@ honeybee_radiance_postprocess/cli/translate.py,sha256=18zkcGeRZALJ5Z82NEB3XZ-iEX
24
24
  honeybee_radiance_postprocess/cli/two_phase.py,sha256=1nZF4jyZ_C7CAfiHCz1UUOEwDaB4yOXr9ga0HIrhOB0,7033
25
25
  honeybee_radiance_postprocess/cli/util.py,sha256=Be9cGmYhcV2W37ma6SgQPCWCpWLLLlroxRYN_l58kY0,4077
26
26
  honeybee_radiance_postprocess/results/__init__.py,sha256=1agBQbfT4Tf8KqSZzlfKYX8MeZryY4jJ1KB4HWqaDDk,182
27
- honeybee_radiance_postprocess/results/annual_daylight.py,sha256=o4Y5kbD3a4X4KRfsbOlWzgrnNKU365GcivM6qQGUGXU,31605
27
+ honeybee_radiance_postprocess/results/annual_daylight.py,sha256=ohysFt4OWlWUn_IvM6pjmiQcRTq_x5b998Iv0pw8AEQ,34964
28
28
  honeybee_radiance_postprocess/results/annual_irradiance.py,sha256=5zwrr4MNeHUebbSRpSBbscPOZUs2AHmYCQfIIbdYImY,8298
29
- honeybee_radiance_postprocess/results/results.py,sha256=jkjsxTuvVfBus6tM2UjQE3ZKPooLInWEd2guqO61v9E,53600
30
- honeybee_radiance_postprocess-0.4.404.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
31
- honeybee_radiance_postprocess-0.4.404.dist-info/METADATA,sha256=PCpt_KJsHH6coj5QydwfjtJjECbqSOCYiSwwQES9Cw4,2245
32
- honeybee_radiance_postprocess-0.4.404.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
33
- honeybee_radiance_postprocess-0.4.404.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
34
- honeybee_radiance_postprocess-0.4.404.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
35
- honeybee_radiance_postprocess-0.4.404.dist-info/RECORD,,
29
+ honeybee_radiance_postprocess/results/results.py,sha256=GwyjIYljaCShx1b6NlYUBcU_gHhckmLcCMNrQ6HVDdE,53507
30
+ honeybee_radiance_postprocess-0.4.405.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
31
+ honeybee_radiance_postprocess-0.4.405.dist-info/METADATA,sha256=F3ddEv9JwAvcVBJqs2viyISoQ8YJtmuIfljRhPmMZRY,2245
32
+ honeybee_radiance_postprocess-0.4.405.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
33
+ honeybee_radiance_postprocess-0.4.405.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
34
+ honeybee_radiance_postprocess-0.4.405.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
35
+ honeybee_radiance_postprocess-0.4.405.dist-info/RECORD,,