Skip to content

Commit

Permalink
Add openstudio-standards repository path to `create_openstudio_stan…
Browse files Browse the repository at this point in the history
…dards_space_data_json_ashrae_90_1()` (#90)

* Add osstd repo path to `create_openstudio_standards_space_data_json_ashrae_90_1()`

* Address review comments.
  • Loading branch information
lymereJ authored Sep 6, 2024
1 parent 9e159a7 commit 2db80d5
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@


def create_openstudio_standards_space_data_json_ashrae_90_1(
conn: sqlite3.Connection, version_90_1: str
conn: sqlite3.Connection, version_90_1: str, osstd_repository_path: str
):
"""Create and export space type related data for a specific version of ASHRAE 90.1 to be used by OpenStudio Standards
"""
Create and export space type related data for a specific version of ASHRAE 90.1 to be used by OpenStudio Standards.
The function should be used when a clone of OpenStudio Standards exists locally, see osstd_repository_path.
:param conn (sqlite3.Connection): database connection
:param version_90_1 (str): code version of ASHRAE 90.1, e.g. "2004", "2007", etc.
:param osstd_repository_path (str): path of the local openstudio-standards repository
"""
check_path(osstd_repository_path)

missing_data_lookup_hierarchy = [
"1999",
"2004",
Expand All @@ -33,7 +38,12 @@ def create_openstudio_standards_space_data_json_ashrae_90_1(
code = "ashrae_90_1"
template = f"90.1-{version_90_1}"
create_openstudio_standards_space_data_json(
conn, template, version_90_1, missing_data_lookup_hierarchy, code
conn,
template,
version_90_1,
missing_data_lookup_hierarchy,
code,
osstd_repository_path,
)


Expand Down Expand Up @@ -79,15 +89,23 @@ def create_openstudio_standards_space_data_json(
code_version: str,
missing_data_lookup_hierarchy: list,
code: str,
osstd_repository_path: str,
):
"""Extract code- and code version-specific OpenStudio Standards space type data from the database and export it to JSON files
"""
Extract code- and code version-specific OpenStudio Standards space type data from the database and export it to JSON files.
The function should be used when a clone of OpenStudio Standards exists locally, see osstd_repository_path.
:param conn (sqlite3.Connection): database connection
:param template (str): template corresponding to the code and code version, e.g. "90.1-2004", or "90.1-2007"
:param code_version (str): verion of the code, e.g. "2004", "2007", etc.
:param missing_data_lookup_hierarchy (list): list (ordered) of values to use to look up record if targeted value cannot be found
:param code (str): name of the building energy code, e.g. "ashrae_90_1"
:param osstd_repository_path (str): path of the local openstudio-standards repository
"""
check_path(osstd_repository_path)

space_map_table = fetch_space_data(conn)

# Drop other code versions
space_map_table = [
rec
Expand Down Expand Up @@ -294,7 +312,7 @@ def create_openstudio_standards_space_data_json(
# Export retrieved data
if len(space_types) > 0:
with open(
f"../../lib/openstudio-standards/standards/{code}/{code}_{code_version}/data/{code}_{code_version}.space_types.json",
f"{osstd_repository_path}/lib/openstudio-standards/standards/{code}/{code}_{code_version}/data/{code}_{code_version}.space_types.json",
"w+",
) as output_report:
output_report.write(json.dumps(space_types, indent=2))
Expand All @@ -309,7 +327,8 @@ def create_openstudio_standards_data_json_ashrae_90_1(
prm: bool = False,
) -> None:
"""
Create and export data for a specific version of ASHRAE 90.1 to be used by OpenStudio Standards
Create and export data for a specific version of ASHRAE 90.1 to be used by OpenStudio Standards.
The function should be used when a clone of OpenStudio Standards exists locally, see osstd_repository_path.
:param conn (sqlite3.Connection): database connection
:param version_90_1 (str): code version of ASHRAE 90.1, e.g. "2004", "2007", etc.
Expand Down

0 comments on commit 2db80d5

Please sign in to comment.