Skip to content
Snippets Groups Projects
Commit f3c35de3 authored by GUEZ Lionel's avatar GUEZ Lionel
Browse files

Blacken

parent 6d1af436
No related branches found
No related tags found
No related merge requests found
...@@ -7,37 +7,43 @@ from os import path ...@@ -7,37 +7,43 @@ from os import path
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("SHPC") parser.add_argument("SHPC")
parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"]) parser.add_argument("orientation", choices=["Anticyclones", "Cyclones"])
args = parser.parse_args() args = parser.parse_args()
n_points = 0 n_points = 0
n_valid_speed = 0 n_valid_speed = 0
with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, with shapefile.Reader(
"extremum")) as extremum, \ path.join(args.SHPC, "Slice_0", args.orientation, "extremum")
shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, ) as extremum, shapefile.Reader(
"outermost_contour")) as outermost_contour: path.join(args.SHPC, "Slice_0", args.orientation, "outermost_contour")
) as outermost_contour:
n_extr = len(extremum) n_extr = len(extremum)
print("number of extrema of SSH:", n_extr, "\n") print("number of extrema of SSH:", n_extr, "\n")
field_names_outer = [f[0] for f in outermost_contour.fields[1:]] field_names_outer = [f[0] for f in outermost_contour.fields[1:]]
for rec_extr, shape_rec_outer in zip(extremum.iterRecords(), for rec_extr, shape_rec_outer in zip(
outermost_contour): extremum.iterRecords(), outermost_contour
):
l = len(shape_rec_outer.shape.points) l = len(shape_rec_outer.shape.points)
n_points += l n_points += l
if rec_extr.speed != 1e4: if rec_extr.speed != 1e4:
n_valid_speed += 1 n_valid_speed += 1
print("average number of points of outermost contour per extremum:", print(
n_points / n_extr, "\n") "average number of points of outermost contour per extremum:",
n_points / n_extr,
"\n",
)
print("number of valid speed values:", n_valid_speed) print("number of valid speed values:", n_valid_speed)
n_max_speed = 0 n_max_speed = 0
n_points = 0 n_points = 0
with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, with shapefile.Reader(
"max_speed_contour")) as max_speed_contour: path.join(args.SHPC, "Slice_0", args.orientation, "max_speed_contour")
) as max_speed_contour:
for shape_rec in max_speed_contour: for shape_rec in max_speed_contour:
l = len(shape_rec.shape.points) l = len(shape_rec.shape.points)
...@@ -45,10 +51,14 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation, ...@@ -45,10 +51,14 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation,
n_max_speed += 1 n_max_speed += 1
n_points += l n_points += l
print("number of non-null maximum-speed contours (distinct from the " print(
"outermost contour):", "number of non-null maximum-speed contours (distinct from the "
n_max_speed) "outermost contour):",
n_max_speed,
)
if n_max_speed != 0: if n_max_speed != 0:
print("average number of points of non-null maximum-speed contours:", print(
n_points / n_max_speed) "average number of points of non-null maximum-speed contours:",
n_points / n_max_speed,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment