ghenv.Component.Name = "HB Deconstruct Equipment"
ghenv.Component.NickName = 'DecnstrEquipment'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = "0"

try:
    from honeybee_energy.load.equipment import ElectricEquipment, GasEquipment
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _equip is not None:
    # check the input
    assert isinstance(_equip, (ElectricEquipment, GasEquipment)), \
        'Expected Equipment object. Got {}.'.format(type(_equip))

    # get the properties of the object
    name = _equip.display_name
    watts_per_area = _equip.watts_per_area
    schedule = _equip.schedule
    radiant_fract = _equip.radiant_fraction
    latent_fract = _equip.latent_fraction
    lost_fract = _equip.lost_fraction
    is_gas = isinstance(_equip, GasEquipment)
Exemplo n.º 2
0
    Returns:
        data_aggr: The data collection aggregated over time. (eg. a data collection
            of Energy values in kWh).
"""

ghenv.Component.Name = 'LB Time Aggregate'
ghenv.Component.NickName = 'Aggr'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:
    from ladybug.datacollection import HourlyDiscontinuousCollection, DailyCollection
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component):
    accept = (HourlyDiscontinuousCollection, DailyCollection)
    assert isinstance(_data, accept), '_data must be a an hourly ot daily data ' \
        'collection. Got {}.'.format(type(_data))
    if _data.header.data_type.time_aggregated_type is not None:
        data_aggr = _data.to_time_aggregated()
    else:
        data_aggr = _data
Exemplo n.º 3
0
try:
    from honeybee.config import folders
    default_folder = os.path.join(folders.default_simulation_folder,
                                  'captured_views')
except:
    home_folder = os.getenv('HOME') or os.path.expanduser('~')
    default_folder = os.path.join(home_folder, 'captured_views')

try:
    from ladybug_rhino.grasshopper import all_required_inputs, bring_to_front
    from ladybug_rhino.viewport import viewport_by_name, capture_view
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _capture:
    # ensure the component runs last on the canvas
    bring_to_front(ghenv.Component)

    # prepare the folder
    folder = _folder_ if _folder_ is not None else default_folder
    preparedir(folder, remove_content=False)

    # get the viewport objects
    vp_names = viewport_ if len(viewport_) != 0 else [None]
    viewports = [viewport_by_name(vp) for vp in vp_names]

    # save the viewports to images
    for i, view_p in enumerate(viewports):
        f_name = _file_name if len(viewports) == 1 else \
            '{}_{}'.format(_file_name, vp_names[i])
            'Imported model units "{}" do not match that of the current Rhino '
            'model units "{}"\nThe model is being automatically converted '
            'to the Rhino doc units.'.format(model.units, units_system()))
        model.convert_to_units(units_system())

    # check that the model tolerance is not too far from the Rhino tolerance
    if model.tolerance / tolerance >= 100:
        msg = 'Imported Model tolerance "{}" is significantly coarser than the ' \
            'current Rhino model tolerance "{}".\nIt is recommended that the ' \
            'Rhino document tolerance be changed to be coarser and this ' \
            'component is re-run.'.format(model.tolerance, tolerance)
        print msg
        give_warning(ghenv.Component, msg)


if all_required_inputs(ghenv.Component) and _load:
    # sense the type of file we are loading
    lower_fname = _gbxml.lower()
    if lower_fname.endswith('.xml') or lower_fname.endswith('.gbxml'):
        cmd_name = 'model-from-gbxml'
    elif lower_fname.endswith('.osm'):
        cmd_name = 'model-from-osm'
    elif lower_fname.endswith('.idf'):
        cmd_name = 'model-from-idf'
    else:
        raise ValueError(
            'Failed to recongize the input _gbxml file type.\n'
            'Make sure that it has an appropriate file extension.')

    # Execute the honybee CLI to obtain the model JSON via CPython
    shell = True if os.name == 'nt' else False
import os
import subprocess

try:  # import the core honeybee dependencies
    from honeybee.config import folders
    from honeybee.model import Model
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:  # import the core ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs, give_warning
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _update:
    # set default variables
    version = version_ if version_ is not None else folders.honeybee_schema_version_str
    name = _name_ if _name_ is not None else \
        os.path.basename(_hbjson).lower().replace('.hbjson', '_UPDATED').replace('.json', '_UPDATED')
    if not (name.endswith('.hbjson') or name.endswith('.json')):
        name = '{}.hbjson'.format(name)
    folder = _folder_ if _folder_ is not None else os.path.dirname(_hbjson)
    hbjson = os.path.join(folder, name)

    # execute the update command and update the HBJSON
    shell = True if os.name == 'nt' else False
    cmds = [
        folders.python_exe_path, '-m', 'honeybee_schema', 'update-model',
        _hbjson, '--version', version, '--output-file', hbjson
    ]
        erf: Data collection of effective radiant field (ERF) in W/m2.
        dmrt: Data collection of mean radiant temperature delta in C.
        mrt: Data collection of mean radiant temperature in C.
"""

