IAGOS.apps.database.components

Calibration

class IAGOS.apps.database.components.models.Calibration(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table calibration. A calibration has a timestamp and is related to a component. Moreover, each calibration can have several calibration parameters. Note that the database doesn’t differ between pre- and postcalibrations.

See also

Warning

If a calibration is deleted, every related calibration parameter will also be deleted.

Parameters
  • component (Component) – Related component

  • timestamp (datetime) – Datetime of the creation

  • name (string) – Name of the calibration (optional)

  • description (string) – Description of the calibration (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_all_parameters(as_dataframe=False)

Returns all parameters of the calibration.

Returns

All parameters of the calibration

Return type

QuerySet(Calibration)

get_calibration_parameter(name)

Returns the calibration parameter with the given name. If the parameter could not found, None will be returned.

Parameters

name (string) – Name of the parameter

Returns

Calibration parameter

Return type

CalibrationParameter or None

static get_calibrations(component, timestamp)

Returns the pre and post calibration of the component.

Parameters
  • component (Component) – Component

  • timestamp (datetime) – Timestamp of the deployment or flight

Returns

Tuple (pre_calibration, post_calibration)

Return type

(Calibration, Calibration)

import_parameters_from_dict(params)

Imports the parameters from the given dictionary.

Parameters

params (dict) – Calibration parameters

Returns

Created calibration parameters

Return type

list

CalibrationFunctionRelation

class IAGOS.apps.database.components.models.CalibrationFunctionRelation(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table calibration_function_relation. A instance of the class holds tight a relation between a calibration and a function. Furthermore, a instance have a order number if that is needed for an evalutation algorithm.

Parameters
  • calibration (Calibration) – Related calibration

  • function (Function) – Related function

  • order_no (integer) – Order number (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Component

class IAGOS.apps.database.components.models.Component(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component. Every component has a component type that saves the metadata of the component. The components differ only in the ID and the serial number. Furthermore, every component could have a status.

Warning

If a component is deleted, every related series will also be deleted.

Parameters
  • component_type (ComponentType) – Type of the component

  • component_status (ComponentStatus) – Current status of the model (optional)

  • serial_no (string) – Unique serial number (optional)

  • internal_no (integer) – Internal number of the component (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

clean(*args, **kwargs)

Cleans the model.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

get_all_calibrations()

Returns all calibrations of the component.

Returns

All calibrations of the component

Return type

QuerySet(Calibration)

get_all_deployments()

Returns all deployments of the component.

Returns

All deployments of the component

Return type

QuerySet(Deployment)

get_all_installations()

Returns all installations of the component.

Returns

All installations

Return type

QuerySet(ComponentRelation)

get_all_installed_components()

Returns all installed components.

Returns

All installed components

Return type

QuerySet(Component)

get_all_parameters()

Returns all component parameters.

Returns

All component parameters

Return type

QuerySet(ComponentParameter)

get_all_status()

Returns all status of the component.

Returns

All status

Return type

QuerySet(ComponentStatus)

get_installations_by_time(timestamp)

Returns all installed components that are/were installed on the given timestamp.

Parameters

timestamp (datetime) – Timestamp to check the installations

Returns

Returns all installed components

Return type

QuerySet(ComponentRelation)

get_series_components()

Returns the components that measure a series.

Returns

Components

Return type

QuerySet(Component)

has_status()

Returns if the field component_status is not None.

Returns

True if not None, False otherwise.

Return type

bool

is_current_status()

Returns if the status is the current status.

Returns

True if current status or status is None, False otherwise.

Return type

bool

is_status_component()

Returns if the component of the status is the component self.

Returns

True if instance of the status is component, False otherwise.

Return type

bool

is_valid()

Returns if the instance is valid. If so, the method returns (True, ‘’). Otherwise, the method will return (False, message) whereby the message explains why the entry is not valid.

Returns

Valid status and the message (valid, error message)

Return type

tuple(bool, string)

save(*args, **kwargs)

Saves the model after checking the constrains.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

ComponentClass

class IAGOS.apps.database.components.models.ComponentClass(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_class. Component classes allow to classify the components. For example, the PT100 is assigned to the class Sensor.

Warning

If a component class is deleted, every related component type will also be deleted.

Parameters

name (string) – Name of the class (e.g. Sensor)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ComponentParameter

class IAGOS.apps.database.components.models.ComponentParameter(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_parameter. A instance of the class is needed by time series. With this class you can define which component did record the time series and have this parameter.

Important

Besides the constraints for the attributes, the class implements the following additional logical constraints:

  • The combination of component and parameter must be unique

Warning

If a component type parameter is deleted, every time series and component parameter will also be deleted.

Parameters
  • component (Component) – Related component

  • parameter (ClimateParameter) – Related climate parameter

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ComponentRelation

class IAGOS.apps.database.components.models.ComponentRelation(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_relation. With that, you can map every component structure to the database.

Important

Besides the constraints for the attributes, the class implements the following additional logical constraints:

  • The installation_timestamp must be before the removal_timestamp

  • The installation periods of a component can not overlap

Parameters
  • component (Component) – Related component

  • parent (Component) – Parent component

  • functionality (RelationFunctionality) – Functionality of the component (optional)

  • installation_timestamp (datetime) – Timestamp of the installation

  • removal_timestamp (datetime) – Timestamp of the removal (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

clean(*args, **kwargs)

Cleans the model.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

component_already_installed()

Returns if the installation is overlapping with another installation. Call only this method when removal_timestamp is null.

Returns

True if no overlapping, false otherwise.

Return type

bool

component_is_valid()

Returns if the installation is overlapping with another installation.

Returns

True if no overlapping, false otherwise.

Return type

bool

has_component()

Returns if the field component is not None.

Returns

True if the component is not None, False otherwise

Return type

bool

is_valid()

Returns if the instance is valid. If so, the method returns (True, ‘’). Otherwise, the method will return (False, message) whereby the message explains why the entry is not valid.

Returns

Valid status and the message (valid, error message)

Return type

tuple(bool, string)

period_is_valid()

Returns if the given period is valid. (start < end).

Returns

True if the period is valid, false otherwise.

Return type

bool

save(*args, **kwargs)

Saves the model after checking the constrains.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

ComponentStatus

class IAGOS.apps.database.components.models.ComponentStatus(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_status. A component-status is limited in time and refers to a status and is assigned to a component.

Parameters
  • component (Component) – Related component

  • status (Status) – Related status

  • start (datetime) – Start date of the status

  • end (datetime) – End date of the status (optional)

  • comments (string) – Additional comments (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

clean(*args, **kwargs)

Cleans the model.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

component_has_already_a_status()

Returns if the component has already a running status.

Warning

Call this method when end is null.

Returns

True if no overlapping, false otherwise.

Return type

bool

has_component()

Returns if the field component is not None.

Returns

True if the component is not None, False otherwise

Return type

bool

is_current_status()

Returns if the status is current status of the component.

Returns

True if current status, False otherwise.

Return type

bool

is_valid()

Returns if the instance is valid. If so, the method returns (True, ‘’). Otherwise, the method will return (False, message) whereby the message explains why the entry is not valid.

Returns

Valid status and the message (valid, error message)

Return type

tuple(bool, string)

no_collisions()

Returns if the status collides with an entry in the database.

Returns

True if no collisions, False otherwise.

Return type

bool

period_is_valid()

Returns if the given period is valid (start < end).

Returns

True if the period is valid, false otherwise.

Return type

bool

save(*args, **kwargs)

Saves the model after checking the constrains.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

ComponentType

class IAGOS.apps.database.components.models.ComponentType(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_type. A component-type has a unique name, a component class, and a description. The model was created to ensure that every instance of a component-type (component) has the same name and the same description. Since each component refers to the type, every component of the type has the same metadata.

Warning

If a type is deleted, every related component will also be deleted

Parameters
  • component_class (ComponentClass) – Class of the component (e.g., Sensor)

  • name (string) – Name of the type (e.g., PT100)

  • description (string) – Description of the type (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ComponentTypeParameter

class IAGOS.apps.database.components.models.ComponentTypeParameter(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table component_type_parameter. With this class, you can define that the sensor PT100 measures temperature. The instances (components) of the component type inherits the parameter. It means that an entry in the table component_parameter will be created automatically whenever a component will create. Even you assign a new parameter when the component is already created, it will have the parameter too.

Important

Besides the constraints for the attributes, the class implements the following additional logical constraints:

  • The combination of a component type and a parameter has to be unique

Warning

If a component type parameter is deleted, every time series and component parameter will also be deleted.

Parameters
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

save(*args, **kwargs)

Saves the model. If components of the type already exist, an entry in the table component_parameter will be created for them.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

Function

class IAGOS.apps.database.components.models.Function(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table function. A deployment has pre-calibration and a post-calibration. The functions are used to reconstruct the shift between the pre and post calibrations. Some functions consider the last ten calibrations. So, it should be possible to assign a function to several calibrations. Furthermore, the functions can also be used for other task like analog conversions.

See also

  • IAGOS.apps.database.components.models.FunctionType

Warning

If a function is deleted, every function parameter will also be deleted.

Parameters
  • name (string) – Name of the function

  • function_type (FunctionType) – Type of the function (e.g. linear)

  • calibration_parameters (ManyToManyField) – Calibration functions

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

property calibrations

Returns all calibrations that are in relation with the function.

Returns

All assigned calibrations

Return type

QuerySet(Calibration)

import_calibration_parameters(calibration, parameters)

Imports the given calibration parameters. The method assumes that the given parameters exist in the database. Otherwise an error will be occured. Note that the method does not store the parameters twice, the method creates references to the calibration parameters.

Parameters
  • calibration (Calibration) – Calibration

  • parameters (Dict(name:value)) – Parameters as a dictionary

Returns

None

Return type

None

property parameters

Returns all parameters of the function.

Returns

All function parameters

Return type

QuerySet(FunctionParameter)

FunctionParameter

class IAGOS.apps.database.components.models.FunctionParameter(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table function_parameter. An instance of the class represents a parameter of a function.

Parameters
  • function (Function) – Related function

  • parameter (Parameter) – Related parameter

  • value (float) – Value of the calibration parameter

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Parameter

class IAGOS.apps.database.components.models.Parameter(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table parameter. A parameter has a unique name, a long name, a unit, a description, and a CF standard name. Note that the class is not only used to define climate paramters, you can also use it for calibration and function parameters.

Warning

If a parameter is deleted, every time series and every component parameter will also be deleted.

Parameters
  • name (string) – Name of the parameter

  • long_name (string) – Long name of the parameter (optional)

  • cf_standard_name (string) – Name in CF convention (optional)

  • unit (string) – Unit of the parameter (optional)

  • description (string) – Description of the parameter (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

static get_series_parameter()

Returns the parameters that are assigned to an entry in the table component_type_parameter.

Important

The method is required for the data series filter. The filter should only contain parameters that can be measured by a sensor or an instrument.

Returns

All parameters

Return type

QuerySet(Parameter)

static import_from_dataframe(df)

Imports the given parameters from the dataframe and returns the created instances.

Parameters

df (pd.DataFrame) – Parameters

Returns

Returns the created instances

Return type

QuerySet(Parameter)

RelationFunctionality

class IAGOS.apps.database.components.models.RelationFunctionality(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table relation_functionality. Sometimes there are several components of the same type installed into a component, but they have different functionalities. For example, two PT100 sensors may be installed inside the HumiCap. The first sensor measures the air temperature and the second one measures the temperature of the unit. In such a case, it wouldn’t be comprehensible which sensor has which functionality. To avoid it, you can use the RelationFunctionality which describes the functionality. An instance of the model has to be passed to the relation.

Parameters
  • name (string) – Name of the functionality

  • description (string) – Description of the functionality (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Status

class IAGOS.apps.database.components.models.Status(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table status. A status has a unique name and a short description.

Warning

If the status is deleted, every related component_status will also be deleted.

Parameters
  • name (string) – Name of the status (e.g. Defect)

  • description (string) – Description of the status (optional)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned