Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openstudio-standards repository path to create_openstudio_standards_space_data_json_ashrae_90_1() #90

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
lymereJ marked this conversation as resolved.
Show resolved Hide resolved
"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
Loading