ghenv.Component.Name = 'LB Solar MRT from Solar Components'
ghenv.Component.NickName = 'ComponentSolarMRT'
ghenv.Component.Message = '1.0.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '1 :: Analyze Data'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:
    from ladybug_comfort.collection.solarcal import HorizontalSolarCal
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _run is True:
    solar_mrt_obj = HorizontalSolarCal(_location, _dir_horiz_rad,
                                       _diff_horiz_rad, _longwave_mrt,
                                       fract_body_exp_, _ground_ref_,
                                       _solar_body_par_)

    erf = solar_mrt_obj.effective_radiant_field
    dmrt = solar_mrt_obj.mrt_delta
    mrt = solar_mrt_obj.mean_radiant_temperature
Exemplo n.º 7
0
    ],
    ['firefox', 'C:\\Program Files\\Mozilla Firefox\\firefox.exe'],
    ['chrome',
     '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome']  # MacOS
]

# URL to epwmap.
url = 'http://www.ladybug.tools/epwmap/'


# function for opening a browser page on Mac
def mac_open(url):
    os.system("open \"\" " + url)


if all_required_inputs(ghenv.Component) and _epw_map is True:
    broswer_found = False
    for browser in acceptable_browsers:
        browser_path = browser[1]
        if broswer_found == False and os.path.isfile(browser_path) == True:
            broswer_found = True
            wb.register(browser[0], None, wb.BackgroundBrowser(browser_path),
                        1)
            try:
                wb.get(browser[0]).open(url, 2, True)
                print "Opening epwmap."
            except ValueError:
                mac_open(url)
    if broswer_found == False:
        print "An accepable broswer was not found on your machine.\n" \
        "The default browser will be used but epwmap may not display correctly there."
Exemplo n.º 8
0
ghenv.Component.Message = '0.1.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '0 :: Import'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

import os

try:
    from ladybug.epw import EPW
    from ladybug.config import folders
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component) and _write:
    # set default values
    _percentile_ = 0.4 if _percentile_ is None else _percentile_
    _folder_ = os.path.join(folders.default_epw_folder, 'ddy') if _folder_ \
        is None else _folder_
    f_name = os.path.basename(_epw_file).replace('.epw', '.ddy')
    f_path = os.path.join(_folder_, f_name)

    # create the DDY file
    epw = EPW(_epw_file)
    ddy_file = epw.to_ddy(f_path, _percentile_)
ghenv.Component.Name = "HB Deconstruct Lighting"
ghenv.Component.NickName = 'DecnstrLighting'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = "0"

try:
    from honeybee_energy.load.lighting import Lighting
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _lighting is not None:
    # check the input
    assert isinstance(_lighting, Lighting), \
        'Expected Lighting object. Got {}.'.format(type(_lighting))

    # get the properties of the object
    name = _lighting.display_name
    watts_per_area = _lighting.watts_per_area
    schedule = _lighting.schedule
    radiant_fract = _lighting.radiant_fraction
    visible_fract = _lighting.visible_fraction
    return_fract = _lighting.return_air_fraction
    baseline = _lighting.baseline_watts_per_area
            err_objs.append(err_obj)
            for warn in err_obj.severe_errors:
                give_warning(ghenv.Component, warn)
            for error in err_obj.fatal_errors:
                print err_obj.file_contents  # print before raising the error
                raise Exception(error)

        # append everything to the global lists
        sql.append(sql_i)
        zsz.append(zsz_i)
        rdd.append(rdd_i)
        html.append(html_i)
        err.append(err_i)


if all_required_inputs(ghenv.Component) and _translate:
    # global lists of outputs to be filled
    osm, idf, sql, zsz, rdd, html, err, err_objs = [], [], [], [], [], [], [], []

    # run the OSW files through OpenStudio CLI
    silent = True if run_ == 2 else False
    if parallel_:
        tasks.Parallel.ForEach(range(len(_osw)), run_osw_and_report_errors)
    else:
        for i in range(len(_osw)):
            run_osw_and_report_errors(i)

    # print out error report if it's only one file
    # otherwise it's too much data to be read-able
    if len(err_objs) == 1:
        print(err_objs[0].file_contents)
