sailor.assetcentral.model
Retrieve Model information from AssetCentral.
Classes are provided for individual Models as well as groups of Models (ModelSet). Models can be of type Equipment, System or FunctionalLocation, but the type is not part of the AC response currently.
- class sailor.assetcentral.model.Model(ac_json)[source]
Bases:
AssetcentralEntity
AssetCentral Model object.
- Parameters
ac_json (dict) –
- find_equipment(*, extended_filters=(), **kwargs)[source]
Get a list of equipment derived from this Model.
- Parameters
extended_filters – See Filter Language.
**kwargs – See Filter Language.
- Return type
Example
Find all Equipment for Model ‘myModelName’. Return an EquipmentSet:
model = find_models(name='myModelName') model[0].find_equipment()
The resulting Equipments can further be filter based on their properties (name, location etc).
- find_model_indicators(*, extended_filters=(), **kwargs)[source]
Return all Indicators assigned to the Model.
- Parameters
extended_filters – See Filter Language.
**kwargs – See Filter Language.
- Return type
Example
Find all indicators for Model ‘myModelName’:
models = find_models(name='myModelName') models[0].find_model_indicators()
- classmethod get_available_properties()
Return the available properties for this class.
- property id
Return the ID of the object.
- class sailor.assetcentral.model.ModelSet(elements)[source]
Bases:
AssetcentralEntitySet
Class representing a group of Models.
- as_df(columns=None)
Return all information on the objects stored in the MasterDataEntitySet as a pandas dataframe.
columns
can be specified to select the columns (and their order) for the DataFrame.- Parameters
columns (Optional[Iterable[str]]) –
- filter(**kwargs)
Select a subset of the collection based on named filter criteria for the attributes of the elements.
All keyword arguments are concatenated as filters with OR operator, i.e., only one of the supplied filters must match for an entity to be selected.
Returns a new AssetcentralEntitySet object.
- Return type
MasterDataEntitySet
- plot_distribution(by=None, fill=None, dropna=False)
Plot the distribution of elements of a MasterDataEntitySet based on their properties.
This effectively creates a histogram with the number of elements per group on the y-axis, and the group (given by the by parameter) on the x-axis. Additionally, the fill colour of the bar can be used to distinguish a second dimension.
- sailor.assetcentral.model.find_models(*, extended_filters=(), **kwargs)[source]
Fetch Models from AssetCentral with the applied filters, return an ModelSet.
This method supports the usual filter criteria, i.e. Any named keyword arguments applied as equality filters, i.e. the name of the Model property is checked against the value of the keyword argument. If the value of the keyword argument is an iterable (e.g. a list) then all objects matching any of the values in the iterable are returned.
- Parameters
extended_filters – See Filter Language.
**kwargs – See Filter Language.
- Return type
Examples
Find all Models with name ‘MyModel’:
find_models(name='MyModel')
Find all Models which either have the name ‘MyModel’ or the name ‘MyOtherModel’:
find_models(name=['MyModel', 'MyOtherModel'])
If multiple named arguments are provided then all conditions have to match.
Example
Find all Models with name ‘MyModel’ which also have the short description ‘Description’:
find_models(name='MyModel', short_description='Description')
The
extended_filters
parameter can be used to specify filters that can not be expressed as an equality. Each extended_filter needs to be provided as a string, multiple filters can be passed as a list of strings. As above, all filter criteria need to match. Extended filters can be freely combined with named arguments. Here, too, all filter criteria need to match for an Model to be returned.Example
Find all Models with an expiration date before January 1, 2018:
find_models(extended_filters=['model_expiration_date < "2018-01-01"'])