viroconwebcontour.plot module

Plots measurement files, distributions and contours.

class contour.plot.FittingFigureCollection[source]

Bases: object

Holds information and images of a fitted distribution parameter to view the fit results of a parameter.

var_number

int, – The dimension number of a distribution.

pdf_images

list of PlottedFigure, – PlottedFigures which show a fitted distribution.

param_image

PlottedFigure, – The PlottedFigure which shows a fit function of a parameter.

param_name

str, – The name of the parameter (shape, loc, scale).

contour.plot.adjust_param_name_latex(param_name)[source]

Adjusts the parameter name for the latex report.

Parameters:param_name (str,) – Name of a parameter.
Returns:
Return type:The adjusted parameter name for the latex report.
contour.plot.assign_parameter_name(dist_name, param_name)[source]

Assigns the correct parameter name matching for the distribution

Parameters:
  • dist_name (str,) – The name of a distribution, must be ‘Weibull’, ‘Lognormal’, ‘Lognormal_SigmaMu’ or ‘Normal’.
  • param_name (str,) – The name of a parameter as it is saved in the database, must be ‘shape’ ‘loc’ or ‘scale’.
Returns:

assigned_name – The parameter name matching to the distribution e.g. ‘σ’.

Return type:

str,

contour.plot.calculate_intervals(interval_centers, dimension_index, interval_center_index)[source]

Calculates the width of a certain interval.

Parameters:
  • interval_centers (list of floats) – The interval centers of the fit.
  • dimension_index (int) – The index of the dimension.
  • interval_center_index (int) – The index of the interval centers in the current dimension.
contour.plot.create_design_conditions_csv(contour_coordinates, environmental_contour)[source]

Creates a .csv file containing the extreme env. design conditions.

The file is saved as a FileField of the EnvironmentalContour object.

Parameters:
  • contour_coordinates (n-dimensional matrix) – The coordinates of the environmental contour. The format is defined by compute_interface.iform().
  • environmental_contour (EnvironmentalContour) – The django model of the environmental contour.
contour.plot.create_latex_report(contour_coordinates, user, environmental_contour, var_names, var_symbols)[source]

Creates a latex-based pdf report describing the performed environmental contour calculation.

Makes use of the ‘latex_report.tex’ template where the document class and packages are defined.

Parameters:
  • contour_coordinates (n-dimensional matrix) – The coordinates of the environmental contour. The format is defined by compute_interface.iform()
  • user (django.contrib.auth.models.User) – The user, who is working with the app. The report will be saved in a directory named like the user.
  • environmental_contour (enviro.models.EnvironmentalContour) – Django’s environmental contour model, which contains the contour’s path, the options that were used to create it and its probabilistc model
  • var_names (list of strings) – Names of the environmental variables used in the probabilistic model, e.g. [‘wind speed [m/s]’, ‘significant wave height [m]’]
  • var_symbols (list of strings) – Symbols of the environental variables used in the probabilistic model, e.g. [‘V’, ‘Hs’]
Returns:

short_file_path_report – The path where the pdf, generated based latex, is saved The path continues after the static files prefix, which is defined in settings.py and currently is ‘enviro/static/’

Return type:

string,

contour.plot.get_latex_eedc_table(matrix, var_names, var_symbols)[source]

Creates a latex string containing a table listing the contour’s extreme environmental design conditions (EEDCs).

Parameters:
  • matrix (n-dimensional matrix) – The coordinates of the environmental contour. The format is defined by compute_interface.iform()
  • var_names (list of strings) – Names of the environmental variables used in the probabil. model, e.g. [‘wind speed [m/s]’, ‘significant wave height [m]’]
  • var_symbols (list of strings) – Symbols of the environental variables used in the probabil. model, e.g. [‘V’, ‘Hs’]
Returns:

table_string – A string in latex format containing a table, which lists the first X extreme environmental design conditions

Return type:

string,

contour.plot.get_latex_eedc_table_head_line(var_names)[source]

Creates a latex string containing the first line of a table.

The table lists the contour’s extreme environmental design conditions (EEDCs).

Parameters:var_names (list of strings) – Names of the environmental variables used in the probabil. model, e.g. [‘wind speed [m/s]’, ‘significant wave height [m]’]
Returns:head_line_string – A string in latex format containing the first row of the table, e.g. “EEDC & significant wave height [m] & peak period [s]”
Return type:string,
contour.plot.is_legit_distribution_parameter_index(distribution_name, index)[source]

Check if the distribution has this kind of parameter index

Parameters:
  • distribution_name (str) – The name of a Distribution must be ‘Normal’, ‘Lognormal’ or ‘Weibull’.
  • index (int) – The index represents a parameter of the three possible parameter shape, loc, scale. (0 = shape, 1 = loc, 2 = scale)
contour.plot.plot_contour(contour_coordinates, user, environmental_contour, var_names)[source]

The function plots a png image of a contour.

