trendminer.sdk.trend.trend module

This module provides user-facing API’s for interacting with Trend Views.

class trendminer.sdk.trend.trend.TrendView(identifier: str, name: str, description: str, owner: User | str, last_modified: datetime, entries: list, layers: list[trendminer.sdk.commons.interval.Interval] | list[trendminer.sdk.commons.layer.Layer], chart: Any | None = None, context_interval: str = '6M', live: bool = False)

Bases: ABC

A Trend View class is the collection of everything that is visualized on the chart in Trendhub.

identifier

Unique identifier to the view object on the appliance

Type:

str

name

The view name

Type:

str

description

The view description

Type:

str

owner

The view owner

Type:

User or str

last_modified

View last modified time

Type:

datetime

entries

List of Tag, Attribute or EntryGroup. Strings are interpreted as tags or assets

Type:

list of Any

layers

Intervals to be converted into Layer instances. Creating and passing Layer instances directly is currently not recommended. The first interval in the list will become the base layer. All other layers will be trimmed or extended to match the base layer length if layers are not the same size.

Type:

list of Interval or list of Layer

context_interval

ContextInterval or any input that can be converted into an Interval or Period

Type:

str, default ‘6M’

live

Whether the view should be live

Type:

bool, default False

chart

StackedChartProperties or TrendChartProperties or ScatterChartProperties Chart configuration as object, default None

Type:

Any, optional

abstract property base_layer: Layer

The base layer of the view. The base layer serves as a reference point for various operations within the view.

Returns:

The base Layer object

Return type:

Layer

abstract get_data(resolution: str) list[pandas.core.frame.DataFrame]

Retrieves timeseries interpolated data for underlying tags and layers.

Parameters:

resolution (str) – Resolution setting for retrieving data. Determines the time interval between data points in the resulting DataFrames. String values are interpreted to timedelta. Floats are assumed to be in seconds

Returns:

A list of DataFrames, one for each layer in the view. Each DataFrame has a DatetimeIndex as its index and uses tag names as column headers

Return type:

list

Example

view = client.view.get_by_name("helloworldview")
view_dfs = view.get_data(resolution="60s")
for view_df in view_dfs:
    view_df.head()
abstract get_index_data(fill: bool = False) list[pandas.core.frame.DataFrame]

Retrieves timeseries index data for underlying tags and layers.

Parameters:

fill (bool, default False) – For chart and index data, tag points timestamps typically do not match. When setting fill=True, tags are interpolated (in accordance with their interpolation type) so that all tags have values associated with every timestamp. When fill=False, NaN values will occur in the dataframes for the timestamps at which there are points for other tags, but not that tag

Returns:

A list of DataFrames, one for each layer in the view. Each DataFrame has a DatetimeIndex as its index and uses tag names as column headers

Return type:

list

Example

view = client.view.get_by_name("helloworldview")
view_dfs = view.get_index_data()
for view_df in view_dfs:
    view_df.head()
abstract get_plot_data(n_intervals: int = 300, fill: bool = False) list[pandas.core.frame.DataFrame]

Retrieves timeseries chart data for underlying tags and layers, including min, max, start, and end data points within each interval.

Parameters:

n_intervals (int, optional) –

Splits the data interval into this number of sub-intervals. Each sub-interval will contain up to 4 data points:

  • Minimum value within the interval

  • Maximum value within the interval

  • Starting data point for the interval

  • Ending data point for the interval

Note

The sub-interval may return less than 4 points if the data points overlap (e.g., start value is also the minimum value), or there’s no data for that specific sub-interval. If n_intervals is not provided, a default value of 300 will be used

Very high values for n_intervals can result in dataframes exceeding memory limitations due to high granularity

fillbool, default False

For chart and index data, tag points timestamps typically do not match. When setting fill=True, tags are interpolated (in accordance with their interpolation type) so that all tags have values associated with every timestamp. When fill=False, NaN values will occur in the dataframes for the timestamps at which there are points for other tags, but not that tag

Note

Ensure that ‘n_intervals’ is chosen such that the resulting resolution remains above 1 second

Returns:

A list of DataFrames, one for each layer in the view. Each DataFrame has a DatetimeIndex as its index and uses tag names as column headers

Return type:

list

Example

view = client.view.get_by_name("helloworldview")
view_dfs = view.get_plot_data(n_intervals=300)
for view_df in view_dfs:
    view_df.head()
abstract property tags: list[trendminer.sdk.tag.tag.Tag]

Flat list of underlying tags in the view. Underlying tags are extracted from attributes and groups.

Returns:

A list of tag objects

Return type:

list

class trendminer.sdk.trend.trend.TrendViewAPI

Bases: ABC

A class that provides user-friendly functions for interacting with TrendView.

abstract all() list[trendminer.sdk.trend.trend.TrendView]

Retrieves all TrendView objects.

Returns:

A list of TrendView objects

Return type:

list

Example

# Fetches all TrendView objects
trend_view = client.view.all()
abstract get_by_identifier(ref: str) TrendView

Loads a TrendView instance directly from its unique identifier.

Parameters:

ref (str) – Unique identifier of the TrendView object on the appliance

Returns:

The TrendView object with the given unique identifier

Return type:

TrendView

Example

# Fetches a TrendView object
trend_view = client.view.get_by_identifier("68cfd6f2-33b1-47b9-8bc3-2b8a3ce137dd")
abstract get_by_name(ref: str) TrendView

Retrieves TrendView object by its name. If there are multiple items with the given name (of the same type), an error is thrown.

Parameters:

ref (str) – Name of the TrendView object

Returns:

The TrendView object with the matching name

Return type:

TrendView

Example

# Fetches a TrendView object
trend_view = client.view.get_by_name("view1")
abstract get_by_path(ref: str) TrendView

Retrieves a TrendView object by its full path.

Parameters:

ref (str) – Full path to the TrendView object. e.g: “my_folder/my_subfolder/my_view”

Returns:

The TrendView object at the specified path

Return type:

TrendView

Example

# Fetches a TrendView object
client.view.get_by_path("my_folder/my_subfolder/my_view")
abstract search(*args, **kwargs) list[trendminer.sdk.trend.trend.TrendView]

Searches TrendHub Views using various search keywords. It executes search methods based on the provided keywords and returns a collection of unique results. Duplicate instances are filtered out when multiple methods return overlapping instances.

Note

Atleast one of the below mentioned Keyword Arguments should be provided. Otherwise, an empty list will be returned. If multiple keywords are provided, they will be combined using an AND operation.

Keyword Arguments:

name (str) – Name as reference

Returns:

A list of TrendView objects matching the search criteria

Return type:

list

Example

# Search for views
trend_views = client.view.search(name="*")