Correlation App

The Correlation App analyzes correlations between asset attributes, taking into account customizable time delays (Lag Intervals), and generates comprehensive reports with visualizations.


Main Functions

  • Time-delay-based correlation: Analyze correlations between attributes for defined time delays.

  • Report generation: Create HTML and PDF reports with heatmaps, scatter plots, and delay charts.

  • Email integration: Send reports directly to defined recipients.

  • Customizable time period: Set the start and end time of the analysis.


Configuration

Environment Variables

Variable
Description
Example

CONNECTION_STRING

Connection details to the Eliona database.

postgres://user:pass@host:port/dbname

API_ENDPOINT

API endpoint for accessing Eliona services.

http://api-v2:3000/v2

API_TOKEN

Authentication token for Eliona services.

your_api_token

API_SERVER_PORT

(Optional) Port for the API server. Default value: 3000.

3000

SMTP_SERVER

Address of the SMTP server.

smtp.example.com

SMTP_PORT

Port of the SMTP server.

587

SMTP_USER

Username for the SMTP server.

SMTP_PASSWORD

Password for the SMTP server.

password

API Endpoints

1. POST /v1/correlate

Description: Calculates the correlation between the specified attributes of multiple assets.

  • If only one asset ID is specified (without an attribute name), all attributes of the asset are correlated with each other.

Request body:

Response:

  • 200 OK: Returns the following data: * Analyzed assets and time delays. * Time period of the analysis. * Correlation results including best_correlation, best_lag, and lag_details. * An HTML report (report_html) with heatmap visualizations. * If to_email is specified, the report is sent via email.

  • 400 Bad Request: Invalid input parameters.


2. POST /v1/correlate-children

Description: Correlates all attributes of child assets of a specified asset.

Request body: Same as with /v1/correlate, but with asset_id instead of a list of assets.

Response: Identical to /v1/correlate, including the HTML report.


3. POST /v1/in-depth-correlation

Description: Performs a detailed correlation analysis for exactly two attributes.

Response:

  • Detailed correlation data including:

    • Best correlation and associated delay.

    • Correlation values for each tested delay.

  • HTML report (report_html) with scatter and delay charts.


Request Parameters

The following parameters can be included in the request:

  • assets: List of asset-attribute pairs for the analysis. Without an attribute specified, all attributes of the asset are analyzed.

  • lags: Optional time delays, e.g., {"hours": 10}.

  • start_time, end_time: Time period of the analysis.

  • to_email: (Optional) Email address for sending the report.

Example Request

Example Response for the API request /v1/correlate

Explanation of the Response Fields

  1. assets:

    • Contains the analyzed assets and their attributes, e.g., temperature and humidity.

  2. lags:

    • List of tested time delays: 15 minutes, 2 hours, and 1 day.

  3. start_time, end_time:

    • The time period of the analysis, here January 1 to January 3, 2025.

  4. correlation:

    • Detailed correlation data:

      • best_correlation: Highest correlation value (0.85).

      • best_lag: The time delay (2 hours) at which the highest correlation occurs.

      • lag_details: Correlation values for different delays (-2, 0, +2 hours).

  5. report_html:

    • An HTML report with visualizations such as heatmaps and scatter plots, ready to be displayed or saved directly.


Report Generation

Reports contain the following visualizations:

HTML Report

Generated for the /v1/correlate and /v1/correlate-children endpoints:

  • Heatmaps: Best correlations between attributes.

  • Correlation numbers: Detailed statistics for each correlation.

Generated for the /v1/in-depth-correlation endpoint:

  • Scatter plots: Relationships between attributes.

  • Delay charts: Time-dependent trends.

Last updated