MariTEAM Analytics Tools (Mastin)¶
Authentification¶
Login management
-
mastin.login.
authentificate
(username, password)¶ Login to MariTEAM Indecol Web service.
- Parameters
username (str) – email of the user
password (str) – user password
- Returns
True on success.
- Return type
bool
Code example¶
Authenticate user
1 2 3 | from mastin import login
login.authentificate('user@email.my', 'password')
|
Ships¶
Ship module to create new Ship object and to load, save and delete ships from remote server.
The uniqueness of ship is represented by the ‘MMSI’ (Maritime Mobile Service Identity) field. There are two types of ships. The ship which already exists in data store and are compiled form SeaWeb. For these the ‘MMSI’ is real ship MMSI. Second type is artificial ship created by user. This user ships will start with 9 followed by 8 digits.
In order to be able to work with Mastin cloud services the MMSI is randomly generated and the user must not change the MMSI by no means. In most cases the ship will not be validated and such a ship will not be able to save in remote database neither run any analytics.
You can read more about Maritime MMSI at https://en.wikipedia.org/wiki/Maritime_Mobile_Service_Identity
-
mastin.ships.
create_empty_ship
()¶ Create ship with only mmsi predefined. All other fields are set to None.
- Returns
- Return type
-
mastin.ships.
create_ship
(**kwargs)¶ Create ship with specified parameters.
It is not possible to specify mmsi since this must be unique number. Please do not modify the mmsi field it can have bad consequences when trying to save it to database.
- Parameters
kwargs – Any of the following attributes of
Ship
inmastin.models.ship
can be specified. Only mmsi will be autogenerated.- Returns
Ship object with specified fields. Omitted fields will be set to None. The mmsi will be generated randomly as negative integer.
- Return type
-
mastin.ships.
create_standard_ship
(ship_type)¶ Create standard ship per segment (ship type) with all values to be calculated as median.
-
mastin.ships.
delete
(mmsi)¶ Delete ship from database.
- Parameters
mmsi (int) – The mmsi of the ship.
- Returns
- Return type
MMSI of deleted ship
- Raises
RuntimeError – if ship can not be saved. With server respond to error message.
-
mastin.ships.
get_ship
(mmsi)¶ Get ship from database.
- Parameters
mmsi (int) – mmsi of the ship
- Returns
ship
- Return type
- Raises
RuntimeError – If ship with specified mmsi can not be retrieved from server.
-
mastin.ships.
save
(ship)¶ Save ship to database.
- Parameters
ship (Ship) –
- Returns
- Return type
MMSI of saved ship.
- Raises
RuntimeError – if ship can not be saved. With server respond to error message.
Code example¶
Show Ship model schema
1 2 3 | from mastin.ships import Ship
dict(Ship.schema())
|
Create empty ship The MMSI is autogenerated and must not be changed
1 2 3 4 5 6 7 8 | from mastin import ships
ship = ships.create_empty_ship()
# Modify ship's parameters
ship.length = 120
ship.ship_type = 'container'
# print ship object
ship
|
Ship Model¶
-
class
mastin.models.ship.
Ship
(**data)¶ Representation of Ship
- Parameters
mmsi (int) – MMSI of ship.
imo_number (int) – IMO of ship.
name (str) – Name of ship.
aux_engine_kw (int) – Auxiliary engine power in kW.
aux_engine_stroke (int) – Number of strokes of auxiliary engine.
breadth (int) – Ship breadth.
built (str) – Year the ship was build in format ‘YYYY-MM’.
draught (float) – Ship draught.
dwt (int) – Ship deadweight tonnage.
fuel_type (str) – Ship fuel type.
gross (int) – TODO
ldt (int) – Ship light displacement.
length (float) – Ship length.
length_bp (float) – Ship length between perpendiculars.
main_engine_cyl (int) – Number of main engine cylinders.
main_engine_kw (int) – Main engine power in kW.
main_engine_model (str) – Main engine model
main_engine_rpm (int) – Main engine rotation per minute.
main_engine_stroke (int) – Number of main engine strokes.
propulsion (str) – TODO
reefer_points (int) – TODO
service_speed (int) – Ship service speed.
ship_type (ShipType) – Ship type.
ship_type_detailed (str) – Ship type in detail.
teu (int) – Ship twenty-foot equivalent unit.
filler (str) – Filler information.
note (str) – User note for.
-
class
mastin.models.ship.
ShipType
¶ Supported ship types.
-
other_offshore
¶ - Type
‘other offshore’,
-
offshore_supply
¶ - Type
‘offshore supply’,
-
passenger
¶ - Type
‘passenger’,
-
oil
¶ - Type
‘oil’,
-
general_cargo
¶ - Type
‘general cargo’,
-
other_cargo
¶ - Type
‘other cargo’,
-
other_bulk
¶ - Type
‘other bulk’,
-
refrigerated_cargo
¶ - Type
‘refrigerated cargo’,
-
other_liquids
¶ - Type
‘other liquids’,
-
bulk_dry
¶ - Type
‘bulk dry’,
-
liquefied_gas
¶ - Type
‘liquefied gas’,
-
ro_ro
¶ - Type
‘ro-ro’,
-
chemical
¶ - Type
‘chemical’,
-
container
¶ - Type
‘container’
-
Operational Profiles¶
Manage Operational profiles (OPs).
Operational Profile is TODO
Each Operational Profile must have MMSI which correspond to operational_profile MMSI. However there can be multiple OPs with same MMSI so the user can modify some fields for different use cases.
The OP is stored with metadata and the file itself.
-
mastin.operational_profiles.
create_operational_profile
(file, mmsi, note='')¶ Create Operational Profile.
- Parameters
mmsi (int) – MMSI of the shipt the OP belongs to
file (str) – path to the file
note (str) – Usr note. default to empty string ‘’
- Returns
MMSI fo the Operational profile
- Return type
int
-
mastin.operational_profiles.
download_operational_profile
(id)¶ Download OperationalProfile as json file from database.
- Parameters
id (int) – id of the OperationalProfile
- Returns
filename
- Return type
name of the downloaded file
- Raises
RuntimeError – If operational_profile with specified id can not be retrieved from server.
-
mastin.operational_profiles.
get_operational_profile
(mmsi)¶ Get list of operational profiles with same mmsi from database.
- Parameters
mmsi (int) – mmsi of the operational_profiles
- Returns
operational_profiles
- Return type
List[OperationalProfile]
- Raises
RuntimeError – If operational_profile with specified mmsi can not be retrieved from server.
-
mastin.operational_profiles.
inspect_operational_profile
(id, records=5)¶ Inspect Operational profile.
- Parameters
id (int) – id of the
OperationalProfile
records (int) – How many records of the data to show. Default 5
- Returns
list of dict records
- Return type
list[dict]
- Raises
RuntimeError – If operational_profile with specified id can not be retrieved from server.
Operational Profile Model¶
-
class
mastin.models.operational_profile.
OperationalProfile
(**data)¶ Model of OperationalProfile
- Parameters
id (int) – Id of the OP
mmsi (int) – MMSI of ship the OP belongs to
created (int) – Time the file was uploaded.
origin (str) – User name who uploaded the file.
note (str) – Arbitrary user description.
filename (str) – Name of the original file.
file_content_type (str) – Media content of the original file