sailor.sap_iot.fetch_aggregates

Timeseries module can be used to retrieve timeseries data from the SAP iot abstract timeseries api.

This is the equivalent to sap_iot.fetch, except we’re retrieving pre-aggregated data from the hot store rather than raw data from the cold store.

sailor.sap_iot.fetch_aggregates.get_indicator_aggregates(start, end, indicator_set, equipment_set, aggregation_functions=('AVG',), aggregation_interval='PT2M')[source]

Fetch timeseries data from SAP Internet of Things for Indicators attached to all equipments in this set.

Unlike sailor.assetcentral.equipment.Equipment.get_indicator_data() this function retrieves pre-aggregated data from the hot store.

Parameters
  • start (Union[str, pd.Timestamp, datetime]) – Date of beginning of requested timeseries data.

  • end (Union[str, pd.Timestamp, datetime]) – Date of end of requested timeseries data.

  • indicator_set (IndicatorSet) – IndicatorSet for which timeseries data is returned.

  • equipment_set (EquipmentSet) – EquipmentSet for which timeseries data is returned.

  • aggregation_functions (Determines which aggregates to retrieve. Possible aggregates are) – ‘MIN’, ‘MAX’, ‘AVG’, ‘STDDEV’, ‘SUM’, ‘FIRST’, ‘LAST’, ‘COUNT’, ‘PERCENT_GOOD’, ‘TMIN’, ‘TMAX’, ‘TFIRST’, ‘TLAST’

  • aggregation_interval (Determines the aggregation interval. Can be specified as an ISO 8601 string) – (like PT2M for 2-minute aggregates) or as a pandas.Timedelta or datetime.timedelta object.

Example

Get indicator data for all Equipment belonging to the Model ‘MyModel’ for a period from 01.06.2020 to 05.12.2020

equipment_set = find_equipment(model_name='MyModel')
indicator_set = equipment_set.find_common_indicators()
get_indicator_aggregates('2020-06-01', '2020-12-05', indicator_set, equipment_set,
                         aggregation_functions=['MIN'], aggregation_interval=pd.Timedelta(hours=2))