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

Define function `in_window`

Put existing code into new function `in_window` because we also want
to use it in another script: `plot_traj.py`.
parent 687f4069
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,13 @@ from os import path
from matplotlib import animation, patches
import f90nml
def in_window(point, window):
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = window
longit = point[0] + math.ceil((llcrnrlon - point[0]) / 360) * 360
# (in [llcrnrlon, llcrnrlon + 2 pi[)
return longit <= urcrnrlon and llcrnrlat <= point[1] <= urcrnrlat
def select_ishapes(k, k1, ishape_last, reader_extr, window = None):
"""Select ishapes at date k and in window."""
......@@ -47,12 +54,7 @@ def select_ishapes(k, k1, ishape_last, reader_extr, window = None):
for ishape in range(ishape_first, ishape_last[k - k1] + 1):
shape_rec_extr = reader_extr.shapeRecord(ishape)
points = shape_rec_extr.shape.points[0]
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = window
points[0] += math.ceil((llcrnrlon - points[0]) / 360) * 360
# (in [llcrnrlon, llcrnrlon + 2 pi[)
if points[0] <= urcrnrlon and llcrnrlat <= points[1] <= urcrnrlat:
ishape_list.append(ishape)
if in_window(points, window): ishape_list.append(ishape)
return ishape_list
......
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