sift_py.data.query
¶
Module containing utilities to construct a data query which is ultimately
passed to sift_py.data.service.DataService.execute to download telemetry.
This module also contains types that represent the result of a data query
which can be easily converted into a pandas data frame or series.
| CLASS | DESCRIPTION |
|---|---|
CalculatedChannelQuery |
Represents a single calculated channel to include in the |
ChannelQuery |
Represents a single channel to include in the |
DataQuery |
A query that is meant to be passed to |
DataQueryResult |
The result of a data query which can contain multiple channels. |
DataQueryResultSet |
Represents time series data for a single channel. Can easily be converted into a |
ExpressionChannelReference |
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
ChannelLookupInfo |
TYPE:
|
ChannelLookupInfo
module-attribute
¶
ChannelLookupInfo: TypeAlias = Union[
str, Tuple[str, ChannelDataType]
]
CalculatedChannelQuery
¶
CalculatedChannelQuery(
channel_key: str,
expression: str,
expression_channel_references: List[
ExpressionChannelReference
],
run_name: Optional[str] = None,
)
Represents a single calculated channel to include in the sift_py.data.query.DataQuery.
| ATTRIBUTE | DESCRIPTION |
|---|---|
channel_key |
TYPE:
|
expression |
TYPE:
|
expression_channel_references |
TYPE:
|
run_name |
|
expression_channel_references
instance-attribute
¶
expression_channel_references: List[
ExpressionChannelReference
] = expression_channel_references
ChannelQuery
¶
Represents a single channel to include in the sift_py.data.query.DataQuery.
| METHOD | DESCRIPTION |
|---|---|
fqn |
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
channel_name |
TYPE:
|
component |
|
run_name |
|
DataQuery
¶
DataQuery(
asset_name: str,
start_time: Union[
Timestamp, Timestamp, datetime, str, int
],
end_time: Union[
Timestamp, Timestamp, datetime, str, int
],
channels: List[
Union[ChannelQuery, CalculatedChannelQuery]
],
sample_ms: int = 0,
_: int = DEFAULT_PAGE_SIZE,
)
A query that is meant to be passed to sift_py.data.service.DataService.execute to
retrieve telemetry.
asset_name: The name of the asset to query telemetry for.start_time: The start time of the time range of the data to request.end_time: The end time of the time range of the data to request.sample_ms: The sampling rate to use when retrieving data. The lower the sampling rate, the greater the data-fidelity. A sampling rate of0retrieves full-fidelity data.channels: List of eitherChannelQueryorCalculatedChannelQuery, but not both. Represents the channels to retrieve data from.
| ATTRIBUTE | DESCRIPTION |
|---|---|
DEFAULT_PAGE_SIZE |
|
asset_name |
TYPE:
|
channels |
TYPE:
|
end_time |
TYPE:
|
page_size |
TYPE:
|
sample_ms |
TYPE:
|
start_time |
TYPE:
|
channels
instance-attribute
¶
channels: List[
Union[ChannelQuery, CalculatedChannelQuery]
] = channels
DataQueryResult
¶
The result of a data query which can contain multiple channels.
| METHOD | DESCRIPTION |
|---|---|
all_channels |
Returns all channel data. |
channel |
Like |
channels |
Returns a |
channel
¶
channel(
lookup: ChannelLookupInfo,
) -> Optional[DataQueryResultSet]
Like channels but returns a single DataQueryResultSet.
channels
¶
channels(
*lookup: ChannelLookupInfo,
) -> List[DataQueryResultSet]
Returns a sift_py.data.channel.ChannelTimeSeries given the lookup argument.
If a lookup is a fully qualified name (FQN) str and there are multiple channels
with the same FQN, this will raise a ValueError. In these situations, lookup must
be a tuple where the first item is the channel FQN and the second the
sift_py.ingestion.channel.ChannelDataType.
If lookup is a tuple, then the channel data-type will be appended to the key referencing
the sift_py.data.channel.ChannelTimeSeries.
DataQueryResultSet
¶
Represents time series data for a single channel. Can easily be converted into a pandas data frame like so:
| METHOD | DESCRIPTION |
|---|---|
columns |
Returns both the time and value columns with options to override the column names. |
time_column |
Returns a single key-value pair dictionary meant to represent the time column of the data-set. |
value_column |
Returns a single key-value pair dictionary meant to represent the value column of the data-set. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
identifier |
TYPE:
|
timestamps |
TYPE:
|
values |
|
columns
¶
columns(
time_column_name: Optional[str] = None,
value_column_name: Optional[str] = None,
) -> Dict[str, List[Any]]
Returns both the time and value columns with options to override the column names.
time_column
¶
Returns a single key-value pair dictionary meant to represent the time column of the data-set.
column_name can be used to override the name of the column.
ExpressionChannelReference
¶
Bases: TypedDict
| ATTRIBUTE | DESCRIPTION |
|---|---|
channel_name |
TYPE:
|
component |
TYPE:
|
data_type |
TYPE:
|
reference |
TYPE:
|