def test_frequency_intervals(): """Test the distance of frequency_intervals""" # Plot windrose epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw') epw = EPW(epw_path) w = WindRose(epw.wind_direction, epw.wind_speed, 3) w.show_zeros = False w.show_freq = False w.frequency_hours = 200.0 test_freq_int = int(math.ceil(w.real_freq_max / 200.0)) assert w.frequency_intervals_compass == pytest.approx(test_freq_int, abs=1e-10) assert w.frequency_intervals_mesh == pytest.approx(test_freq_int, abs=1e-10) # Test changing interals from 18 # Reduce w.frequency_intervals_compass = 10.0 test_freq_int = 10.0 assert w.frequency_maximum == pytest.approx(10 * 200.0, abs=1e-10) assert w.frequency_intervals_compass == pytest.approx(test_freq_int, abs=1e-10) assert w.frequency_intervals_mesh == pytest.approx(test_freq_int, abs=1e-10) # Check that resetting frequency_max works w._frequency_intervals_compass = None # w.real_freq_max: 4406 chk_max = int(math.ceil(4406 / 200)) * 200 assert w.frequency_maximum == pytest.approx(chk_max, abs=1e-10) assert w.frequency_intervals_compass == pytest.approx(23, abs=1e-10) assert w.frequency_intervals_mesh == pytest.approx(23, abs=1e-10)
win_dir = _wind_direction windrose = WindRose(win_dir, speed_data, _dir_count_) if len(legend_par_) > 0: try: # sense when several legend parameters are connected 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)