IAGOS.apps.database.dataseries

DataDescription

class IAGOS.apps.database.dataseries.models.DataDescription(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_description. Every instance of the class has a name and a description and describes the data. The class is used by Data point extensions and Data series. With this approach, you can make sure that the same series with other properties (level, revision) have the same description because both refer to the same DataDescription.

Parameters
  • name (string) – Name of the data

  • description (string) – Description of the data

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

static import_from_dictionary(dictionary)

Imports the data descriptions from the dictionary. The key of the dictionary must be the name of the data description and the value must be the description. The method returns the created data descriptions.

Parameters

dictionary (dictionary) – Dictionary(key=name, value=description)

Returns

Queryset with created entries

Return type

Queryset

DataLevel

class IAGOS.apps.database.dataseries.models.DataLevel(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_level. A level describes the state of the time series. A level has a unique name and a description.

Warning

If a level is deleted, every data point will also be deleted.

Parameters
  • name (string) – State of processing flag (e.g. Raw data)

  • description (string) – Description of the level (e.g. Calibrated data)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DataPoint

class IAGOS.apps.database.dataseries.models.DataPoint(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_point. A data point is assigned to a time series and has a timestamp, a value, and validity. Furthermore, every data point can have additional information. These can be comments to the data point or additional values (see DataPointExtension).

Parameters
  • data_series (DataSeries) – Related data series

  • data_validity (DataValidity) – State of validity flag (e.g. Limited)

  • timestamp (datetime) – Datetime of the observation

  • value (float) – Recorded value (e.g. 23.321)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DataPointExtension

class IAGOS.apps.database.dataseries.models.DataPointExtension(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_point_extension. This make it possible that you store additional informations for the point.

Parameters
  • data_point (integer) – ID of the data point

  • data_description (integer) – ID of the data description

  • values (JSONField) – Values as a json string

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

static import_from_dataframe(df)

Imports the data point extensions from the given DataFrame.

Parameters

df (pd.DataFrame) – DataFrame(values, data_points, data_description)

Returns

Returns the created data point extensions

Return type

QuerySet(DataPointExtension)

DataSeries

class IAGOS.apps.database.dataseries.models.DataSeries(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_series. A time series has a name, a period, a creation timestamp, a description, and a revision. The creation timestamp records when the time series was imported into the database. Every series should be assigned to a component and the parameter (component parameter).

Important

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

  • The period_start * must be before the *period_end

  • The period of the series must be inside the period of the deployment

  • The series must have a unique revision

  • If a project is deleted, every related deployment and every related

Warning

If a series is deleted, every related data point will also be deleted

Parameters
  • component_parameter (ComponentParameter) – Related ComponentParameter

  • deployment (Deployment) – Related deployment

  • data_level (DataLevel) – State of processing flag (e.g. Final data)

  • data_description (integer) – ID of the data description

  • period_start (datetime) – Start of the data series period

  • period_end (datetime) – End of the data series period

  • timestamp (datetime) – Creation date of the data series

  • revision (int) – Number of revision

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

property component

Returns the component that recorded the data series.

Returns

Component

Return type

Component

convert_to_pandas(without_ids=True, only_values=False)

Returns a pandas data series.

Parameters
  • without_ids (bool) – Without data series id (default: True)*

  • only_values (bool) – Only values (default: False)

Returns

Pandas Series

Return type

Series

property data_points

Returns all data points of the data series.

Returns

All data points

Return type

QuerySet(DataPoint)

data_points_are_inside()

Returns whether all data points are included by the period.

Returns

True if points are included, False otherwise.

Return type

bool

deployment_is_valid()

Returns whether the deployment is valid.

Returns

True if deployment is valid, False otherwise.

Return type

bool

property deployment_string

Returns a string to represent the deployment.

Returns

String representation of the deployment

Return type

string

property error_description

Returns the data description for the errors.

Returns

Data description for the error

Return type

DataDescription

property flags_description

Returns the description for the flags.

Returns

Data description for the error

Return type

DataDescription

property flight

Returns the flight.

Returns

All data points

Return type

QuerySet(DataPoint)

get_extensions(points=None, description='Flags')

This method returns the data point extensions in a data frame. If the parameter points is None, all extensions will be returned. Otherwise only the extensions of the given points. If there is no extension, None will be returned.

Parameters

points (pd.DataFrame) – Points

Returns

Extensions in pd.DataFrame

Return type

pd.DataFrame

has_data_description()

Returns if the field data_description is not None.

Returns

True if data description is not None, False otherwise.

Return type

bool

has_deployment()

Returns if the field deployment is not None.

Returns

True if deployment is not None, False otherwise.

Return type

bool

import_data_points_from_pandas(df)

Imports the given DataFrame to the database.

Parameters

df (pd.DataFrame) – DataFrame(timestamp, value, validity)

Returns

Created data points

Return type

QuerySet(DataPoint)

import_errors(errros)

Imports the given errors.

Parameters

errors (pd.Series) – Errors

Returns

None

Return type

None

import_flags(flags)

Imports the given flags.

Parameters

flags (pd.DataFrame) – Flags

Returns

None

Return type

None

is_valid()

Returns whether the parameter of the instance are valid.

Returns

Valid status and the message (valid, error message)

Return type

tuple(bool, string)

property location

Returns the location of the deployment.

Returns

The location of the deployment.

Return type

Aircraft or MeasurementLocation

property manual_flags

Returns the points that was manual flagged.

Returns

Data points

Return type

QuerySet(DataPoint)

property parameter_name

Returns the parameter of the data series.

Returns

Parameter

Return type

Parameter

period_is_in_deployment()

Returns whether the data series is inside the deployment period.

Returns

True if the revision is does not exist, false otherwise.

Return type

bool

period_is_valid()

Returns whether the period is valid. (start < end).

Returns

True if the period is valid, false otherwise.

Return type

bool

prepare_for_display(data_points=None, resample=True, replace_with_zero=False)

Prepares the series for displaying the series. If the series’ points were already queried, use the parameter data_points to avoid a new query. The application resamples the series to reduce the number of points.

Parameters
  • data_points (QuerySet(DataPoint)) – Data points of the series

  • resample (bool) – The series should be resampled

  • replace_with_zero (true) – Replace invalid values with zero

Returns

Prepared series that can be displayed

Return type

pd.DataFrame

save(*args, **kwargs)

Saves the model after checking the constrains.

Parameters
  • args (list) – Arguments

  • kwargs (dict) – Keyword arguments

Returns

None

Return type

None

set_validities(start, end, validity)

Set the validities of the series manually.

Parameters
  • start (datetime) – Start timestamp

  • end (datetime) – End timestamp

  • validity (int or DataValidity) – Validity

Returns

None

Return type

None

update_data_points_from_pandas(df)

Imports the given DataFrame to the database.

Parameters

df (pd.DataFrame) – DataFrame(id, timestamp, value, validity)

Returns

None

Return type

None

DataValidity

class IAGOS.apps.database.dataseries.models.DataValidity(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table data_validity. A validity is used to mark a data point as doubtful, good, or missing, etc. A validity has a unique name and a description.

Warning

If a validity is deleted, every data point will also delete.

Parameters
  • name (string) – State of validity flag (e.g. Limited)

  • description (string) – Description of the state (e.g. Doubtful)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

static get_validities(series)

Returns the instances for the given IDs. For example, if you pass a series that contains 0, 2, 0, etc., you will get the validities with the related IDs. In case of IAGOS, it would be Good, Limited, Good.

Parameters

series (pd.Series) – Series with the validities IDs

Returns

DataValidities instances

Return type

List(DataValidity)

DeploymentExtension

class IAGOS.apps.database.dataseries.models.DeploymentExtension(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the table deployment_extension. An instance of the class stores additional information about the deployment. An example for a deployment extension is the nighttime of set, of a Package 2b deployment.

Important

To avoid circular dependencies, the class is implemented in this application instead of in deployments.

Parameters
  • name (string) – Name of the extension

  • values (string) – Values of the extension (JSON)

  • deployment (Deployment) – Related deployment

  • series (ManyToManyField) – Related series that were used to calculate the extension

  • revision (integer) – Revision of the deployment

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

SeriesRelation

class IAGOS.apps.database.dataseries.models.SeriesRelation(*args, **kwargs)

Bases: django.db.models.base.Model

This class implements the database table series_relation. The relations gives you the possibility to store relations between series. It allows you to store which series, calibrations and functions were used to calculate the series. In conclusion, every relation is the base for reprocessing, restoring, and memory management.

Parameters
  • series (DataSeries) – Series that is in relation with the other parameters.

  • relation_series (List(DataSeries)) – Related series

  • related_calibrations (List(Calibration)) – Related calibrations

  • related_deployment_extensions (List(DeploymentExtension)) – Related deplomyent extensions

  • relation_functions (List(Function)) – Related functions

  • description (string) – Description

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned