From 4a97a802478102792f528f6cd8524ad37d916488 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 13:21:15 -0400 Subject: [PATCH 01/31] New: Adds documentation pkgs in requirements --- requirements-dev.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2c4d6506e..d8edac24c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,4 +4,6 @@ pytest pytest-cov scikit-learn scipy -sphinx \ No newline at end of file +sphinx +sphinx_rtd_theme +recommonmark \ No newline at end of file From bee9c0b9608dc949d5143767bf19d534aaad73f9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 13:46:04 -0400 Subject: [PATCH 02/31] New: Adds documentation for Translator --- docs/converter_idf.rst | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docs/converter_idf.rst diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst new file mode 100644 index 000000000..4e7e035fa --- /dev/null +++ b/docs/converter_idf.rst @@ -0,0 +1,8 @@ +Translator IDF to BUI +============ + +The necessity of translating IDF files (EnergyPlus input files) to BUI files (TRNBuild input files) emerged from the +need of modeling building archetypes1. Knowing that a lot of different models from different sources (NECB and US-DOE) +have already been developed under EnergyPlus, and it can be a tedious task to create a multizone building in a model +editor (e.g. TRNBuild), we assume the development of a file translator could be useful for simulationist. + From 2bdf3d3670e80f89388c33c5aecff5692e3b887f Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 14:35:19 -0400 Subject: [PATCH 03/31] New: Adds Command Line Interface (CLI) for trnsys module --- archetypal/__init__.py | 3 +- archetypal/cli.py | 120 +++++++++++++++++++++++++++++++++++++++++ setup.py | 6 ++- 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 archetypal/cli.py diff --git a/archetypal/__init__.py b/archetypal/__init__.py index ccb924ae0..389b928f6 100644 --- a/archetypal/__init__.py +++ b/archetypal/__init__.py @@ -16,4 +16,5 @@ from .schedule import Schedule from .dataportal import * from .plot import * -from .trnsys import * \ No newline at end of file +from .trnsys import * +from .cli import * \ No newline at end of file diff --git a/archetypal/cli.py b/archetypal/cli.py new file mode 100644 index 000000000..901709c43 --- /dev/null +++ b/archetypal/cli.py @@ -0,0 +1,120 @@ +################################################################################ +# Module: cli.py +# Description: Implements archetypal functions as Command Line Interfaces +# License: MIT, see full license in LICENSE.txt +# Web: https://github.com/samuelduchesne/archetypal +################################################################################ +import os + +import click + +import archetypal +from archetypal import settings + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class Config(object): + def __init__(self): + self.data_folder = settings.data_folder, + self.logs_folder = settings.logs_folder, + self.imgs_folder = settings.imgs_folder, + self.cache_folder = settings.cache_folder, + self.use_cache = settings.use_cache, + self.log_file = settings.log_file, + self.log_console = settings.log_console, + self.log_level = settings.log_level, + self.log_name = settings.log_name, + self.log_filename = settings.log_filename, + self.useful_idf_objects = settings.useful_idf_objects, + self.umitemplate = settings.umitemplate, + self.trnsys_default_folder = settings.trnsys_default_folder + + +pass_config = click.make_pass_decorator(Config, ensure=True) + + +@click.group(context_settings=CONTEXT_SETTINGS) +@click.option('--data-folder', type=click.Path(), + help='where to save and load data files', + default=settings.data_folder) +@click.option('--logs-folder', type=click.Path(), + help='where to write the log files', + default=settings.logs_folder) +@click.option('--imgs-folder', type=click.Path(), + help='where to save figures', + default=settings.imgs_folder) +@click.option('--cache-folder', type=click.Path(), + help='where to save the simluation results', + default=settings.cache_folder) +@click.option('--use-cache/--no-cache', + help='Use a local cache to save/retrieve many of ' + 'archetypal outputs such as EnergyPlus simulation results', + default=settings.use_cache) +@click.option('--log-file/--no-log-file', + help='save log output to a log file in logs_folder', + default=settings.log_file) +@click.option('--log-console/--no-log-console', + help='print log output to the console', + default=settings.log_console) +@click.option('--log-level', type=click.INT, + help='CRITICAL=50, ERROR=40, WARNING=30, INFO=20, DEBUG=10', + default=settings.log_level) +@click.option('--log-name', help='name of the logger', + default=settings.log_name) +@click.option('--log-filename', help='name of the log file', + default=settings.log_filename) +@click.option('--trnsys-default-folder', type=click.Path(), + help='root folder of TRNSYS install', + default=settings.trnsys_default_folder) +@pass_config +def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, + use_cache, log_file, log_console, log_level, log_name, log_filename, + trnsys_default_folder): + """Description""" + config.data_folder = data_folder + config.logs_folder = logs_folder + config.imgs_folder = imgs_folder + config.cache_folder = cache_folder + config.use_cache = use_cache + config.log_file = log_file + config.log_console = log_console + config.log_level = log_level + config.log_name = log_name + config.log_filename = log_filename + config.trnsys_default_folder = trnsys_default_folder + archetypal.config(**config.__dict__) + + +@cli.command() +@click.argument('idf-file') +@click.argument('output-folder') +@click.option('--return-idf', '-i', is_flag=True, default=False) +@click.option('--return_b18', '-b', is_flag=True, default=True) +@click.option('--return_t3d', '-t', is_flag=True, default=False) +@click.option('--return_dck', '-t', is_flag=True, default=False) +@click.option('--window-lib', type=click.Path(), default=None, + help='Path of the window library (from Berkeley Lab)') +@click.option('--trnsidf_exe_dir', type=click.Path(), + help='Path to trnsidf.exe', + default=os.path.join( + settings.trnsys_default_folder, + r"Building\trnsIDF\trnsidf.exe")) +@click.option('--template', type=click.Path(), + default=settings.path_template_d18, + help='Path to d18 template file') +@pass_config +def convert(config, idf_file, window_lib, return_idf, return_b18, return_t3d, + return_dck, output_folder, trnsidf_exe_dir, template): + """Convert regular IDF file (EnergyPlus) to TRNBuild file (TRNSYS)""" + archetypal.convert_idf_to_trnbuild(idf_file, window_lib, + return_idf, return_b18, + return_t3d, return_dck, + output_folder, trnsidf_exe_dir, + template) + + +@cli.command() +@pass_config +def reduce(): + pass diff --git a/setup.py b/setup.py index b2a4adb3e..f644f433c 100644 --- a/setup.py +++ b/setup.py @@ -62,5 +62,9 @@ def find_version(*file_paths): extras_require={'tests': ['coverage', 'coveralls', 'pytest', 'matplotlib'], 'docs': ['sphinx', 'nbsphinx', 'jupyter_client', 'ipykernel']}, - test_suite='tests' + test_suite='tests', + entry_points=''' + [console_scripts] + archetypal=archetypal.cli:cli + ''', ) From 9aa6e987f0767aa8b2ddbc6126b2cb7b2839986b Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 14:36:47 -0400 Subject: [PATCH 04/31] Removes deprecated command get_common_umi_objects from config() --- archetypal/utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/archetypal/utils.py b/archetypal/utils.py index 4c9afafac..11e552a60 100644 --- a/archetypal/utils.py +++ b/archetypal/utils.py @@ -43,7 +43,6 @@ def config(data_folder=settings.data_folder, log_filename=settings.log_filename, useful_idf_objects=settings.useful_idf_objects, umitemplate=settings.umitemplate, - get_common_umi_objects=False, trnsys_default_folder=settings.trnsys_default_folder): """ Configurations @@ -85,9 +84,6 @@ def config(data_folder=settings.data_folder, settings.umitemplate = umitemplate settings.trnsys_default_folder = validate_trnsys_folder( trnsys_default_folder) - if get_common_umi_objects: - settings.common_umi_objects = get_list_of_common_umi_objects( - settings.umitemplate) # if logging is turned on, log that we are configured if settings.log_file or settings.log_console: From ffc5603bdbeb4e67159c79a917729569e1a51184 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 14:37:21 -0400 Subject: [PATCH 05/31] Adds file assertions + code cleanup --- archetypal/trnsys.py | 154 +++++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 63 deletions(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index e9580fc7f..07cb23b5e 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -26,7 +26,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, return_idf=False, return_b18=True, return_t3d=False, return_dck=False, - output_folder=None, trnidf_exe_dir=os.path.join( + output_folder=None, trnsidf_exe_dir=os.path.join( settings.trnsys_default_folder, r"Building\trnsIDF\trnsidf.exe"), template=settings.path_template_d18, @@ -42,6 +42,15 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, * the path to the TRNBuild input file (.idf) * the path to the TRNSYS dck file (.dck) + Example: + >>> # Exemple of setting kwargs to be unwrapped in the function + >>> kwargs_dict = {'u_value': 2.5, 'shgc': 0.6, 't_vis': 0.78, + 'tolerance': 0.05, 'ordered': True} + >>> # Exemple how to call the function + >>> convert_idf_to_trnbuild(idf_file=idf_file, + window_lib=window_filepath, + **kwargs_dict) + Args: idf_file: window_lib (str): File path of the window library (from Berkeley Lab). @@ -54,7 +63,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, return_dck (bool, optional): If True, also return the path to the TRNSYS dck file (.dck). output_folder (str, optional): location where output files will be - trnidf_exe_dir (str): Path to *trnsidf.exe*. + trnsidf_exe_dir (str): Path to *trnsidf.exe*. template (str): Path to d18 template file. kwargs (dict): keyword arguments sent to :func:`convert_idf_to_trnbuild()` or :func:`trnbuild_idf()` or @@ -73,17 +82,17 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, * retrun_trn (str): the path to the TRNSYS dck file (.dck). Only provided if *return_dck* is True. - Example: - >>> # Exemple of setting kwargs to be unwrapped in the function - >>> kwargs_dict = {'u_value': 2.5, 'shgc': 0.6, 't_vis': 0.78, - 'tolerance': 0.05, 'ordered': True} - >>> # Exemple how to call the function - >>> convert_idf_to_trnbuild(idf_file=idf_file, - window_lib=window_filepath, - **kwargs_dict) - + Todo: + - Add console info at beginning of each steps of this method + - Add console info about the outputs of the function at the end when + it is completed. + - Add option to hide name conversion report """ + idf_file, window_lib, output_folder, trnsidf_exe_dir, template = \ + _assert_files(idf_file, window_lib, output_folder, trnsidf_exe_dir, + template) + # Check if cache exists start_time = time.time() cache_filename = hash_file(idf_file) @@ -97,8 +106,11 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # Clean names of idf objects (e.g. 'MATERIAL') start_time = time.time() clear_name_idf_objects(idf) - idf.saveas(filename=os.path.join(settings.cache_folder, cache_filename, - cache_filename + '.idf')) + path = os.path.join(settings.cache_folder, cache_filename, + cache_filename + '.idf') + if not os.path.exists(path): + os.makedirs(os.path.dirname(path)) + idf.saveas(filename=path) # save_idf_object_to_cache(idf, idf_file, cache_filename, 'pickle') log("Cleaned IDF object names in {:,.2f} seconds".format( time.time() - start_time), lg.INFO) @@ -318,7 +330,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, trnbuild_idf(t3d_path, template, dck=dck, nonum=nonum, N=N, geo_floor=geo_floor, refarea=refarea, volume=volume, capacitance=capacitance, - trnidf_exe_dir=trnidf_exe_dir) + trnidf_exe_dir=trnsidf_exe_dir) # Prepare return arguments pre, ext = os.path.splitext(t3d_path) @@ -330,18 +342,37 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, [return_idf, return_b18, return_t3d, return_dck])) +def _assert_files(idf_file, window_lib, output_folder, trnsidf_exe_dir, + template): + """Ensure the files and directory are here""" + if not os.path.isfile(idf_file): + raise IOError("idf_file file not found") + + if window_lib: + if not os.path.isfile(window_lib): + raise IOError("window_lib file not found") + + if not os.path.exists(output_folder): + raise IOError("output_folder directory does not exist") + + if not os.path.isfile(trnsidf_exe_dir): + raise IOError("trnsidf.exe not found") + + if not os.path.isfile(template): + raise IOError("template file not found") + + return idf_file, window_lib, output_folder, trnsidf_exe_dir, template + + def _add_change_adj_surf(buildingSurfs, idf): """Adds or changes adjacent surfaces if needed Args: buildingSurfs (idf_MSequence): IDF object from idf.idfobjects(). List of - building surfaces ("BUILDINGSURFACE:DETAILED" in the IDF). - Building surfaces to iterate over and determine if either a change on - an adjacent surface is needed or the creation of a new one + building surfaces ("BUILDINGSURFACE:DETAILED" in the IDF). Building + surfaces to iterate over and determine if either a change on an + adjacent surface is needed or the creation of a new one idf (archetypal.idfclass.IDF): IDF object - - Returns: - """ adj_surfs_to_change = {} adj_surfs_to_make = [] @@ -803,6 +834,18 @@ def trnbuild_idf(idf_file, template=os.path.join( on the geometric information of the IDF file and the template D18 file. In addition, an template DCK file can be generated. + Example: + >>> # Exemple of setting kwargs to be unwrapped in the function + >>> kwargs_dict = {'dck': True, 'geo_floor': 0.57} + >>> # Exemple how to call the function + >>> trnbuild_idf(idf_file, template=os.path.join( + settings.trnsys_default_folder, + r"Building\\trnsIDF\\NewFileTemplate.d18"), + trnidf_exe_dir=os.path.join(settings.trnsys_default_folder, + r"Building\\trnsIDF\\trnsidf.exe"), **kwargs_dict) + >>> INFO: Where settings.trnsys_default_folder must be defined inside + the configuration file of the package + Args: idf_file (str): path/filename.idf template (str): path/NewFileTemplate.d18 @@ -822,20 +865,9 @@ def trnbuild_idf(idf_file, template=os.path.join( str: status Raises: - CalledProcessError: When could not run command with trnsidf.exe (to - create BUI file from IDF (T3D) file + * CalledProcessError: When could not run command with trnsidf.exe (to - Example: - >>> # Exemple of setting kwargs to be unwrapped in the function - >>> kwargs_dict = {'dck': True, 'geo_floor': 0.57} - >>> # Exemple how to call the function - >>> trnbuild_idf(idf_file, template=os.path.join( - settings.trnsys_default_folder, - r"Building\\trnsIDF\\NewFileTemplate.d18"), - trnidf_exe_dir=os.path.join(settings.trnsys_default_folder, - r"Building\\trnsIDF\\trnsidf.exe"), **kwargs_dict) - >>> INFO: Where settings.trnsys_default_folder must be defined inside - the configuration file of the package + * create BUI file from IDF (T3D) file """ # first copy idf_file into output folder if not os.path.isdir(settings.data_folder): @@ -937,8 +969,8 @@ def _write_zone_buildingSurf_fenestrationSurf(buildingSurfs, coordSys, count_fs, count_fs (int): Count of the number of fenestration surfaces. count_slope (int): Count of the different window's slopes fenestrationSurfs (idf_MSequence): IDF object from idf.idfobjects(). - List of fenestration surfaces ("FENESTRATIONSURFACE:DETAILED" in - the IDF). + List of fenestration surfaces ("FENESTRATIONSURFACE:DETAILED" in the + IDF). idf (archetypal.idfclass.IDF): IDF object lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here @@ -1088,7 +1120,8 @@ def _modify_adj_surface(buildingSurf, idf): '"{surfname}" that have "{outside_bound}" as Outside ' \ 'Boundary Condition Object.'.format( idfname=os.path.basename( - idf.idfname), surfname=buildingSurf.Name, outside_bound=outside_bound_surf) + idf.idfname), surfname=buildingSurf.Name, + outside_bound=outside_bound_surf) raise NotImplementedError(msg) else: # Replace the Outside_Boundary_Condition_Object that was the @@ -1118,9 +1151,9 @@ def _modify_adj_surface(buildingSurf, idf): 'BUILDINGSURFACE:DETAILED') a = idf.getobject( - 'BUILDINGSURFACE:DETAILED', - outside_bound_surf) - b=1 + 'BUILDINGSURFACE:DETAILED', + outside_bound_surf) + b = 1 def _inverse_vertices_surf(buildingSurf, idf, outside_bound_surf, @@ -1326,8 +1359,8 @@ def _write_gains(equipments, idf, lights, lines, peoples): equipments (idf_MSequence): IDF object from idf.idfobjects(). List of equipments ("ELECTRICEQUIPMENT" in the IDF). idf (archetypal.idfclass.IDF): IDF object - lights (idf_MSequence): IDF object from idf.idfobjects(). List of - lights ("LIGHTS" in the IDF). + lights (idf_MSequence): IDF object from idf.idfobjects(). List of lights + ("LIGHTS" in the IDF). lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here peoples (idf_MSequence): IDF object from idf.idfobjects() @@ -1405,8 +1438,8 @@ def _write_light_gain(gainNum, lights, lines): Args: gainNum (int): Line number where to write the equipment gains - lights (idf_MSequence): IDF object from idf.idfobjects(). List of - lights ("LIGHTS" in the IDF). + lights (idf_MSequence): IDF object from idf.idfobjects(). List of lights + ("LIGHTS" in the IDF). lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here """ @@ -1503,10 +1536,8 @@ def _write_materials(lines, materialAirGap, materialNoMass, materials): Args: lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here - materialAirGap (idf_MSequence): IDF object from idf.idfobjects(). List of - air gap materials ("MATERIAL:AIRGAP" in the IDF). - materialNoMass (idf_MSequence): IDF object from idf.idfobjects(). List of - material no mass ("MATERIAL:NOMASS" in the IDF) + materialAirGap (idf_MSequence): IDF object from idf.idfobjects(). + materialNoMass (idf_MSequence): IDF object from idf.idfobjects(). materials (idf_MSequence): IDF object from idf.idfobjects(). List of materials ("MATERIAL" in the IDF) """ @@ -1528,8 +1559,7 @@ def _write_material_airgap(layerNum, lines, listLayerName, materialAirGap): lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here listLayerName (list): list of material's names. To be appended when - materialAirGap materialAirGap (idf_MSequence): IDF object from idf.idfobjects(). List of - air gap materials ("MATERIAL:AIRGAP" in the IDF). + materialAirGap (materialAirGap): IDF object from """ for i in range(0, len(materialAirGap)): @@ -1553,8 +1583,7 @@ def _write_material_nomass(layerNum, lines, listLayerName, materialNoMass): lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here listLayerName (list): list of material's names. To be appended when - materialNoMass (idf_MSequence): IDF object from idf.idfobjects(). List of - material no mass ("MATERIAL:NOMASS" in the IDF) + materialNoMass (idf_MSequence): IDF object from idf.idfobjects(). """ for i in range(0, len(materialNoMass)): @@ -1695,11 +1724,11 @@ def _get_ground_vertex(buildingSurfs): def _is_coordSys_world(coordSys, zones): """ Args: - coordSys (str): If already assigned ('Relative' or 'Absolute), - function returns the value + coordSys (str): If already assigned ('Relative' or 'Absolute), function + returns the value zones (idf_MSequence): IDF object from idf.idfobjects(). List of zones - ("ZONES" in the IDF). Zones object to iterate over, to determine - if the coordinate system is 'World' + ("ZONES" in the IDF). Zones object to iterate over, to determine if + the coordinate system is 'World' """ X_zones = [] Y_zones = [] @@ -1721,13 +1750,12 @@ def _write_location_geomrules(globGeomRules, lines, locations): """ Args: globGeomRules (idf_MSequence): IDF object from idf.idfobjects(). List of - global geometry rules ("GLOBALGEOMETRYRULES" in the IDF). - Normally there should be only one global geometry rules. + global geometry rules ("GLOBALGEOMETRYRULES" in the IDF). Normally + there should be only one global geometry rules. lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here - locations (idf_MSequence): IDF object from idf.idfobjects(). List of - the building locations ("SITE:LOCATION" in the IDF). Normally - there + locations (idf_MSequence): IDF object from idf.idfobjects(). List of the + building locations ("SITE:LOCATION" in the IDF). Normally there should be only one location. """ # Get line number where to write @@ -1776,9 +1804,9 @@ def _write_version(lines, versions): Args: lines (list): Text to create the T3D file (IDF file to import in TRNBuild). To be appended (insert) here - versions (idf_MSequence): IDF object from idf.idfobjects(). List of - the IDF file versions ("VERSION" in the IDF). - Normally there should be only one version. + versions (idf_MSequence): IDF object from idf.idfobjects(). List of the + IDF file versions ("VERSION" in the IDF). Normally there should be + only one version. """ # Get line number where to write versionNum = checkStr(lines, From b8d49775a003ce91bede963ef1e7867bcd60a0c1 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 15:33:16 -0400 Subject: [PATCH 06/31] Adds click as a requirement click is used to create the command line interface --- requirements-dev.txt | 3 ++- requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2c4d6506e..9897f32c9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,4 +4,5 @@ pytest pytest-cov scikit-learn scipy -sphinx \ No newline at end of file +sphinx +sphinx-click diff --git a/requirements.txt b/requirements.txt index 1834f2b4a..9205fa2dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,5 @@ pandas>=0.21 pyomo numpy>=1.13 tqdm -tabulate \ No newline at end of file +tabulate +click From 597002dd480122c487ac259f164875bc27d1bec1 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 15:33:34 -0400 Subject: [PATCH 07/31] Adds new documentation for archetypal commands --- docs/commands.rst | 24 ++++++++++++++++++++++++ docs/commands/convert.rst | 5 +++++ docs/conf.py | 1 + docs/index.rst | 3 +-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 docs/commands.rst create mode 100644 docs/commands/convert.rst diff --git a/docs/commands.rst b/docs/commands.rst new file mode 100644 index 000000000..c539c4507 --- /dev/null +++ b/docs/commands.rst @@ -0,0 +1,24 @@ +================= +Command reference +================= + +Archetypal provides many commands for managing packages and environments. +The links on this page provide help for each command. +You can also access help from the command line with the +``--help`` flag: + +.. code-block:: bash + + archetypal --help + + +Archetypal general commands +=========================== + +The following commands are part of archetypal: + +.. toctree:: + :glob: + :maxdepth: 2 + + commands/* diff --git a/docs/commands/convert.rst b/docs/commands/convert.rst new file mode 100644 index 000000000..99bc19aae --- /dev/null +++ b/docs/commands/convert.rst @@ -0,0 +1,5 @@ + + +.. click:: archetypal:convert + :prog: archetypal convert + :show-nested: diff --git a/docs/conf.py b/docs/conf.py index 11a1fc8c5..2ad8b3bae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,6 +48,7 @@ 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx.ext.napoleon', + 'sphinx_click.ext', ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index e3316b1d8..355d40790 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,6 +29,7 @@ developed by the MIT Sustainable Design Lab. :maxdepth: 1 :caption: Reference Guide + commands Package Modules @@ -38,5 +39,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - - From a030638c77f728024c76dd34aae0320adccb8cf8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 17:03:10 -0400 Subject: [PATCH 08/31] Adds converter_idf.rst in the toctree --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index 355d40790..80f3ce7a1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,6 +24,7 @@ developed by the MIT Sustainable Design Lab. Getting Started Modelign Assumptions Schedules + Translator IDF to BUI .. toctree:: :maxdepth: 1 From 45b57a382a28c7a95952af0883e3ab78048f9b51 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 17:13:31 -0400 Subject: [PATCH 09/31] New: Adds description of the Translator module in documentation Adds description of the translator module in documentation with an "objectives" and a "methodology" sections --- docs/converter_idf.rst | 59 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 4e7e035fa..0f17d50c5 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -2,7 +2,62 @@ Translator IDF to BUI ============ The necessity of translating IDF files (EnergyPlus input files) to BUI files (TRNBuild input files) emerged from the -need of modeling building archetypes1. Knowing that a lot of different models from different sources (NECB and US-DOE) +need of modeling building archetypes [#]_. Knowing that a lot of different models from different sources (NECB and US-DOE) have already been developed under EnergyPlus, and it can be a tedious task to create a multizone building in a model -editor (e.g. TRNBuild), we assume the development of a file translator could be useful for simulationist. +editor (e.g. TRNBuild), we assume the development of a file translator could be useful for simulationists. + +Objectives +------------ +The principal ojectives of this module was to translate the geometry of the building, the different schedules used in +the model, and the thermal gains. + +1. Geometry + +The building geometry is kept with all the zoning, the different surfaces (construction and windows) and the thermal +properties of the walls. The thermal properties of windows are not from the IDF, but chosen by the user. The user gives +a U-value, a SHGC value and Tvis value. Then a window is chosen in the Berkeley Lab library (library used in TRNBuild). +For more information, see the methodology_ section please. + +2. Schedules + +All schedules from the IDF file are translated. The translator is able to process all schedule types defined by +EnergyPlus (see the different schedules_ for more information). Only day and week schedules are written in the output +BUI file + +3. Gains + +Internal thermal gains such as “people”, “lights” and “equipment” are translated from the IDF file to the BUI file. + + +Methodology +------------ + +The module is divided in 2 major operations. The first one consist in translating the IDF file from EnergyPlus, to an +IDF file proper to an input file for TRNBuild (T3D file), usually created by the TRNSYS plugin "Trnsys3D_" in SketchUp. +The second operation is the conversion of the IDF file for TRNBuild to a BUI file done with the executable trnsidf.exe +(installed by default in the TRNSYS installation folder: TRNSYS18\Building\trnsIDF\) + +1. IDF to T3D + +The conversion from the IDF EnergyPlus file to the IDF TRNBuild file (called here T3D file) is the important part of +the module, which uses the Eppy_ python package, allowing, with object classes, to find the IDF objects, modify them if +necessary and re-transcribe them in the T3D file + +2. T3D to BUI + +The operation to convert the T3D file to the BUI one is just done by running the trnsidf.exe executable with a command +line. + +.. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its + usage. Usually used to create urban building model by assigning different archetypes to represent at best the building + stock we want to model. + +.. _schedules: https://bigladdersoftware.com/epx/docs/8-9/input-output-reference/group-schedules.html#group-schedules + +.. _Trnsys3D: https://www.trnsys.de/docs/trnsys3d/trnsys3d_uebersicht_en.htm + +.. _Eppy: https://pythonhosted.org/eppy/Main_Tutorial.html + + + From 83f40fbb0b011eb4b7146516702a800549fe2d30 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 17:35:45 -0400 Subject: [PATCH 10/31] Heading sectons must be underlined with same number of characters as the title --- docs/converter_idf.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 0f17d50c5..09aadc97e 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -1,5 +1,5 @@ Translator IDF to BUI -============ +===================== The necessity of translating IDF files (EnergyPlus input files) to BUI files (TRNBuild input files) emerged from the need of modeling building archetypes [#]_. Knowing that a lot of different models from different sources (NECB and US-DOE) @@ -7,7 +7,7 @@ have already been developed under EnergyPlus, and it can be a tedious task to cr editor (e.g. TRNBuild), we assume the development of a file translator could be useful for simulationists. Objectives ------------- +---------- The principal ojectives of this module was to translate the geometry of the building, the different schedules used in the model, and the thermal gains. @@ -30,7 +30,7 @@ Internal thermal gains such as “people”, “lights” and “equipment” ar Methodology ------------- +----------- The module is divided in 2 major operations. The first one consist in translating the IDF file from EnergyPlus, to an IDF file proper to an input file for TRNBuild (T3D file), usually created by the TRNSYS plugin "Trnsys3D_" in SketchUp. From 4336ed1a9b27850209b0c211986c8aa9d510c5a2 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 17:36:08 -0400 Subject: [PATCH 11/31] For some directives, better to have all the text on one line --- docs/converter_idf.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 09aadc97e..93e414a5c 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -48,9 +48,7 @@ necessary and re-transcribe them in the T3D file The operation to convert the T3D file to the BUI one is just done by running the trnsidf.exe executable with a command line. -.. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its - usage. Usually used to create urban building model by assigning different archetypes to represent at best the building - stock we want to model. +.. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its usage. Usually used to create urban building model by assigning different archetypes to represent at best the building stock we want to model. .. _schedules: https://bigladdersoftware.com/epx/docs/8-9/input-output-reference/group-schedules.html#group-schedules From 55b6319ede96564c055422054860558eae8d7b4f Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 17:44:37 -0400 Subject: [PATCH 12/31] Use escape character "\" to tell sphinx to use a special character literally --- docs/converter_idf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 93e414a5c..279b72ce1 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -35,7 +35,7 @@ Methodology The module is divided in 2 major operations. The first one consist in translating the IDF file from EnergyPlus, to an IDF file proper to an input file for TRNBuild (T3D file), usually created by the TRNSYS plugin "Trnsys3D_" in SketchUp. The second operation is the conversion of the IDF file for TRNBuild to a BUI file done with the executable trnsidf.exe -(installed by default in the TRNSYS installation folder: TRNSYS18\Building\trnsIDF\) +(installed by default in the TRNSYS installation folder: `C:TRNSYS18\\Building\\trnsIDF\\`) 1. IDF to T3D From fe4d9f6815a9fcc0906869e4d7942b1ffd08cf6d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 17:45:20 -0400 Subject: [PATCH 13/31] Auto stash before merge of "feature/cli" and "samuelduchesne/feature/cli" --- docs/converter_idf.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 93e414a5c..08cf3182a 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -28,7 +28,6 @@ BUI file Internal thermal gains such as “people”, “lights” and “equipment” are translated from the IDF file to the BUI file. - Methodology ----------- @@ -48,7 +47,16 @@ necessary and re-transcribe them in the T3D file The operation to convert the T3D file to the BUI one is just done by running the trnsidf.exe executable with a command line. -.. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its usage. Usually used to create urban building model by assigning different archetypes to represent at best the building stock we want to model. +How to convert an IDF file +--------------------------- + + + + + +.. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its + usage. Usually used to create urban building model by assigning different archetypes to represent at best the building + stock we want to model. .. _schedules: https://bigladdersoftware.com/epx/docs/8-9/input-output-reference/group-schedules.html#group-schedules From fe3b755073389582cb9615814f2c7ddff27b7927 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 18:55:17 -0400 Subject: [PATCH 14/31] Fix: correct a typo in the options, "-d" instead of "-t" for the dck flag --- archetypal/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archetypal/cli.py b/archetypal/cli.py index 901709c43..6954f6074 100644 --- a/archetypal/cli.py +++ b/archetypal/cli.py @@ -92,7 +92,7 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, @click.option('--return-idf', '-i', is_flag=True, default=False) @click.option('--return_b18', '-b', is_flag=True, default=True) @click.option('--return_t3d', '-t', is_flag=True, default=False) -@click.option('--return_dck', '-t', is_flag=True, default=False) +@click.option('--return_dck', '-d', is_flag=True, default=False) @click.option('--window-lib', type=click.Path(), default=None, help='Path of the window library (from Berkeley Lab)') @click.option('--trnsidf_exe_dir', type=click.Path(), From b830f0d1bf089a3b47c2ce6cecf000232a0fe51b Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Jun 2019 19:36:38 -0400 Subject: [PATCH 15/31] New: Adds the documentation to use the cli, with examples --- docs/converter_idf.rst | 48 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index cf3ba0c6f..21a288550 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -48,11 +48,57 @@ The operation to convert the T3D file to the BUI one is just done by running the line. How to convert an IDF file ---------------------------- +-------------------------- +You have to run the command line:: + archetypal convert [OPTIONS] IDF_FILE OUTPUT_FOLDER +1. `IDF_FILE` is the file path of the IDF file we want to convert. If there is space characters in the path, should be +between quotation marks. +2. `OUTPUT_FOLDER` is the folder where we want the output folders to be written. If there is space characters in the +path, should be between quotation marks. + +Example:: + + archetypal convert "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + +3. `OPTIONS`: There is different option that can be given to the command line + + - if `-i` is given as an option, the IDF file to convert is returned in the output folder + Example:: + + archetypal convert -i "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + + - if `-b` is given as an option, the BUI file (converted from the IDF file) is returned in the output folder + Example:: + + archetypal convert -b "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - if `-t` is given as an option, the T3D file (converted from the IDF file) is returned in the output folder + Example:: + + archetypal convert -t "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - if `-d` is given as an option, a DCK file (TRNSYS input file) is returned in the output folder + Example:: + + archetypal convert -d "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `window-lib PATH` is the path of the window library (from Berkeley Lab). Should be between quotation marks if there is space characters in the path + Example:: + + archetypal convert "/Users/Documents/W74-lib.dat" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `trnsidf_exe_dir PATH` is the path of the trnsidf.exe executable. Should be between quotation marks if there is space characters in the path + Example:: + + archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\trnsidf.exe" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `template PATH` is the path of the d18 template file (usually in the same directory of the `trnsidf.exe` executable) + Example:: + + archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\NewFileTemplate.d18" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `-h` Shows the "help" message + Example:: + + archetypal convert -h .. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its usage. Usually used to create urban building model by assigning different archetypes to represent at best the building From e02da851fdca58b547f7db2782686f4309914098 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 20:18:30 -0400 Subject: [PATCH 16/31] Updates configuration file to latest sphinx version logic --- docs/conf.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 2ad8b3bae..fc7d7241b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,6 +49,7 @@ 'sphinx.ext.githubpages', 'sphinx.ext.napoleon', 'sphinx_click.ext', + 'recommonmark', ] # Add any paths that contain templates here, relative to this directory. @@ -57,11 +58,6 @@ # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # -from recommonmark.parser import CommonMarkParser - -source_parsers = { - '.md': CommonMarkParser, -} source_suffix = ['.rst', '.md'] @@ -212,9 +208,11 @@ def setup(app): # -- Autodoc Skip Memebrs ____________________________________________________ -autodoc_default_flags = ['members', 'private-members', 'special-members', - # 'undoc-members', - 'show-inheritance'] +autodoc_default_options = {'members':True, + 'private-members':True, + 'special-members':True, + 'undoc-members':True, + 'show-inheritance':True} def autodoc_skip_member(app, what, name, obj, skip, options): From 73e89ab3fcbf52044596e6c64a5768ce3a9f8319 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 20:59:50 -0400 Subject: [PATCH 17/31] Adds a banner image for converter docs --- docs/converter_idf.rst | 5 +++++ docs/images/converter@2x.png | Bin 0 -> 8580 bytes 2 files changed, 5 insertions(+) create mode 100644 docs/images/converter@2x.png diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 21a288550..7ce1c5e2a 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -1,6 +1,11 @@ Translator IDF to BUI ===================== +.. figure:: images/converter@2x.png + :alt: converter logo + :width: 100% + :align: center + The necessity of translating IDF files (EnergyPlus input files) to BUI files (TRNBuild input files) emerged from the need of modeling building archetypes [#]_. Knowing that a lot of different models from different sources (NECB and US-DOE) have already been developed under EnergyPlus, and it can be a tedious task to create a multizone building in a model diff --git a/docs/images/converter@2x.png b/docs/images/converter@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b80b2cf229a2566df72c03be985b417b615e2abd GIT binary patch literal 8580 zcmeHNX*iVq+r9^35EVraSxS~1 z2n|6DtgH;+FZ!xC$G{gHt#9E4K_|}AKQIGR(KQGXh77J~-}1{?o-n$fx06X+54c&R zu*hI0{7i8}n_2S7idJz7U&PIXBoRBuszA^ABdqVeu4gCd{*0LUNQ~$daWPNQEfBHe z^oX#ltPRG9ocQE;;Y8Gf=-Y>{Fk77-{$M$}k;8$$@XZ1(h zh8vv6Bk^rw)0#=C?4J@?MWqum<5$#(f%QJkZeU8bS&=q3ECe9Q$tq$>B zpktd|nU7uW=)<7zR_;DEzJdI`4b>57cUOH7%EB)K&rHn2`;k zL-E%=rmFH4hF-@UZvF6mhVp^can=StizuEduX&wsJg;hwgURRZ;%#hpLZG0op3Z6C=3D;LcKF9XQNHyp6o)`kL|(S#i2Nb0RF9p|vo0^Evk<*)-qs!pBQ0 zvMo)t63uF>pgkoa8*5)5j@E%X2S$l~ zVo%=lL`e{pIlSiM^Fe$L{Jn%O+OP5zZzarxm5`X3R3zDQp~u^0ef7qsBKJu2T$fcQ z@5pw?CT?QDl~+b-J4H!VlXAVC1#auNlmpF9aC0Hl_TFSCs(|$DnT1|-Qwffk(9OZi zG*%KULUv5LNtx`*9N;ww+JIn=u0Z_i!Vvd7L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G zjlOJ?2#AAzFqzM^JPkZ=v61KuW)+_Fz{ni5-QKAW2bqus=)3XJwEh&VU+sA*4tzk> z-p1G-*cHlaKheo~TZy+GT_mih_B;M$g+{@A8oz-vRogQm_srj5$3@U;Q5}Hr45v5Y zxh?||Vd3thN1cmR*M4FJ*m8-G;43gaeZLQ#0Guq6cz z!5_N(@FL3qFL*4iXj-T27VVBlv)E}U7DD>NAlCGXnvcbVtr z6Lr6M@?7%=u$v^}w-3gNTv_KWyCJz}phY3(Yz^!B^^tU1-ezG}`MFlVDnUL7f>;4y zLQt3-0JlFEe`4^b4*sw7g1eaMIS7KCqyI0!pU(W>JM%x1JZv-}v+O&LM*6)a0LUPN MtHxK#b!@}`2miI8?EnA( literal 0 HcmV?d00001 From 96cca371c8d8aee89bafdffd9381180df604bb3f Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 21:01:12 -0400 Subject: [PATCH 18/31] Change literal-blocks to code-blocks They add more flexibility --- docs/converter_idf.rst | 52 +++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 7ce1c5e2a..4a141aded 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -65,45 +65,61 @@ between quotation marks. 2. `OUTPUT_FOLDER` is the folder where we want the output folders to be written. If there is space characters in the path, should be between quotation marks. -Example:: +Example + +.. code-block:: python archetypal convert "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" -3. `OPTIONS`: There is different option that can be given to the command line +3. `OPTIONS`: There ar different option that can be given to the command line - if `-i` is given as an option, the IDF file to convert is returned in the output folder - Example:: - archetypal convert -i "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert -i "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - if `-b` is given as an option, the BUI file (converted from the IDF file) is returned in the output folder - Example:: - archetypal convert -b "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert -b "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - if `-t` is given as an option, the T3D file (converted from the IDF file) is returned in the output folder - Example:: - archetypal convert -t "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert -t "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - if `-d` is given as an option, a DCK file (TRNSYS input file) is returned in the output folder - Example:: - archetypal convert -d "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert -d "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `window-lib PATH` is the path of the window library (from Berkeley Lab). Should be between quotation marks if there is space characters in the path - Example:: - archetypal convert "/Users/Documents/W74-lib.dat" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert "/Users/Documents/W74-lib.dat" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `trnsidf_exe_dir PATH` is the path of the trnsidf.exe executable. Should be between quotation marks if there is space characters in the path - Example:: - archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\trnsidf.exe" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\trnsidf.exe" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `template PATH` is the path of the d18 template file (usually in the same directory of the `trnsidf.exe` executable) - Example:: - archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\NewFileTemplate.d18" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + .. code-block:: python + + archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\NewFileTemplate.d18" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + - `-h` Shows the "help" message - Example:: - archetypal convert -h + .. code-block:: python + + archetypal convert -h .. [#] Archetype: building model representing a type of building based on its geometry, thermal properties and its usage. Usually used to create urban building model by assigning different archetypes to represent at best the building From 81242b8c258c6aa678d29090d822b34da49909fd Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 22:52:25 -0400 Subject: [PATCH 19/31] Updates cli arguments for convert --- archetypal/cli.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/archetypal/cli.py b/archetypal/cli.py index 6954f6074..a961ce309 100644 --- a/archetypal/cli.py +++ b/archetypal/cli.py @@ -89,13 +89,15 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, @cli.command() @click.argument('idf-file') @click.argument('output-folder') -@click.option('--return-idf', '-i', is_flag=True, default=False) -@click.option('--return_b18', '-b', is_flag=True, default=True) -@click.option('--return_t3d', '-t', is_flag=True, default=False) -@click.option('--return_dck', '-d', is_flag=True, default=False) +@click.option('--return-idf', '-i', is_flag=True, default=False, + help='Save modified IDF file to output_folder') +@click.option('--return_t3d', '-t', is_flag=True, default=False, + help='Save T3D file to output_folder') +@click.option('--return_dck', '-d', is_flag=True, default=False, + help='Generate dck file and save to output_folder') @click.option('--window-lib', type=click.Path(), default=None, help='Path of the window library (from Berkeley Lab)') -@click.option('--trnsidf_exe_dir', type=click.Path(), +@click.option('--trnsidf-exe-dir', type=click.Path(), help='Path to trnsidf.exe', default=os.path.join( settings.trnsys_default_folder, @@ -103,18 +105,23 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, @click.option('--template', type=click.Path(), default=settings.path_template_d18, help='Path to d18 template file') -@pass_config -def convert(config, idf_file, window_lib, return_idf, return_b18, return_t3d, - return_dck, output_folder, trnsidf_exe_dir, template): +@click.option('--window', nargs=3, type=float, default=(2.2, 0.64, 0.8), + help="Specify window properties ") +@click.option('--ordered', is_flag=True, + help="sort idf object names") +def convert(idf_file, window_lib, return_idf, return_t3d, + return_dck, output_folder, trnsidf_exe_dir, template, window, + ordered): """Convert regular IDF file (EnergyPlus) to TRNBuild file (TRNSYS)""" + u_value, shgc, t_vis = window + window_kwds = {'u_value': u_value, 'shgc': shgc, 't_vis': t_vis} archetypal.convert_idf_to_trnbuild(idf_file, window_lib, - return_idf, return_b18, + return_idf, True, return_t3d, return_dck, output_folder, trnsidf_exe_dir, - template) + template, **window_kwds, ordered=ordered) @cli.command() -@pass_config def reduce(): pass From 3310c9b2a03b16fd92002136bde50e1263fb599f Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 22:57:01 -0400 Subject: [PATCH 20/31] Better docstrings + code cleanup --- archetypal/trnsys.py | 70 ++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index 07cb23b5e..15743a80d 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -26,30 +26,35 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, return_idf=False, return_b18=True, return_t3d=False, return_dck=False, - output_folder=None, trnsidf_exe_dir=os.path.join( - settings.trnsys_default_folder, - r"Building\trnsIDF\trnsidf.exe"), - template=settings.path_template_d18, + output_folder=None, trnsidf_exe_dir=None, + template=None, **kwargs): """Convert regular IDF file (EnergyPlus) to TRNBuild file (TRNSYS) There are three optional outputs: - * the path to the modified IDF with the - new names, coordinates, etc. of the IDF objects. It is an input file - for EnergyPlus (.idf) + * the path to the modified IDF with the new names, coordinates, etc. of + the IDF objects. It is an input file for EnergyPlus (.idf) * the path to the TRNBuild file (.b18) * the path to the TRNBuild input file (.idf) * the path to the TRNSYS dck file (.dck) + Todo: + - Add console info at beginning of each steps of this method + - Add console info about the outputs of the function at the end when it + is completed. + - Add option to hide name conversion report + Example: >>> # Exemple of setting kwargs to be unwrapped in the function >>> kwargs_dict = {'u_value': 2.5, 'shgc': 0.6, 't_vis': 0.78, 'tolerance': 0.05, 'ordered': True} >>> # Exemple how to call the function + >>> idf_file = "/file.idf" + >>> window_filepath = "/W74-lib.dat" >>> convert_idf_to_trnbuild(idf_file=idf_file, - window_lib=window_filepath, - **kwargs_dict) + >>> window_lib=window_filepath, + >>> **kwargs_dict) Args: idf_file: @@ -81,12 +86,6 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, provided if *return_t3d* is True. * retrun_trn (str): the path to the TRNSYS dck file (.dck). Only provided if *return_dck* is True. - - Todo: - - Add console info at beginning of each steps of this method - - Add console info about the outputs of the function at the end when - it is completed. - - Add option to hide name conversion report """ idf_file, window_lib, output_folder, trnsidf_exe_dir, template = \ @@ -160,6 +159,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # region Get schedules from IDF start_time = time.time() + log("Reading schedules from the idf file...") schedule_names, schedules = _get_schedules(idf) log("Got yearly, weekly and daily schedules in {:,.2f} seconds".format( @@ -194,15 +194,17 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # Write data from IDF file to T3D file start_time = time.time() - + log("Writing data from idf file to t3d file...") # Write VERSION from IDF to lines (T3D) _write_version(lines, versions) # Write BUILDING from IDF to lines (T3D) + log("Writing building info from idf file to t3d file...") _write_building(buildings, lines) # Write LOCATION and GLOBALGEOMETRYRULES from IDF to lines (T3D) and # define if coordinate system is "Relative" + log("Writing location info from idf file to t3d file...") coordSys = _write_location_geomrules(globGeomRules, lines, locations) # Determine if coordsSystem is "World" (all zones at (0,0,0)) @@ -344,7 +346,15 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, def _assert_files(idf_file, window_lib, output_folder, trnsidf_exe_dir, template): - """Ensure the files and directory are here""" + """Ensure the files and directory are here + + Args: + idf_file: + window_lib: + output_folder: + trnsidf_exe_dir: + template: + """ if not os.path.isfile(idf_file): raise IOError("idf_file file not found") @@ -355,9 +365,16 @@ def _assert_files(idf_file, window_lib, output_folder, trnsidf_exe_dir, if not os.path.exists(output_folder): raise IOError("output_folder directory does not exist") + if not trnsidf_exe_dir: + trnsidf_exe_dir = os.path.join(settings.trnsys_default_folder, + r"Building\trnsIDF\trnsidf.exe") + if not os.path.isfile(trnsidf_exe_dir): raise IOError("trnsidf.exe not found") + if not template: + template = settings.path_template_d18 + if not os.path.isfile(template): raise IOError("template file not found") @@ -834,17 +851,19 @@ def trnbuild_idf(idf_file, template=os.path.join( on the geometric information of the IDF file and the template D18 file. In addition, an template DCK file can be generated. + Important: + Where settings.trnsys_default_folder must be defined inside the + configuration file of the package + Example: >>> # Exemple of setting kwargs to be unwrapped in the function >>> kwargs_dict = {'dck': True, 'geo_floor': 0.57} >>> # Exemple how to call the function >>> trnbuild_idf(idf_file, template=os.path.join( - settings.trnsys_default_folder, - r"Building\\trnsIDF\\NewFileTemplate.d18"), - trnidf_exe_dir=os.path.join(settings.trnsys_default_folder, - r"Building\\trnsIDF\\trnsidf.exe"), **kwargs_dict) - >>> INFO: Where settings.trnsys_default_folder must be defined inside - the configuration file of the package + >>> settings.trnsys_default_folder, + >>> r"Building\\trnsIDF\\NewFileTemplate.d18"), + >>> trnidf_exe_dir=os.path.join(settings.trnsys_default_folder, + >>> r"Building\\trnsIDF\\trnsidf.exe"), **kwargs_dict) Args: idf_file (str): path/filename.idf @@ -865,9 +884,8 @@ def trnbuild_idf(idf_file, template=os.path.join( str: status Raises: - * CalledProcessError: When could not run command with trnsidf.exe (to - - * create BUI file from IDF (T3D) file + CalledProcessError: When could not run command with trnsidf.exe (to + create BUI file from IDF (T3D) file """ # first copy idf_file into output folder if not os.path.isdir(settings.data_folder): From 34bb7762f02965427d0b131f662e5768dd59a90e Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 22:57:24 -0400 Subject: [PATCH 21/31] Syntax changes in docs --- docs/converter_idf.rst | 57 ++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/docs/converter_idf.rst b/docs/converter_idf.rst index 4a141aded..feaaa8dc1 100644 --- a/docs/converter_idf.rst +++ b/docs/converter_idf.rst @@ -55,67 +55,60 @@ line. How to convert an IDF file -------------------------- -You have to run the command line:: +Converting an IDF file to a BUI file is done using the command line. First, open the Command Prompt on Windows. Note +that if you used Anaconda to install python on your machine, you will most likely avoid some issues by using the +Anaconda Prompt instead. - archetypal convert [OPTIONS] IDF_FILE OUTPUT_FOLDER - -1. `IDF_FILE` is the file path of the IDF file we want to convert. If there is space characters in the path, should be -between quotation marks. - -2. `OUTPUT_FOLDER` is the folder where we want the output folders to be written. If there is space characters in the -path, should be between quotation marks. - -Example +Then simply run following command: .. code-block:: python - archetypal convert "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - -3. `OPTIONS`: There ar different option that can be given to the command line - - - if `-i` is given as an option, the IDF file to convert is returned in the output folder - - .. code-block:: python - - archetypal convert -i "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + archetypal convert [OPTIONS] IDF_FILE OUTPUT_FOLDER - - if `-b` is given as an option, the BUI file (converted from the IDF file) is returned in the output folder +1. ``IDF_FILE`` is the file path of the IDF file to convert. If there are space characters in the path, it should be +enclosed in quotation marks. - .. code-block:: python +2. ``OUTPUT_FOLDER`` is the folder where we want the output folders to be written. If there are space characters in +the path, it should enclosed in quotation marks. - archetypal convert -b "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" +Here is an example. Make sure to replace the last two arguments with the idf file path and the output folder path +respectively. - - if `-t` is given as an option, the T3D file (converted from the IDF file) is returned in the output folder +.. code-block:: python - .. code-block:: python + archetypal convert "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - archetypal convert -t "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" +3. `OPTIONS`: There are different options to the `convert` command. The first 3 manage the requested output files. +Users can chose to return a combination of flags - - if `-d` is given as an option, a DCK file (TRNSYS input file) is returned in the output folder + - if ``-i`` is added, the IDF file to convert is returned in the output folder. If ``-t`` is added, the T3D file + (converted from the IDF file) is returned in the output folder. If ``-d`` is added, the DCK file (TRNSYS input + file) is returned in the output folder. .. code-block:: python - archetypal convert -d "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + archetypal convert -i -t -d "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - - `window-lib PATH` is the path of the window library (from Berkeley Lab). Should be between quotation marks if there is space characters in the path + - ``--window-lib`` is the path of the window library (W74-lib.dat). .. code-block:: python archetypal convert "/Users/Documents/W74-lib.dat" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - - `trnsidf_exe_dir PATH` is the path of the trnsidf.exe executable. Should be between quotation marks if there is space characters in the path + - ``--trnsidf_exe_dir`` is the path of the trnsidf.exe executable. .. code-block:: python archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\trnsidf.exe" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - - `template PATH` is the path of the d18 template file (usually in the same directory of the `trnsidf.exe` executable) + - ``--template`` is the path of the .d18 template file (usually in the same directory of the `trnsidf.exe` + executable) .. code-block:: python - archetypal convert "C:TRNSYS18\\Building\\trnsIDF\\NewFileTemplate.d18" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" + archetypal convert --template "C:TRNSYS18\\Building\\trnsIDF\\NewFileTemplate.d18" "/Users/Documents/NECB 2011 - Warehouse.idf" "/Users/Documents/WIP" - - `-h` Shows the "help" message + - ``-h`` Shows the "help" message .. code-block:: python From 036b4f05291e87e2443805cb60f09386dd86a9a5 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Tue, 25 Jun 2019 22:58:25 -0400 Subject: [PATCH 22/31] Adds requirements-dev to the setup extras_require `pip install --editable .[dev]` will install the extra requirements --- setup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f644f433c..d7910e576 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,10 @@ def find_version(*file_paths): requirements_lines = f.readlines() install_requires = [r.strip() for r in requirements_lines] +with open(path.join(here, 'requirements-dev.txt')) as f: + requirements_lines = f.readlines() +dev_requires = [r.strip() for r in requirements_lines] + setup( name='archetypal', version=find_version('archetypal', '__init__.py'), @@ -59,9 +63,7 @@ def find_version(*file_paths): keywords='Building archetypes', python_requires='>=3.6', install_requires=install_requires, - extras_require={'tests': ['coverage', 'coveralls', 'pytest', 'matplotlib'], - 'docs': ['sphinx', 'nbsphinx', 'jupyter_client', - 'ipykernel']}, + extras_require={'dev': dev_requires}, test_suite='tests', entry_points=''' [console_scripts] From 70cd67ea8c9e6f0fcba9219e47919d0db43c60b2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 11:29:58 -0400 Subject: [PATCH 23/31] New: Adds console info at beginning of each steps of this method --- archetypal/trnsys.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index 15743a80d..077db48e7 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -93,6 +93,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, template) # Check if cache exists + log("Loading IDF file...", lg.INFO) start_time = time.time() cache_filename = hash_file(idf_file) idf = load_idf_object_from_cache(idf_file, how='idf') @@ -159,7 +160,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # region Get schedules from IDF start_time = time.time() - log("Reading schedules from the idf file...") + log("Reading schedules from the IDF file...") schedule_names, schedules = _get_schedules(idf) log("Got yearly, weekly and daily schedules in {:,.2f} seconds".format( @@ -238,6 +239,8 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, win_slope_dict = {} # Writing zones in lines + log("Writing geometry (zones, building and fenestration surfaces info from " + "idf file to t3d file...") count_fs = 0 _write_zone_buildingSurf_fenestrationSurf(buildingSurfs, coordSys, count_fs, count_slope, fenestrationSurfs, @@ -247,6 +250,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # endregion # region Write CONSTRUCTION from IDF to lines (T3D) + log("Writing constructions info from idf file to t3d file...") _write_constructions(constr_list, idf, lines, mat_name, materials) # endregion @@ -254,14 +258,17 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, _write_constructions_end(constr_list, idf, lines) # region Write LAYER from IDF to lines (T3D) + log("Writing materials (layers) info from idf file to t3d file...") _write_materials(lines, materialAirGap, materialNoMass, materials) # endregion # region Write GAINS (People, Lights, Equipment) from IDF to lines (T3D) + log("Writing gains info from idf file to t3d file...") _write_gains(equipments, idf, lights, lines, peoples) # endregion # region Write SCHEDULES from IDF to lines (T3D) + log("Writing schedules info from idf file to t3d file...") _write_schedules(lines, schedule_names, schedules) # endregion @@ -271,7 +278,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, # window = (win_id, description, design, u_win, shgc_win, t_sol_win, rf_sol, # t_vis_win, lay_win, width, window_bunches[win_id], # and maybe tolerance) - + log("Get windows info from window library...") win_u_value = kwargs.get('u_value', 2.2) win_shgc = kwargs.get('shgc', 0.64) win_tvis = kwargs.get('t_vis', 0.8) @@ -291,6 +298,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, lg.INFO) # Write windows in lines + log("Writing windows info from idf file to t3d file...") _write_window(lines, win_slope_dict, window) # Write window pool in lines @@ -322,6 +330,7 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, idf.saveas(filename=new_idf_path) # Run trnsidf to convert T3D to BUI + log("Converting t3d file to bui file. Running trnsidf.exe...") dck = return_dck nonum = kwargs.get('nonum', False) N = kwargs.get('N', False) From 36dfddcc9beeba72876b59273f581d97d2b38833 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 11:31:17 -0400 Subject: [PATCH 24/31] If output_folder does not exist, creates it --- archetypal/trnsys.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index 077db48e7..2d15665af 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -371,8 +371,10 @@ def _assert_files(idf_file, window_lib, output_folder, trnsidf_exe_dir, if not os.path.isfile(window_lib): raise IOError("window_lib file not found") - if not os.path.exists(output_folder): - raise IOError("output_folder directory does not exist") + if not output_folder: + output_folder = os.path.relpath(settings.data_folder) + if not os.path.exists(output_folder): + os.mkdir(output_folder) if not trnsidf_exe_dir: trnsidf_exe_dir = os.path.join(settings.trnsys_default_folder, From 1136d593785a1a23005d7b86c5e80b6564490ed5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 11:34:56 -0400 Subject: [PATCH 25/31] Fix: Changes path to create cache directory for a specific idf file --- archetypal/trnsys.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index 2d15665af..fb5b909c6 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -104,11 +104,12 @@ def convert_idf_to_trnbuild(idf_file, window_lib=None, time.time() - start_time), lg.INFO) # Clean names of idf objects (e.g. 'MATERIAL') + log("Cleaning names of the IDF objects...", lg.INFO) start_time = time.time() clear_name_idf_objects(idf) path = os.path.join(settings.cache_folder, cache_filename, cache_filename + '.idf') - if not os.path.exists(path): + if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) idf.saveas(filename=path) # save_idf_object_to_cache(idf, idf_file, cache_filename, 'pickle') From ac52319476a38beb39c3f4659a171a1197eeaf16 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 11:58:37 -0400 Subject: [PATCH 26/31] Update tests --- tests/test_trnsys.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_trnsys.py b/tests/test_trnsys.py index a1366c65d..33644b710 100644 --- a/tests/test_trnsys.py +++ b/tests/test_trnsys.py @@ -21,7 +21,7 @@ def test_trnbuild_from_idf(config): ".0_4A_USA_MD_BALTIMORE.idf", "ASHRAE90.1_Warehouse_STD2004_Rochester.idf", "NECB 2011 - Warehouse.idf"] - idf_file = os.path.join(file_upper_path, files[0]) + idf_file = os.path.join(file_upper_path, files[2]) idf_file = copy_file(idf_file) window_file = 'W74-lib.dat' @@ -34,6 +34,8 @@ def test_trnbuild_from_idf(config): 'tolerance': 0.05, 'ordered': True} convert_idf_to_trnbuild(idf_file=idf_file[0], window_lib=window_filepath, + template="tests/input_data/trnsys/NewFileTemplate.d18", + trnsidf_exe_dir='docker/trnsidf/trnsidf.exe', **kwargs_dict) From 89d88170bb80b33ce62fae5124be4e9435162ef2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 12:30:20 -0400 Subject: [PATCH 27/31] Fix: Fixes typo in choose_window() --- archetypal/trnsys.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index fb5b909c6..1e3f3ef51 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -802,8 +802,8 @@ def choose_window(u_value, shgc, t_vis, tolerance, window_lib_path): shgc = float(shgc) if not isinstance(t_vis, float): t_vis = float(t_vis) - if not isinstance(t_vis, float): - t_vis = float(t_vis) + if not isinstance(tolerance, float): + tolerance = float(tolerance) # Parse window library df_windows, window_bunches = parse_window_lib(window_lib_path) From 3241857a81c65e19aff285c7771cbcf12b565f4f Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 12:30:35 -0400 Subject: [PATCH 28/31] Corrects docstring --- archetypal/trnsys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archetypal/trnsys.py b/archetypal/trnsys.py index 1e3f3ef51..d79ce304a 100644 --- a/archetypal/trnsys.py +++ b/archetypal/trnsys.py @@ -884,7 +884,7 @@ def trnbuild_idf(idf_file, template=os.path.join( nonum (bool, optional): If True, no renumeration of surfaces N (optional): BatchJob Modus geo_floor (float, optional): generates GEOSURF values for distributing - direct solar radiation where 60 % is directed to the floor, the rest + direct solar radiation where `geo_floor` % is directed to the floor, the rest to walls/windows. Default = 0.6 refarea (bool, optional): If True, floor reference area of airnodes is updated From b44afd01d7e54b391348d03227db8cfa96574b79 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 12:31:49 -0400 Subject: [PATCH 29/31] New: Adds kwargs of trnbuild_idf() as option in the cli --- archetypal/cli.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/archetypal/cli.py b/archetypal/cli.py index a961ce309..7337d69c6 100644 --- a/archetypal/cli.py +++ b/archetypal/cli.py @@ -71,7 +71,7 @@ def __init__(self): def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, use_cache, log_file, log_console, log_level, log_name, log_filename, trnsys_default_folder): - """Description""" + """Retrieve, construct, simulate, and analyse building templates""" config.data_folder = data_folder config.logs_folder = logs_folder config.imgs_folder = imgs_folder @@ -105,21 +105,40 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, @click.option('--template', type=click.Path(), default=settings.path_template_d18, help='Path to d18 template file') -@click.option('--window', nargs=3, type=float, default=(2.2, 0.64, 0.8), - help="Specify window properties ") +@click.option('--window', nargs=4, type=float, default=(2.2, 0.64, 0.8, 0.05), + help="Specify window properties ") @click.option('--ordered', is_flag=True, help="sort idf object names") +@click.option('--nonum', is_flag=True, default=False, + help="Do not renumber surfaces") +@click.option('--batchJob', '-N', is_flag=True, default=False, + help="BatchJob Modus") +@click.option('--geofloor', type=float, default=0.6, + help="Generates GEOSURF values for distributing; direct solar " + "radiation where `geo_floor` % is directed to the floor, " + "the rest; to walls/windows. Default = 0.6") +@click.option('--refarea', is_flag=True, default=False, + help="Upadtes floor reference area of airnodes") +@click.option('--volume', is_flag=True, default=False, + help="Upadtes volume of airnodes") +@click.option('--capacitance', is_flag=True, default=False, + help="Upadtes capacitance of airnodes") def convert(idf_file, window_lib, return_idf, return_t3d, return_dck, output_folder, trnsidf_exe_dir, template, window, - ordered): + ordered, nonum, batchJob, geofloor, refarea, volume, capacitance): """Convert regular IDF file (EnergyPlus) to TRNBuild file (TRNSYS)""" - u_value, shgc, t_vis = window - window_kwds = {'u_value': u_value, 'shgc': shgc, 't_vis': t_vis} + u_value, shgc, t_vis, tolerance = window + window_kwds = {'u_value': u_value, 'shgc': shgc, 't_vis': t_vis, + 'tolerance': tolerance} archetypal.convert_idf_to_trnbuild(idf_file, window_lib, return_idf, True, return_t3d, return_dck, output_folder, trnsidf_exe_dir, - template, **window_kwds, ordered=ordered) + template, **window_kwds, ordered=ordered, + nonum=nonum, N=batchJob, + geo_floor=geofloor, + refarea=refarea, volume=volume, + capacitance=capacitance) @cli.command() From 16987bf3b30b46c281180e89c097b4057a18fa47 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 13:12:25 -0400 Subject: [PATCH 30/31] New: Runs cli in the output_folder (with cd) --- archetypal/cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/archetypal/cli.py b/archetypal/cli.py index 7337d69c6..93425fdb3 100644 --- a/archetypal/cli.py +++ b/archetypal/cli.py @@ -9,7 +9,7 @@ import click import archetypal -from archetypal import settings +from archetypal import settings, cd CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) @@ -125,20 +125,21 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, help="Upadtes capacitance of airnodes") def convert(idf_file, window_lib, return_idf, return_t3d, return_dck, output_folder, trnsidf_exe_dir, template, window, - ordered, nonum, batchJob, geofloor, refarea, volume, capacitance): + ordered, nonum, batchjob, geofloor, refarea, volume, capacitance): """Convert regular IDF file (EnergyPlus) to TRNBuild file (TRNSYS)""" u_value, shgc, t_vis, tolerance = window window_kwds = {'u_value': u_value, 'shgc': shgc, 't_vis': t_vis, 'tolerance': tolerance} - archetypal.convert_idf_to_trnbuild(idf_file, window_lib, - return_idf, True, - return_t3d, return_dck, - output_folder, trnsidf_exe_dir, - template, **window_kwds, ordered=ordered, - nonum=nonum, N=batchJob, - geo_floor=geofloor, - refarea=refarea, volume=volume, - capacitance=capacitance) + with cd(output_folder): + archetypal.convert_idf_to_trnbuild(idf_file, window_lib, + return_idf, True, + return_t3d, return_dck, + output_folder, trnsidf_exe_dir, + template, **window_kwds, ordered=ordered, + nonum=nonum, N=batchjob, + geo_floor=geofloor, + refarea=refarea, volume=volume, + capacitance=capacitance) @cli.command() From 2d3ffa43eb9f0f0b75b7aaa1e4977500b7e396ad Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Jun 2019 13:13:06 -0400 Subject: [PATCH 31/31] Fix: Changes log-file and log_console option in cli. --- archetypal/cli.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archetypal/cli.py b/archetypal/cli.py index 93425fdb3..c2c307719 100644 --- a/archetypal/cli.py +++ b/archetypal/cli.py @@ -51,12 +51,12 @@ def __init__(self): help='Use a local cache to save/retrieve many of ' 'archetypal outputs such as EnergyPlus simulation results', default=settings.use_cache) -@click.option('--log-file/--no-log-file', +@click.option('--log-file', is_flag=True, help='save log output to a log file in logs_folder', default=settings.log_file) -@click.option('--log-console/--no-log-console', - help='print log output to the console', - default=settings.log_console) +@click.option('--log-console', '--verbose', '-v', is_flag=True, + default=settings.log_console, + help='print log output to the console') @click.option('--log-level', type=click.INT, help='CRITICAL=50, ERROR=40, WARNING=30, INFO=20, DEBUG=10', default=settings.log_level) @@ -111,7 +111,7 @@ def cli(config, data_folder, logs_folder, imgs_folder, cache_folder, help="sort idf object names") @click.option('--nonum', is_flag=True, default=False, help="Do not renumber surfaces") -@click.option('--batchJob', '-N', is_flag=True, default=False, +@click.option('--batchjob', '-N', is_flag=True, default=False, help="BatchJob Modus") @click.option('--geofloor', type=float, default=0.6, help="Generates GEOSURF values for distributing; direct solar "