Example #1
0
def schedule_from_idf(schedule_idf, output_file):
    """Translate a schedule IDF file to a honeybee JSON as an array of schedules.
    \n
    Args:
        schedule_idf: Full path to a Schedule IDF file. Only the schedules
            and schedule type limits in this file will be extracted.
    """
    try:
        # check that the schedule JSON is there
        assert os.path.isfile(schedule_idf), \
            'No Schedule IDF file found at {}.'.format(schedule_idf)

        # re-serialize the schedules to Python
        schedules = ScheduleRuleset.extract_all_from_idf_file(schedule_idf)

        # create the honeybee dictionaries
        hb_obj_list = [sch.to_dict() for sch in schedules]

        # write out the JSON file
        output_file.write(json.dumps(hb_obj_list))
    except Exception as e:
        _logger.exception('Schedule translation failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
Example #2
0
def test_schedule_ruleset_from_idf_file_compact():
    """Test the initalization of ScheduleRuleset from file with Schedule:Week:Compact
    and Schedule:Compact.
    """
    office_sched_idf = './tests/idf/OfficeOccupancySchedule_Compact.idf'
    office_scheds = ScheduleRuleset.extract_all_from_idf_file(
        office_sched_idf, True)

    office_occ = office_scheds[0]

    assert office_occ.identifier == 'Medium Office Bldg Occ'
    assert isinstance(office_occ.default_day_schedule, ScheduleDay)
    assert office_occ.default_day_schedule.identifier == \
        'Medium Office Bldg Occ Default Schedule'
    assert office_occ.summer_designday_schedule.identifier == \
        'Medium Office Bldg Occ Summer Design Day'
    assert office_occ.winter_designday_schedule.identifier == \
        'Medium Office Bldg Occ Winter Design Day'
    assert len(office_occ.schedule_rules) == 2
    assert office_occ.schedule_rules[0].schedule_day.identifier == \
        'Medium Office Bldg Occ Saturday Schedule'
    assert office_occ.schedule_rules[1].schedule_day.identifier == \
        'Medium Office Bldg Occ Sunday Schedule'

    office_occ = office_scheds[1]
    assert office_occ.schedule_rules[0].schedule_day.identifier == \
        "saturday"

    assert isinstance(office_occ.schedule_type_limit, ScheduleTypeLimit)
Example #3
0
def test_schedule_ruleset_from_idf_file_cross_referenced():
    """Test ScheduleRuleset from_idf_file with cross-referenced ScheduleDay."""
    cool_sched_idf = './tests/idf/cross_referenced_schedule_day.idf'
    cooling_avail_schs = ScheduleRuleset.extract_all_from_idf_file(
        cool_sched_idf)

    cooling_avail = cooling_avail_schs[0]
    assert len(cooling_avail.schedule_rules) == 2
Example #4
0
"""Load all schedules from the IDF libraries."""
from honeybee_energy.schedule.ruleset import ScheduleRuleset

import os

# empty dictionaries to hold idf-loaded schedules
_idf_schedules = {}

# load schedules from the default and user-supplied files
cur_dir = os.path.dirname(__file__)
schedule_lib = os.path.join(cur_dir, 'library', 'schedules')
for f in os.listdir(schedule_lib):
    f_path = os.path.join(schedule_lib, f)
    if os.path.isfile(f_path) and f_path.endswith('.idf'):
        schedule_rulesets = ScheduleRuleset.extract_all_from_idf_file(f_path)
        for sch in schedule_rulesets:
            sch.lock()
            _idf_schedules[sch.name] = sch