honeybee_doe2.util module

Various utilities used throughout the package.

honeybee_doe2.util.calculate_value_with_global_parameter(global_parameters, input_expr)[source]

Evaluate an INP Global Parameter expression with #PA(”…”).

Note that this method will only return a float value if the expression is strictly an inline math expression.

Parameters:
  • global_parameters – A dict with parameter names as keys and floats as values.

  • input_expr – A string of an expression to be evaluated. See an example below.

Returns:

Evaluated float result or None is not an inline math expression.

'{0.66 * #PA("...")}' or '{0.66 * #PA("...") + #PA("...")}
honeybee_doe2.util.clean_inp_file_contents(inp_file_contents)[source]

Clean the contents of an INP file by removing comment lines.

Global parameter lines are also solved if they are inline math expressions.

Parameters:

inp_file_contents – The file contents of an INP file as a text string.

Returns:

The input text string cleaned of comments and with global parameters solved.

honeybee_doe2.util.doe2_object_blocks(inp_file_contents)[source]

Get the object blocks of a DOE-2 INP file.

Parameters:

inp_file_contents – A string of the INP file to parse.

Returns:

A list of strings, where each string is a complete block of the INP file.

honeybee_doe2.util.generate_inp_string(u_name, command, keywords, values)[source]

Get an INP string representation of a DOE-2 object.

This method is written in a generic way so that it can describe practically any element of the INP Building Description Language (BDL).

Parameters:
  • u_name – Text for the unique, user-specified name of the object being created. This must be 32 characters or less and not contain special or non-ASCII characters. The clean_doe2_string method may be used to convert strings to a format that is acceptable here. For example, a U-Name of a space might be “Floor2W ClosedOffice5”.

  • command – Text indicating the type of instruction that the DOE-2 object executes. Commands are typically in capital letters and examples include POLYGON, FLOOR, SPACE, EXTERIOR-WALL, WINDOW, CONSTRUCTION, etc.

  • keywords – A list of text with the same length as the values that denote the attributes of the DOE-2 object.

  • values – A list of values with the same length as the keywords that describe the values of the attributes for the object.

Returns:

inp_str – A DOE-2 INP string representing a single object.

honeybee_doe2.util.generate_inp_string_list_format(u_name, command, keywords, values)[source]

Get an INP string of a DOE-2 object with nicer formatting for list values.

This method will process any values that are a list or tuple and format them such that they are indented and more readable. This method is written in a generic way so that it can describe practically any element of the INP Building Description Language (BDL).

Parameters:
  • u_name – Text for the unique, user-specified name of the object being created. This must be 32 characters or less and not contain special or non-ASCII characters. The clean_doe2_string method may be used to convert strings to a format that is acceptable here. For example, a U-Name of a space might be “Floor2W ClosedOffice5”.

  • command – Text indicating the type of instruction that the DOE-2 object executes. Commands are typically in capital letters and examples include POLYGON, FLOOR, SPACE, EXTERIOR-WALL, WINDOW, CONSTRUCTION, etc.

  • keywords – A list of text with the same length as the values that denote the attributes of the DOE-2 object.

  • values – A list of values with the same length as the keywords that describe the values of the attributes for the object. The items in this list can be list themselves, in which case they will be translated with nice indented formatting.

Returns:

inp_str – A DOE-2 INP string representing a single object.

honeybee_doe2.util.header_comment_major(header_text)[source]

Create a header given header_text, which can help organize the INP file contents.

honeybee_doe2.util.header_comment_minor(header_text)[source]

Create a header given header_text, which can help organize the INP file contents.

honeybee_doe2.util.inp_path_from_folder(folder_path=None, filename=None)[source]

Get the path to an INP file from a specified folder or the current directory.

Parameters:
  • folder_path – Path to the folder containing the INP file. If None, the current directory will be used.

  • filename – Name of the INP file. If None, the first file found in the folder with an .inp extension will be returned

Returns:

Path to the INP file.

Raises:

FileNotFoundError – If no INP file is found.

honeybee_doe2.util.parse_inp_string(inp_string)[source]

Parse an INP string of a single DOE-2 object into a list of values.

Note that this method is only equipped to parse DOE-2 test strings that originate from eQuest or from this package. It has not yet been generalized to parse all formats of text formats that can appear in a DOE-2 file.

Parameters:

inp_string – An INP string for a single DOE-2 object.

Returns:

A tuple with four elements.

  • u_name: Text for the unique name of the object. Will be None if the object is a Parameter.

  • command: Text for the type of instruction that the DOE-2 object executes.

  • keywords: A list of text with the same length as the values that denote the attributes of the DOE-2 object.

  • values: A list of values with the same length as the keywords that describe the values of the attributes for the object.

honeybee_doe2.util.switch_statement_id(value)[source]

Convert a string into a 4-character ID that can be used for switch statements.

This is needed to deal with the major limitations that DOE-2 places on switch statement IDs, where every ID must be 4 characters