honeybee-radiance-postprocess 0.4.555__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.
- honeybee_radiance_postprocess/__init__.py +1 -0
- honeybee_radiance_postprocess/__main__.py +4 -0
- honeybee_radiance_postprocess/annual.py +73 -0
- honeybee_radiance_postprocess/annualdaylight.py +289 -0
- honeybee_radiance_postprocess/annualirradiance.py +35 -0
- honeybee_radiance_postprocess/breeam/__init__.py +1 -0
- honeybee_radiance_postprocess/breeam/breeam.py +552 -0
- honeybee_radiance_postprocess/cli/__init__.py +33 -0
- honeybee_radiance_postprocess/cli/abnt.py +392 -0
- honeybee_radiance_postprocess/cli/breeam.py +96 -0
- honeybee_radiance_postprocess/cli/datacollection.py +133 -0
- honeybee_radiance_postprocess/cli/grid.py +295 -0
- honeybee_radiance_postprocess/cli/leed.py +143 -0
- honeybee_radiance_postprocess/cli/merge.py +161 -0
- honeybee_radiance_postprocess/cli/mtxop.py +161 -0
- honeybee_radiance_postprocess/cli/postprocess.py +1092 -0
- honeybee_radiance_postprocess/cli/schedule.py +103 -0
- honeybee_radiance_postprocess/cli/translate.py +216 -0
- honeybee_radiance_postprocess/cli/two_phase.py +252 -0
- honeybee_radiance_postprocess/cli/util.py +121 -0
- honeybee_radiance_postprocess/cli/viewfactor.py +157 -0
- honeybee_radiance_postprocess/cli/well.py +110 -0
- honeybee_radiance_postprocess/data_type.py +102 -0
- honeybee_radiance_postprocess/dynamic.py +273 -0
- honeybee_radiance_postprocess/electriclight.py +24 -0
- honeybee_radiance_postprocess/en17037.py +304 -0
- honeybee_radiance_postprocess/helper.py +266 -0
- honeybee_radiance_postprocess/ies/__init__.py +1 -0
- honeybee_radiance_postprocess/ies/lm.py +224 -0
- honeybee_radiance_postprocess/ies/lm_schedule.py +248 -0
- honeybee_radiance_postprocess/leed/__init__.py +1 -0
- honeybee_radiance_postprocess/leed/leed.py +801 -0
- honeybee_radiance_postprocess/leed/leed_schedule.py +256 -0
- honeybee_radiance_postprocess/metrics.py +439 -0
- honeybee_radiance_postprocess/reader.py +80 -0
- honeybee_radiance_postprocess/results/__init__.py +4 -0
- honeybee_radiance_postprocess/results/annual_daylight.py +752 -0
- honeybee_radiance_postprocess/results/annual_irradiance.py +196 -0
- honeybee_radiance_postprocess/results/results.py +1416 -0
- honeybee_radiance_postprocess/type_hints.py +38 -0
- honeybee_radiance_postprocess/util.py +211 -0
- honeybee_radiance_postprocess/vis_metadata.py +49 -0
- honeybee_radiance_postprocess/well/__init__.py +1 -0
- honeybee_radiance_postprocess/well/well.py +509 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/METADATA +79 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/RECORD +50 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/WHEEL +5 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/entry_points.txt +2 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/licenses/LICENSE +661 -0
- honeybee_radiance_postprocess-0.4.555.dist-info/top_level.txt +1 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
import json
|
2
|
+
from pathlib import Path
|
3
|
+
try:
|
4
|
+
import cupy as np
|
5
|
+
is_gpu = True
|
6
|
+
except ImportError:
|
7
|
+
is_gpu = False
|
8
|
+
import numpy as np
|
9
|
+
|
10
|
+
from ladybug.datatype.energyflux import EnergyFlux
|
11
|
+
|
12
|
+
from ..metrics import (average_values_array2d, cumulative_values_array2d,
|
13
|
+
peak_values_array2d)
|
14
|
+
from ..util import filter_array, hoys_mask
|
15
|
+
from ..annualirradiance import _annual_irradiance_vis_metadata
|
16
|
+
from .. import type_hints
|
17
|
+
from ..dynamic import DynamicSchedule
|
18
|
+
from .results import Results
|
19
|
+
|
20
|
+
|
21
|
+
class AnnualIrradiance(Results):
|
22
|
+
"""Annual Daylight Results class.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
folder: Path to results folder.
|
26
|
+
schedule: 8760 values as a list. Values must be either 0 or 1. Values of 1
|
27
|
+
indicates occupied hours. If no schedule is provided a default schedule
|
28
|
+
will be used. (Default: None).
|
29
|
+
load_arrays: Set to True to load all NumPy arrays. If False the arrays will be
|
30
|
+
loaded only once they are needed. In both cases the loaded array(s) will be
|
31
|
+
stored in a dictionary under the arrays property. (Default: False).
|
32
|
+
|
33
|
+
Properties:
|
34
|
+
* schedule
|
35
|
+
* occ_pattern
|
36
|
+
* total_occ
|
37
|
+
* sun_down_occ_hours
|
38
|
+
* occ_mask
|
39
|
+
* arrays
|
40
|
+
* valid_states
|
41
|
+
* datatype
|
42
|
+
"""
|
43
|
+
def __init__(self, folder, schedule: list = None, load_arrays: bool = False,
|
44
|
+
cache_arrays: bool = False):
|
45
|
+
"""Initialize Results."""
|
46
|
+
Results.__init__(self, folder, datatype=EnergyFlux('Irradiance'),
|
47
|
+
schedule=schedule, unit='W/m2', load_arrays=load_arrays,
|
48
|
+
cache_arrays=cache_arrays)
|
49
|
+
|
50
|
+
def cumulative_values(
|
51
|
+
self, hoys: list = [], states: DynamicSchedule = None,
|
52
|
+
t_step_multiplier: float = 1000, grids_filter: str = '*',
|
53
|
+
res_type: str = 'total') -> type_hints.cumulative_values:
|
54
|
+
"""Get cumulative values for each sensor over a given period.
|
55
|
+
|
56
|
+
The hoys input can be used to filter the data for a particular time
|
57
|
+
period.
|
58
|
+
|
59
|
+
Args:
|
60
|
+
hoys: An optional numbers or list of numbers to select the hours of
|
61
|
+
the year (HOYs) for which results will be computed. Defaults to [].
|
62
|
+
states: A dictionary of states. Defaults to None.
|
63
|
+
t_step_multiplier: A value that will be multiplied with the timestep.
|
64
|
+
grids_filter: The name of a grid or a pattern to filter the grids.
|
65
|
+
Defaults to '*'.
|
66
|
+
res_type: Type of results to load. Defaults to 'total'.
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
Tuple: A tuple with the cumulative value for each sensor and grid
|
70
|
+
information.
|
71
|
+
"""
|
72
|
+
cumulative_values, grids_info = \
|
73
|
+
super(AnnualIrradiance, self).cumulative_values(
|
74
|
+
hoys=hoys, states=states, t_step_multiplier=t_step_multiplier,
|
75
|
+
grids_filter=grids_filter, res_type=res_type
|
76
|
+
)
|
77
|
+
|
78
|
+
return cumulative_values, grids_info
|
79
|
+
|
80
|
+
def cumulative_values_to_folder(
|
81
|
+
self, target_folder: str, hoys: list = [],
|
82
|
+
states: DynamicSchedule = None, t_step_multiplier: float = 1000,
|
83
|
+
grids_filter: str = '*', res_type: str = 'total'):
|
84
|
+
"""Get cumulative values for each sensor over a given period and write
|
85
|
+
the values to a folder.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
target_folder: Folder path to write annual metrics in. Usually this
|
89
|
+
folder is called 'metrics'.
|
90
|
+
hoys: An optional numbers or list of numbers to select the hours of
|
91
|
+
the year (HOYs) for which results will be computed. Defaults to [].
|
92
|
+
states: A dictionary of states. Defaults to None.
|
93
|
+
t_step_multiplier: A value that will be multiplied with the timestep.
|
94
|
+
grids_filter: The name of a grid or a pattern to filter the grids.
|
95
|
+
Defaults to '*'.
|
96
|
+
res_type: Type of results to load. Defaults to 'total'.
|
97
|
+
"""
|
98
|
+
super(AnnualIrradiance, self).cumulative_values_to_folder(
|
99
|
+
target_folder, hoys=hoys, states=states,
|
100
|
+
t_step_multiplier=t_step_multiplier, grids_filter=grids_filter,
|
101
|
+
res_type=res_type
|
102
|
+
)
|
103
|
+
|
104
|
+
def annual_metrics(
|
105
|
+
self, hoys: list = [], states: DynamicSchedule = None,
|
106
|
+
grids_filter: str = '*') -> type_hints.annual_irradiance_metrics:
|
107
|
+
"""Calculate multiple annual irradiance metrics.
|
108
|
+
|
109
|
+
This method will calculate the following metrics:
|
110
|
+
* Average Irradiance (W/m2)
|
111
|
+
* Peak Irradiance (W/m2)
|
112
|
+
* Cumulative Radiation (kWh/m2)
|
113
|
+
|
114
|
+
Args:
|
115
|
+
hoys: An optional numbers or list of numbers to select the hours of
|
116
|
+
the year (HOYs) for which results will be computed. Defaults to [].
|
117
|
+
states: A dictionary of states. Defaults to None.
|
118
|
+
grids_filter: The name of a grid or a pattern to filter the grids.
|
119
|
+
Defaults to '*'.
|
120
|
+
|
121
|
+
Returns:
|
122
|
+
Tuple: A tuple with the three annual irradiance metrics and grid information.
|
123
|
+
"""
|
124
|
+
grids_info = self._filter_grids(grids_filter=grids_filter)
|
125
|
+
mask = hoys_mask(self.sun_up_hours, hoys)
|
126
|
+
full_length = len(self.study_hours)
|
127
|
+
|
128
|
+
average = []
|
129
|
+
peak = []
|
130
|
+
cumulative = []
|
131
|
+
for grid_info in grids_info:
|
132
|
+
array = self._array_from_states(grid_info, states=states, res_type='total')
|
133
|
+
if np.any(array):
|
134
|
+
array_filter = np.apply_along_axis(
|
135
|
+
filter_array, 1, array, mask=mask)
|
136
|
+
average_results = average_values_array2d(
|
137
|
+
array_filter, full_length=full_length)
|
138
|
+
peak_results, max_i = peak_values_array2d(
|
139
|
+
array_filter)
|
140
|
+
cumulative_results = cumulative_values_array2d(
|
141
|
+
array_filter, self.timestep, 1000)
|
142
|
+
else:
|
143
|
+
average_results = peak_results = cumulative_results = \
|
144
|
+
np.zeros(grid_info['count'])
|
145
|
+
average.append(average_results)
|
146
|
+
peak.append(peak_results)
|
147
|
+
cumulative.append(cumulative_results)
|
148
|
+
|
149
|
+
return average, peak, cumulative, grids_info
|
150
|
+
|
151
|
+
def annual_metrics_to_folder(
|
152
|
+
self, target_folder: str, hoys: list = [],
|
153
|
+
states: DynamicSchedule = None, grids_filter: str = '*'):
|
154
|
+
"""Calculate and write multiple annual irradiance metrics to a folder.
|
155
|
+
|
156
|
+
This command generates 3 files for each input grid.
|
157
|
+
* average_irradiance/{grid-name}.res -- Average Irradiance (W/m2)
|
158
|
+
* peak_irradiance/{grid-name}.res -- Peak Irradiance (W/m2)
|
159
|
+
* cumulative_radiation/{grid-name}.res -- Cumulative Radiation (kWh/m2)
|
160
|
+
|
161
|
+
Args:
|
162
|
+
target_folder: Folder path to write annual metrics in. Usually this
|
163
|
+
folder is called 'metrics'.
|
164
|
+
hoys: An optional numbers or list of numbers to select the hours of
|
165
|
+
the year (HOYs) for which results will be computed. Defaults to [].
|
166
|
+
states: A dictionary of states. Defaults to None.
|
167
|
+
grids_filter: The name of a grid or a pattern to filter the grids.
|
168
|
+
Defaults to '*'.
|
169
|
+
"""
|
170
|
+
folder = Path(target_folder)
|
171
|
+
folder.mkdir(parents=True, exist_ok=True)
|
172
|
+
|
173
|
+
average, peak, cumulative, grids_info = self.annual_metrics(
|
174
|
+
hoys=hoys, states=states, grids_filter=grids_filter)
|
175
|
+
|
176
|
+
pattern = {
|
177
|
+
'average_irradiance': average, 'peak_irradiance': peak,
|
178
|
+
'cumulative_radiation': cumulative,
|
179
|
+
}
|
180
|
+
for metric, data in pattern.items():
|
181
|
+
metric_folder = folder.joinpath(metric)
|
182
|
+
for count, grid_info in enumerate(grids_info):
|
183
|
+
d = data[count]
|
184
|
+
full_id = grid_info['full_id']
|
185
|
+
output_file = metric_folder.joinpath(f'{full_id}.res')
|
186
|
+
output_file.parent.mkdir(parents=True, exist_ok=True)
|
187
|
+
np.savetxt(output_file, d, fmt='%.2f')
|
188
|
+
|
189
|
+
for metric in pattern.keys():
|
190
|
+
info_file = folder.joinpath(metric, 'grids_info.json')
|
191
|
+
info_file.write_text(json.dumps(grids_info))
|
192
|
+
|
193
|
+
metric_info_dict = _annual_irradiance_vis_metadata()
|
194
|
+
for metric, data in metric_info_dict.items():
|
195
|
+
vis_metadata_file = folder.joinpath(metric, 'vis_metadata.json')
|
196
|
+
vis_metadata_file.write_text(json.dumps(data, indent=4))
|