From 33ca623cdfd03eb4b7d8e4877e62f8200b38aa04 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Tue, 21 Feb 2023 21:20:16 +0100 Subject: [PATCH] Remove tests on validity of eddies in shapefiles --- Inst_eddies/Analysis/distribution_function.py | 8 +-- Inst_eddies/Analysis/plot_eddy_contours.py | 66 +++++++------------ Inst_eddies/Analysis/stat_SHPC.py | 26 ++------ 3 files changed, 32 insertions(+), 68 deletions(-) diff --git a/Inst_eddies/Analysis/distribution_function.py b/Inst_eddies/Analysis/distribution_function.py index e571fd4b..062faae6 100755 --- a/Inst_eddies/Analysis/distribution_function.py +++ b/Inst_eddies/Analysis/distribution_function.py @@ -25,8 +25,7 @@ def read(dirname): amplitude of outermost contour, radius and amplitude of maximum speed contour, as Numpy arrays. - Select valid speed values and valid outermost contour (with - sufficient area). + Select valid speed values. """ extr_file = path.join(dirname, "extremum") @@ -47,9 +46,8 @@ def read(dirname): max_speed_cont.iterRecords()): if rec_extr.speed != 1e4: speed.append(rec_extr.speed) - if rec_extr.valid == 1: - rad_outer.append(rec_outer.r_eq_area) - amp_outer.append(rec_extr.ssh - rec_outer.ssh) + rad_outer.append(rec_outer.r_eq_area) + amp_outer.append(rec_extr.ssh - rec_outer.ssh) if rec_max.r_eq_area != - 100: rad_speed.append(rec_max.r_eq_area) diff --git a/Inst_eddies/Analysis/plot_eddy_contours.py b/Inst_eddies/Analysis/plot_eddy_contours.py index f17166e8..5c487dfa 100755 --- a/Inst_eddies/Analysis/plot_eddy_contours.py +++ b/Inst_eddies/Analysis/plot_eddy_contours.py @@ -4,16 +4,12 @@ Red for anti-cyclones, blue for cyclones. -Without the --light option. Empty circles for extrema -with a valid outermost contour, empty squares for other -extrema. Squares on outermost contour for a well-defined but invalid -outermost contour. Crosses on outermost contour for a valid outermost -contour but with no distinct max-speed contour. Filled circles on -outermost contour and max-speed contour for a valid outermost contour -with a distinct max-speed contour. +Without the --light option. Empty circles for extrema. Crosses on +outermost contour for an eddy with no distinct max-speed +contour. Filled circles on outermost contour and max-speed contour for +an eddy with a distinct max-speed contour. -With the --light option. Crosses for extrema with a valid outermost -contour. +With the --light option. Crosses for extrema. This script takes about 30 s of CPU for a 90° by 90° window, about 4 mn for a 180° by 180° window. @@ -95,15 +91,10 @@ def snapshot(ax, ishape_list, SHPC, i_slice, orientation, *, dashed = False, color = color_outer, fillstyle = "none", transform = src_crs) - if not hasattr(shape_rec_extr.record, "valid") \ - or shape_rec_extr.record.valid == 1: - if light: - lines[0].set_marker("+") - else: - lines[0].set_marker("o") - elif not light: - # Invalid outermost contour - lines[0].set_marker("s") + if light: + lines[0].set_marker("+") + else: + lines[0].set_marker("o") if not light: ax.annotate(str(shape_rec_extr.record.eddy_index), @@ -111,32 +102,25 @@ def snapshot(ax, ishape_list, SHPC, i_slice, orientation, *, dashed = False, src_crs), xytext = (3, 3), textcoords = "offset points") - if shape_outer.shapeType != shapefile.NULL and not light \ - or shape_rec_extr.record.valid: - points = np.array(shape_outer.points) - lines = ax.plot(points[:, 0], points[:, 1], color = color_outer, - transform = src_crs) + points = np.array(shape_outer.points) + lines = ax.plot(points[:, 0], points[:, 1], color = color_outer, + transform = src_crs) - if not light: - if hasattr(shape_rec_extr.record, "valid") \ - and shape_rec_extr.record.valid == 0: - # Invalid outermost contour - lines[0].set_marker("s") - lines[0].set_fillstyle("none") - elif shape_m_s == None \ - or shape_m_s.shapeType == shapefile.NULL: - lines[0].set_marker("x") - else: - lines[0].set_marker("o") + if not light: + if shape_m_s == None \ + or shape_m_s.shapeType == shapefile.NULL: + lines[0].set_marker("x") + else: + lines[0].set_marker("o") - if dashed: lines[0].set_linestyle("dashed") + if dashed: lines[0].set_linestyle("dashed") - if shape_m_s != None and shape_m_s.shapeType != shapefile.NULL: - points = np.array(shape_m_s.points) - lines = ax.plot(points[:, 0], points[:, 1], color = color_m_s, - transform = src_crs) - if not light: lines[0].set_marker("o") - if dashed: lines[0].set_linestyle("dashed") + if shape_m_s != None and shape_m_s.shapeType != shapefile.NULL: + points = np.array(shape_m_s.points) + lines = ax.plot(points[:, 0], points[:, 1], color = color_m_s, + transform = src_crs) + if not light: lines[0].set_marker("o") + if dashed: lines[0].set_linestyle("dashed") def plot_grid_bb(grid_nml, ax): """Grid bounding box.""" diff --git a/Inst_eddies/Analysis/stat_SHPC.py b/Inst_eddies/Analysis/stat_SHPC.py index d6a4bae8..d42e010d 100755 --- a/Inst_eddies/Analysis/stat_SHPC.py +++ b/Inst_eddies/Analysis/stat_SHPC.py @@ -10,12 +10,9 @@ parser.add_argument("SHPC") parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"]) args = parser.parse_args() -n_valid = 0 n_outer = 0 -n_points_valid = 0 n_points = 0 n_valid_speed = 0 -n_null = 0 with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, "extremum")) as extremum, \ @@ -33,12 +30,7 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, outermost_contour): l = len(shape_rec_outer.shape.points) n_points += l - if l == 0: n_null += 1 - if rec_extr.valid == 1: - n_valid += 1 - n_points_valid += l - if shape_rec_outer.record.r_eq_area >= 0: n_outer += 1 if with_radius_4: @@ -60,28 +52,18 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, n_valid_speed += 1 print("number of extrema of SSH:", n_extr, "\n") -print("number of null outermost contours:", n_null, "\n") -print("number of valid eddies (outermost contour found with sufficient area):", - n_valid, "\n") if with_radius_4: print("number of extrema with radius4 == 0 (no outermost contour or " "insufficient area):", n_radius4[0]) - print("number of extrema with radius4 == 1 (valid eddies with radius4 " - "== 1):", n_radius4[1]) - print("number of extrema with radius4 >= 2 (valid eddies with radius4 " - ">= 2):", n_radius4[2], "\n") + print("number of extrema with radius4 == 1:", n_radius4[1]) + print("number of extrema with radius4 >= 2:", n_radius4[2], "\n") print("number of outermost contours (outermost contour found, but may be with " "sufficient area or not):", n_outer) -if n_valid != 0: - print("average number of points of outermost contour per valid eddy:", - n_points_valid / n_valid) - -print("average number of points of outermost contour per extremum (valid or " - "invalid eddy, including null outermost contours):", n_points / n_extr, - "\n") +print("average number of points of outermost contour per extremum:", + n_points / n_extr, "\n") print("number of valid speed values:", n_valid_speed) if with_radius_4: -- GitLab