Commit 66355c11 authored by Félix Hartmann's avatar Félix Hartmann
Browse files

Adding a 'mean curvature' plot to the 'Time series' window.

parent d667ba64
......@@ -1402,22 +1402,17 @@ def show_time_series(tige_id=None):
tige_hdf_id = get_hdf5_tigeid(hdf5file, cur_tige)
# Retrieving useful data as time-indexed arrays
radii = tiges_data.diam[cur_tige].mean(axis=1) / 2 # space-averaged tige radii
x, y, s, lengths, angles, tip_angles, measure_zone, lines = \
x, y, s, lengths, angles, tip_angles, dummy, lines = \
load_postprocessed_data(hdf5file, tige_hdf_id)
# Create the figure with the tige name
tige_name = h5store.get_tiges_names(hdf5file, tige_hdf_id)
fig_time = mpl.figure(strings["Organ"] + ' %s'%str(tige_name), figsize=(10, 6))
# grid = mpl.GridSpec(4, 3, wspace=.4, hspace=.4)
grid = mpl.GridSpec(6, 3)
# Space-average radii along the organ to have mean radii over time
radii = tiges_data.diam[cur_tige].mean(axis=1) / 2
# Scaling
length_unit = "pix"
length_unit, inv_length_unit = "pix", r"pix$^{-1}$"
scale_cmpix = h5store.get_pixelscale(hdf5file)
if scale_cmpix is not None:
length_unit = "cm"
length_unit, inv_length_unit = "cm", r"cm$^{-1}$"
x *= scale_cmpix
y *= scale_cmpix
s *= scale_cmpix
......@@ -1435,11 +1430,26 @@ def show_time_series(tige_id=None):
if excluded_image is not None: # steady-state image excluded from time series
times = times[mask]
lengths = lengths[mask]
radii = radii[mask]
s = s[mask]
angles = angles[mask]
radii = radii[mask]
tip_angles = tip_angles[mask]
lines = lines[mask]
W = compute_moving_window_size(tiges_data, cur_tige, hdf5file, mask=mask)
# Get curvatures along the organ as 2-D spatio-temporal array
curvatures_st = get_tige_curvatures(
angles, s, angle_smoothing=True, window_width=W)
# Space-average curvatures along the organ to have mean radii over time
curvatures_t = curvatures_st.mean(axis=1)
# Create the figure with the tige name
tige_name = h5store.get_tiges_names(hdf5file, tige_hdf_id)
fig_time = mpl.figure(strings["Organ"] + ' %s'%str(tige_name), figsize=(10, 6))
grid = mpl.GridSpec(8, 3)
# Subplot with tige profiles
axProfiles = fig_time.add_subplot(grid[:,0])
lcollec = LineCollection(lines, linewidth=(2,), cmap='viridis')
......@@ -1474,10 +1484,16 @@ def show_time_series(tige_id=None):
axRadius = fig_time.add_subplot(grid[4:6, 1:], sharex=axAngle)
axRadius.grid(True)
axRadius.xaxis.set_major_locator(MultipleLocator(graduation))
axRadius.set_xlabel(time_label)
axRadius.set_ylabel(strings["radius"] + " (%s)"%length_unit)
axRadius.set_ylabel(_("mean radius") + " (%s)"%length_unit)
axRadius.plot(times, radii, '+-', color=tiges_colors[cur_tige], lw=2)
axCurvature = fig_time.add_subplot(grid[6:8, 1:], sharex=axAngle)
axCurvature.grid(True)
axCurvature.xaxis.set_major_locator(MultipleLocator(graduation))
axCurvature.set_xlabel(time_label)
axCurvature.set_ylabel(_("mean curvature") + " (%s)"%inv_length_unit)
axCurvature.plot(times, curvatures_t, '+-', color=tiges_colors[cur_tige], lw=2)
if excluded_image == cur_image:
# If the steady-state image has to be excluded from time series and is the current
# image, just create empty Line2D.
......@@ -1499,12 +1515,15 @@ def show_time_series(tige_id=None):
'k--', lw=1.5)
time_select_radius, = axRadius.plot([cur_time, cur_time], axRadius.get_ylim(),
'k--', lw=1.5)
time_select_curvature, = axCurvature.plot(
[cur_time, cur_time], axCurvature.get_ylim(), 'k--', lw=1.5)
def on_press(event):
if event.xdata is not None and (axAngle.contains(event)[0]
or axLength.contains(event)[0]
or axRadius.contains(event)[0]):
or axRadius.contains(event)[0]
or axCurvature.contains(event)[0]):
# image closest to clicked point
image = ((times - event.xdata)**2).argmin()
......@@ -1518,6 +1537,7 @@ def show_time_series(tige_id=None):
time_select_angle.set_xdata([times[image], times[image]])
time_select_length.set_xdata([times[image], times[image]])
time_select_radius.set_xdata([times[image], times[image]])
time_select_curvature.set_xdata([times[image], times[image]])
# redraw figure
fig_time.canvas.draw()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment