diff --git a/Common/util_eddies.py b/Common/util_eddies.py index 571df9c0749d4f6743449be47197c07c8053967a..adb820009482219967be06d5234c99a53912c1bc 100644 --- a/Common/util_eddies.py +++ b/Common/util_eddies.py @@ -126,7 +126,7 @@ class SHPC_class: return self._ishape_last[i_slice][orientation] - def get_reader(self, i_slice, layer, orientation): + def get_reader(self, i_slice, orientation, layer): if layer not in self._readers[i_slice][orientation]: my_shapefile = path.join(self.dir, f"Slice_{i_slice}", orientation, layer) @@ -143,8 +143,7 @@ class SHPC_class: def get_n_shapes(self, i_slice, orientation): if self._n_shapes[i_slice][orientation] == 0: - reader = self.get_reader(i_slice, layer = "extremum", - orientation = orientation) + reader = self.get_reader(i_slice, orientation, layer = "extremum") self._n_shapes[i_slice][orientation] = len(reader) return self._n_shapes[i_slice][orientation] @@ -154,7 +153,7 @@ class SHPC_class: last_date = self.d_init[i_slice] date_ishape = [] # list of tuples (date, ishape) - reader = self.get_reader(i_slice, "extremum", orientation) + reader = self.get_reader(i_slice, orientation, "extremum") if reader is None: print('Could not create "ishape_last.txt".') diff --git a/Inst_eddies/Analysis/anim_eddy_contours.py b/Inst_eddies/Analysis/anim_eddy_contours.py index f7b7d7e38b209789e9fcb2009d09fe1860e15db8..b3d79ae5483d96db11a7d90a53cbb57e9738e454 100755 --- a/Inst_eddies/Analysis/anim_eddy_contours.py +++ b/Inst_eddies/Analysis/anim_eddy_contours.py @@ -60,8 +60,8 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light): for orientation in ["Anticyclones", "Cyclones"]: b2 = compute_bbox(ishape_lists_all[orientation], - SHPC.get_reader(0, "outermost_contour", - orientation)) + SHPC.get_reader(0, orientation, + "outermost_contour")) bbox = bbox_union(bbox, b2) else: bbox = window diff --git a/Inst_eddies/Analysis/eddy_dump.py b/Inst_eddies/Analysis/eddy_dump.py index 53454c026017ad46036ca5888a8c818af201530b..6f1ca5d0bb4c95330a284c2a936a626a2f9a479d 100755 --- a/Inst_eddies/Analysis/eddy_dump.py +++ b/Inst_eddies/Analysis/eddy_dump.py @@ -44,7 +44,7 @@ for layer in ["extremum", "outermost_contour", "max_speed_contour", "centroid"]: print() try: - shapeRec = SHPC.get_reader(0, layer, args.orientation)\ + shapeRec = SHPC.get_reader(0, args.orientation, layer)\ .shapeRecord(ishape) except AttributeError: pass diff --git a/Inst_eddies/Analysis/plot_eddy_contours.py b/Inst_eddies/Analysis/plot_eddy_contours.py index a4ef1d359a5803eaccca3279585282c1fede044e..3f2b500c17bf7a151809351208b313af195029ba 100755 --- a/Inst_eddies/Analysis/plot_eddy_contours.py +++ b/Inst_eddies/Analysis/plot_eddy_contours.py @@ -39,8 +39,7 @@ def select_ishapes(d: int, SHPC: util_eddies.SHPC_class, i_slice: int, ishape_list_filt = ishape_list else: ishape_list_filt = [] - reader = SHPC.get_reader(i_slice, layer = "extremum", - orientation = orientation) + reader = SHPC.get_reader(i_slice, orientation, layer = "extremum") for ishape in ishape_list: points = reader.shape(ishape).points[0] @@ -67,12 +66,11 @@ def snapshot(ax: geoaxes.GeoAxesSubplot, ishape_list, SHPC, i_slice, color_outer = "red" color_m_s = "magenta" - reader_extr = SHPC.get_reader(i_slice, layer = "extremum", - orientation = orientation) - reader_outer = SHPC.get_reader(i_slice, layer = "outermost_contour", - orientation = orientation) - reader_m_s = SHPC.get_reader(i_slice, layer = "max_speed_contour", - orientation = orientation) + reader_extr = SHPC.get_reader(i_slice, orientation, layer = "extremum") + reader_outer = SHPC.get_reader(i_slice, orientation, + layer = "outermost_contour") + reader_m_s = SHPC.get_reader(i_slice, orientation, + layer = "max_speed_contour") for ishape in ishape_list: shape_rec_extr = reader_extr.shapeRecord(ishape) diff --git a/Inst_eddies/Analysis/write_date_range.py b/Inst_eddies/Analysis/write_date_range.py index 55fd8ccb861f1788e96ba3d6f3b06eaa58e7a369..024af7039e15b53469e5f880f94c9e402b660881 100755 --- a/Inst_eddies/Analysis/write_date_range.py +++ b/Inst_eddies/Analysis/write_date_range.py @@ -29,9 +29,9 @@ os.makedirs(slice_dir) for orientation in ["Anticyclones", "Cyclones"]: orient_dir = path.join(slice_dir, orientation) os.mkdir(orient_dir) - extremum = SHPC.get_reader(i_slice, "extremum", orientation) - outermost_cont = SHPC.get_reader(i_slice, "outermost_contour", orientation) - max_speed_cont = SHPC.get_reader(i_slice, "max_speed_contour", orientation) + extremum = SHPC.get_reader(i_slice, orientation, "extremum") + outermost_cont = SHPC.get_reader(i_slice, orientation, "outermost_contour") + max_speed_cont = SHPC.get_reader(i_slice, orientation, "max_speed_contour") fname = path.join(orient_dir, "ishape_last.txt") with shapefile.Writer(path.join(orient_dir, "extremum")) as extremum_filt, \ diff --git a/Overlap/report_graph.py b/Overlap/report_graph.py index f501370ab32f3c5b1149e40942937ce078e9fa48..d26d5f31c833a4e88660a4b522965845a28e3823 100755 --- a/Overlap/report_graph.py +++ b/Overlap/report_graph.py @@ -46,7 +46,7 @@ def read_eddy_graph(edgelist, shpc_dir = None, orientation = "Cyclones"): return G def set_attribute(G, SHPC, orientation): - reader = SHPC.get_reader(0, "extremum", orientation) + reader = SHPC.get_reader(0, orientation, "extremum") if G.number_of_nodes() <= SHPC.get_n_shapes(0, orientation) / 100: for n in G: diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py index 444995d96af4ec03275636fc14f7ba7b29a06c66..d2e5470428b0065e9c6e8fb864edc3e5a0385147 100755 --- a/Trajectories/cost_function.py +++ b/Trajectories/cost_function.py @@ -69,15 +69,16 @@ def node_to_prop(node_list, e_overestim, SHPC, orientation): date_index, eddy_index = report_graph.node_to_date_eddy(n, e_overestim) i_slice = SHPC.get_slice(date_index) ishape = SHPC.comp_ishape(date_index, eddy_index, i_slice, orientation) - shapeRec = SHPC.get_reader(i_slice, "extremum", orientation)\ + shapeRec = SHPC.get_reader(i_slice, orientation, "extremum")\ .shapeRecord(ishape) prop = {"pos": shapeRec.shape.points[0], "speed": shapeRec.record.speed} - prop["radius"] = SHPC.get_reader(i_slice, "max_speed_contour", - orientation).record(ishape).r_eq_area + prop["radius"] \ + = SHPC.get_reader(i_slice, orientation, "max_speed_contour")\ + .record(ishape).r_eq_area if prop["radius"] < 0: - prop["radius"] = SHPC.get_reader(i_slice, "outermost_contour", - orientation)\ + prop["radius"] = SHPC.get_reader(i_slice, orientation, + "outermost_contour")\ .record(ishape).r_eq_area properties.append(prop) diff --git a/Trajectories/plot_traj.py b/Trajectories/plot_traj.py index 3898e483621db54146a571af862332fef6df2f7d..3b8392e5aad11268ae1cc95cefe09ace4cc0d504 100755 --- a/Trajectories/plot_traj.py +++ b/Trajectories/plot_traj.py @@ -12,8 +12,8 @@ def get_extr_coord(traj, e_overestim, SHPC, orientation): e_overestim) i_slice = SHPC.get_slice(date_index) ishape = SHPC.comp_ishape(date_index, eddy_index, i_slice, orientation) - shape = SHPC.get_reader(i_slice, layer = "extremum", - orientation = orientation).shape(ishape) + shape = SHPC.get_reader(i_slice, orientation, layer = "extremum")\ + .shape(ishape) x.append(shape.points[0][0]) y.append(shape.points[0][1])