def output_plot_series_period_time(modf, info, output_path): elements = [] # Section title default_title = _('Plot time series') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_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) # 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 = _('Time series plot') + ': {}'.format( info['title_descriptor']) caption = get_key(info, 'time_series_figure_caption_section', default_caption) path = get_output_name(location=location, driver=driver, name=descriptor, block=block, title=section, kind=kind) summary.plot_series(data_crop, title='', var_name=var_name, var_unit=var_unit, fig_filename=os.path.join(output_path, path), circular=circular) elements.append([path, kind, caption]) return pd.DataFrame(elements, columns=['path', 'kind', 'caption']), title
def create_part(conf, doc, driver, metocean, modf, output_path): info_driver = conf['DRIVERS'][driver] sections = conf['SECTIONS'] for section in get_children(sections): info_section = sections[section] info = get_info(metocean, info_section, None) if check_visibility(info) is True: with doc.create( Chapter(NoEscape(get_key(info_section, 'title', section)))): for descriptor in get_children(info_driver): info_descriptor = info_driver[descriptor] info = get_info(metocean, info_section, info_descriptor) if check_visibility(info) is True: with doc.create( Section( NoEscape( get_key(info_descriptor, 'title', descriptor)))): for subsection in get_children(info_section): info_subsection = info_section[subsection] module = import_module('.' + section.lower(), 'report.sections') func = 'output_' + subsection.lower() info = get_info(metocean, info_subsection, info_descriptor) if check_visibility(info) is True: call = getattr(module, func) elements, title = call( modf, info, output_path) with doc.create( Subsection( NoEscape( get_key( info_subsection, 'title', title)))): add_elements(doc, elements)
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_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 output_plot_daily_variability(modf, info, output_path): elements = [] # Section title default_title = _('Boxplot daily variability') # Required values location = info['location_metocean'] driver = info['name_driver'] descriptor = info['name_descriptor'] block = info['name_block'] section = info['name_section'] variability = 'dayofyear' # 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) # Figure kind = 'figure' default_caption = _('Boxplot daily variability') + ': {}'.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, 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_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