From f5820c219d05b84a837bae52da3c0f66e5250ea9 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 16 Mar 2023 17:40:57 +0100 Subject: [PATCH] Return x and y separately Simpler because that is what the plot command needs. --- Trajectories/plot_traj.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Trajectories/plot_traj.py b/Trajectories/plot_traj.py index 4e646e07..f9e93f4a 100755 --- a/Trajectories/plot_traj.py +++ b/Trajectories/plot_traj.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 import report_graph -import numpy as np import random def get_extr_coord(traj, e_overestim, SHPC): - xy = [] + x = [] + y = [] for node in traj: date_index, eddy_index = report_graph.node_to_date_eddy(node, @@ -13,19 +13,19 @@ def get_extr_coord(traj, e_overestim, SHPC): i_slice = SHPC.get_slice(date_index) ishape = SHPC.comp_ishape(date_index, eddy_index, i_slice) shape = SHPC.get_reader(i_slice, layer = "extremum").shape(ishape) - xy.append(shape.points[0]) + x.append(shape.points[0][0]) + y.append(shape.points[0][1]) - return np.array(xy) + return x, y def plot_single_traj(traj, e_overestim, SHPC, ax, src_crs, annotate_flag): - xy = get_extr_coord(traj, e_overestim, SHPC) - ax.plot(xy[:, 0], xy[:, 1], color = "red", transform = src_crs) - ax.plot(xy[0, 0], xy[0, 1], marker = "s", color = "black", - transform = src_crs) + x, y = get_extr_coord(traj, e_overestim, SHPC) + ax.plot(x, y, color = "red", transform = src_crs) + ax.plot(x[0], y[0], marker = "s", color = "black", transform = src_crs) if annotate_flag: ax.annotate(str(traj[0]), - ax.projection.transform_point(xy[0, 0], xy[0, 1], src_crs), + ax.projection.transform_point(x[0], y[0], src_crs), xytext = (3 * random.random(), 3 * random.random()), textcoords = "offset points") -- GitLab