Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
english correction
  • Loading branch information
AntSimi committed Jan 11, 2022
commit cc540c03c27ac40194d049e547b9ca1cc2307572
22 changes: 11 additions & 11 deletions examples/02_eddy_identification/pet_statistics_on_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def update_axes(ax, mappable=None):
)[:365]

# %%
# Merge all identification dataset in one object
# Merge all identification datasets in one object
all_a = EddiesObservations.concatenate(
[EddiesObservations.load_file(i) for i in file_objects]
)
Expand All @@ -50,14 +50,14 @@ def update_axes(ax, mappable=None):
x0, x1, y0, y1 = 15, 20, 33, 38
xs = np.array([[x0, x1, x1, x0, x0]], dtype="f8")
ys = np.array([[y0, y0, y1, y1, y0]], dtype="f8")
# Polygon object is create to be usable by match function.
# Polygon object created for the match function use.
polygon = dict(contour_lon_e=xs, contour_lat_e=ys, contour_lon_s=xs, contour_lat_s=ys)

# %%
# Geographic frequency of eddies
step = 0.125
ax = start_axes("")
# Count pixel used for each contour
# Count pixel encompassed in each contour
g_a = all_a.grid_count(bins=((-10, 37, step), (30, 46, step)), intern=True)
m = g_a.display(
ax, cmap="terrain_r", vmin=0, vmax=0.75, factor=1 / all_a.nb_days, name="count"
Expand All @@ -66,7 +66,7 @@ def update_axes(ax, mappable=None):
update_axes(ax, m)

# %%
# We use match function to count number of eddies which intersect the polygon defined previously.
# We use the match function to count the number of eddies that intersect the polygon defined previously
# `p1_area` option allow to get in c_e/c_s output, precentage of area occupy by eddies in the polygon.
i_e, j_e, c_e = all_a.match(polygon, p1_area=True, intern=False)
i_s, j_s, c_s = all_a.match(polygon, p1_area=True, intern=True)
Expand All @@ -79,22 +79,22 @@ def update_axes(ax, mappable=None):
# translate julian day in datetime64
t = all_a.time.astype("datetime64") - dt
# %%
# Count how many are in polygon
# Number of eddies within a polygon
ax = plt.figure(figsize=(12, 6)).add_subplot(111)
ax.set_title("Different way to count eddies presence in a polygon")
ax.set_title("Different ways to count eddies within a polygon")
ax.set_ylabel("Count")
m = all_a.mask_from_polygons(((xs, ys),))
ax.hist(t[m], label="center in polygon", **kw_hist)
ax.hist(t[i_s[c_s > 0]], label="intersect speed contour with polygon", **kw_hist)
ax.hist(t[i_e[c_e > 0]], label="intersect extern contour with polygon", **kw_hist)
ax.hist(t[m], label="Eddy Center in polygon", **kw_hist)
ax.hist(t[i_s[c_s > 0]], label="Intersection Speed contour and polygon", **kw_hist)
ax.hist(t[i_e[c_e > 0]], label="Intersection Effective contour and polygon", **kw_hist)
ax.legend()
ax.set_xlim(np.datetime64("2010"), np.datetime64("2011"))
ax.grid()

# %%
# Percent of are of interest occupy by eddies
# Percent of the area of interest occupied by eddies.
ax = plt.figure(figsize=(12, 6)).add_subplot(111)
ax.set_title("Percent of polygon occupy by an anticyclonic eddy")
ax.set_title("Percent of polygon occupied by an anticyclonic eddy")
ax.set_ylabel("Percent of polygon")
ax.hist(t[i_s[c_s > 0]], weights=c_s[c_s > 0] * 100.0, label="speed contour", **kw_hist)
ax.hist(
Expand Down