Skip to content
Merged
Show file tree
Hide file tree
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
- refactoring
  • Loading branch information
AntSimi committed Dec 11, 2021
commit 9e9b90d6f67df93829d82675d90709dbfae82baa
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ Fixed

- Fix bug in convolution(filter), lowest rows was replace by zeros in convolution computation.
Important impact for tiny kernel
- Fix method of sampling before contour fitting

Added
^^^^^

- Allow to replace mask by isnan method to manage nan data instead of masked data
- Add drifter colocation example

[3.5.0] - 2021-06-22
--------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/06_grid_manipulation/pet_advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
8 changes: 2 additions & 6 deletions examples/06_grid_manipulation/pet_lavd.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down Expand Up @@ -159,11 +159,7 @@ def update(i_frame):
# Format LAVD data
lavd = RegularGridDataset.with_array(
coordinates=("lon", "lat"),
datas=dict(
lavd=lavd.T,
lon=x_g,
lat=y_g,
),
datas=dict(lavd=lavd.T, lon=x_g, lat=y_g,),
centered=True,
)

Expand Down
2 changes: 1 addition & 1 deletion examples/07_cube_manipulation/pet_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
18 changes: 9 additions & 9 deletions examples/10_tracking_diagnostics/pet_normalised_lifetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ def eddy_norm_lifetime(self, name, nb, factor=1):
# %%
# Figure
# ------
fig, axs = plt.subplots(nrows=2, figsize=(8, 6))
fig, (ax0, ax1) = plt.subplots(nrows=2, figsize=(8, 6))

axs[0].set_title("Normalised Mean Radius")
axs[0].plot(*AC_radius), axs[0].plot(*CC_radius)
axs[0].set_ylabel("Radius (km)"), axs[0].grid()
axs[0].set_xlim(0, 1), axs[0].set_ylim(0, None)
ax0.set_title("Normalised Mean Radius")
ax0.plot(*AC_radius), ax0.plot(*CC_radius)
ax0.set_ylabel("Radius (km)"), ax0.grid()
ax0.set_xlim(0, 1), ax0.set_ylim(0, None)

axs[1].set_title("Normalised Mean Amplitude")
axs[1].plot(*AC_amplitude, label="AC"), axs[1].plot(*CC_amplitude, label="CC")
axs[1].set_ylabel("Amplitude (cm)"), axs[1].grid(), axs[1].legend()
_ = axs[1].set_xlim(0, 1), axs[1].set_ylim(0, None)
ax1.set_title("Normalised Mean Amplitude")
ax1.plot(*AC_amplitude, label="AC"), ax1.plot(*CC_amplitude, label="CC")
ax1.set_ylabel("Amplitude (cm)"), ax1.grid(), ax1.legend()
_ = ax1.set_xlim(0, 1), ax1.set_ylim(0, None)
10 changes: 5 additions & 5 deletions examples/12_external_data/pet_drifter_loopers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Colocate looper with eddy from altimetry
========================================

