Asset
Asset is the core data structure that represents a single object being monitored by a condition monitoring device, and that is a subject of reporting activities.
One of the main features of data coming from sensors is that they are going in two different styles:
- Devices are performing periodic measurements (usually every 1h) and they are reporting only the main properties (like mean value, standard deviation, kurtosis, etc.) of measured signals.
- Device might be triggered to perform so call raw data collection - in such a case device performs measurement and send all measured data.
On the data perspective, it contains information describing the monitored machine and actual values of raw data measurement and KPIs (represented by the structures defined in previous chapters and limited by start_date and end_date parameters provided at initialization).
Secondly, each asset object have to be initialized with AssetDataReader object that provides methods to get the data from external sources and asset_id that identifies which Asset object it represents.
Asset provides many methods and properties that are used throughout the report generation process. Check API docs for more details.
Most of the methods and properties are type-independent and are implemented in parent Asset class. However, since the Powertrain differentiates several asset types (Motor, Generic Machine) that represents different types of monitored machines, there are child classes of MotorAsset and GenericMachineAsset and DriveAsset, that inherit form the parent and provides a specific implementations for some of the methods or adds new ones.
Important
Asset Reports uses Asset objects of corresponding type. That is, MotorAssetReport expects MotorAsset, and GenericMachineAssetReport - GenericMachineAsset
API
smartreport.v3.models.asset.asset.Asset
Representation of the Asset Model. It is the main data object used by the Report objects to get the data for the report.
asset_identifier
property
Gets the asset identifier. It's anonymized if the asset is anonymous.
display_name
property
writable
Gets the asset display name from the asset details. It's anonymized if the asset is anonymous.
name
property
Gets the asset name from the asset details. It's anonymized if the asset is anonymous.
organization_name
property
Gets the organization from the asset details. It's anonymized if the asset is anonymous.
serial_number
property
Gets the serial number from the asset details. It's anonymized if the asset is anonymous.
site_name
property
Gets the site name from the asset details. It's anonymized if the asset is anonymous.
type
property
Gets the asset type from the asset details
unit_standard
property
writable
Gets the unit standard from the asset data reader.
unit_standard_converter
property
Gets the unit standard from the asset data reader.
Config
Configuration for Asset class. Should be overridden in subclasses.
expected_type: Expected AssetType for the Asset object. bearing_data_config: Configuration for bearing frequencies' data. nominal_parameter_mapping: Mapping of asset properties to nominal parameters. condition_indices_mapping: List of condition index parameters.
__init__(asset_id, asset_data_reader, start_date=None, end_date=None, **kwargs)
Initialize Asset object.
If you work with Powertrain API, you can use the from_access_token class method to create the Asset object.
Note
In the Powertrain API, the asset_id is an integer, that identifies the asset internally in the Powertrain microservices, but it's not visible on the portal.
On the other hand the asset_identifier is a string that is used to identify the asset on the portal.
We use the asset_id in the Asset object to identify the asset in the Powertrain API.
To get the asset_identifier you can use the asset_identifier property.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset Identifier used to by the AssetDataReader to get the data. |
required |
asset_data_reader
|
AssetDataReader
|
AssetDataReader that can provide the data to Asset Model |
required |
start_date
|
Union[None, str, datetime]
|
Start date of reporting period |
None
|
end_date
|
Union[None, str, datetime]
|
End date of reporting period |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
anonymous |
bool
|
If True, the asset will be treated as anonymous and will not provide any sensitive information.
Default: |
calculate_data_availability(symbolic_names, algorithm_names, start_date=None, end_date=None)
Calculates the data availability for this asset in a given time period. Data availability is expressed as a float between 0 and 1, and it represents the ratio of available data to the expected data in the given time period.
It uses the trends listed in symbolic_names and compare number of existing valid data points
vs expected number of data points. Expected number of data points can be provided.
If it's not provided, then it's estimated based on the asset properties or the default
sampling interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic_names
|
Sequence[Tuple[str, timedelta]]
|
List of tuples with (symbolic_name, expected_sampling_period) |
required |
algorithm_names
|
Sequence[Tuple[str, timedelta]]
|
List of tuples with (algorithm_name, expected_sampling_period) |
required |
start_date
|
Optional[datetime]
|
Start date of the time range. If None, the asset start_date is used. |
None
|
end_date
|
Optional[datetime]
|
End date of the time range. If None, the asset end_date is used. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
DataValue between 0 and 1. When not a single datapoint is available then it's equal to 0. If all data points are available for all KPIs then it's 1. |
from_access_token(access_token, asset_id, asset_type=None, **kwargs)
classmethod
Create Asset object from Powertrain token. This is the most convenient way to create the Asset object, when you work with Powertrain API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
Access token to Powertrain API |
required |
asset_id
|
int
|
Asset Identifier used to by the AssetDataReader to get the data. |
required |
asset_type
|
Optional[AssetType]
|
AssetType of the asset. If None, the object will be created with the class that holds this method. Default: None. |
None
|
Examples:
>>> # Create MotorAsset explicitly from provided asset type
>>> motor_asset = Asset.from_access_token(access_token=access_token, asset_id=1234, asset_type=AssetType.MOTOR)
>>> # Create DriveAsset implicitly from the class method
>>> drive_asset = DriveAsset.from_access_token(access_token=access_token, asset_id=5678)
Other Parameters:
| Name | Type | Description |
|---|---|---|
start_date |
datetime
|
Default start date for the asset's time range. |
end_date |
datetime
|
Default end date for the asset's time range. |
Returns:
| Type | Description |
|---|---|
'Asset'
|
Initialized Asset object. |
get_algorithm_results(algorithm_name, start_date=None, end_date=None, extend=False, upsample_interval=None, upsample_offset=None)
Gets the algorithm results for the asset.
Algorithms are identified by their name. If dates are not provided, the asset start_date and end_date are used.
Results are returned as a pandas DataFrame. It's up to the user to interpret the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm_name
|
str
|
Name of the algorithm |
required |
start_date
|
Optional[datetime]
|
Start date of the results. If None, we use the asset.start_date. |
None
|
end_date
|
Optional[datetime]
|
End date of the results. If None, we use the asset.end_date. |
None
|
extend
|
bool
|
If True, the signal is extended to the start_date and end_date timerange. Default: False. |
False
|
upsample_interval
|
Timedelta
|
Interval for upsampling the signal. Default: None. |
None
|
upsample_offset
|
Timedelta
|
Offset for upsampling the signal. Default: 10% of interval. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with the algorithm results. |
get_asset_details()
Gets the asset details of the Asset.
Returns:
| Type | Description |
|---|---|
AssetDetails
|
AssetDetails object with the asset details. |
get_asset_property(key)
Get asset property identified by the provided key parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Key identifying the asset property |
required |
Returns:
| Type | Description |
|---|---|
AssetProperty
|
AssetProperty object. Empty if property not found. |
get_bearing_frequencies(bearing_data_config=None)
Gets the BearingFrequencyData object for the asset.
It uses the asset properties to get the bearing manufacturer and model. Then it reads the bearing frequencies from the asset data reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bearing_data_config
|
Optional[Sequence[BearingConfigDataType]]
|
List of tuples with (side, manufacturer_key, model_key). If None, the default mapping from the Config is used. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, BearingFreqData]
|
Dictionary with bearing frequencies for asset's bearings. |
get_condition_indices(start_date=None, end_date=None, condition_indices_mapping=None)
Gets the condition indices results for the asset.
Condition indices is a subset of algorithms. This subset is defined by the mapping parameter. By default, mapping comes from the Config.condition_indices_mapping.
If dates are not provided, the asset start_date and end_date are used.
Results are returned as a ConditionIndicesResults object. It allows to easily filter and get the desired results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
Optional[datetime]
|
Start date of the results. If None, we use the asset.start_date. |
None
|
end_date
|
Optional[datetime]
|
End date of the results. If None, we use the asset.end_date. |
None
|
condition_indices_mapping
|
Optional[Sequence[ConditionIndicesMappingType]]
|
List of tuples with (model_type, symbolic_name, signal_type, algorithm_name). If None, the default mapping from the Config is used. |
None
|
Returns:
| Type | Description |
|---|---|
ConditionIndicesResults
|
ConditionIndicesResults object with the results. |
get_measurements(mode='latest', start_date=None, end_date=None, **kwargs)
Gets a list of JobMeasurements related to this asset, created in the time range defined by start_date and end_date.
If time range is not provided then the default asset time range is used.
Based on the provided mode, the measurements are filtered:
- "first": The first found measurement.
- "latest": The latest found measurement.
- "sample": Evenly spaced n samples in the time range.
You need to provide the sample parameter with the number of samples.
- "all": All measurements in the time range.
Additionally, you can provide timestamp as a mode input, and it will return only the single measurement
if it exists at that timestamp (with the tolerance of 1 min).
Finally, the sensor_codes, can be provided to filter the raw data files by the sensor code. Known sensor codes are: - "msr4m" - MACHsense-R - "ss4m" - SmartSensor Gen1 - "sssp" - SmartSensor Standard Performance - "sshp" - SmartSensor High Perfomance - "sshh" - SmartSensor Handheld
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
MeasurementModes
|
Information about which measurements to provide. One of "first", "latest", "sample", "all". |
'latest'
|
start_date
|
Optional[datetime]
|
Start date of the time range. |
None
|
end_date
|
Optional[datetime]
|
End date of the time range. |
None
|
Keyword Args:
sensor_prefixes (Sequence[str]): List of sensor prefixes to filter the measurements by.
include_nominal_parameters (bool): If True, nominal parameters will be added to the measurements.
Returns:
| Type | Description |
|---|---|
List[RawDataMeasurement]
|
List of JobMeasurement objects. |
get_nominal_parameters()
Gets a data model with nominal parameters. It can be used to extend raw measurements with extra data.
Returns:
| Type | Description |
|---|---|
NominalParameters
|
NominalParameters data model. |
get_sensor_details()
Gets the sensor details of the Asset.
Returns:
| Type | Description |
|---|---|
SensorDetails
|
SensorDetails object with the sensor details. |
get_threshold(symbolic_name)
Gets the threshold data for the given symbolic name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic_name
|
str
|
Symbolic name of the threshold |
required |
Returns:
| Type | Description |
|---|---|
Threshold
|
Threshold object. Empty if threshold not found. |
get_trend(symbolic_name, start_date=None, end_date=None, extend=False, upsample_interval=None, upsample_offset=None)
Gets the trend data for the given symbolic name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic_name
|
str
|
Symbolic name of the timeseries |
required |
start_date
|
Optional[datetime]
|
Start date of the trend. If None, the asset start_date is used. |
None
|
end_date
|
Optional[datetime]
|
End date of the trend. If None, the asset end_date is used. |
None
|
extend
|
bool
|
If True, the signal is extended to the start_date and end_date timerange. Default: False. |
False
|
upsample_interval
|
Timedelta
|
Interval for upsampling the signal. Default: None. |
None
|
upsample_offset
|
Timedelta
|
Offset for upsampling the signal. Default: 10% of interval. |
None
|
Returns:
| Type | Description |
|---|---|
Trend
|
Trend object. Empty if trend not found. |
is_algorithm_supported(algorithm_name)
Checks if the algorithm is supported by the asset. It checks if the algorithm is present in the algorithms overview of the asset. Args: algorithm_name: Name of the algorithm to check Returns: True if the algorithm is supported, False otherwise.
prefetch_data(symbolic_names, algorithm_names, start_date=None, end_date=None, **kwargs)
Prefetches asset data using AssetDataReader methods for prefetching.
Depending on the AssetDataReader implementation, it can be speed up the data retrieval process, by fetching the data in advance and storing it in the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic_names
|
Sequence[str]
|
List of symbolic names to prefetch |
required |
algorithm_names
|
Sequence[str]
|
List of algorithm names to prefetch |
required |
start_date
|
Optional[datetime]
|
Start date of the prefetch time range. If None, the asset start_date is used. |
None
|
end_date
|
Optional[datetime]
|
End date of the prefetch time range. If None, the asset end_date is used. |
None
|
set_dates(start_date, end_date)
Set the dates for the asset object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
datetime
|
Start date of the asset |
required |
end_date
|
datetime
|
End date of the asset |
required |
smartreport.v3.models.asset.asset.MotorAsset
smartreport.v3.models.asset.asset.GenericMachineAsset
Bases: Asset
smartreport.v3.models.asset.asset.DriveAsset
Bases: Asset