diff --git a/Common/util_eddies.py b/Common/util_eddies.py index e6d23f1f016f06ec8eae57eed28bb7d5be211a0b..760bd343440f0c69cd5de3ec9c13b5b5a3acfcf3 100644 --- a/Common/util_eddies.py +++ b/Common/util_eddies.py @@ -199,14 +199,18 @@ class SHPC_class: assert i_slice >= 0 return i_slice - def comp_ishape(self, date, eddy_index, orientation, i_slice): - """Compute the location in the shapefiles. Returns None if ishape_last - was not found and could not be created. Crashes if date is not - in i_slice. Returns None if eddy_index is greater than the + def comp_ishape(self, date, eddy_index, orientation, i_slice = None): + """Compute the location in the shapefiles: return `(i_slice, ishape)`. + Compute i_slice if i_slice is None. + + Returns None if ishape_last was not found and could not be + created. Crashes if i_slice is not None and date is not in + i_slice. Returns None if eddy_index is greater than the maximum value. """ + if i_slice is None: i_slice = self.get_slice(date) ishape_last = self.get_ishape_last(i_slice, orientation) if ishape_last is None: @@ -225,15 +229,15 @@ class SHPC_class: else: ishape = None - return ishape + return i_slice, ishape def ishape_range(self, date, i_slice, orientation): """Returns an empty list if ishape_last was not found and could not be - created. Crashes if date is not in i_slice. + created. Crashes if i_slice is not None and date is not in i_slice. """ - ishape_start = self.comp_ishape(date, 1, orientation, i_slice) + i_slice, ishape_start = self.comp_ishape(date, 1, orientation, i_slice) if ishape_start is None: return [] diff --git a/Inst_eddies/Analysis/eddy_dump.py b/Inst_eddies/Analysis/eddy_dump.py index d2c8de0ccfcf54ea0fa36d96a3377611afc4393c..98df7a05c7471f9a53b4f142016952c3af8a3083 100755 --- a/Inst_eddies/Analysis/eddy_dump.py +++ b/Inst_eddies/Analysis/eddy_dump.py @@ -40,7 +40,7 @@ else: assert eddy_index >= 1 i_slice = SHPC.get_slice(date) - ishape = SHPC.comp_ishape(date, eddy_index, args.orientation, i_slice) + i_slice, ishape = SHPC.comp_ishape(date, eddy_index, args.orientation, i_slice) print("ishape =", ishape) diff --git a/Overlap/Analysis/plot_edge_contours.py b/Overlap/Analysis/plot_edge_contours.py index f95dee845c632a29efc1d178c8979ad6d35de221..c389bd9a9463fa62b586dda69ac262a1c9afb7a6 100755 --- a/Overlap/Analysis/plot_edge_contours.py +++ b/Overlap/Analysis/plot_edge_contours.py @@ -24,8 +24,8 @@ print(f"{date_head=}") print(f"{date_tail=}") i_slice_head = SHPC.get_slice(date_head) i_slice_tail = SHPC.get_slice(date_tail) -ishape_head = SHPC.comp_ishape(date_head,eddy_i_head,orientation,i_slice_head) -ishape_tail = SHPC.comp_ishape(date_tail,eddy_i_tail,orientation,i_slice_tail) +i_slice_head, ishape_head = SHPC.comp_ishape(date_head,eddy_i_head,orientation,i_slice_head) +i_slice_tail, ishape_tail = SHPC.comp_ishape(date_tail,eddy_i_tail,orientation,i_slice_tail) fig = plt.figure() projection = ccrs.PlateCarree() ax = plt.axes(projection = projection) diff --git a/Overlap/Analysis/report_graph.py b/Overlap/Analysis/report_graph.py index 72fcf3f42689c7db3805e9419a4145fbce12a3fd..ed5c3ac8959094f91d8f6fa275637aad9b0a4044 100755 --- a/Overlap/Analysis/report_graph.py +++ b/Overlap/Analysis/report_graph.py @@ -46,7 +46,7 @@ def set_attribute(G, SHPC, orientation): n, G.graph["e_overestim"] ) i_slice = SHPC.get_slice(date_index) - ishape = SHPC.comp_ishape( + i_slice, ishape = SHPC.comp_ishape( date_index, eddy_index, orientation, i_slice ) reader = SHPC.get_reader(i_slice, orientation, "extremum") diff --git a/Trajectories/Analysis/plot_traj.py b/Trajectories/Analysis/plot_traj.py index 4b05e93e670cbad7aac44d0f3b5fcaca693b5499..499fc6c327b0c06e7c48128e3afe7b35161c4fd8 100755 --- a/Trajectories/Analysis/plot_traj.py +++ b/Trajectories/Analysis/plot_traj.py @@ -26,7 +26,7 @@ def get_extr_coord(traj, e_overestim, SHPC, orientation): node, e_overestim ) i_slice = SHPC.get_slice(date_index) - ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) + i_slice, ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) shape = SHPC.get_reader(i_slice, orientation, layer="extremum").shape( ishape ) diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py index 5f131ed52314b0b08bb86456b7c10522d1ea604d..c6f88061f1e3cf799442ac12b60f6030c77a5506 100755 --- a/Trajectories/cost_function.py +++ b/Trajectories/cost_function.py @@ -78,7 +78,7 @@ def node_to_prop(node_list, e_overestim, SHPC, orientation): for n in node_list: date_index, eddy_index = util_eddies.node_to_date_eddy(n, e_overestim) i_slice = SHPC.get_slice(date_index) - ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) + i_slice, ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) shapeRec = SHPC.get_reader( i_slice, orientation, "extremum" ).shapeRecord(ishape)