ghenv.Component.Name = "HB Deconstruct Setpoint"
ghenv.Component.NickName = 'DecnstrSetpoint'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = "0"

try:
    from honeybee_energy.load.setpoint import Setpoint
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component) and _setpoint is not None:
    # check the input
    assert isinstance(_setpoint, Setpoint), \
        'Expected Setpoint object. Got {}.'.format(type(_setpoint))

    # get the properties of the object
    name = _setpoint.display_name
    heating_sch = _setpoint.heating_schedule
    cooling_sch = _setpoint.cooling_schedule
    humid_setpt = _setpoint.humidifying_setpoint
    dehumid_setpt = _setpoint.dehumidifying_setpoint
Exemplo n.º 12
0
"""

ghenv.Component.Name = "HB Deconstruct People"
ghenv.Component.NickName = 'DecnstrPeople'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = "0"

try:
    from honeybee_energy.load.people import People
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component) and _people is not None:
    # check the input
    assert isinstance(_people, People), \
        'Expected People object. Got {}.'.format(type(_people))

    # get the properties of the object
    name = _people.display_name
    ppl_per_area = _people.people_per_area
    occupancy_sch = _people.occupancy_schedule
    activity_sch = _people.activity_schedule
ghenv.Component.Name = 'HB Deconstruct Hot Water'
ghenv.Component.NickName = 'DecnstrHotWater'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:
    from honeybee_energy.load.hotwater import ServiceHotWater
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _hot_water is not None:
    # check the input
    assert isinstance(_hot_water, ServiceHotWater), \
        'Expected ServiceHotWater object. Got {}.'.format(type(_hot_water))

    # get the properties of the object
    name = _hot_water.display_name
    flow_per_area = _hot_water.flow_per_area
    schedule = _hot_water.schedule
    target_temp = _hot_water.target_temperature
    sensible_fract = _hot_water.sensible_fraction
    latent_fract = _hot_water.latent_fraction
    raise ImportError('\nFailed to import ladybug_geometry:\n\t{}'.format(e))

try:
    from ladybug_rhino.config import conversion_to_meters, tolerance
    from ladybug_rhino.color import color_to_color
    from ladybug_rhino.togeometry import to_point2d
    from ladybug_rhino.fromgeometry import from_mesh2d, from_mesh2d_to_outline, \
        from_polyline2d, from_linesegment2d
    from ladybug_rhino.text import text_objects
    from ladybug_rhino.colorize import ColoredPolyline
    from ladybug_rhino.fromobjects import legend_objects
    from ladybug_rhino.grasshopper import all_required_inputs, schedule_solution
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and None not in _data:
    # set default values for the chart dimensions
    z_val = _base_pt_.Z if _base_pt_ is not None else 0
    z_val_tol = z_val + tolerance
    _base_pt_ = to_point2d(_base_pt_) if _base_pt_ is not None else Point2D()
    _x_dim_ = _x_dim_ if _x_dim_ is not None else 10.0 / conversion_to_meters()
    _y_dim_ = _y_dim_ if _y_dim_ is not None else 40.0 / conversion_to_meters()
    stack_ = stack_ if stack_ is not None else False
    percentile_ = percentile_ if percentile_ is not None else 34.0
    lpar = legend_par_[0] if len(legend_par_) != 0 else None

    # create the monthly chart object and get the main pieces of geometry
    month_chart = MonthlyChart(_data, lpar, _base_pt_, _x_dim_, _y_dim_,
                               stack_, percentile_)
    if len(legend_par_) > 1:
        if legend_par_[1].min is not None:
try:  # import the core honeybee dependencies
    from honeybee.model import Model
    from honeybee.typing import clean_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:  # import the ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs
    from ladybug_rhino.config import units_system, tolerance, angle_tolerance
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


def check_all_geo_none():
    """Check whether all of the geometry inputs to this component are None."""
    return all(obj_list == [] or obj_list == [None] for obj_list in
               (rooms_, faces_, shades_, apertures_, doors_))


if all_required_inputs(ghenv.Component) and not check_all_geo_none():
    # set a default name and get the Rhino Model units
    name = clean_string(_name_) if _name_ is not None else 'unnamed'
    units = units_system()

    # create the model
    model = Model(name, rooms_, faces_, shades_, apertures_, doors_,
                  units=units, tolerance=tolerance, angle_tolerance=angle_tolerance)
    if _name_ is not None:
        model.display_name = _name_