halem package¶
Submodules¶
halem.functions module¶
- halem.functions.HALEM_co2(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the least pollutant route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.functions.HALEM_cost(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the cheapest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.functions.HALEM_func(start, stop, t0, vmax, Roadmap, costfunction)[source]¶
Base of the functions HALEM_time, HALEM_cost, HALEM_space, HALEM_co2. This function takes the pre-processing file, start location, stop location, departure time, and sailing velocity and returns the optimized route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties. costfunction Costfunction of the route optimization.
Roadmap.weight_time returns fastest route Roadmap.weight_space returns shortest route Roadmap.weight_cost returns cheapest route Roadmap.weight_co2 retruns least pollutant route
- halem.functions.HALEM_space(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the shortest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.functions.HALEM_time(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the fastest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.functions.costfunction_spaceseries(edge, V_max, WD_min, flow, WVPI, L, tria)[source]¶
Function that returns the time series of the weights of a specifiv edge.
- edge: (int) cosidered edge. edge: index of the location node
in Roadmap.nodes
V_max: Shipping velocity in deep water in meters per second WD_min: minimal needed draft in meters flow: Class that contains the hydrodynamic conditions WVPI: Weight of the vessel in tf L: (int) number of neighbouring layers. tria: triangulation of the nodes (output of scipy.spatial.Delaunay(nodes)
- halem.functions.costfunction_timeseries(edge, V_max, WD_min, flow, WVPI, L, tria)[source]¶
Function that returns the time series of the weights of a specific edge.
- edge: (int) cosidered edge. edge: index of the location node
in Roadmap.nodes
V_max: Shipping velocity in deep water in meters per second WD_min: minimal needed draft in meters flow: Class that contains the hydrodynamic conditions WVPI: Weight of the vessel in tf L: (int) number of neighbouring layers. tria: triangulation of the nodes (output of scipy.spatial.Delaunay(nodes)
- halem.functions.find_neighbors(pindex, triang)[source]¶
Function that can find the neighbours of a Delauney mesh.
pindex: Index of the considered node. triang: Triangulation generated with scipy.spatial.Delaunay()
- halem.functions.find_neighbors2(index, triang, depth)[source]¶
Function that can find the neighbours of a Delauney mesh, for multiple layers of neighbours.
pindex: Index of the considered node. triang: Triangulation generated with scipy.spatial.Delaunay() Depth: Number of neigbouring layers (nb)
- halem.functions.haversine(coord1, coord2)[source]¶
use the Haversine function to determine the distance between two points in the WGS84 coordinate system. Returns the distance between the two points in meters. Source: https://janakiev.com/blog/gps-points-distance-python/
coord1: (lat, lon) coordinates of first point coord2: (lat, lon) coordinates of second point
- halem.functions.inbetweenpoints(start, stop, LL, tria)[source]¶
This node returns the nodes of influence for a specific arc. This function retruns the start and stop node plus the nodes in between the start and stop node. This function makes sure the route does not jump over hydrodynamic features when the neightbouring layers are higher than one.
start: (int) index of the start node stop: (int) index of the destination node LL: (int) number of neighbouring layers. tria: triangulation of the nodes (output of scipy.spatial.Delaunay(nodes)
- halem.functions.plot_timeseries(path, time, Roadmap, Color='r', range_CP=5)[source]¶
This function can plot the time series for the route and shows a contourplot of the unsaiable areas of that route.
- path: lon, lat coordinates of the route.
This is in the format of the output from halem.HALEM_func[0]
- time: time series of the path.
This is in the format of the output from halem.HALEM_func[1]
Roadmap: Roadmap that is used to calculate the route. Color: Color of the plot of the time series.
Type sting, with matplotlib color
- halem.functions.squat(h, T, V_max, LWL, WWL, ukc, WVPI)[source]¶
Function for reducing the sailing velocity in deep water to the sailing velocity in shallow unconfined waters.
h: Array of the water depth in meters V_max: Sailing velocity in deep water in meters per second WWL: Width over Water Line of the vessel in meters LWL: Length over Water Line of the vessel in meters ukc: Minimal needed under keel clearance in meters. T: numpy array with the draft of the vessel. Numpy
array has the shape of the number of discretisations in the dynamic sailing velocity in meters
WVPI: total weight of the the vessel in tf
- V: Array of sailing velocities reduced for squat,
corresponding to the input arrat h.
halem.path_finder module¶
- class halem.path_finder.PathFinder(start, stop, Roadmap, t0, graph_functions)[source]¶
Bases:
object
This class contains the code for calculating the optimal route from the Roadmap
start: start location (lat, lon) stop: destination location (lat, lon) Roadmap: Preprocessing file graph_functions: class that selects the correct weights from the Roadmap.
halem.roadmap module¶
- class halem.roadmap.BaseRoadmap(number_of_neighbor_layers, vship, WD_min, WVPI, repeat=False, WWL=20, LWL=80, ukc=1.5, optimization_type=None, nodes_index=None, *args, **kwargs)[source]¶
Bases:
ABC
,NodeReduction
Absctract Base class for the Roadmap.
Pre-processing function for the HALEM optimizations. In this fucntion the hydrodynamic model and the vessel properties are transformed into weights for the Time dependend Dijkstra function.
- number_of_neighbor_layers: number of neigbouring layers for which edges are
created. increasing this number results in a higher directional resolution.
- vship: (N (rows) * M (columns)) numpy array that indicates the sailing velocity
in deep water. For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity. For the optimization type cost and co2 N must be larger or equal to 2.
- WD_min: numpy array with the draft of the vessel.
Numpy array has the shape of the number of discretisations in the dynamic sailing velocity
WVPI: Numpy array with the total weight of the vessel.
WWL: Width over Water Line of the vessel in meters
LWL: Length over Water Line of the vessel in meters
ukc: Minimal needed under keel clearance in meters.
- repeat: Indicator if the roadmap can be repeated (True / False)
True for hydrodynamic models based on a tidal analysis
- optimization_type: list of optimization types.
Excluding one or more not needed optimization types can significantly decrease the size of the preprocessing file
- nodes_index: Numpy array that contains the indices of the nodes of the reduced
hydrodynamic model. nodes_index is the output of Roadmap.nodes_index. This option allows you to skip the node reduction step if this is already done.
- calc_weights_time(edge, i, j, vship, WD_min, WVPI, self_f, compute_cost, compute_co2, number_of_neighbor_layers)[source]¶
Function that retruns the weight of an arc
- class halem.roadmap.Graph[source]¶
Bases:
object
class that contains the nodes, arcs, and weights for the time-dependent, directional, weighted, and Non-FIFO graph of the route optimization problem. This class is used multiple times in the halem.mesh_maker.GraphFlowModel() function
- class halem.roadmap.NodeReduction(dx_min, blend, nl, *args, **kwargs)[source]¶
Bases:
object
This class can reduce the number of gridpoints of the hydrodynamic model. This is done based on the vorticity and the magnitude of the flow. The nodes are pruned based on a length scale. The formula for this length scale is: LS / ∆min = α(1+|∇×u|)^−βc+(1−α)(1+|u|)^−βm. With: LS = resulting length scale, α = blend factor between the curl and the magnitude method, ∆min = minimal length scale, βc = non linearity parameter for the method with the curl of the flow, βm = non linearity parameter for the method with the magnitude of the flow, and u = the velocity vector of the flow.
- flow: class that contains the hydrodynamic properties.
class must have the following instances. u: numpy array with shape (N, M) v: numpy array with shape (N, M) WD: numpy array with shape (N, M) nodes: numpy array with shape (N, 2) (lat, lon) t: numpy array with shape M (seconds since 01-01-1970 00:00:00) tria: triangulation of the nodes (output of scipy.spatial.Delaunay) in which N is the number of nodes of the hydrodynamic model, and M is the number of time steps of the hydrodynamic model
- dx_min: float, minimal spatial resolution.
Parameter of the lengt scale function concerning the node reduction
- blend: blend factor between the verticity and magnitude of the flow.
Parameter of the lengt scale function concerning the node reduction
- nl: float (nl_c, nl_m)
Non linearity factor consisting out of two numbers nl_c non-linearity factor for the corticity, nl_m non-linearity factor for the magnitude of the flow. Parameter of the lengt scale function concerning the node reduction
- number_of_neighbor_layers: number of neigbouring layers for which edges are
created. increasing this number results in a higher directional resolution.
Module contents¶
- class halem.BaseRoadmap(number_of_neighbor_layers, vship, WD_min, WVPI, repeat=False, WWL=20, LWL=80, ukc=1.5, optimization_type=None, nodes_index=None, *args, **kwargs)[source]¶
Bases:
ABC
,NodeReduction
Absctract Base class for the Roadmap.
Pre-processing function for the HALEM optimizations. In this fucntion the hydrodynamic model and the vessel properties are transformed into weights for the Time dependend Dijkstra function.
- number_of_neighbor_layers: number of neigbouring layers for which edges are
created. increasing this number results in a higher directional resolution.
- vship: (N (rows) * M (columns)) numpy array that indicates the sailing velocity
in deep water. For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity. For the optimization type cost and co2 N must be larger or equal to 2.
- WD_min: numpy array with the draft of the vessel.
Numpy array has the shape of the number of discretisations in the dynamic sailing velocity
WVPI: Numpy array with the total weight of the vessel.
WWL: Width over Water Line of the vessel in meters
LWL: Length over Water Line of the vessel in meters
ukc: Minimal needed under keel clearance in meters.
- repeat: Indicator if the roadmap can be repeated (True / False)
True for hydrodynamic models based on a tidal analysis
- optimization_type: list of optimization types.
Excluding one or more not needed optimization types can significantly decrease the size of the preprocessing file
- nodes_index: Numpy array that contains the indices of the nodes of the reduced
hydrodynamic model. nodes_index is the output of Roadmap.nodes_index. This option allows you to skip the node reduction step if this is already done.
- calc_weights_time(edge, i, j, vship, WD_min, WVPI, self_f, compute_cost, compute_co2, number_of_neighbor_layers)[source]¶
Function that retruns the weight of an arc
- halem.HALEM_co2(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the least pollutant route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.HALEM_cost(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the cheapest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.HALEM_func(start, stop, t0, vmax, Roadmap, costfunction)[source]¶
Base of the functions HALEM_time, HALEM_cost, HALEM_space, HALEM_co2. This function takes the pre-processing file, start location, stop location, departure time, and sailing velocity and returns the optimized route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties. costfunction Costfunction of the route optimization.
Roadmap.weight_time returns fastest route Roadmap.weight_space returns shortest route Roadmap.weight_cost returns cheapest route Roadmap.weight_co2 retruns least pollutant route
- halem.HALEM_space(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the shortest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.HALEM_time(start, stop, t0, vmax, Roadmap)[source]¶
Implementation of the function HALEM_func() for the fastest route.
start: (lon, lat) coordinates of the start location stop: (lon, lat) coordinates of the destination location t0: string that indcates the departure time
(‘day’/’month’/’year’ ‘hour’:’minute’:’seconds’)
vmax: (N (rows) * M (columns)) numpy array that indicates the sailing velocity in deep water.
For which N is the number of discretisations in the load factor, and M is the number of discretisations in the dynamic sailing velocity
For the optimization type cost and co2 N must be larger or equal to 2.
Roadmap: Preprocessing file that contains the hydrodynamic properties.
- halem.plot_timeseries(path, time, Roadmap, Color='r', range_CP=5)[source]¶
This function can plot the time series for the route and shows a contourplot of the unsaiable areas of that route.
- path: lon, lat coordinates of the route.
This is in the format of the output from halem.HALEM_func[0]
- time: time series of the path.
This is in the format of the output from halem.HALEM_func[1]
Roadmap: Roadmap that is used to calculate the route. Color: Color of the plot of the time series.
Type sting, with matplotlib color