Exemplo n.º 1
0
def test_filter_by_analysis_period_continuous_hour_subset():
    """Test filtering hour subset analysis period on hourly continuous collection."""
    header = Header(Temperature(), 'C', AnalysisPeriod())
    values = list(xrange(8760))
    dc = HourlyContinuousCollection(header, values)
    a_per = AnalysisPeriod(3, 2, 9, 3, 8, 17)
    filt_dc = dc.filter_by_analysis_period(a_per)
    assert len(filt_dc) == 7 * 9
    assert filt_dc.header.analysis_period == a_per
    assert filt_dc.datetimes[0] == DateTime(3, 2, 9)
    assert filt_dc.datetimes[-1] == DateTime(3, 8, 17)
    assert not isinstance(filt_dc, HourlyContinuousCollection)
Exemplo n.º 2
0
def test_filter_by_analysis_period_continuous_reversed():
    """Test filtering by reversed analysis period on hourly continuous collection."""
    header = Header(Temperature(), 'C', AnalysisPeriod())
    values = list(xrange(8760))
    dc = HourlyContinuousCollection(header, values)
    a_per = AnalysisPeriod(st_month=12, end_month=3)
    filt_dc = dc.filter_by_analysis_period(a_per)
    assert len(filt_dc) == (31 + 31 + 28 + 31) * 24
    assert filt_dc.header.analysis_period == a_per
    assert filt_dc.datetimes[0] == DateTime(12, 1, 0)
    assert filt_dc.datetimes[-1] == DateTime(3, 31, 23)
    assert isinstance(filt_dc, HourlyContinuousCollection)
Exemplo n.º 3
0
def test_filter_by_analysis_period_continuous_large():
    """Test filtering large analysis period on hourly continuous collection."""
    header = Header(Temperature(), 'C', AnalysisPeriod(st_month=3,
                                                       end_month=3))
    values = list(xrange(24 * 31))
    dc = HourlyContinuousCollection(header, values)
    a_per = AnalysisPeriod(st_hour=9, end_hour=17)
    filt_dc = dc.filter_by_analysis_period(a_per)
    assert len(filt_dc) == 31 * 9
    assert filt_dc.header.analysis_period == AnalysisPeriod(3, 1, 9, 3, 31, 17)
    assert filt_dc.datetimes[0] == DateTime(3, 1, 9)
    assert filt_dc.datetimes[-1] == DateTime(3, 31, 17)
    assert not isinstance(filt_dc, HourlyContinuousCollection)
Exemplo n.º 4
0
def test_hourlyplot_reversed_analysis_period():
    """Test the initialization of MonthlyChart with a reversed analysis period."""
    header = Header(Temperature(), 'C', AnalysisPeriod())
    values = list(range(8760))
    data_coll = HourlyContinuousCollection(header, values)
    period = AnalysisPeriod(12, 1, 0, 1, 31, 23)
    data_coll = data_coll.filter_by_analysis_period(period)
    month_chart = MonthlyChart([data_coll])

    assert month_chart.analysis_period == period
    meshes = month_chart.data_meshes
    assert len(meshes) == 1
    assert isinstance(meshes[0], Mesh2D)
    assert len(meshes[0].faces) == 2 * 24
Exemplo n.º 5
0
def test_hourlyplot_analysis_period():
    """Test the initialization of MonthlyChart with an analysis period."""
    header = Header(Temperature(), 'C', AnalysisPeriod())
    values = list(range(8760))
    data_coll = HourlyContinuousCollection(header, values)
    period1 = AnalysisPeriod(3, 1, 0, 3, 31, 23)
    data_coll1 = data_coll.filter_by_analysis_period(period1)
    month_chart = MonthlyChart([data_coll1])

    assert month_chart.analysis_period == period1
    meshes = month_chart.data_meshes
    assert len(meshes) == 1
    assert isinstance(meshes[0], Mesh2D)
    assert len(meshes[0].faces) == 24

    period2 = AnalysisPeriod(3, 1, 0, 6, 30, 23)
    data_coll2 = data_coll.filter_by_analysis_period(period2)
    month_chart = MonthlyChart([data_coll2])

    assert month_chart.analysis_period == period2
    meshes = month_chart.data_meshes
    assert len(meshes) == 1
    assert isinstance(meshes[0], Mesh2D)
    assert len(meshes[0].faces) == 24 * 4
Exemplo n.º 6
0
def test_hourlyplot_reversed_analysis_period():
    """Test the initialization of HourlyPlot with a reversed analysis period."""
    header = Header(Temperature(), 'C', AnalysisPeriod())
    values = list(range(8760))
    data_coll = HourlyContinuousCollection(header, values)
    period = AnalysisPeriod(12, 1, 0, 1, 31, 23)
    data_coll = data_coll.filter_by_analysis_period(period)
    hour_plot = HourlyPlot(data_coll, y_dim=1)

    assert hour_plot.analysis_period == period
    mesh = hour_plot.colored_mesh2d
    assert isinstance(mesh, Mesh2D)
    assert len(mesh.faces) == 31 * 2 * 24
    assert mesh.min == Point2D(0, 0)
    assert mesh.max == Point2D(31 * 2, 24)