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

Use `SHPC_class`

We want to add the possibility to choose a date in the slice. Note
that the script was created when there was only a single date in the
collection of shapefiles, and the script did not really change since
then.
parent 2f581028
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import shapefile
import numpy as np
import jumble_matplotlib
import util_eddies
def read(dirname):
......@@ -16,33 +17,30 @@ def read(dirname):
Select valid speed values.
"""
extr_file = path.join(dirname, "extremum")
outer_file = path.join(dirname, "outermost_contour")
max_speed_file = path.join(dirname, "max_speed_contour")
with shapefile.Reader(extr_file) as extremum, shapefile.Reader(
outer_file
) as outerm_cont, shapefile.Reader(max_speed_file) as max_speed_cont:
speed = []
rad_outer = []
rad_speed = []
amp_outer = []
amp_speed = []
for rec_extr, rec_outer, rec_max in zip(
extremum.iterRecords(),
outerm_cont.iterRecords(),
max_speed_cont.iterRecords(),
):
if rec_extr.speed != 1e4:
speed.append(rec_extr.speed)
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)
amp_speed.append(rec_extr.ssh - rec_max.ssh)
SHPC = util_eddies.SHPC_class(dirname)
extremum = SHPC.get_reader(0, "Anticyclones", "extremum")
outerm_cont = SHPC.get_reader(0, "Anticyclones", "outermost_contour")
max_speed_cont = SHPC.get_reader(0, "Anticyclones", "max_speed_contour")
speed = []
rad_outer = []
rad_speed = []
amp_outer = []
amp_speed = []
for rec_extr, rec_outer, rec_max in zip(
extremum.iterRecords(),
outerm_cont.iterRecords(),
max_speed_cont.iterRecords(),
):
if rec_extr.speed != 1e4:
speed.append(rec_extr.speed)
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)
amp_speed.append(rec_extr.ssh - rec_max.ssh)
return {
"speed": np.array(speed),
......@@ -133,12 +131,10 @@ if __name__ == "__main__":
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument(
"dir", help="directory containing collection of shapefiles"
)
parser.add_argument("SHPC", help="directory containing SHPC")
parser.add_argument("--save", action="store_true")
args = parser.parse_args()
d = read(args.dir)
d = read(args.SHPC)
fig_list = plot_all([d])
if args.save:
......
......@@ -130,7 +130,7 @@
"Distribution": {
"command": [
"$src_dir/Inst_eddies/Analysis/distribution_function.py",
"$tests_old_dir/Region_5_15_days/SHPC/Slice_0/Anticyclones",
"$tests_old_dir/Region_5_15_days/SHPC",
"--save"
]
}
......
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