From 7fde39195a66a098b54e06e5e4e0f327b9dc9fc1 Mon Sep 17 00:00:00 2001 From: Martin Pontius Date: Tue, 26 Mar 2024 14:53:06 +0100 Subject: [PATCH] Add environmental data to shipparams and write them to geojson --- WeatherRoutingTool/algorithms/isobased.py | 32 +++ WeatherRoutingTool/routeparams.py | 75 +++++- WeatherRoutingTool/ship/ship.py | 33 +++ WeatherRoutingTool/ship/shipparams.py | 274 +++++++++++++++++++++- 4 files changed, 408 insertions(+), 6 deletions(-) diff --git a/WeatherRoutingTool/algorithms/isobased.py b/WeatherRoutingTool/algorithms/isobased.py index 01508cf..70a59b1 100644 --- a/WeatherRoutingTool/algorithms/isobased.py +++ b/WeatherRoutingTool/algorithms/isobased.py @@ -616,6 +616,27 @@ def update_shipparams(self, ship_params_single_step): new_rshallow = np.vstack((ship_params_single_step.get_rshallow(), self.shipparams_per_step.get_rshallow())) new_rroughness = np.vstack( (ship_params_single_step.get_rroughness(), self.shipparams_per_step.get_rroughness())) + new_wave_height = np.vstack((ship_params_single_step.get_wave_height(), + self.shipparams_per_step.get_wave_height())) + new_wave_direction = np.vstack((ship_params_single_step.get_wave_direction(), + self.shipparams_per_step.get_wave_direction())) + new_wave_period = np.vstack((ship_params_single_step.get_wave_period(), + self.shipparams_per_step.get_wave_period())) + new_u_currents = np.vstack((ship_params_single_step.get_u_currents(), + self.shipparams_per_step.get_u_currents())) + new_v_currents = np.vstack((ship_params_single_step.get_v_currents(), + self.shipparams_per_step.get_v_currents())) + new_u_wind_speed = np.vstack((ship_params_single_step.get_u_wind_speed(), + self.shipparams_per_step.get_u_wind_speed())) + new_v_wind_speed = np.vstack((ship_params_single_step.get_v_wind_speed(), + self.shipparams_per_step.get_v_wind_speed())) + new_pressure = np.vstack((ship_params_single_step.get_pressure(), self.shipparams_per_step.get_pressure())) + new_air_temperature = np.vstack((ship_params_single_step.get_air_temperature(), + self.shipparams_per_step.get_air_temperature())) + new_salinity = np.vstack((ship_params_single_step.get_salinity(), + self.shipparams_per_step.get_salinity())) + new_water_temperature = np.vstack((ship_params_single_step.get_water_temperature(), + self.shipparams_per_step.get_water_temperature())) new_status = np.vstack((ship_params_single_step.get_status(), self.shipparams_per_step.get_status())) self.shipparams_per_step.set_rpm(new_rpm) @@ -626,6 +647,17 @@ def update_shipparams(self, ship_params_single_step): self.shipparams_per_step.set_rwaves(new_rwaves) self.shipparams_per_step.set_rshallow(new_rshallow) self.shipparams_per_step.set_rroughness(new_rroughness) + self.shipparams_per_step.set_wave_height(new_wave_height) + self.shipparams_per_step.set_wave_direction(new_wave_direction) + self.shipparams_per_step.set_wave_period(new_wave_period) + self.shipparams_per_step.set_u_currents(new_u_currents) + self.shipparams_per_step.set_v_currents(new_v_currents) + self.shipparams_per_step.set_u_wind_speed(new_u_wind_speed) + self.shipparams_per_step.set_v_wind_speed(new_v_wind_speed) + self.shipparams_per_step.set_pressure(new_pressure) + self.shipparams_per_step.set_air_temperature(new_air_temperature) + self.shipparams_per_step.set_salinity(new_salinity) + self.shipparams_per_step.set_water_temperature(new_water_temperature) self.shipparams_per_step.set_status(new_status) def check_course_def(self): diff --git a/WeatherRoutingTool/routeparams.py b/WeatherRoutingTool/routeparams.py index 37f8cd1..e07fd2b 100644 --- a/WeatherRoutingTool/routeparams.py +++ b/WeatherRoutingTool/routeparams.py @@ -146,6 +146,17 @@ def return_route_to_API(self, filename): properties['wave_resistance'] = {'value': -99, 'unit': 'N'} properties['shallow_water_resistance'] = {'value': -99, 'unit': 'N'} properties['hull_roughness_resistance'] = {'value': -99, 'unit': 'N'} + properties['wave_height'] = {'value': -99, 'unit': 'm'} + properties['wave_direction'] = {'value': -99, 'unit': 'radian'} + properties['wave_period'] = {'value': -99, 'unit': 's'} + properties['u_currents'] = {'value': -99, 'unit': 'm/s'} + properties['v_currents'] = {'value': -99, 'unit': 'm/s'} + properties['u_wind_speed'] = {'value': -99, 'unit': 'm/s'} + properties['v_wind_speed'] = {'value': -99, 'unit': 'm/s'} + properties['pressure'] = {'value': -99, 'unit': 'Pa'} + properties['air_temperature'] = {'value': -99, 'unit': '°C'} + properties['salinity'] = {'value': -99, 'unit': '-'} + properties['water_temperature'] = {'value': -99, 'unit': '°C'} properties['status'] = {'value': -99} else: properties['speed'] = {'value': self.ship_params_per_step.speed[i].value, 'unit': 'm/s'} @@ -159,12 +170,24 @@ def return_route_to_API(self, filename): properties['calm_resistance'] = {'value': self.ship_params_per_step.r_calm[i].value, 'unit': 'N'} properties['wind_resistance'] = {'value': self.ship_params_per_step.r_wind[i].value, 'unit': 'N'} properties['wave_resistance'] = {'value': self.ship_params_per_step.r_waves[i].value, 'unit': 'N'} - properties['shallow_water_resistance'] = { - 'value': self.ship_params_per_step.r_shallow[i].value, - 'unit': 'N' - } + properties['shallow_water_resistance'] = {'value': self.ship_params_per_step.r_shallow[i].value, + 'unit': 'N'} properties['hull_roughness_resistance'] = {'value': self.ship_params_per_step.r_roughness[i].value, 'unit': 'N'} + properties['wave_height'] = {'value': self.ship_params_per_step.wave_height[i].value, 'unit': 'm'} + properties['wave_direction'] = {'value': self.ship_params_per_step.wave_direction[i].value, + 'unit': 'radian'} + properties['wave_period'] = {'value': self.ship_params_per_step.wave_period[i].value, 'unit': 's'} + properties['u_currents'] = {'value': self.ship_params_per_step.u_currents[i].value, 'unit': 'm/s'} + properties['v_currents'] = {'value': self.ship_params_per_step.v_currents[i].value, 'unit': 'm/s'} + properties['u_wind_speed'] = {'value': self.ship_params_per_step.u_wind_speed[i].value, 'unit': 'm/s'} + properties['v_wind_speed'] = {'value': self.ship_params_per_step.v_wind_speed[i].value, 'unit': 'm/s'} + properties['pressure'] = {'value': self.ship_params_per_step.pressure[i].value, 'unit': 'Pa'} + properties['air_temperature'] = {'value': self.ship_params_per_step.air_temperature[i].value, + 'unit': '°C'} + properties['salinity'] = {'value': self.ship_params_per_step.salinity[i].value, 'unit': '-'} + properties['water_temperature'] = {'value': self.ship_params_per_step.water_temperature[i].value, + 'unit': '°C'} properties['status'] = {'value': self.ship_params_per_step.status[i]} feature['type'] = 'Feature' @@ -201,6 +224,17 @@ def from_file(cls, filename): r_waves = np.full(count, -99.) r_shallow = np.full(count, -99.) r_roughness = np.full(count, -99.) + wave_height = np.full(count, -99.) + wave_direction = np.full(count, -99.) + wave_period = np.full(count, -99.) + u_currents = np.full(count, -99.) + v_currents = np.full(count, -99.) + u_wind_speed = np.full(count, -99.) + v_wind_speed = np.full(count, -99.) + pressure = np.full(count, -99.) + air_temperature = np.full(count, -99.) + salinity = np.full(count, -99.) + water_temperature = np.full(count, -99.) course_per_step = np.full(count - 1, -99.) status = np.full(count, -99) fuel_type = np.full(count, "") @@ -223,6 +257,17 @@ def from_file(cls, filename): r_waves[ipoint] = property['wave_resistance']['value'] r_shallow[ipoint] = property['shallow_water_resistance']['value'] r_roughness[ipoint] = property['hull_roughness_resistance']['value'] + wave_height[ipoint] = property['wave_height']['value'] + wave_direction[ipoint] = property['wave_direction']['value'] + wave_period[ipoint] = property['wave_period']['value'] + u_currents[ipoint] = property['u_currents']['value'] + v_currents[ipoint] = property['v_currents']['value'] + u_wind_speed[ipoint] = property['u_wind_speed']['value'] + v_wind_speed[ipoint] = property['v_wind_speed']['value'] + pressure[ipoint] = property['pressure']['value'] + air_temperature[ipoint] = property['air_temperature']['value'] + salinity[ipoint] = property['salinity']['value'] + water_temperature[ipoint] = property['water_temperature']['value'] status[ipoint] = property['status']['value'] speed = speed[:-1] * u.meter/u.second @@ -234,6 +279,17 @@ def from_file(cls, filename): r_waves = r_waves[:-1] * u.newton r_shallow = r_shallow[:-1] * u.newton r_roughness = r_roughness[:-1] * u.newton + wave_height = wave_height[:-1] * u.meter + wave_direction = wave_direction[:-1] * u.radian + wave_period = wave_period[:-1] * u.second + u_currents = u_currents[:-1] * u.meter/u.second + v_currents = v_currents[:-1] * u.meter/u.second + u_wind_speed = u_wind_speed[:-1] * u.meter/u.second + v_wind_speed = v_wind_speed[:-1] * u.meter/u.second + pressure = pressure[:-1] * u.kg/u.meter/u.second**2 + air_temperature = air_temperature[:-1] * u.deg_C + salinity = salinity[:-1] * u.dimensionless_unscaled + water_temperature = water_temperature[:-1] * u.deg_C start = (lats_per_step[0], lons_per_step[0]) finish = (lats_per_step[count - 1], lons_per_step[count - 1]) @@ -255,6 +311,17 @@ def from_file(cls, filename): r_waves=r_waves, r_shallow=r_shallow, r_roughness=r_roughness, + wave_height=wave_height, + wave_direction=wave_direction, + wave_period=wave_period, + u_currents=u_currents, + v_currents=v_currents, + u_wind_speed=u_wind_speed, + v_wind_speed=v_wind_speed, + pressure=pressure, + air_temperature=air_temperature, + salinity=salinity, + water_temperature=water_temperature, status=status ) diff --git a/WeatherRoutingTool/ship/ship.py b/WeatherRoutingTool/ship/ship.py index b835ed7..a5acd3c 100644 --- a/WeatherRoutingTool/ship/ship.py +++ b/WeatherRoutingTool/ship/ship.py @@ -69,6 +69,17 @@ def get_ship_parameters(self, courses, lats, lons, time, speed=None, unique_coor r_waves=dummy_array * u.N, r_shallow=dummy_array * u.N, r_roughness=dummy_array * u.N, + wave_height=dummy_array * u.meter, + wave_direction=dummy_array * u.radian, + wave_period=dummy_array * u.second, + u_currents=dummy_array * u.meter/u.second, + v_currents=dummy_array * u.meter/u.second, + u_wind_speed=dummy_array * u.meter/u.second, + v_wind_speed=dummy_array * u.meter/u.second, + pressure=dummy_array * u.kg/u.meter/u.second**2, + air_temperature=dummy_array * u.deg_C, + salinity=dummy_array * u.dimensionless_unscaled, + water_temperature=dummy_array * u.deg_C, status=dummy_array ) @@ -402,6 +413,17 @@ def extract_params_from_netCDF(self, ds): r_waves = ds['Wave_resistance'].to_numpy().flatten() * u.newton r_shallow = ds['Shallow_water_resistance'].to_numpy().flatten() * u.newton r_roughness = ds['Hull_roughness_resistance'].to_numpy().flatten() * u.newton + wave_height = ds['VHM0'].to_numpy().flatten() * u.meter + wave_direction = ds['VMDR'].to_numpy().flatten() * u.radian + wave_period = ds['VTPK'].to_numpy().flatten() * u.second + u_currents = ds['utotal'].to_numpy().flatten() * u.meter/u.second + v_currents = ds['vtotal'].to_numpy().flatten() * u.meter/u.second + u_wind_speed = ds['u-component_of_wind_height_above_ground'].to_numpy().flatten() * u.meter/u.second + v_wind_speed = ds['v-component_of_wind_height_above_ground'].to_numpy().flatten() * u.meter/u.second + pressure = ds['Pressure_reduced_to_MSL_msl'].to_numpy().flatten() * u.kg/u.meter/u.second**2 + air_temperature = ds['Temperature_surface'].to_numpy().flatten() * u.deg_C + salinity = ds['so'].to_numpy().flatten() * u.dimensionless_unscaled + water_temperature = ds['thetao'].to_numpy().flatten() * u.deg_C status = ds['Status'].to_numpy().flatten() speed = np.repeat(self.speed, power.shape) @@ -415,6 +437,17 @@ def extract_params_from_netCDF(self, ds): r_waves=r_waves, r_shallow=r_shallow, r_roughness=r_roughness, + wave_height=wave_height, + wave_direction=wave_direction, + wave_period=wave_period, + u_currents=u_currents, + v_currents=v_currents, + u_wind_speed=u_wind_speed, + v_wind_speed=v_wind_speed, + pressure=pressure, + air_temperature=air_temperature, + salinity=salinity, + water_temperature=water_temperature, status=status ) diff --git a/WeatherRoutingTool/ship/shipparams.py b/WeatherRoutingTool/ship/shipparams.py index e0e9083..238e0d7 100644 --- a/WeatherRoutingTool/ship/shipparams.py +++ b/WeatherRoutingTool/ship/shipparams.py @@ -16,11 +16,24 @@ class ShipParams(): r_waves: np.ndarray # (N) r_shallow: np.ndarray # (N) r_roughness: np.ndarray # (N) + wave_height: np.ndarray # (m) + wave_direction: np.ndarray # (radian) + wave_period: np.ndarray # (s) + u_currents: np.ndarray # (m/s) + v_currents: np.ndarray # (m/s) + u_wind_speed: np.ndarray # (m/s) + v_wind_speed: np.ndarray # (m/s) + pressure: np.ndarray # Pa + air_temperature: np.ndarray # °C + salinity: np.ndarray # dimensionless (kg/kg) + water_temperature: np.ndarray # °C status: np.array fuel_type: str - def __init__(self, fuel_rate, power, rpm, speed, r_calm, r_wind, r_waves, r_shallow, r_roughness, status): + def __init__(self, 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): self.fuel_rate = fuel_rate self.power = power self.rpm = rpm @@ -30,6 +43,17 @@ def __init__(self, fuel_rate, power, rpm, speed, r_calm, r_wind, r_waves, r_shal self.r_waves = r_waves self.r_shallow = r_shallow self.r_roughness = r_roughness + self.wave_height = wave_height + self.wave_direction = wave_direction + self.wave_period = wave_period + self.u_currents = u_currents + self.v_currents = v_currents + self.u_wind_speed = u_wind_speed + self.v_wind_speed = v_wind_speed + self.pressure = pressure + self.air_temperature = air_temperature + self.salinity = salinity + self.water_temperature = water_temperature self.status = status self.fuel_type = 'HFO' @@ -46,6 +70,17 @@ def set_default_array(cls): r_waves=np.array([[0]]) * u.newton, r_shallow=np.array([[0]]) * u.newton, r_roughness=np.array([[0]]) * u.newton, + wave_height=np.array([[0]]) * u.meter, + wave_direction=np.array([[0]]) * u.radian, + wave_period=np.array([[0]]) * u.second, + u_currents=np.array([[0]]) * u.meter/u.second, + v_currents=np.array([[0]]) * u.meter/u.second, + u_wind_speed=np.array([[0]]) * u.meter/u.second, + v_wind_speed=np.array([[0]]) * u.meter/u.second, + pressure=np.array([[0]]) * u.kg/u.meter/u.second**2, + air_temperature=np.array([[0]]) * u.deg_C, + salinity=np.array([[0]]) * u.dimensionless_unscaled, + water_temperature=np.array([[0]]) * u.deg_C, status=np.array([[0]]) ) @@ -60,6 +95,17 @@ def set_default_array_1D(cls, ncoorinate_points): r_waves=np.full(shape=ncoorinate_points, fill_value=0), r_shallow=np.full(shape=ncoorinate_points, fill_value=0), r_roughness=np.full(shape=ncoorinate_points, fill_value=0), + wave_height=np.full(shape=ncoorinate_points, fill_value=0), + wave_direction=np.full(shape=ncoorinate_points, fill_value=0), + wave_period=np.full(shape=ncoorinate_points, fill_value=0), + u_currents=np.full(shape=ncoorinate_points, fill_value=0), + v_currents=np.full(shape=ncoorinate_points, fill_value=0), + u_wind_speed=np.full(shape=ncoorinate_points, fill_value=0), + v_wind_speed=np.full(shape=ncoorinate_points, fill_value=0), + pressure=np.full(shape=ncoorinate_points, fill_value=0), + air_temperature=np.full(shape=ncoorinate_points, fill_value=0), + salinity=np.full(shape=ncoorinate_points, fill_value=0), + water_temperature=np.full(shape=ncoorinate_points, fill_value=0), status=np.full(shape=ncoorinate_points, fill_value=0)) def print(self): @@ -72,6 +118,18 @@ def print(self): logger.info('r_waves: ' + str(self.r_waves.value) + ' ' + self.r_waves.unit.to_string()) logger.info('r_shallow: ' + str(self.r_shallow.value) + ' ' + self.r_shallow.unit.to_string()) logger.info('r_roughness: ' + str(self.r_roughness.value) + ' ' + self.r_roughness.unit.to_string()) + logger.info('wave_height: ' + str(self.wave_height.value) + ' ' + self.wave_height.unit.to_string()) + logger.info('wave_direction: ' + str(self.wave_direction.value) + ' ' + self.wave_direction.unit.to_string()) + logger.info('wave_period: ' + str(self.wave_period.value) + ' ' + self.wave_period.unit.to_string()) + logger.info('u_currents: ' + str(self.u_currents.value) + ' ' + self.u_currents.unit.to_string()) + logger.info('v_currents: ' + str(self.v_currents.value) + ' ' + self.v_currents.unit.to_string()) + logger.info('u_wind_speed: ' + str(self.u_wind_speed.value) + ' ' + self.u_wind_speed.unit.to_string()) + logger.info('v_wind_speed: ' + str(self.v_wind_speed.value) + ' ' + self.v_wind_speed.unit.to_string()) + logger.info('pressure: ' + str(self.pressure.value) + ' ' + self.pressure.unit.to_string()) + logger.info('air_temperature: ' + str(self.air_temperature.value) + ' ' + self.air_temperature.unit.to_string()) + logger.info('salinity: ' + str(self.salinity.value) + ' ' + self.salinity.unit.to_string()) + logger.info('water_temperature: ' + str(self.water_temperature.value) + ' ' + + self.water_temperature.unit.to_string()) logger.info('status', self.status) logger.info('fuel_type: ' + str(self.fuel_type)) @@ -85,6 +143,17 @@ def print_shape(self): logger.info('r_waves: ', self.r_waves.shape) logger.info('r_shallow: ', self.r_shallow.shape) logger.info('r_roughness: ', self.r_roughness.shape) + logger.info('wave_height: ', self.wave_height.shape) + logger.info('wave_direction: ', self.wave_direction.shape) + logger.info('wave_period: ', self.wave_period.shape) + logger.info('u_currents: ', self.u_currents.shape) + logger.info('v_currents: ', self.v_currents.shape) + logger.info('u_wind_speed: ', self.u_wind_speed.shape) + logger.info('v_wind_speed: ', self.v_wind_speed.shape) + logger.info('pressure: ', self.pressure.shape) + logger.info('air_temperature: ', self.air_temperature.shape) + logger.info('salinity: ', self.salinity.shape) + logger.info('water_temperature: ', self.water_temperature.shape) logger.info('status', self.status) def define_courses(self, courses_segments): @@ -97,6 +166,17 @@ def define_courses(self, courses_segments): self.r_waves = np.repeat(self.r_waves, courses_segments + 1, axis=1) self.r_shallow = np.repeat(self.r_shallow, courses_segments + 1, axis=1) self.r_roughness = np.repeat(self.r_roughness, courses_segments + 1, axis=1) + self.wave_height = np.repeat(self.wave_height, courses_segments + 1, axis=1) + self.wave_direction = np.repeat(self.wave_direction, courses_segments + 1, axis=1) + self.wave_period = np.repeat(self.wave_period, courses_segments + 1, axis=1) + self.u_currents = np.repeat(self.u_currents, courses_segments + 1, axis=1) + self.v_currents = np.repeat(self.v_currents, courses_segments + 1, axis=1) + self.u_wind_speed = np.repeat(self.u_wind_speed, courses_segments + 1, axis=1) + self.v_wind_speed = np.repeat(self.v_wind_speed, courses_segments + 1, axis=1) + self.pressure = np.repeat(self.pressure, courses_segments + 1, axis=1) + self.air_temperature = np.repeat(self.air_temperature, courses_segments + 1, axis=1) + self.salinity = np.repeat(self.salinity, courses_segments + 1, axis=1) + self.water_temperature = np.repeat(self.water_temperature, courses_segments + 1, axis=1) self.status = np.repeat(self.status, courses_segments + 1, axis=1) def get_power(self): @@ -129,6 +209,39 @@ def get_rpm(self): def get_speed(self): return self.speed + def get_wave_height(self): + return self.wave_height + + def get_wave_direction(self): + return self.wave_direction + + def get_wave_period(self): + return self.wave_period + + def get_u_currents(self): + return self.u_currents + + def get_v_currents(self): + return self.v_currents + + def get_u_wind_speed(self): + return self.u_wind_speed + + def get_v_wind_speed(self): + return self.v_wind_speed + + def get_pressure(self): + return self.pressure + + def get_air_temperature(self): + return self.air_temperature + + def get_salinity(self): + return self.salinity + + def get_water_temperature(self): + return self.water_temperature + def get_status(self): return self.status @@ -159,6 +272,39 @@ def set_rshallow(self, new_rshallow): def set_rroughness(self, new_rroughnes): self.r_roughness = new_rroughnes + def set_wave_height(self, new_wave_height): + self.wave_height = new_wave_height + + def set_wave_direction(self, new_wave_direction): + self.wave_direction = new_wave_direction + + def set_wave_period(self, new_wave_period): + self.wave_period = new_wave_period + + def set_u_currents(self, new_u_currents): + self.u_currents = new_u_currents + + def set_v_currents(self, new_v_currents): + self.v_currents = new_v_currents + + def set_u_wind_speed(self, new_u_wind_speed): + self.u_wind_speed = new_u_wind_speed + + def set_v_wind_speed(self, new_v_wind_speed): + self.v_wind_speed = new_v_wind_speed + + def set_pressure(self, new_pressure): + self.pressure = new_pressure + + def set_air_temperature(self, new_air_temperature): + self.air_temperature = new_air_temperature + + def set_salinity(self, new_salinity): + self.salinity = new_salinity + + def set_water_temperature(self, new_water_temperature): + self.water_temperature = new_water_temperature + def set_status(self, new_status): self.status = new_status @@ -172,6 +318,17 @@ def select(self, idxs): self.r_waves = self.r_waves[:, idxs] self.r_shallow = self.r_shallow[:, idxs] self.r_roughness = self.r_roughness[:, idxs] + self.wave_height = self.wave_height[:, idxs] + self.wave_direction = self.wave_direction[:, idxs] + self.wave_period = self.wave_period[:, idxs] + self.u_currents = self.u_currents[:, idxs] + self.v_currents = self.v_currents[:, idxs] + self.u_wind_speed = self.u_wind_speed[:, idxs] + self.v_wind_speed = self.v_wind_speed[:, idxs] + self.pressure = self.pressure[:, idxs] + self.air_temperature = self.air_temperature[:, idxs] + self.salinity = self.salinity[:, idxs] + self.water_temperature = self.water_temperature[:, idxs] self.status = self.status[:, idxs] def flip(self): @@ -185,6 +342,17 @@ def flip(self): self.r_waves = self.r_waves[:-1] self.r_shallow = self.r_shallow[:-1] self.r_roughness = self.r_roughness[:-1] + self.wave_height = self.wave_height[:-1] + self.wave_direction = self.wave_direction[:-1] + self.wave_period = self.wave_period[:-1] + self.u_currents = self.u_currents[:-1] + self.v_currents = self.v_currents[:-1] + self.u_wind_speed = self.u_wind_speed[:-1] + self.v_wind_speed = self.v_wind_speed[:-1] + self.pressure = self.pressure[:-1] + self.air_temperature = self.air_temperature[:-1] + self.salinity = self.salinity[:-1] + self.water_temperature = self.water_temperature[:-1] self.status = self.status[:-1] self.speed = np.flip(self.speed, 0) @@ -196,6 +364,17 @@ def flip(self): self.r_waves = np.flip(self.r_waves, 0) self.r_shallow = np.flip(self.r_shallow, 0) self.r_roughness = np.flip(self.r_roughness, 0) + self.wave_height = np.flip(self.wave_height, 0) + self.wave_direction = np.flip(self.wave_direction, 0) + self.wave_period = np.flip(self.wave_period, 0) + self.u_currents = np.flip(self.u_currents, 0) + self.v_currents = np.flip(self.v_currents, 0) + self.u_wind_speed = np.flip(self.u_wind_speed, 0) + self.v_wind_speed = np.flip(self.v_wind_speed, 0) + self.pressure = np.flip(self.pressure, 0) + self.air_temperature = np.flip(self.air_temperature, 0) + self.salinity = np.flip(self.salinity, 0) + self.water_temperature = np.flip(self.water_temperature, 0) self.status = np.flip(self.status, 0) self.speed = np.append(self.speed, -99 * self.speed.unit) @@ -207,6 +386,17 @@ def flip(self): self.r_waves = np.append(self.r_waves, -99 * self.r_waves.unit) self.r_shallow = np.append(self.r_shallow, -99 * self.r_shallow.unit) self.r_roughness = np.append(self.r_roughness, -99 * self.r_roughness.unit) + self.wave_height = np.append(self.wave_height, -99 * self.wave_height.unit) + self.wave_direction = np.append(self.wave_direction, -99 * self.wave_direction.unit) + self.wave_period = np.append(self.wave_period, -99 * self.wave_period.unit) + self.u_currents = np.append(self.u_currents, -99 * self.u_currents.unit) + self.v_currents = np.append(self.v_currents, -99 * self.v_currents.unit) + self.u_wind_speed = np.append(self.u_wind_speed, -99 * self.u_wind_speed.unit) + self.v_wind_speed = np.append(self.v_wind_speed, -99 * self.v_wind_speed.unit) + self.pressure = np.append(self.pressure, -99 * self.pressure.unit) + self.air_temperature = np.append(self.air_temperature, -99 * self.air_temperature.unit) + self.salinity = np.append(self.salinity, -99 * self.salinity.unit) + self.water_temperature = np.append(self.water_temperature, -99 * self.water_temperature.unit) self.status = np.append(self.status, -99) def expand_axis_for_intermediate(self): @@ -219,6 +409,17 @@ def expand_axis_for_intermediate(self): self.r_waves = np.expand_dims(self.r_waves, axis=1) self.r_shallow = np.expand_dims(self.r_shallow, axis=1) self.r_roughness = np.expand_dims(self.r_roughness, axis=1) + self.wave_height = np.expand_dims(self.wave_height, axis=1) + self.wave_direction = np.expand_dims(self.wave_direction, axis=1) + self.wave_period = np.expand_dims(self.wave_period, axis=1) + self.u_currents = np.expand_dims(self.u_currents, axis=1) + self.v_currents = np.expand_dims(self.v_currents, axis=1) + self.u_wind_speed = np.expand_dims(self.u_wind_speed, axis=1) + self.v_wind_speed = np.expand_dims(self.v_wind_speed, axis=1) + self.pressure = np.expand_dims(self.pressure, axis=1) + self.air_temperature = np.expand_dims(self.air_temperature, axis=1) + self.salinity = np.expand_dims(self.salinity, axis=1) + self.water_temperature = np.expand_dims(self.water_temperature, axis=1) self.status = np.expand_dims(self.status, axis=1) def get_element(self, idx): @@ -232,13 +433,27 @@ def get_element(self, idx): r_waves = self.r_waves[idx] r_shallow = self.r_shallow[idx] r_roughness = self.r_roughness[idx] + wave_height = self.wave_height[idx] + wave_direction = self.wave_direction[idx] + wave_period = self.wave_period[idx] + u_currents = self.u_currents[idx] + v_currents = self.v_currents[idx] + u_wind_speed = self.u_wind_speed[idx] + v_wind_speed = self.v_wind_speed[idx] + pressure = self.pressure[idx] + air_temperature = self.air_temperature[idx] + salinity = self.salinity[idx] + water_temperature = self.water_temperature[idx] status = self.status[idx] except ValueError: raise ValueError( 'Index ' + str(idx) + ' is not available for array with length ' + str(self.speed.shape[0])) - return fuel_rate, power, rpm, speed, r_wind, r_calm, r_waves, r_shallow, r_roughness, status + return (fuel_rate, power, rpm, speed, r_wind, r_calm, r_waves, r_shallow, r_roughness, wave_height, + wave_direction, wave_period, u_currents, v_currents, u_wind_speed, v_wind_speed, v_wind_speed, pressure, + air_temperature, salinity, water_temperature, status) def get_single_object(self, idx): + # ToDo: reuse get_element here try: speed = self.speed[idx] fuel_rate = self.fuel_rate[idx] @@ -249,6 +464,17 @@ def get_single_object(self, idx): r_waves = self.r_waves[idx] r_shallow = self.r_shallow[idx] r_roughness = self.r_roughness[idx] + wave_height = self.wave_height[idx] + wave_direction = self.wave_direction[idx] + wave_period = self.wave_period[idx] + u_currents = self.u_currents[idx] + v_currents = self.v_currents[idx] + u_wind_speed = self.u_wind_speed[idx] + v_wind_speed = self.v_wind_speed[idx] + pressure = self.pressure[idx] + air_temperature = self.air_temperature[idx] + salinity = self.salinity[idx] + water_temperature = self.water_temperature[idx] status = self.status[idx] except ValueError: @@ -265,6 +491,17 @@ def get_single_object(self, idx): r_waves=r_waves, r_shallow=r_shallow, r_roughness=r_roughness, + wave_height=wave_height, + wave_direction=wave_direction, + wave_period=wave_period, + u_currents=u_currents, + v_currents=v_currents, + u_wind_speed=u_wind_speed, + v_wind_speed=v_wind_speed, + pressure=pressure, + air_temperature=air_temperature, + salinity=salinity, + water_temperature=water_temperature, status=status ) return sp @@ -282,6 +519,17 @@ def get_reduced_2D_object(self, row_start=None, row_end=None, col_start=None, co r_waves = self.r_waves[row_start:row_end, col_start:col_end] r_shallow = self.r_shallow[row_start:row_end, col_start:col_end] r_roughness = self.r_roughness[row_start:row_end, col_start:col_end] + wave_height = self.wave_height[row_start:row_end, col_start:col_end] + wave_direction = self.wave_direction[row_start:row_end, col_start:col_end] + wave_period = self.wave_period[row_start:row_end, col_start:col_end] + u_currents = self.u_currents[row_start:row_end, col_start:col_end] + v_currents = self.v_currents[row_start:row_end, col_start:col_end] + u_wind_speed = self.u_wind_speed[row_start:row_end, col_start:col_end] + v_wind_speed = self.v_wind_speed[row_start:row_end, col_start:col_end] + pressure = self.pressure[row_start:row_end, col_start:col_end] + air_temperature = self.air_temperature[row_start:row_end, col_start:col_end] + salinity = self.salinity[row_start:row_end, col_start:col_end] + water_temperature = self.water_temperature[row_start:row_end, col_start:col_end] status = self.status[row_start:row_end, col_start:col_end] else: speed = self.speed[:, idxs] @@ -293,6 +541,17 @@ def get_reduced_2D_object(self, row_start=None, row_end=None, col_start=None, co r_waves = self.r_waves[:, idxs] r_shallow = self.r_shallow[:, idxs] r_roughness = self.r_roughness[:, idxs] + wave_height = self.wave_height[:, idxs] + wave_direction = self.wave_direction[:, idxs] + wave_period = self.wave_period[:, idxs] + u_currents = self.u_currents[:, idxs] + v_currents = self.v_currents[:, idxs] + u_wind_speed = self.u_wind_speed[:, idxs] + v_wind_speed = self.v_wind_speed[:, idxs] + pressure = self.pressure[:, idxs] + air_temperature = self.air_temperature[:, idxs] + salinity = self.salinity[:, idxs] + water_temperature = self.water_temperature[:, idxs] status = self.status[:, idxs] except ValueError: raise ValueError( @@ -308,6 +567,17 @@ def get_reduced_2D_object(self, row_start=None, row_end=None, col_start=None, co r_waves=r_waves, r_shallow=r_shallow, r_roughness=r_roughness, + wave_height=wave_height, + wave_direction=wave_direction, + wave_period=wave_period, + u_currents=u_currents, + v_currents=v_currents, + u_wind_speed=u_wind_speed, + v_wind_speed=v_wind_speed, + pressure=pressure, + air_temperature=air_temperature, + salinity=salinity, + water_temperature=water_temperature, status=status ) return sp