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
def output_plot_histogram(modf, info, output_path): elements = [] # Section title default_title = _('Plot histogram') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_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) kernel = get_key(info, 'kernel_section', False) bins = get_key(info, 'bins_section', 'auto') # Input tex section input_tex(elements, info, output_path, section) # Computation data = extract_data(modf, descriptor_name=descriptor) # Figure kind = 'figure' default_caption = _('Histogram plot') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'histogram_figure_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) summary.plot_histogram(data, title='', var_name=var_name, var_unit=var_unit, fig_filename=os.path.join(output_path, path), circular=circular, kernel=kernel, bins=bins) elements.append([path, kind, caption]) return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title
def input_tex(elements, info, output_path, section): kind = 'tex' driver = info['name_driver'] location = info['location_metocean'] descriptor = info['name_descriptor'] block = info['name_block'] path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) open(os.path.join(output_path, path), 'a').close() elements.append([path, kind, None])
def output_table_summary(modf, info, output_path): elements = [] # Section title default_title = _('Summary table') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_section'] # Optional values and default values title = get_key(info, 'title_section', default_title) # Input tex section input_tex(elements, info, output_path, section) # Computation data = extract_data(modf, descriptor_name=descriptor) # Table kind = 'table' default_caption = _('Summary table') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'summary_table_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) data_summary = summary.get_summary(data) save_table(data_summary, os.path.join(output_path, path)) elements.append([os.path.join(output_path, path), kind, caption]) return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title
def output_plot_empirical_cdf(modf, info, output_path): elements = [] # Section title default_title = _('Plot empirical CDF') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_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) label_empirical = get_key(info, 'label_empirical_section', '') label_kernel = get_key(info, 'label_kernel_section', '') bins = get_key(info, 'bins_section', 100) # Input tex section input_tex(elements, info, output_path, section) # Computation data = extract_data(modf, descriptor_name=descriptor) cumulative = True data_empirical = empirical_distributions.ecdf_histogram(data) data_kernel = empirical_distributions.kde_sm(data, cumulative=cumulative, gridsize=bins) # Figure kind = 'figure' default_caption = _('Empirical CDF') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'empirical_pdf_figure_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) empirical_distributions.plot_kde(data_empirical, data_kernel, cumulative, title='', var_name=var_name, var_unit=var_unit, fig_filename=os.path.join( output_path, path), circular=circular, label_empirical=label_empirical, label_kernel=label_kernel) elements.append([path, kind, caption]) return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title
def output_missing_values(modf, info, output_path): elements = [] # Section title default_title = _('Missing values') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_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) # Input tex section input_tex(elements, info, output_path, section) # Computation data = extract_data(modf, descriptor_name=descriptor) time_step = missing_values.find_timestep(data) data_gaps = missing_values.find_missing_values(data, time_step) # Figure kind = 'figure' default_caption = _('Missing values plot') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'missing_values_figure_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) missing_values.plot_missing_values(data=data, data_gaps=data_gaps, title='', var_name=var_name, var_unit=var_unit, fig_filename=os.path.join( output_path, path), circular=circular, label=var_name) elements.append([path, kind, caption]) # Table kind = 'table' default_caption = _('Missing values table') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'missing_values_table_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) data_gaps_report = missing_values.missing_values_report(data, data_gaps) save_table(data_gaps_report, os.path.join(output_path, path)) elements.append([os.path.join(output_path, path), kind, caption]) return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title