예제 #1
0
 def draw_contour(self):
     t0, t1 = self.period
     # select contour for this time step
     m = self.t == self.now
     self.ax.figure.canvas.restore_region(self.bg_cache)
     if m.sum():
         self.segs.append(
             create_vertice(
                 flatten_line_matrix(self.x[m]), flatten_line_matrix(self.y[m])
             )
         )
     else:
         self.segs.append(empty((0, 2)))
     self.contour.set_paths(self.segs)
     self.contour.set_color(self.colors[-len(self.segs) :])
     self.contour.set_lw(arange(len(self.segs)) / len(self.segs) * 2.5)
     self.txt.set_text(f"{self.now} - {1/self.sleep_event:.0f} frame/s")
     self.ax.draw_artist(self.contour)
     self.ax.draw_artist(self.txt)
     # Remove first segment to keep only T contour
     if len(self.segs) > self.nb_step:
         self.segs.pop(0)
     # paint updated artist
     self.ax.figure.canvas.blit(self.ax.bbox)
예제 #2
0
    "longitude",
    "latitude",
)

# %%
# For each contours, we will get pixels indice in contour.
fig = plt.figure(figsize=(12, 6))
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
ax.set_aspect("equal")
ax.set_xlim(10, 70)
ax.set_ylim(-50, -25)
# We will used the outter contour
x_name, y_name = a.intern(False)
adt = g.grid("adt")
mask = ones(adt.shape, dtype='bool')
for eddy in a:
    i, j = Path(create_vertice(eddy[x_name], eddy[y_name])).pixels_in(g)
    mask[i, j] = False
adt.mask[:] += ~mask
g.display(ax, "adt")
a.display(ax, label="Anticyclonic", color="g", lw=1, extern_only=True)
# %%
fig = plt.figure(figsize=(12, 6))
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
ax.set_aspect("equal")
ax.set_xlim(10, 70)
ax.set_ylim(-50, -25)
adt.mask[:] = mask
g.display(ax, "adt")
a.display(ax, label="Anticyclonic", color="g", lw=1, extern_only=True)
예제 #3
0
def get_wrap_vertice(x0, y0, x1, y1, i):
    x0_, x1_ = x0[i], x1[i]
    if abs(x0_[0] - x1_[0]) > 180:
        ref = x0_[0] - x0.dtype.type(180)
        x1_ = (x1[i] - ref) % 360 + ref
    return create_vertice(x0_, y0[i]), create_vertice(x1_, y1[i])