Control chart appliction

admin

Definition of the django admin area

class control_chart.admin.CalculationRuleAdmin(model, admin_site)[source]

Admin display for CalculationRules

class control_chart.admin.CharacteristicValueAdmin(model, admin_site)[source]

Admin display for CharacteristicValues

class control_chart.admin.CharacteristicValueDefinitionAdmin(model, admin_site)[source]

Admin display for CharacteristicValueDefinitions

apps

Contains the configuration of the control_chart App

class control_chart.apps.ControlChartConfig(app_name, app_module)[source]

App-Configuration class to handle the automatic generation of user groups after the migration of the database

ready()[source]

Connecting the user group generation with the post_migrate signal

forms

Module for the definition of form classes

class control_chart.forms.NewMeasurementItemForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None)[source]

Form class for the input of new measurement items with autocomplete fields

class control_chart.forms.NewMeasurementOrderForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None)[source]

Form class for input of new MeasurementOrders used in combinated item and order form.

models

Models for control_chart

class control_chart.models.AccessLogDict(*args, **kwargs)[source]

Dict variation which records the access to non existing keys

get_missing_keys()[source]

Returns the non existing keys which have tried to access

class control_chart.models.CalcValueQuerySet(*args, **kwargs)[source]

QuerySet for CharacteristicValues to enable lazy calculation. The value is only the first time or after the CalculationRule has changed.

count_invalid()[source]
Returns:Number of uncalculated CharacteristicValues
count_unfinished()[source]
Returns:Returns the number of unfinished(not all necessary Measurements are available) CharacteristicValues
filter(*args, **kwargs)[source]

Overrides the filter method to enable lazy calculation

filter_with_product(products, *args, **kwargs)[source]

Filter CharacteristicValues for given product :param products: Single value or List of Products or Product ids :return: QuerySet of CharacteristicValues

recalculation()[source]

Calculates the value for invalid CharacteristicValues in the QuerySet

to_dataframe(fieldnames=(), verbose=True, index=None, coerce_float=False)[source]

Returns a DataFrame from the queryset, overrides the base method to enalbe lazy calculation

Parameters:
  • fieldnames – The model field names(columns) to utilise in creating the DataFrame. You can span a relationships in the usual Django ORM way by using the foreign key field name separated by double underscores and refer to a field in a related model.
  • index – specify the field to use for the index. If the index field is not in fieldnames it will be appended. This is mandatory for timeseries.
  • verbose – If this is True then populate the DataFrame with the human readable versions for foreign key fields else use the actual values set in the model
class control_chart.models.CalculationRule(*args, **kwargs)[source]

Calculation (python) code to calculate the characteristic value

calculate(measurements)[source]

Calculates a CharacteristicValue out of the given Measurements :param measurements: List of measurements :return: Value for the CharacteristicValue

is_changed()[source]

Has the CalculationRule changed

missing_keys

After call of the calculate member it returns the MeasurementTag-Name which are missing to calculate the CharacteristicValue yet. :return: Set of missing MeasurementTag-Names

save(force_insert=False, force_update=False, using=None, update_fields=None)[source]

Overrides the method of the base class to mark the linked CharacteristicValues as invalid if the CalculationRule has changed

class control_chart.models.CharacteristicValue(*args, **kwargs)[source]

Single characteristic value of an item (height, width, length etc.). The type is defined over the value_type (CharacteristicValue) which defines the name and how to calculate the value. The calculation of the value is lazy and is only done if the value is needed. CharacteristicValue is created automatically after a new Measurement is saved. It is possible that one Measurement creates many CharacteristicValues or that one CharacteristicValue needs many Measurement for the calculation.

get_value_type_name()[source]

Easy access to the name of the CharacteristicValueDefinition

is_valid

Is the value valid, or is a recalculation necessary

missing_keys

Returns the name of MeasurementTags which are missing for the calculation

product

Easy access to the product of the associated MeasurementItem

value

Value of the CharacteristicValue. If the value isn’t calculated yet, it will be calculated

class control_chart.models.CharacteristicValueDefinition(*args, **kwargs)[source]

Definition of a type of characteristic values

class control_chart.models.Measurement(*args, **kwargs)[source]

Single measurement with raw and meta data

get_absolute_url()[source]

Returns the url of the measurement :return: Update-url

class control_chart.models.MeasurementDevice(*args, **kwargs)[source]

Measurement device used for the measurement

class control_chart.models.MeasurementItem(*args, **kwargs)[source]

Item which is measured

class control_chart.models.MeasurementOrder(*args, **kwargs)[source]

Instance of an MeasurementOrder defined by the MeasurementOrderDefiniton

class control_chart.models.MeasurementOrderDefinition(*args, **kwargs)[source]

Definition of MeasurementOrder to define which CharacteristicValues have to be measured for a given MeasurementItem

class control_chart.models.MeasurementTag(*args, **kwargs)[source]

Tag to differ Measurements for CharacteristicValues which need more then one Measurement

class control_chart.models.PlotConfig(*args, **kwargs)[source]

Configurtion of a plot which defines which data should be displayed and how.

annotations

Annotations (Control limits, Mean etc) which should be displayed in the plot. The list is saved in the database as pickle

filter_args

Returns dictionary with the filter arguments to get plot data. The dictionary is saved in the database as pickle

get_annotation_container()[source]

Returns a Container with all annotations which will be displayed in the plot

plot_args

Returns dictionary with the plot arguments for the plot (color, line style etc). The dictionary is saved in the database as pickle

titles

List of Titles of the plot

class control_chart.models.Product(*args, **kwargs)[source]

Product to group the MeasurementItems

class control_chart.models.ProductQuerySet(*args, **kwargs)[source]

QuerySet for Product with easy access to the CharacteristicValueDefinitions which are linked to one product.

get_charac_value_definitions()[source]

Easy access to the CharacteristicValueDefinitions :return: Set of linked CharacteristicValueDefinitions

class control_chart.models.UserPlotSession(*args, **kwargs)[source]

Currently connected browser bokeh plot session

control_chart.models.after_charac_value_saved(instance, update_fields, **kwargs)[source]

Calculates the value of CharacteristicValues and updates the Plot sessions. Called via the post_saved signal

control_chart.models.after_measurement_saved(instance, **kwargs)[source]

Creates new CharacteristicValues after new Measurement was saved. Called via post_save signal

control_chart.models.create_product_plotconfig(instance, **kwargs)[source]

Creates a configuration for a plot which shows plot for all CharacteristicValues of a product. Called everytime the ManyToManyField characteristic_values in a MeasurementOrderDefinition is changed :param instance: Changed MeasurementOrderDefinition

control_chart.models.get_file_directory(_, filename)[source]

Creates the path where the raw data file should be saved. The function is necessary to be able to change the path dynamic for the unit tests

multiform

View class to create at Form at of multiple ModelsForms

class control_chart.multiform.MultiFormMixin[source]

Mixin Class to handle the data of a MultiFormView

forms_invalid(forms)[source]

Renders the forms

forms_valid(forms, form_name)[source]

Calls the form_valid method of the given form :param forms: Dictonary of all Form classes :param form_name: Form name which should check :return: Returns the result of the from_valid method or redirects to the success_url if the form has no valid method

get_form_classes()[source]

Retruns a dictonary with the classes of the used ModelForms

get_form_kwargs(form_name, bind_form=False)[source]

Gets the prefix, initials and POST arguments from a given form :param form_name: Name of the form :param bind_form: Set True to read the POST data :return: Dictionary with the following keys [‘initial’, ‘prefix’ and ‘data’, files (only if bind_form)]

get_forms(form_classes, form_names=None, bind_all=False)[source]

Creates the form instances out of the given form classes :param form_classes: Dictonary with form classes :param form_names: List of forms which data should be used in the kwargs :param bind_all: Set True to use the data of all forms :return: Dictonary with the created form instances

get_initial(form_name)[source]

Calls the get_initial method for the given fomr :param form_name: Name of the form :return: Dictonary with initial data

get_prefix(form_name)[source]

Prefix of the given form

get_success_url(form_name=None)[source]

Returns the success_url form the given form or if no form_name given the success_url of the MultiForm

class control_chart.multiform.MultiFormsView(**kwargs)[source]

View class to create at Form at of multiple ModelsForms

plot_annotation

