def add_scalar_field(self, geological_feature, **kwargs): """ Parameters ---------- geological_feature : GeologicalFeature the geological feature to colour the scalar field by kwargs kwargs for lavavu Returns ------- """ name = kwargs.get('name', geological_feature.name + '_scalar_field') points, tri = create_box(self.bounding_box, self.nsteps) surf = self.lv.triangles(name) surf.vertices(self.model.rescale(points)) surf.indices(tri) val = geological_feature.evaluate_value(self.model.scale(points)) surf.values(val, geological_feature.name) surf["colourby"] = geological_feature.name cmap = kwargs.get('cmap', lavavu.cubehelix(100)) logger.info("Adding scalar field of %s to viewer. Min: %f, max: %f" % (geological_feature.name, geological_feature.min(), geological_feature.max())) vmin = kwargs.get('vmin', np.nanmin(val)) vmax = kwargs.get('vmax', np.nanmax(val)) surf.colourmap(cmap, range=(vmin, vmax))
def add_support_box(self, geological_feature, paint=False, **kwargs): name = kwargs.get('name', geological_feature.name + '_support') box = np.vstack([ geological_feature.interpolator.support.origin, geological_feature.interpolator.support.maximum ]) points, tri = create_box(box, self.nsteps) surf = self.lv.triangles(name) surf.vertices(self.model.rescale(points)) surf.indices(tri) if paint: val = geological_feature.evaluate_value(self.model.scale(points)) surf.values(val, geological_feature.name) surf["colourby"] = geological_feature.name cmap = kwargs.get('cmap', lavavu.cubehelix(100)) logger.info( "Adding scalar field of %s to viewer. Min: %f, max: %f" % (geological_feature.name, geological_feature.min(), geological_feature.max())) vmin = kwargs.get('vmin', np.nanmin(val)) vmax = kwargs.get('vmax', np.nanmax(val)) surf.colourmap(cmap, range=(vmin, vmax))
def add_section(self, geological_feature=None, axis='x', value=None, **kwargs): """ Plot a section/map thru the model and paint with a geological feature Parameters ---------- geological_feature : Geological feature The feature to paint the section with axis : string which axis, x,y,z value : float Where to make the section kwargs additional kwargs passes to lavavu for colourmaps etc Returns ------- """ print('aa') if axis == 'x': tri, yy, zz = create_surface(self.bounding_box[:, [1, 2]], self.nsteps[[1, 2]]) xx = np.zeros(zz.shape) if value is None: xx[:] = np.nanmean(self.bounding_box[:, 0]) else: xx[:] = value if axis == 'y': tri, xx, zz = create_surface(self.bounding_box[:, [0, 2]], self.nsteps[[0, 2]]) yy = np.zeros(xx.shape) if value is None: yy[:] = np.nanmean(self.bounding_box[:, 1]) else: yy[:] = value if axis == 'z': tri, xx, yy = create_surface(self.bounding_box[:, 0:2], self.nsteps[0:2]) zz = np.zeros(xx.shape) if value is None: zz[:] = np.nanmean(self.bounding_box[:, 2]) else: zz[:] = value name = kwargs.get('name', axis + '_slice') colour = kwargs.get('colour', 'red') # create an array to evaluate the feature on for the section points = np.zeros((len(xx), 3)) # points[:, 0] = xx points[:, 1] = yy points[:, 2] = zz surf = self.lv.triangles(name) surf.vertices(self.model.rescale(points, inplace=False)) surf.indices(tri) logger.info("Adding %s section at %f" % (axis, value)) if geological_feature is None: surf.colours(colour) if geological_feature is not None and type( geological_feature) == GeologicalFeature: if 'norm' in kwargs: surf.values( np.linalg.norm( geological_feature.evaluate_gradient(points), axis=1), geological_feature.name) else: surf.values(geological_feature.evaluate_value(points), geological_feature.name) surf["colourby"] = geological_feature.name cmap = lavavu.cubehelix(100) if 'cmap' in kwargs: cmap = kwargs['cmap'] logger.info("Colouring section with %s min: %f, max: %f" % (geological_feature.name, geological_feature.min(), geological_feature.max())) surf.colourmap( cmap, range=[geological_feature.min(), geological_feature.max()]) if geological_feature == 'model' and self.model is not None: name = kwargs.get('name', 'model_section') surf.values(self.model.evaluate_model(points, scale=True), name) surf["colourby"] = name cmap = lavavu.cubehelix(100) if 'cmap' in kwargs: cmap = kwargs['cmap']