WeatherRoutingTool.ship package

Submodules

WeatherRoutingTool.ship.ship module

class WeatherRoutingTool.ship.ship.Boat(ship_config: ShipConfig)[source]

Bases: object

Base class representing a vessel used by the Weather Routing Tool.

  • Sub-classes (for example MariPowerTanker, DirectPowerBoat or SailingBoat) implement

    vessel-specific power and fuel estimation methods. This class provides shared functionality used by all boat types such as keeping basic ship parameters (draught, under-keel clearance), handling weather data access and helper methods for extracting weather fields from a NetCDF file.

  • Sub-classes should implement vessel-specific behaviour by overriding

    get_ship_parameters. Individual methods are documented on the method itself.

Parameters:
  • weather_path (str) – Path to the NetCDF file that contains weather/oceanographic variables.

  • under_keel_clearance (astropy.units.Quantity) – Minimum clearance below the hull as defined in the ship configuration.

  • draught_aft (astropy.units.Quantity) – Aft draught read from the ship configuration.

  • draught_fore (astropy.units.Quantity) – Fore draught read from the ship configuration.

  • time_min_max (list) – Cached min/max time values available in the weather file.

  • lat_min_max (list) – Cached min/max latitude values available in the weather file.

  • lon_min_max (list) – Cached min/max longitude values available in the weather file.

approx_weather(var, lats, lons, time, height=None, depth=None)[source]
check_data_meaningful()[source]

This is an optional method to check if default boat variables have been changed into meaningful values. It can be implemented in Child classes.

evaluate_weather(ship_params, lats, lons, time)[source]

Populate weather-related fields of a ShipParams object.

This method reads the NetCDF file referenced by self.weather_path and interpolates (nearest) the required variables to the provided coordinates and times. The populated fields on ship_params include wave height, wave period, wave direction, wind and current components, pressure, temperatures and salinity.

Parameters:
  • ship_params (ShipParams) – ShipParams instance to populate.

  • lats (array-like) – latitudes for the lookups.

  • lons (array-like) – longitudes for the lookups.

  • time (array-like) – times for the lookups (array-like, datetime-like objects).

Returns:

the same ship_params instance populated with weather fields.

Return type:

ShipParams

get_required_water_depth()[source]

Return required water depth in metres.

The required water depth is computed as the maximum of fore and aft draught plus the under-keel clearance.

Returns:

required water depth in metres (float)

Return type:

float

get_ship_parameters(courses, lats, lons, time, speed, unique_coords=False)[source]

Return ShipParams for the requested positions and times.

Sub-classes must override this method to provide vessel-specific power, RPM and fuel estimations.

Parameters:
  • courses (array-like) – course angles for each routing segment (radians or degrees depending on caller conventions).

  • lats (array-like) – latitudes of start points for each routing segment.

  • lons (array-like) – longitudes of start points for each routing segment.

  • time (array-like) – start times for each routing segment (array of datetimes).

  • speed (array-like) – speeds to evaluate at (one per segment).

  • unique_coords (bool) – if True, the implementation may assume coordinates are unique and optimise lookups accordingly.

Returns:

a ShipParams instance populated for each requested segment.

Return type:

ShipParams

get_weather_data()[source]

Return the lazily opened weather dataset.

The NetCDF data file referenced by self.weather_path is opened once and then reused across subsequent weather lookups to avoid repeatedly reopening the same dataset. The data is loaded into memory on first access so repeated selections do not keep hitting disk.

Returns:

xarray dataset containing the weather fields used by the vessel.

Return type:

xarray.Dataset

load_data()[source]

Optional hook to (re)load vessel-specific data.

Child classes may implement this to load auxiliary data (e.g. lookup tables) required for power/fuel computations.

print_init()[source]

Log basic boat initialisation information.

Implementations should use the project’s logging/formatting helpers to print relevant initialisation values (e.g. fuel rate or geometry).

weather_path: str
class WeatherRoutingTool.ship.ship.ConstantFuelBoat(ship_config: ShipConfig)[source]

Bases: Boat

fuel_rate: float
get_ship_parameters(courses, lats, lons, time, speed, unique_coords=False)[source]

