def import_readymade_meso_v2_membrane(**kwargs): """ Compute bilayer midplane structures for studying undulations. Adapted from `undulations.py`. """ import ipdb ipdb.set_trace() #---parameters sn = kwargs['sn'] work = kwargs['workspace'] calc = kwargs['calc'] #---import mesh points points = import_membrane_mesh(sn=sn, calc=calc, work=work) #---ensure there are the same number of points points_shapes = list(set([p.shape for p in points])) if len(points_shapes) != 1: raise Exception('some frames have a different number of points: %s' % points_shapes) else: npoints, ncols = points_shapes[0] if ncols != 4: raise Exception('expecting 4-column input on incoming data') #---with a consistent number of points everything is an array points = np.array(points)[:, :, :3] #---previously checked that the minimum points were identically zero but this was not always true #---box vectors are just the maximum points #---! check that this assumption makes sense vecs = points.max(axis=1)[:, :3] #---debug the shapes in 3D if False: from codes import review3d fr = 0 review3d.pbcbox(vecs[fr]) review3d.review3d(points=[points[fr][:, :3]], radius=10) grid_spacing = calc['specs']['grid_spacing'] nframes = len(points) #---choose grid dimensions grid = np.array([round(i) for i in np.mean(vecs, axis=0) / grid_spacing])[:2] #---compute in parallel start = time.time() mesh = [[]] mesh[0] = Parallel(n_jobs=work.nprocs, verbose=0)( delayed(makemesh_regular, has_shareable_memory)(points[fr], vecs[fr], grid) for fr in framelooper(nframes, start=start, text='frame')) checktime() #---pack attrs, result = {}, {} result['mesh'] = np.array(mesh) result['grid'] = np.array(grid) result['nframes'] = np.array(nframes) result['vecs'] = vecs attrs['grid_spacing'] = grid_spacing #---introduce a dated validator string to ensure that any changes to the pipeline do not overwrite #---...other data and are fully propagated downstream attrs['validator'] = '2017.08.16.1930' return result, attrs
if 'review3d' in routine: import mayavi from mayavi import mlab from codes.review3d import review3d, pbcbox sn = 'mk004' dat = data[sn]['data'] mn, fr = 1, 10 pts = dat['%d.%d.%s' % (mn, fr, 'points')] vec = dat['%d.%d.%s' % (mn, fr, 'vec')] mean_curvs = dat['%d.%d.%s' % (mn, fr, 'mean')] mean_curvs_normed = mean_curvs / np.abs(mean_curvs).max() + 0.5 review3d(points=[pts], tube=0.02, radius=0.2, noshow=True, colorset=mean_curvs_normed, cmap='seismic') review3d(points=data_prot[sn]['data']['points_all'][fr], radius=0.4, noshow=True) pbcbox(vec) mlab.show() #---block: heat map of curvature from the mesh if 'curvature' in routine: #---settings spacing = 0.5 mn = 0
counts, bins = np.histogram(postdat[sn], bins=hbins) ax.plot((hbins[1:] + hbins[:-1]) / 2., counts, label=sn) legend = ax.legend() ax.axvline(0.0, c='k') picturesave('fig.undulations.height_histograms', work.plotdir, backup=False, version=True, meta={}, extras=[legend]) #---block: plot the average heights if 'debug3d' in routine: if 'review3d' not in globals(): from codes import review3d from codes.readymade_meso_v1 import import_membrane_mesh #---get the calc object data_raw, calc_raw = plotload('import_readymade_meso_v1_membrane') sns = work.sns() sn = sns[0] points = import_membrane_mesh(sn=sn, calc=calc_raw, work=work) vecs = data[sn]['data']['vecs'] fr = 0 ### review3d.pbcbox(vecs[fr]) zs = points[fr][:, 2] - points[fr][:, 2].mean() colorset = (zs - zs.min()) / (zs.max() - zs.min()) mean_zs = np.array([points[p][:, :3] for p in range(len(points))]).mean(axis=0) review3d.review3d(points=[mean_zs], radius=3.0, colorset=colorset)