Last active
August 2, 2018 13:54
-
-
Save glyg/215fd06f8c7c601ac59bacd80cf6c081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import ipyvolume as ipv | |
from tyssue import Sheet, config, SheetGeometry | |
from tyssue.draw import sheet_view | |
from tyssue.io import hdf5 | |
from pathlib import Path | |
import numpy as np | |
import pandas as pd | |
i = 0 | |
files = ''' | |
1.08_contractility_5_critical_area_10_radialtension_0015.hf5 | |
1.08_contractility_5_critical_area_10_radialtension_0073.hf5 | |
1.08_contractility_5_critical_area_20_radialtension_0011.hf5 | |
1.08_contractility_5_critical_area_20_radialtension_0068.hf5 | |
1.08_contractility_5_critical_area_30_radialtension_0011.hf5 | |
1.08_contractility_5_critical_area_30_radialtension_0074.hf5 | |
1.08_contractility_5_critical_area_40_radialtension_0009.hf5 | |
1.08_contractility_5_critical_area_40_radialtension_0074.hf5 | |
'''.strip().split('\n') | |
file = Path("/media/data/Sophie/Simulations/FichiersGuillaume_avecForce")/files[i] | |
dsets = hdf5.load_datasets(file, | |
data_names=['vert', 'edge', 'face']) | |
sheet = Sheet('ellipse', dsets) | |
SheetGeometry.update_all(sheet) | |
def view3d(sheet): | |
ipv.style.use(['dark', 'minimal']) | |
draw_spec = config.draw.sheet_spec() | |
draw_spec['edge']['visible'] = False | |
draw_spec['face']['visible'] = True | |
sheet.face_df['visible'] = sheet.face_df.z < 0 | |
draw_spec['face']['color'] = sheet.face_df.area/sheet.face_df.area.mean() | |
draw_spec['face']['colormap'] = 'Blues' | |
draw_spec['face']['color_range'] = (0, 2.5) | |
# function plotting two meshes | |
fig, meshes = sheet_view(sheet, mode='3D', coords=list('zxy'), **draw_spec) | |
fig = ipv.gcf() | |
#ipv.show() | |
central_verts = sheet.vert_df[np.abs(sheet.vert_df['z']) < 2][['x', 'y']] | |
central_verts['theta'] = np.arctan2(central_verts.y, central_verts.x) | |
ring = central_verts[['x', 'y']].loc[central_verts.sort_values('theta').index] | |
ring = ring.append(pd.DataFrame({'x':[0], 'y':[0]}), ignore_index=True) | |
ring['z'] = 2 | |
Nr = ring.shape[0] | |
triangles = np.vstack(( | |
np.full((Nr,), Nr-1, dtype=int), | |
np.arange(Nr), | |
np.roll(np.arange(Nr), -2))).T | |
fig = ipv.gcf() | |
ipv.plot_trisurf(ring.z.values, | |
ring.x.values, | |
ring.y.values, | |
triangles=triangles, color='k') | |
fig.anglex = -0.65 | |
fig.angley = 0.65 | |
fig.anglez = 2.65 | |
ipv.clear() | |
view3d(sheet) | |
ipv.xyzlim(-90, 90) | |
ipv.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment