Control chart appliction¶
admin¶
Definition of the django admin area
-
class
control_chart.admin.
CalculationRuleAdmin
(model, admin_site)[source]¶ Admin display for CalculationRules
apps¶
Contains the configuration of the control_chart App
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
-
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_unfinished
()[source]¶ Returns: Returns the number of unfinished(not all necessary Measurements are available) CharacteristicValues
-
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
-
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
-
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
-
-
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.
-
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
-
class
control_chart.models.
MeasurementDevice
(*args, **kwargs)[source]¶ Measurement device used for the measurement
-
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.
ProductQuerySet
(*args, **kwargs)[source]¶ QuerySet for Product with easy access to the CharacteristicValueDefinitions which are linked to one product.
-
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
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_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_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
-
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
-
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
-
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.
-
class
control_chart.plot_annotation.
PlotAnnotationContainer
(create_default=True)[source]¶ Bundles all annotations of a plot
-
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
-
create_default_annotations
()[source]¶ Creates a mean, upper control limit and lower control limit as a default set of annotations.
-
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
-
static
-
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
urls¶
Url-mapping for the control_chart app