示例#1
0
def test_schedule_fixedinterval_from_idf():
    """Test the ScheduleFixedInterval from_idf method."""
    idf_str = \
        """Schedule:File,
            Electrochromic Control,   !- schedule name
            On-Off,                   !- schedule type limits
            ./tests/csv/Electrochromic_Control.csv, !- file name
            1,                        !- column number
            0,                        !- rows to skip
            8760,                     !- number of hours of data
            Comma,                    !- column separator
            No,                       !- interpolate to timestep
            60;                       !- minutes per item
        """
    ec_schedule = ScheduleFixedInterval.from_idf(idf_str)

    assert ec_schedule.identifier == 'Electrochromic Control'
    assert len(ec_schedule.values) == 8760
    assert ec_schedule[0] == 0
    assert ec_schedule.schedule_type_limit is None
    assert ec_schedule.timestep == 1
    assert not ec_schedule.interpolate
    assert ec_schedule.start_date == Date(1, 1)
    assert ec_schedule.end_date_time == DateTime(12, 31, 23)
    assert not ec_schedule.is_leap_year
    assert ec_schedule.placeholder_value == 0
示例#2
0
def test_schedule_fixedinterval_to_idf():
    """Test the methods that go to and from an IDF."""
    random_occ = [0.5] * 8760
    occ_sched = ScheduleFixedInterval('Random Occupancy', random_occ,
                                      schedule_types.fractional)

    schedule_file = occ_sched.to_idf('./tests/csv/', include_datetimes=False)
    sch_type = schedule_types.fractional.to_idf()

    rebuilt_schedule = ScheduleFixedInterval.from_idf(schedule_file, sch_type)
    assert rebuilt_schedule == occ_sched
    assert rebuilt_schedule.to_idf('./tests/csv/') == schedule_file

    schedule_file = occ_sched.to_idf('./tests/csv/', include_datetimes=True)
    rebuilt_schedule = ScheduleFixedInterval.from_idf(schedule_file, sch_type)
    assert rebuilt_schedule == occ_sched

    os.remove('./tests/csv/Random_Occupancy.csv')