Offers different annotation for the plot like mean, lower control limit, upper control limit etc. Use one of this classes as base to create your own annotations.

class control_chart.plot_annotation.FixedMaxAnnotation(max_bottom, fill_color='red', **kwargs)[source]

Marks all over the given maximum bottom level

class control_chart.plot_annotation.FixedMinAnnotation(min_top, fill_color='red', **kwargs)[source]

Marks all under the given minimum bottom level

class control_chart.plot_annotation.LowerControlLimitAnnotation(**kwargs)[source]

Show the lower control limit (LCL)

class control_chart.plot_annotation.MeanAnnotation(line_color='green', line_alpha=1.0, **kwargs)[source]

Annotation to mark the mean of a plot

bottom(y_values)[source]

Returns the mean value

top(y_values)[source]

Returns the mean value

class control_chart.plot_annotation.MultiStdAnnotation(factor, fill_color='None', fill_alpha=0.0, line_color='red', line_alpha=0.6, line_dash='dashed', **kwargs)[source]

Annotation to mark a area with the width factor*std around the mean of the plot

bottom(y_values)[source]

Returns mean - factor*std

top(y_values)[source]

Returns mean + factor*std

class control_chart.plot_annotation.PlotAnnotation(**kwargs)[source]

Base class for all annotation. With annotation it is possible to show colored y-ranges or horizontal lines to mark special areas in the plot.

bottom(y_values)[source]

Returns bottom value of the annotation calculated out of the y_values. This method must be overridden by each implementation of a PlotAnnotation

top(y_values)[source]

Returns top value of the annotation calculated out of the y_values. This method must be overridden by each implementation of a PlotAnnotation.

class control_chart.plot_annotation.PlotAnnotationContainer(create_default=True)[source]

Bundles all annotations of a plot

add_annotation(key, annotation)[source]

Add an annotation to the container

calc_min_max_annotation(y_values)[source]

Calculates the borders of all annotations and returns the exterma :param y_values: y-values of the plot :return: min and max value reached by one annotation

count()[source]

Returns the number of annotations

create_default_annotations()[source]

Creates a mean, upper control limit and lower control limit as a default set of annotations.

keys()[source]

List of keys

plot(plot, y_values)[source]

Adds the annotations to the plot :param plot: Bokeh plot to add the annotations :param y_values: y-values of the plot

remove_annotation(key)[source]

Removes the annotation with the given key

class control_chart.plot_annotation.UpperControlLimitAnnotation(line_alpha=1.0, **kwargs)[source]

Show the upper control limit (UCL)

plot_util

Wrapping the creation of the bokeh plots

class control_chart.plot_util.PlotGenerator(configuration, index=None, max_calc_points=100)[source]

Encapsulates the the creation of the bokeh plots

static calc_histogram_data(values)[source]

Classifies the data for a histogram :param values: Dataframe with the raw-values :return: ColumnDataSource with the histogram data

create_x_y_values(index)[source]

Create the lists for the x and y values for the plot out of the raw_data :param index: Index of the filter argument set of the PlotConfig :return: Tuple of list of x label, list of values and the number of invalid values

plot_code_iterator()[source]

Iterator over the single bokeh plot :return: Tuple of js-script code for the plot and number of invalid values

summary_for_last_plot()[source]

Summary data (mean, lower and upper control limit) for the last plot :return: Tuple of mean, lcl, ucl

values_for_last_plot()[source]

Returns the DataFrame with the values of the last plot

control_chart.plot_util.autoload_server(*args, **kwargs)[source]

Wrapper around the bokeh autoload_server, which read the enviroment variable BOKEH_SERVER to get the server address. Manly used in unit tests

control_chart.plot_util.pull_session(*args, **kwargs)[source]

Wrapper around the bokeh pull_session, which read the enviroment variable BOKEH_SERVER to get the server address. Manly used in unit tests

control_chart.plot_util.push_session(*args, **kwargs)[source]

Wrapper around the bokeh push_session, which read the enviroment variable BOKEH_SERVER to get the server address. Manly used in unit tests

control_chart.plot_util.update_plot_sessions()[source]

Updates the plot of exsiting browser sessions. If a saved session is disconnected the session will be deleted

urls

Url-mapping for the control_chart app