WeatherRoutingTool.ship package
Submodules
WeatherRoutingTool.ship.ship module
- class WeatherRoutingTool.ship.ship.Boat(ship_config: ShipConfig)[source]
Bases:
objectBase 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.
- 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_pathand interpolates (nearest) the required variables to the provided coordinates and times. The populated fields onship_paramsinclude 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_paramsinstance populated with weather fields.- Return type:
- 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:
- get_weather_data()[source]
Return the lazily opened weather dataset.
The NetCDF data file referenced by
self.weather_pathis 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:
WeatherRoutingTool.ship.ship_factory module
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
- fuel_rate: Quantity
- fuel_type: str
- get_reduced_2D_object(row_start=None, row_end=None, col_start=None, col_end=None, idxs=None)[source]
- message: ndarray
- power: Quantity
- pressure: Quantity
- r_calm: Quantity
- r_roughness: Quantity
- r_shallow: Quantity
- r_waves: Quantity
- r_wind: Quantity
- rpm: Quantity
- salinity: Quantity
- 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