view.lv.control.DualRange(['zmin', 'zmax'], label="z clip", step=0.01, values=[0.0, 1.0]) view.lv.control.Range(command='background', range=(0, 1), step=0.1, value=0.8) view.lv.control.show() #Show the control panel, including the viewer window for layer in surface_verts: f = open( vtk_path + model_name + '/' + layer.replace("_iso_0.000000", "") + '.obj', 'w') vert = surface_verts[layer][0].shape[0] tri = surface_verts[layer][1].shape[0] for v in range(0, vert): ostr = "v {} {} {}\n"\ .format(surface_verts[layer][0][v][0],surface_verts[layer][0][v][1],surface_verts[layer][0][v][2]) f.write(ostr) for t in range(0, tri): ostr = "f {} {} {}\n"\ .format(surface_verts[layer][1][t][0]+1,surface_verts[layer][1][t][1]+1,surface_verts[layer][1][t][2]+1) f.write(ostr) first = False f.close() t2 = time.time() print("surfaces saved as vtk and obj formats in directory", vtk_path + model_name) print("m2l", (t1 - t0) / 60.0, "LoopStructural", (t2 - t1) / 60.0, "Total", (t2 - t0) / 60.0, "minutes") view.interactive()
def loop2LoopStructural(thickness_file,orientation_file,contacts_file,bbox): from LoopStructural import GeologicalModel from LoopStructural.visualisation import LavaVuModelViewer import lavavu df = pd.read_csv(thickness_file) thickness = {} for f in df['formation'].unique(): thickness[f] = np.mean(df[df['formation']==f]['thickness']) #display(thickness) order = ['P__TKa_xs_k','P__TKo_stq','P__TKk_sf','P__TK_s', 'A_HAu_xsl_ci', 'A_HAd_kd', 'A_HAm_cib', 'A_FOj_xs_b', 'A_FO_xo_a', 'A_FO_od', 'A_FOu_bbo', 'A_FOp_bs', 'A_FOo_bbo', 'A_FOh_xs_f', 'A_FOr_b'] strat_val = {} val = 0 for o in order: if o in thickness: strat_val[o] = val val+=thickness[o] #display(strat_val) orientations = pd.read_csv(orientation_file) contacts = pd.read_csv(contacts_file) contacts['val'] = np.nan for o in strat_val: contacts.loc[contacts['formation']==o,'val'] = strat_val[o] data = pd.concat([orientations,contacts],sort=False) data['type'] = np.nan for o in order: data.loc[data['formation']==o,'type'] = 's0' data boundary_points = np.zeros((2,3)) boundary_points[0,0] = bbox[0] boundary_points[0,1] = bbox[1] boundary_points[0,2] = -20000 boundary_points[1,0] = bbox[2] boundary_points[1,1] = bbox[3] boundary_points[1,2] = 1200 model = GeologicalModel(boundary_points[0,:],boundary_points[1,:]) model.set_model_data(data) strati = model.create_and_add_foliation('s0', #identifier in data frame interpolatortype="FDI", #which interpolator to use nelements=400000, # how many tetras/voxels buffer=0.1, # how much to extend nterpolation around box solver='external', external=solve_pyamg ) #viewer = LavaVuModelViewer() viewer = LavaVuModelViewer(model) viewer.add_data(strati['feature']) viewer.add_isosurface(strati['feature'], # nslices=10, slices= strat_val.values(), # voxet={'bounding_box':boundary_points,'nsteps':(100,100,50)}, paint_with=strati['feature'], cmap='tab20' ) #viewer.add_scalar_field(model.bounding_box,(100,100,100), # 'scalar', ## norm=True, # paint_with=strati['feature'], # cmap='tab20') viewer.add_scalar_field(strati['feature']) viewer.set_viewer_rotation([-53.8190803527832, -17.1993350982666, -2.1576387882232666]) #viewer.save("fdi_surfaces.png") viewer.interactive()
model.set_model_data(data[data['random'] < 0.01])#[np.isnan(data['val'])]) strati = model.create_and_add_foliation("strati", interpolatortype="surfe", method='single_surface' ) print(strati.evaluate_value(model.regular_grid((10,10,10)))) viewer = LavaVuModelViewer(model,background="white") # determine the number of unique surfaces in the model from # the input data and then calculate isosurfaces for this unique = np.unique(strati.interpolator.get_value_constraints()[:,3]) viewer.add_isosurface(model.features[0], slices=unique, cmap='prism', paint_with=model.features[0]) # # # viewer.add_section(model.features[0], # # axis='x', # # value=0, # # boundary_points=model.bounding_box, # # nsteps=np.array([30,30,30]), # # voxet=model.voxet(), # # cmap='prism') # viewer.add_scalar_field(model.features[0], # cmap='prism') # # Add the data addgrad/addvalue arguments are optional # viewer.add_data(model.features[0],addgrad=True,addvalue=True, cmap='prism') # viewer.lv.rotate([-85.18760681152344, 42.93233871459961, 0.8641873002052307]) viewer.interactive()# to add an interactive display