Return ShipParams for the requested positions and times.

Sub-classes must override this method to provide vessel-specific power, RPM and fuel estimations.

Parameters:
  • courses (array-like) – course angles for each routing segment (radians or degrees depending on caller conventions).

  • lats (array-like) – latitudes of start points for each routing segment.

  • lons (array-like) – longitudes of start points for each routing segment.

  • time (array-like) – start times for each routing segment (array of datetimes).

  • speed (array-like) – speeds to evaluate at (one per segment).

  • unique_coords (bool) – if True, the implementation may assume coordinates are unique and optimise lookups accordingly.

Returns:

a ShipParams instance populated for each requested segment.

Return type:

ShipParams

print_init()[source]

Log basic boat initialisation information.

Implementations should use the project’s logging/formatting helpers to print relevant initialisation values (e.g. fuel rate or geometry).

WeatherRoutingTool.ship.ship_factory module

class WeatherRoutingTool.ship.ship_factory.ShipFactory[source]

Bases: object

static get_ship(boat_type: str, ship_config)[source]

WeatherRoutingTool.ship.shipparams module

class WeatherRoutingTool.ship.shipparams.ShipParams(fuel_rate, power, rpm, speed, r_calm, r_wind, r_waves, r_shallow, r_roughness, wave_height, wave_direction, wave_period, u_currents, v_currents, u_wind_speed, v_wind_speed, pressure, air_temperature, salinity, water_temperature, status, message)[source]

Bases: object

air_temperature: Quantity
define_courses(courses_segments)[source]
expand_axis_for_intermediate()[source]
flip()[source]
fuel_rate: Quantity
fuel_type: str
get_air_temperature()[source]
get_element(idx)[source]
get_fuel_rate()[source]
get_fuel_type()[source]
get_message()[source]
get_power()[source]
get_pressure()[source]
get_rcalm()[source]
get_reduced_2D_object(row_start=None, row_end=None, col_start=None, col_end=None, idxs=None)[source]
get_rpm()[source]
get_rroughness()[source]
get_rshallow()[source]
get_rwaves()[source]
get_rwind()[source]
get_salinity()[source]
get_single_object(idx)[source]
get_speed()[source]
get_status()[source]
get_u_currents()[source]
get_u_wind_speed()[source]
get_v_currents()[source]
get_v_wind_speed()[source]
get_water_temperature()[source]
get_wave_direction()[source]
get_wave_height()[source]
get_wave_period()[source]
message: ndarray
power: Quantity
pressure: Quantity
print()[source]
print_shape()[source]
r_calm: Quantity
r_roughness: Quantity
r_shallow: Quantity
r_waves: Quantity
r_wind: Quantity
rpm: Quantity
salinity: Quantity
select(idxs)[source]
set_air_temperature(new_air_temperature)[source]
classmethod set_default_array()[source]
classmethod set_default_array_1D(ncoorinate_points)[source]
set_fuel_rate(new_fuel)[source]
set_message(new_message)[source]
set_power(new_power)[source]
set_pressure(new_pressure)[source]
set_rcalm(new_rcalm)[source]
set_rpm(new_rpm)[source]
set_rroughness(new_rroughnes)[source]
set_rshallow(new_rshallow)[source]
set_rwaves(new_rwaves)[source]
set_rwind(new_rwind)[source]
set_salinity(new_salinity)[source]
set_speed(new_speed)[source]
set_status(new_status)[source]
set_u_currents(new_u_currents)[source]
set_u_wind_speed(new_u_wind_speed)[source]
set_v_currents(new_v_currents)[source]
set_v_wind_speed(new_v_wind_speed)[source]
set_water_temperature(new_water_temperature)[source]
set_wave_direction(new_wave_direction)[source]
set_wave_height(new_wave_height)[source]
set_wave_period(new_wave_period)[source]
speed: Quantity
status: array
u_currents: Quantity
u_wind_speed: Quantity
v_currents: Quantity
v_wind_speed: Quantity
water_temperature: Quantity
wave_direction: Quantity
wave_height: Quantity
wave_period: Quantity

Module contents