Exemplo n.º 1
0
def test_windrose_set_north():
    """Test setting north property"""

    epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw')
    epw = EPW(epw_path)
    w = WindRose(epw.wind_direction, epw.wind_speed, 5)

    assert abs(w.north) < 1e-10

    with pytest.raises(AssertionError):
        w.north = 'string'

    # Ensure modulo works
    w.north = 365.0
    assert w.north == pytest.approx(5.0, abs=1e-10)

    # Check compass orientation
    assert w.compass.north_angle == pytest.approx(5.0, abs=1e-10)
Exemplo n.º 2
0
                lpar = legend_par_[i]
            except IndexError:
                lpar = legend_par_[-1]
            windrose.legend_parameters = lpar

        if _freq_hours_ is not None:
            windrose.frequency_hours = _freq_hours_

        # Add and check optional visualization parameters
        if _max_freq_lines_ is not None:
            windrose.frequency_intervals_compass = _max_freq_lines_

        if _freq_dist_ is not None:
            windrose.frequency_spacing_distance = _freq_dist_

        windrose.north = north_
        windrose.show_freq = _show_freq_

        calm_text = ''
        if isinstance(speed_data.header.data_type, Speed):
            windrose.show_zeros = _show_calmrose_
            calm_text = '\nCalm for {}% of the time = {} hours.'.format(
                round(
                    windrose._zero_count / len(windrose.analysis_values) *
                    100.0, 2), windrose._zero_count)
        windrose.base_point = Point2D(center_pt_2d.x, center_pt_2d.y)

        # Make the mesh
        mesh = from_mesh2d(windrose.colored_mesh, _center_pt_.z)

        # Make the graphic outputs