예제 #1
0
def output_plot_variability_period_time(modf, info, output_path):
    elements = []

    # Section title
    default_title = _('Plot variability')

    # Required values
    location = info['location_metocean']
    driver = info['name_driver']
    descriptor = info['name_descriptor']
    block = info['name_block']
    section = info['name_section']
    variability = info['variability_section']
    initial_date = info['initial_date_section']
    final_date = info['final_date_section']

    # Optional values and default values
    title = get_key(info, 'title_section', default_title)
    var_name = get_key(info, 'var_name_descriptor', descriptor)
    var_unit = get_key(info, 'unit_descriptor', '')
    circular = get_key(info, 'circular_descriptor', False)
    x_step = get_key(info, 'x_step_section', 1)

    # Input tex section
    input_tex(elements, info, output_path, section)

    # Computation
    data = extract_data(modf, descriptor_name=descriptor)
    mask = ((data.index > initial_date) & (data.index < final_date))
    data_crop = data[mask]

    # Figure
    kind = 'figure'
    default_caption = _('Variability boxplot') + ': {}'.format(
        info['title_descriptor'])
    caption = get_key(info, 'variability_figure_caption_section',
                      default_caption)

    path = get_output_name(location=location,
                           driver=driver,
                           name=descriptor,
                           block=block,
                           title=section,
                           kind=kind)

    summary.plot_variability(data_crop,
                             frecuency=variability,
                             title='',
                             var_name=var_name,
                             var_unit=var_unit,
                             fig_filename=os.path.join(output_path, path),
                             circular=circular,
                             x_step=x_step)

    elements.append([path, kind, caption])

    return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title
예제 #2
0
def test_plot_variability_circular():
    data_simar = tests.read_sample_simar(
        'SIMAR_1052046', os.path.join(tests.full_data_path, 'simar'))

    summary.plot_variability(
        data_simar['DirM'],
        'month',
        title='Monthly variability circular',
        var_name='$Dir_W$',
        var_unit='º',
        circular=True,
        fig_filename=tests.get_img_path('monthly_variability_circular.png'))
예제 #3
0
def test_annual_variability_river_discharge():
    name = 'river_flow.txt'
    data_path = os.path.join(tests.full_data_path, 'saih', name)

    # Read Saih
    data = saih.read_file(data_path)

    summary.plot_variability(
        data[4],
        'dayofyear',
        title='Day of year variability',
        var_name='$Q$',
        var_unit='$m^3 \, s^{-1}$',
        fig_filename=tests.get_img_path('dayofyear_variability.png'))
예제 #4
0
def test_plot_variability():
    data_simar = tests.read_sample_simar(
        'SIMAR_1052046', os.path.join(tests.full_data_path, 'simar'))

    summary.plot_variability(
        data_simar['Hm0'],
        'month',
        title='Monthly variability',
        var_name='$H_s$',
        var_unit='m',
        fig_filename=tests.get_img_path('monthly_variability.png'))
    summary.plot_variability(
        data_simar.loc['2000':, 'Hm0'],
        'year',
        title='Yearly variability',
        var_name='$H_s$',
        var_unit='m',
        fig_filename=tests.get_img_path('yearly_variability.png'))
    summary.plot_variability(
        data_simar['Hm0'],
        'dayofyear',
        title='Day of year variability',
        var_name='$H_s$',
        var_unit='m',
        fig_filename=tests.get_img_path('dayofyear_variability.png'))