|
3 | 3 | from ocean_navigation_simulator.utils import simulation_utils |
4 | 4 | from ocean_navigation_simulator.planners.hj_reachability_planners.platform_2D_for_sim import Platform2D_for_sim |
5 | 5 | import os |
6 | | -from scipy.interpolate import interp1d |
7 | | -import bisect |
8 | 6 | import sys |
9 | 7 | # Note: if you develop on hj_reachability and this library simultaneously uncomment this line |
10 | 8 | # sys.path.extend([os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))) + 'hj_reachability_c3']) |
@@ -49,7 +47,7 @@ def __init__(self, problem, gen_settings, specific_settings): |
49 | 47 | # this is just a variable that persists after planning for plotting/debugging |
50 | 48 | self.x_t = None |
51 | 49 | # initializes variables needed for planning, they will be filled in the plan method |
52 | | - self.reach_times, self.all_values, self.times_abs, self.grid, self.diss_scheme = [None]*5 |
| 50 | + self.reach_times, self.all_values, self.grid, self.diss_scheme = [None]*4 |
53 | 51 | self.x_traj, self.contr_seq, self.distr_seq = [None]*3 |
54 | 52 | # initialize variables needed for solving the PDE in non_dimensional terms |
55 | 53 | self.characteristic_vec, self.offset_vec, self.nonDimGrid, self.nondim_dynamics = [None] * 4 |
@@ -213,9 +211,13 @@ def update_current_data(self, x_t): |
213 | 211 | t_interval, lat_bnds, lon_bnds, |
214 | 212 | file_dicts=self.cur_forecast_dicts) |
215 | 213 |
|
| 214 | + # calculate target shape of the grid |
| 215 | + x_n_res = int((grids_dict['x_grid'][-1] - grids_dict['x_grid'][0])/self.specific_settings['grid_res'][0]) |
| 216 | + y_n_res = int((grids_dict['y_grid'][-1] - grids_dict['y_grid'][0])/self.specific_settings['grid_res'][1]) |
| 217 | + |
216 | 218 | # do spatial interpolation to the desired resolution to run HJ_reachability |
217 | 219 | grids_dict['x_grid'], grids_dict['y_grid'], water_u, water_v = simulation_utils.spatial_interpolation( |
218 | | - grids_dict, water_u, water_v, target_shape=self.specific_settings['grid_res'], kind='linear') |
| 220 | + grids_dict, water_u, water_v, target_shape=(x_n_res, y_n_res), kind='linear') |
219 | 221 |
|
220 | 222 | # set absolute time in UTC Posix time |
221 | 223 | self.current_data_t_0 = grids_dict['t_grid'][0] |
@@ -327,11 +329,12 @@ def get_dim_dynamical_system(self): |
327 | 329 |
|
328 | 330 | def initialize_hj_grid(self, grids_dict): |
329 | 331 | """Initialize the dimensional grid in degrees lat, lon""" |
| 332 | + # initialize grid using the grids_dict x-y shape as shape |
330 | 333 | self.grid = hj.Grid.from_grid_definition_and_initial_values( |
331 | 334 | domain=hj.sets.Box( |
332 | 335 | lo=np.array([grids_dict['x_grid'][0], grids_dict['y_grid'][0]]), |
333 | 336 | hi=np.array([grids_dict['x_grid'][-1], grids_dict['y_grid'][-1]])), |
334 | | - shape=self.specific_settings['grid_res']) |
| 337 | + shape=(len(grids_dict['x_grid']), len(grids_dict['y_grid']))) |
335 | 338 |
|
336 | 339 | def get_initial_values(self, center): |
337 | 340 | return hj.shapes.shape_ellipse(grid=self.nonDimGrid, |
|
0 commit comments