Parameters:
  • contour_coordinates (list of floats) – Data points of the contour.
  • user (str) – Who gives the contour calculation order.
  • environmental_contour (EnvironmentalContour) – The model object contains all information about a environmental contour.
  • var_names (list of str) – Name of the variables of the probabilistic model
contour.plot.plot_data_set_as_scatter(measure_file_model, var_names)[source]

Plots the data of a measurement file as a scatter plot.

In case the measurement file has more than 2 variables, multiple scatter plots are generated.

Parameters:
  • measure_file_model (MeasureFileModel,) – The measurement file model, which should be plotted.
  • var_names (list of str,) – The names of the variables (each column in the measurement file represents one environmental variable).
contour.plot.plot_fit(fit, var_names, var_symbols, directory, probabilistic_model)[source]

Visualize a fit generated by the virconcom package.

Parameters:
  • fit (Fit) – Holds data and information about the fit.
  • var_names (list of str) – The list contains the names of distributions
  • var_symbols (list of str) – The symbols of the distribution.
  • directory (str) – Path to the directory where the images will be stored.
  • probabilistic_model (ProbabilisticModel) – Model for a multivariate distribution, e.g. a sea state description.
contour.plot.plot_parameter_fit_overview(dim_index, parent_var_name, para_name, param_at, param_values, fit_func, dist_name, probabilistic_model)[source]

Plots an image which shows the fit of a function.

Parameters:
  • dim_index (int,) – Index of the related distribution.
  • parent_var_name (str,) – Name of the variable that the parameter depends on.
  • para_name (str,) – Parameter name like shape, location, scale.
  • param_at (list of float,) – The list contains the x-values of a fitted function for a parameter e.g. shape, loc or scale.
  • param_values (list of float,) – The list contains the y-values of a fitted function for a parameter e.g. shape, loc or scale.
  • fit_func (FunctionParam,) – The fit function e.g. power function, exponential
  • directory (str,) – The directory where the figure will be saved.
  • dist_name (str,) – Name of the distribution, e.g. “Lognormal”.
  • probabilistic_model (ProbabilisticModel) – Probabilistic model that was created based on this fit.
contour.plot.plot_pdf_with_raw_data(dim_index, parent_index, low_index, shape, loc, scale, distribution_type, dist_points, interval, var_name, symbol_parent_var, probabilistic_model)[source]

Creates and saves an image, which shows a fit of a distribution.

Parameters:
  • dim_index (int,) – The index of the current dimension (distribution). The index is used to recognise the image later.
  • parent_index (int,) – The index of the variable on which the conditional is based (when no condition: None).
  • low_index (int,) – The index of the interval. (needed to recognize the images later)
  • shape (float,) – The value of the shape parameter.
  • loc (float,) – The value of the loc parameter. (location)
  • scale (float,) – The value of the scale parameter.
  • distribution_type (str,) – Name of the distribution, must be “Normal”, “Weibull” or “Lognormal”
  • dist_points (list of float,) – The dates for the histogram.
  • interval (list of float,) – The list contains the interval of the plotted distribution.
  • var_name (str,) – The name of a single variable of the probabilistic model.
  • symbol_parent_var (str,) – Symbol of the variable on which the conditional variable is based.
  • probabilistic_model (ProbabilisticModel,) – Probabilistic model which has the particular pdf.
contour.plot.plot_var_dependent(fit, param_name, dim_index, var_names, var_symbols, probabilistic_model, do_dependent_plot=True)[source]

Plots the fitted distribution for each interval and the resulting fit function for a parameter like shape, loc or scale.

Parameters:
  • fit (Fit,) – Holds data and information about the fit.
  • param_name (str,) – The name of the parameter (e.g. shape, loc or scale).
  • dim_index (int,) – The dimension of the distribution.
  • var_names (list of str,) – Variable names of all distributions.
  • var_symbols (list of str,) – Variable symbols of all distributions.
  • probabilistic_model (ProbabilisticModel,) – Probabilistic model that was created based on that fit.
  • do_dependent_plot (Boolean, optional) – True: Probability density functions will be plotted. False: Probability density functions will not be plotted. Defaults to True.
contour.plot.plot_var_independent(param_name, dim_index, var_names, fit_inspection_data, fit, probabilistic_model)[source]

Plots the fitted distribution of a independent parameter (e.g. shape, loc or scale).

Parameters:
  • param_name (str) – The name of the parameter (e.g. shape, loc or scale).
  • dim_index (int) – The dimension of the distribution.
  • var_names (list of str) – The name of the distribution.
  • fit_inspection_data (FitInspectionData) – Information for plotting the fits of a single dimension.
  • fit (Fit) – Holds data and information about the fit.
  • probabilistic_model (ProbabilisticModel) – Probabilistic model that was created based on that fit.
contour.plot.sort_plotted_figures(probabilistic_model)[source]

Sorts the images showing the fits to generate a structured overview in the template.

Parameters:probabilistic_model (ProbabilisticModel,) – A probabilistic model generated by a fit.
Returns:figure_collections – The FittingFiguresCollections represents all images that are linked to a parameter of a distribution.
Return type:list of FittingFigureCollection,