All loopers data used in this example are a subset from the dataset describe in this article
All loopers data used in this example are a subset from the dataset described in this article
[Lumpkin, R. : Global characteristics of coherent vortices from surface drifter trajectories](https://doi.org/10.1002/2015JC011435)
"""

Expand All @@ -29,7 +29,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down Expand Up @@ -71,15 +71,15 @@ def update_axes(ax, mappable=None):
# %%
# Global view
# ===========
ax = start_axes("All drifter available in med from Lumpkin dataset")
ax = start_axes("All drifters available in Med from Lumpkin dataset")
loopers_med.plot(ax, lw=0.5, color="r", ref=-10)
update_axes(ax)

# %%
# One segment of drifter
# ======================
#
# Get a drifter segment (index used have no correspondance with original dataset).
# Get a drifter segment (the indexes used have no correspondance with the original dataset).
looper = loopers_med.extract_ids((3588,))
fig = plt.figure(figsize=(16, 6))
ax = fig.add_subplot(111, aspect="equal")
Expand Down Expand Up @@ -138,7 +138,7 @@ def update_axes(ax, mappable=None):


# %%
# Animation which show drifter with colocated eddy
# Animation of a drifter and its colocated eddy
def update(frame):
# We display last 5 days of loopers trajectory
m = (looper.time < frame) * (looper.time > (frame - 5))
Expand Down
2 changes: 1 addition & 1 deletion examples/16_network/pet_follow_particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is used to create thumbnail which are not used but consumes same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
2 changes: 1 addition & 1 deletion examples/16_network/pet_group_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
2 changes: 1 addition & 1 deletion examples/16_network/pet_ioannou_2017_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down
5 changes: 2 additions & 3 deletions examples/16_network/pet_segmentation_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _repr_html_(self, *args, **kwargs):

def save(self, *args, **kwargs):
if args[0].endswith("gif"):
# In this case gif is use to create thumbnail which are not use but consume same time than video
# In this case gif is used to create thumbnail which is not used but consume same time than video
# So we create an empty file, to save time
with open(args[0], "w") as _:
pass
Expand Down Expand Up @@ -96,8 +96,7 @@ def update(i_frame):

indices_frames = INDICES[i_frame]
mappable_CONTOUR.set_data(
e.contour_lon_e[indices_frames],
e.contour_lat_e[indices_frames],
e.contour_lon_e[indices_frames], e.contour_lat_e[indices_frames],
)
mappable_CONTOUR.set_color(cmap.colors[tr[indices_frames] % len(cmap.colors)])
return (mappable_tracks,)
Expand Down
18 changes: 9 additions & 9 deletions notebooks/python_module/06_grid_manipulation/pet_advect.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Grid advection\n\nDummy advection which use only static geostrophic current, which didn't solve the complex circulation of the ocean.\n"
"\nGrid advection\n==============\n\nDummy advection which use only static geostrophic current, which didn't solve the complex circulation of the ocean.\n"
]
},
{
Expand Down Expand Up @@ -91,14 +91,14 @@
},
"outputs": [],
"source": [
"class VideoAnimation(FuncAnimation):\n def _repr_html_(self, *args, **kwargs):\n \"\"\"To get video in html and have a player\"\"\"\n content = self.to_html5_video()\n return re.sub(\n r'width=\"[0-9]*\"\\sheight=\"[0-9]*\"', 'width=\"100%\" height=\"100%\"', content\n )\n\n def save(self, *args, **kwargs):\n if args[0].endswith(\"gif\"):\n # In this case gif is use to create thumbnail which are not use but consume same time than video\n # So we create an empty file, to save time\n with open(args[0], \"w\") as _:\n pass\n return\n return super().save(*args, **kwargs)"
"class VideoAnimation(FuncAnimation):\n def _repr_html_(self, *args, **kwargs):\n \"\"\"To get video in html and have a player\"\"\"\n content = self.to_html5_video()\n return re.sub(\n r'width=\"[0-9]*\"\\sheight=\"[0-9]*\"', 'width=\"100%\" height=\"100%\"', content\n )\n\n def save(self, *args, **kwargs):\n if args[0].endswith(\"gif\"):\n # In this case gif is used to create thumbnail which is not used but consume same time than video\n # So we create an empty file, to save time\n with open(args[0], \"w\") as _:\n pass\n return\n return super().save(*args, **kwargs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Anim\nParticles setup\n\n"
"Anim\n----\nParticles setup\n\n"
]
},
{
Expand Down Expand Up @@ -152,7 +152,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Filament forward\nDraw 3 last position in one path for each particles.,\nit could be run backward with `backward=True` option in filament method\n\n"
"Filament forward\n^^^^^^^^^^^^^^^^\nDraw 3 last position in one path for each particles.,\nit could be run backward with `backward=True` option in filament method\n\n"
]
},
{
Expand All @@ -170,7 +170,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Particle forward\nForward advection of particles\n\n"
"Particle forward\n^^^^^^^^^^^^^^^^^\nForward advection of particles\n\n"
]
},
{
Expand Down Expand Up @@ -206,14 +206,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Particles stat\n\n"
"Particles stat\n--------------\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Time_step settings\nDummy experiment to test advection precision, we run particles 50 days forward and backward with different time step\nand we measure distance between new positions and original positions.\n\n"
"Time_step settings\n^^^^^^^^^^^^^^^^^^\nDummy experiment to test advection precision, we run particles 50 days forward and backward with different time step\nand we measure distance between new positions and original positions.\n\n"
]
},
{
Expand All @@ -231,7 +231,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Time duration\nWe keep same time_step but change time duration\n\n"
"Time duration\n^^^^^^^^^^^^^\nWe keep same time_step but change time duration\n\n"
]
},
{
Expand Down Expand Up @@ -262,7 +262,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
20 changes: 10 additions & 10 deletions notebooks/python_module/06_grid_manipulation/pet_lavd.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# LAVD experiment\n\nNaive method to reproduce LAVD(Lagrangian-Averaged Vorticity deviation) method with a static velocity field.\nIn the current example we didn't remove a mean vorticity.\n\nMethod are described here:\n\n - Abernathey, Ryan, and George Haller. \"Transport by Lagrangian Vortices in the Eastern Pacific\",\n Journal of Physical Oceanography 48, 3 (2018): 667-685, accessed Feb 16, 2021,\n https://doi.org/10.1175/JPO-D-17-0102.1\n - `Transport by Coherent Lagrangian Vortices`_,\n R. Abernathey, Sinha A., Tarshish N., Liu T., Zhang C., Haller G., 2019,\n Talk a t the Sources and Sinks of Ocean Mesoscale Eddy Energy CLIVAR Workshop\n\n https://usclivar.org/sites/default/files/meetings/2019/presentations/Aberernathey_CLIVAR.pdf\n"
"\nLAVD experiment\n===============\n\nNaive method to reproduce LAVD(Lagrangian-Averaged Vorticity deviation) method with a static velocity field.\nIn the current example we didn't remove a mean vorticity.\n\nMethod are described here:\n\n - Abernathey, Ryan, and George Haller. \"Transport by Lagrangian Vortices in the Eastern Pacific\",\n Journal of Physical Oceanography 48, 3 (2018): 667-685, accessed Feb 16, 2021,\n https://doi.org/10.1175/JPO-D-17-0102.1\n - `Transport by Coherent Lagrangian Vortices`_,\n R. Abernathey, Sinha A., Tarshish N., Liu T., Zhang C., Haller G., 2019,\n Talk a t the Sources and Sinks of Ocean Mesoscale Eddy Energy CLIVAR Workshop\n\n https://usclivar.org/sites/default/files/meetings/2019/presentations/Aberernathey_CLIVAR.pdf\n"
]
},
{
Expand Down Expand Up @@ -48,14 +48,14 @@
},
"outputs": [],
"source": [
"class VideoAnimation(FuncAnimation):\n def _repr_html_(self, *args, **kwargs):\n \"\"\"To get video in html and have a player\"\"\"\n content = self.to_html5_video()\n return re.sub(\n r'width=\"[0-9]*\"\\sheight=\"[0-9]*\"', 'width=\"100%\" height=\"100%\"', content\n )\n\n def save(self, *args, **kwargs):\n if args[0].endswith(\"gif\"):\n # In this case gif is use to create thumbnail which are not use but consume same time than video\n # So we create an empty file, to save time\n with open(args[0], \"w\") as _:\n pass\n return\n return super().save(*args, **kwargs)"
"class VideoAnimation(FuncAnimation):\n def _repr_html_(self, *args, **kwargs):\n \"\"\"To get video in html and have a player\"\"\"\n content = self.to_html5_video()\n return re.sub(\n r'width=\"[0-9]*\"\\sheight=\"[0-9]*\"', 'width=\"100%\" height=\"100%\"', content\n )\n\n def save(self, *args, **kwargs):\n if args[0].endswith(\"gif\"):\n # In this case gif is used to create thumbnail which is not used but consume same time than video\n # So we create an empty file, to save time\n with open(args[0], \"w\") as _:\n pass\n return\n return super().save(*args, **kwargs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\nTo compute vorticity ($\\omega$) we compute u/v field with a stencil and apply the following equation with stencil\nmethod :\n\n\\begin{align}\\omega = \\frac{\\partial v}{\\partial x} - \\frac{\\partial u}{\\partial y}\\end{align}\n\n"
"Data\n----\nTo compute vorticity ($\\omega$) we compute u/v field with a stencil and apply the following equation with stencil\nmethod :\n\n\\begin{align}\\omega = \\frac{\\partial v}{\\partial x} - \\frac{\\partial u}{\\partial y}\\end{align}\n\n"
]
},
{
Expand Down Expand Up @@ -91,7 +91,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Particles\nParticles specification\n\n"
"Particles\n---------\nParticles specification\n\n"
]
},
{
Expand All @@ -109,7 +109,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## LAVD\n\n"
"LAVD\n----\n\n"
]
},
{
Expand All @@ -127,7 +127,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Anim\nMovie of LAVD integration at each integration time step.\n\n"
"Anim\n^^^^\nMovie of LAVD integration at each integration time step.\n\n"
]
},
{
Expand All @@ -138,14 +138,14 @@
},
"outputs": [],
"source": [
"def update(i_frame):\n global lavd, i\n i += 1\n x, y = particule.__next__()\n # Interp vorticity on new_position\n lavd += abs(g.interp(\"vort\", x, y).reshape(original_shape) * 1 / nb_time)\n txt.set_text(f\"T0 + {i / step_by_day:.2f} days of advection\")\n pcolormesh.set_array(lavd / i * nb_time)\n return pcolormesh, txt\n\n\nkw_video = dict(frames=arange(nb_time), interval=1000.0 / step_by_day / 2, blit=True)\nfig, ax, txt = start_ax(dpi=60)\nx_g_, y_g_ = arange(0 - step / 2, 36 + step / 2, step), arange(\n 28 - step / 2, 46 + step / 2, step\n)\n# pcolorfast will be faster than pcolormesh, we could use pcolorfast due to x and y are regular\npcolormesh = ax.pcolorfast(x_g_, y_g_, lavd, **kw_vorticity)\nupdate_axes(ax, pcolormesh)\n_ = VideoAnimation(ax.figure, update, **kw_video)"
"def update(i_frame):\n global lavd, i\n i += 1\n x, y = particule.__next__()\n # Interp vorticity on new_position\n lavd += abs(g.interp(\"vort\", x, y).reshape(original_shape) * 1 / nb_time)\n txt.set_text(f\"T0 + {i / step_by_day:.2f} days of advection\")\n pcolormesh.set_array(lavd / i * nb_time)\n return pcolormesh, txt\n\n\nkw_video = dict(frames=arange(nb_time), interval=1000.0 / step_by_day / 2, blit=True)\nfig, ax, txt = start_ax(dpi=60)\nx_g_, y_g_ = (\n arange(0 - step / 2, 36 + step / 2, step),\n arange(28 - step / 2, 46 + step / 2, step),\n)\n# pcolorfast will be faster than pcolormesh, we could use pcolorfast due to x and y are regular\npcolormesh = ax.pcolorfast(x_g_, y_g_, lavd, **kw_vorticity)\nupdate_axes(ax, pcolormesh)\n_ = VideoAnimation(ax.figure, update, **kw_video)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Final LAVD\n\n"
"Final LAVD\n^^^^^^^^^^\n\n"
]
},
{
Expand All @@ -163,7 +163,7 @@
},
"outputs": [],
"source": [
"lavd = RegularGridDataset.with_array(\n coordinates=(\"lon\", \"lat\"),\n datas=dict(\n lavd=lavd.T,\n lon=x_g,\n lat=y_g,\n ),\n centered=True,\n)"
"lavd = RegularGridDataset.with_array(\n coordinates=(\"lon\", \"lat\"),\n datas=dict(lavd=lavd.T, lon=x_g, lat=y_g,),\n centered=True,\n)"
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
Loading