honeybee-energy 1.115.3__py2.py3-none-any.whl → 1.116.1__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.

Potentially problematic release.


This version of honeybee-energy might be problematic. Click here for more details.

@@ -11,6 +11,7 @@ from ladybug.commandutil import process_content_to_output
11
11
  from ladybug.analysisperiod import AnalysisPeriod
12
12
  from ladybug.epw import EPW
13
13
  from ladybug.stat import STAT
14
+ from ladybug.futil import preparedir
14
15
  from honeybee.model import Model
15
16
  from honeybee.typing import clean_rad_string
16
17
  from honeybee.config import folders as hb_folders
@@ -22,7 +23,8 @@ from honeybee_energy.construction.window import WindowConstruction
22
23
  from honeybee_energy.schedule.dictutil import dict_to_schedule
23
24
  from honeybee_energy.schedule.ruleset import ScheduleRuleset
24
25
  from honeybee_energy.properties.model import ModelEnergyProperties
25
- from honeybee_energy.run import run_osw, from_gbxml_osw, from_osm_osw, from_idf_osw, \
26
+ from honeybee_energy.run import to_openstudio_sim_folder, run_osw, \
27
+ from_gbxml_osw, from_osm_osw, from_idf_osw, \
26
28
  _parse_os_cli_failure, HB_OS_MSG
27
29
  from honeybee_energy.writer import energyplus_idf_version, _preprocess_model_for_trace
28
30
  from honeybee_energy.config import folders
@@ -35,6 +37,146 @@ def translate():
35
37
  pass
36
38
 
37
39
 
40
+ @translate.command('model-to-sim-folder')
41
+ @click.argument('model-file', type=click.Path(
42
+ exists=True, file_okay=True, dir_okay=False, resolve_path=True))
43
+ @click.argument('epw-file', type=click.Path(
44
+ exists=True, file_okay=True, dir_okay=False, resolve_path=True))
45
+ @click.option('--sim-par-json', '-sp', help='Full path to a honeybee energy '
46
+ 'SimulationParameter JSON that describes all of the settings for '
47
+ 'the simulation. This will be ignored if the input model-file is '
48
+ 'an OSM or IDF.', default=None, show_default=True,
49
+ type=click.Path(exists=False, file_okay=True, dir_okay=False,
50
+ resolve_path=True))
51
+ @click.option('--measures', '-m', help='Full path to a folder containing an OSW JSON '
52
+ 'be used as the base for the execution of the OpenStudio CLI. While this '
53
+ 'OSW can contain paths to measures that exist anywhere on the machine, '
54
+ 'the best practice is to copy the measures into this measures '
55
+ 'folder and use relative paths within the OSW. '
56
+ 'This makes it easier to move the inputs for this command from one '
57
+ 'machine to another.', default=None, show_default=True,
58
+ type=click.Path(file_okay=False, dir_okay=True, resolve_path=True))
59
+ @click.option('--additional-string', '-as', help='An additional IDF text string to get '
60
+ 'appended to the IDF before simulation. The input should include '
61
+ 'complete EnergyPlus objects as a single string following the IDF '
62
+ 'format. This input can be used to include small EnergyPlus objects that '
63
+ 'are not currently supported by honeybee.', default=None, type=str)
64
+ @click.option('--additional-idf', '-ai', help='An IDF file with text to be '
65
+ 'appended before simulation. This input can be used to include '
66
+ 'large EnergyPlus objects that are not currently supported by honeybee.',
67
+ default=None, show_default=True,
68
+ type=click.Path(exists=False, file_okay=True, dir_okay=False,
69
+ resolve_path=True))
70
+ @click.option('--folder', '-f', help='Folder on this computer, into which the IDF '
71
+ 'and result files will be written. If None, the files will be output '
72
+ 'to the honeybee default simulation folder and placed in a project '
73
+ 'folder with the same name as the model-file.',
74
+ default=None, show_default=True,
75
+ type=click.Path(file_okay=False, dir_okay=True, resolve_path=True))
76
+ @click.option('--log-file', '-log', help='Optional log file to output the paths of the '
77
+ 'generated files (osw, osm, idf) if successfully'
78
+ ' created. By default the list will be printed out to stdout',
79
+ type=click.File('w'), default='-', show_default=True)
80
+ def simulate_model(
81
+ model_file, epw_file, sim_par_json, measures, additional_string, additional_idf,
82
+ folder, log_file
83
+ ):
84
+ """Simulate a Model in EnergyPlus.
85
+
86
+ \b
87
+ Args:
88
+ model_file: Full path to a Model file as a HBJSON or HBPkl.
89
+ epw_file: Full path to an .epw file.
90
+ """
91
+ try:
92
+ # get a ddy variable that might get used later
93
+ epw_folder, epw_file_name = os.path.split(epw_file)
94
+ ddy_file = os.path.join(epw_folder, epw_file_name.replace('.epw', '.ddy'))
95
+ stat_file = os.path.join(epw_folder, epw_file_name.replace('.epw', '.stat'))
96
+
97
+ # sense what type of file has been input
98
+ proj_name = os.path.basename(model_file).lower()
99
+
100
+ # set the default folder to the default if it's not specified
101
+ if folder is None:
102
+ for ext in ('.hbjson', '.json', '.hbpkl', '.pkl'):
103
+ proj_name = proj_name.replace(ext, '')
104
+ folder = os.path.join(folders.default_simulation_folder, proj_name)
105
+ folder = os.path.join(folder, 'openstudio')
106
+ preparedir(folder, remove_content=False)
107
+
108
+ # process the simulation parameters and write new ones if necessary
109
+ def ddy_from_epw(epw_file, sim_par):
110
+ """Produce a DDY from an EPW file."""
111
+ epw_obj = EPW(epw_file)
112
+ des_days = [epw_obj.approximate_design_day('WinterDesignDay'),
113
+ epw_obj.approximate_design_day('SummerDesignDay')]
114
+ sim_par.sizing_parameter.design_days = des_days
115
+
116
+ if sim_par_json is None or not os.path.isfile(sim_par_json):
117
+ sim_par = SimulationParameter()
118
+ sim_par.output.add_zone_energy_use()
119
+ sim_par.output.add_hvac_energy_use()
120
+ sim_par.output.add_electricity_generation()
121
+ sim_par.output.reporting_frequency = 'Monthly'
122
+ else:
123
+ with open(sim_par_json) as json_file:
124
+ data = json.load(json_file)
125
+ sim_par = SimulationParameter.from_dict(data)
126
+ if len(sim_par.sizing_parameter.design_days) == 0 and \
127
+ os.path.isfile(ddy_file):
128
+ try:
129
+ sim_par.sizing_parameter.add_from_ddy_996_004(ddy_file)
130
+ except AssertionError: # no design days within the DDY file
131
+ ddy_from_epw(epw_file, sim_par)
132
+ elif len(sim_par.sizing_parameter.design_days) == 0:
133
+ ddy_from_epw(epw_file, sim_par)
134
+ if sim_par.sizing_parameter.climate_zone is None and \
135
+ os.path.isfile(stat_file):
136
+ stat_obj = STAT(stat_file)
137
+ sim_par.sizing_parameter.climate_zone = stat_obj.ashrae_climate_zone
138
+
139
+ # process the measures input if it is specified
140
+ base_osw = None
141
+ if measures is not None and measures != '' and os.path.isdir(measures):
142
+ for f_name in os.listdir(measures):
143
+ if f_name.lower().endswith('.osw'):
144
+ base_osw = os.path.join(measures, f_name)
145
+ # write the path of the measures folder into the OSW
146
+ with open(base_osw) as json_file:
147
+ osw_dict = json.load(json_file)
148
+ osw_dict['measure_paths'] = [os.path.abspath(measures)]
149
+ with open(base_osw, 'w') as fp:
150
+ json.dump(osw_dict, fp)
151
+ break
152
+
153
+ # Write the osw file to translate the model to osm
154
+ strings_to_inject = additional_string if additional_string is not None else ''
155
+ if additional_idf is not None and os.path.isfile(additional_idf):
156
+ with open(additional_idf, "r") as add_idf_file:
157
+ strings_to_inject = strings_to_inject + '\n' + add_idf_file.read()
158
+
159
+ # run the Model re-serialization and convert to OSM, OSW, and IDF
160
+ osm, osw, idf = None, None, None
161
+ model = Model.from_file(model_file)
162
+ osm, osw, idf = to_openstudio_sim_folder(
163
+ model, folder, epw_file=epw_file, sim_par=sim_par, enforce_rooms=True,
164
+ base_osw=base_osw, strings_to_inject=strings_to_inject,
165
+ print_progress=True)
166
+ gen_files = [osm]
167
+ if osw is not None:
168
+ gen_files.append(osw)
169
+ if idf is not None:
170
+ gen_files.append(idf)
171
+
172
+ log_file.write(json.dumps(gen_files, indent=4))
173
+ except Exception as e:
174
+ _logger.exception('Model simulation failed.\n{}'.format(e))
175
+ sys.exit(1)
176
+ else:
177
+ sys.exit(0)
178
+
179
+
38
180
  @translate.command('model-to-osm')
39
181
  @click.argument('model-file', type=click.Path(
40
182
  exists=True, file_okay=True, dir_okay=False, resolve_path=True))
