示例#1
0
def schedule_fixedinterval_random_annual(directory):
    occ_sched = ScheduleFixedInterval(
        'Random Occupancy', [round(random.random(), 4) for i in range(8760)],
        schedule_types.fractional)

    dest_file = os.path.join(directory,
                             'schedule_fixedinterval_random_annual.json')
    with open(dest_file, 'w') as fp:
        json.dump(occ_sched.to_dict(True), fp, indent=4)
def schedule_fixedinterval_increasing_fine_timestep(directory):
    increase_sched = ScheduleFixedInterval(
        'Solstice Increasing', [round(x / 143, 4) for x in range(144)],
        schedule_types.fractional, start_date=Date(6, 21), timestep=6,)

    dest_file = os.path.join(
        directory, 'schedule_fixedinterval_increasing_fine_timestep.json')
    with open(dest_file, 'w') as fp:
        json.dump(increase_sched.to_dict(True), fp, indent=4)
def schedule_fixedinterval_leap_year(directory):
    test_vals = [15, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 20,
                 20, 20, 20, 20, 20, 20, 20, 20, 15, 15, 15, 15]
    sched = ScheduleFixedInterval(
        'Weekly Temperature', test_vals * 7,
        schedule_types.temperature, start_date=Date(2, 29, True))

    dest_file = os.path.join(directory, 'schedule_fixedinterval_leap_year.json')
    with open(dest_file, 'w') as fp:
        json.dump(sched.to_dict(True), fp, indent=4)
示例#4
0
def test_schedule_fixedinterval_dict_methods():
    """Test the ScheduleFixedInterval to/from dict methods."""
    trans_sched = ScheduleFixedInterval('Custom Transmittance',
                                        [x / 8760 for x in range(8760)],
                                        schedule_types.fractional)

    sch_dict = trans_sched.to_dict()
    new_schedule = ScheduleFixedInterval.from_dict(sch_dict)
    assert new_schedule == trans_sched
    assert sch_dict == new_schedule.to_dict()