honeybee_energy/run.py CHANGED
@@ -239,32 +239,33 @@ def to_openstudio_sim_folder(
239
239
  osw_dict['file_paths'].append(schedule_directory)
240
240
  if epw_file is not None:
241
241
  osw_dict['weather_file'] = epw_file
242
- if 'measure_paths' not in osw_dict:
243
- osw_dict['measure_paths'] = []
244
- measure_paths = set() # set of all unique measure paths
245
- # ensure measures are correctly ordered
246
- m_dict = {'ModelMeasure': [], 'EnergyPlusMeasure': [], 'ReportingMeasure': []}
247
- for measure in additional_measures:
248
- m_dict[measure.type].append(measure)
249
- sorted_measures = m_dict['ModelMeasure'] + m_dict['EnergyPlusMeasure'] + \
250
- m_dict['ReportingMeasure']
251
- # add the measures and the measure paths to the OSW
252
- for measure in sorted_measures:
253
- measure.validate() # ensure that all required arguments have values
254
- measure_paths.add(os.path.dirname(measure.folder))
255
- osw_dict['steps'].append(measure.to_osw_dict()) # add measure to workflow
256
- for m_path in measure_paths:
257
- osw_dict['measure_paths'].append(m_path)
258
- # if there were reporting measures, add the ladybug adapter to get sim progress
259
- adapter = folders.honeybee_adapter_path
260
- if adapter is not None:
261
- if 'run_options' not in osw_dict:
262
- osw_dict['run_options'] = {}
263
- osw_dict['run_options']['output_adapter'] = {
264
- 'custom_file_name': adapter,
265
- 'class_name': 'HoneybeeAdapter',
266
- 'options': {}
267
- }
242
+ if additional_measures is not None:
243
+ if 'measure_paths' not in osw_dict:
244
+ osw_dict['measure_paths'] = []
245
+ measure_paths = set() # set of all unique measure paths
246
+ # ensure measures are correctly ordered
247
+ m_dict = {'ModelMeasure': [], 'EnergyPlusMeasure': [], 'ReportingMeasure': []}
248
+ for measure in additional_measures:
249
+ m_dict[measure.type].append(measure)
250
+ sorted_measures = m_dict['ModelMeasure'] + m_dict['EnergyPlusMeasure'] + \
251
+ m_dict['ReportingMeasure']
252
+ # add the measures and the measure paths to the OSW
253
+ for measure in sorted_measures:
254
+ measure.validate() # ensure that all required arguments have values
255
+ measure_paths.add(os.path.dirname(measure.folder))
256
+ osw_dict['steps'].append(measure.to_osw_dict()) # add measure to workflow
257
+ for m_path in measure_paths:
258
+ osw_dict['measure_paths'].append(m_path)
259
+ # if there were reporting measures, add the ladybug adapter to get sim progress
260
+ adapter = folders.honeybee_adapter_path
261
+ if adapter is not None:
262
+ if 'run_options' not in osw_dict:
263
+ osw_dict['run_options'] = {}
264
+ osw_dict['run_options']['output_adapter'] = {
265
+ 'custom_file_name': adapter,
266
+ 'class_name': 'HoneybeeAdapter',
267
+ 'options': {}
268
+ }
268
269
  # write the dictionary to a workflow.osw
269
270
  osw = os.path.abspath(os.path.join(directory, 'workflow.osw'))
270
271
  if (sys.version_info < (3, 0)): # we need to manually encode it as UTF-8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: honeybee-energy
3
- Version: 1.115.3
3
+ Version: 1.116.1
4
4
  Summary: Energy simulation library for honeybee.
5
5
  Home-page: https://github.com/ladybug-tools/honeybee-energy
6
6
  Author: Ladybug Tools
@@ -17,7 +17,7 @@ License-File: LICENSE
17
17
  Requires-Dist: honeybee-core==1.61.12
18
18
  Requires-Dist: honeybee-standards==2.0.7
19
19
  Provides-Extra: openstudio
20
- Requires-Dist: honeybee-openstudio==0.2.3; extra == "openstudio"
20
+ Requires-Dist: honeybee-openstudio==0.2.4; extra == "openstudio"
21
21
  Provides-Extra: standards
22
22
  Requires-Dist: honeybee-energy-standards==2.3.0; extra == "standards"
23
23
 
@@ -11,7 +11,7 @@ honeybee_energy/internalmass.py,sha256=8b4NuQpi5jBue31Q56YvMTx1iXPEEKmKe9-J9aLh5
11
11
  honeybee_energy/measure.py,sha256=S4MBqC8eLWzqCLFeTa0uQQgWE6-NOPcmUU0wlu9uXB0,17403
12
12
  honeybee_energy/programtype.py,sha256=yJJc0WYZPc7-m27h5hlDXW-jmwPu8CMhhP_AlwDorqM,34221
13
13
  honeybee_energy/reader.py,sha256=PTiv0WCfc3kGPA--__8QiR-JhnRgq1VkcU-PvvzLjzM,1856
14
- honeybee_energy/run.py,sha256=vHC5QR5j5tK5iqSlWwnrTTpEFlaNbl3cIISQbutq6lQ,74488
14
+ honeybee_energy/run.py,sha256=DDi-1wS-C1_i32nxV00-F2TciMqXJxFNaTEvdIjJxnE,74636
15
15
  honeybee_energy/shw.py,sha256=9CifpIhF0q48DtKb58vF_zoeouZ15OAYcWTGL6NJJQY,12727
16
16
  honeybee_energy/writer.py,sha256=lIDc_jZjIcWtoRItiyb5iwXwtgBg3WRQa58KrH7nTZU,48437
17
17
  honeybee_energy/baseline/__init__.py,sha256=pAN81W4x__LwHO6nsvV3FIdoSyI9cDAeS1xM-LeOtvU,91
@@ -34,7 +34,7 @@ honeybee_energy/cli/result.py,sha256=Cqg1KwkDqeqLjpBn8dpWXvHqg_UyxNmLTgj64gfpBWY
34
34
  honeybee_energy/cli/setconfig.py,sha256=c22bvTyCH1ieebkP39-YI2uI3irjVjGOL90ysrRdgmg,4386
35
35
  honeybee_energy/cli/settings.py,sha256=gDPQDN1XmYiIxEag9aYboWoifrCcD2AYOEw3M_b8_v4,28731
36
36
  honeybee_energy/cli/simulate.py,sha256=5i5_O8m_iXHXukr53TVyqfNmwZSUqgNiLB8K9EbNjLA,18589
37
- honeybee_energy/cli/translate.py,sha256=Dds7lxr0tvYNaGAaoEK1PILCIRKTtNQreKWmo_fZRqo,73884
37
+ honeybee_energy/cli/translate.py,sha256=TUeIYZHsvJ3VZxmjM2NFhILqrcREQjDG5cUd9S0FJVs,81361
38
38
  honeybee_energy/cli/validate.py,sha256=viXYu6Xx_LOdDK2NUqpwIr6QyWd5_AGgKZTCYUmpaoA,9339
39
39
  honeybee_energy/construction/__init__.py,sha256=oCfbVLV3m_Imqf8JK0_IyVdKuMJphPQOCQ5_MjcH9Us,37
40
40
  honeybee_energy/construction/_base.py,sha256=s-ha1K2FsbZELYZEqcBBjgkFnA9Ik-LxCnFsDVUsSVc,14321
@@ -156,9 +156,9 @@ honeybee_energy/ventcool/opening.py,sha256=ZywoADlNQ6_8OfjV71ZUpbCAetQrRVj7aprBj
156
156
  honeybee_energy/ventcool/simulation.py,sha256=gMF4sgCQ5R4iFWPnvvB3wxgeP_zEwnWl71ObIIe4XGU,14423
157
157
  tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
158
  tests/fixtures/userdata_fixtures.py,sha256=yDvBR6nsltel_U8hUoUsJ6yufPKTR7Wnsgxe68HtswQ,313
159
- honeybee_energy-1.115.3.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
160
- honeybee_energy-1.115.3.dist-info/METADATA,sha256=i8FGbz0_ST4tzUBam2In3IyT9aW9mmbW86ZFREWLcgA,3562
161
- honeybee_energy-1.115.3.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
162
- honeybee_energy-1.115.3.dist-info/entry_points.txt,sha256=QOMJbH-StaxT4hCjskZtqetNCMNioP3ZiuhoLQ6MANc,63
163
- honeybee_energy-1.115.3.dist-info/top_level.txt,sha256=V9Lz0281hfT83Fy0fSdn_6vwRK9vTQe1_LQXd0_-gAI,22
164
- honeybee_energy-1.115.3.dist-info/RECORD,,
159
+ honeybee_energy-1.116.1.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
160
+ honeybee_energy-1.116.1.dist-info/METADATA,sha256=YOd378iDxoTI7DqjdmNdYOglkm1q5aWdQkgKlrWyWKY,3562
161
+ honeybee_energy-1.116.1.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
162
+ honeybee_energy-1.116.1.dist-info/entry_points.txt,sha256=QOMJbH-StaxT4hCjskZtqetNCMNioP3ZiuhoLQ6MANc,63
163
+ honeybee_energy-1.116.1.dist-info/top_level.txt,sha256=V9Lz0281hfT83Fy0fSdn_6vwRK9vTQe1_LQXd0_-gAI,22
164
+ honeybee_energy-1.116.1.dist-info/RECORD,,