def test_outside_box_normal(): for interpolator in ['PLI', 'FDI']: print(f'Running test for {interpolator} with normal constraints') model = GeologicalModel(np.zeros(3), np.ones(3)) data = pd.DataFrame( [[0.5, 0.5, 0.5, 0, 1., 0., 'strati'], [1.5, 0.5, 0.5, 0, 1., 0., 'strati'], [0.5, 1.5, 1.5, 0, 1., 0., 'strati']], columns=['X', 'Y', 'Z', 'nx', 'ny', 'nz', 'feature_name']) model.data = data model.create_and_add_foliation('strati', interpolatortype=interpolator) model.update()
def build_model(m2l_data, evaluate=True, skip_faults=False, unconformities=False, fault_params=None, foliation_params=None, rescale=True, skip_features=[], **kwargs): """[summary] [extended_summary] Parameters ---------- m2l_data : dict [description] skip_faults : bool, optional [description], by default False fault_params : dict, optional [description], by default None foliation_params : dict, optional [description], by default None Returns ------- [type] [description] """ from LoopStructural import GeologicalModel boundary_points = np.zeros((2, 3)) boundary_points[0, 0] = m2l_data["bounding_box"]["minx"] boundary_points[0, 1] = m2l_data["bounding_box"]["miny"] boundary_points[0, 2] = m2l_data["bounding_box"]["lower"] boundary_points[1, 0] = m2l_data["bounding_box"]["maxx"] boundary_points[1, 1] = m2l_data["bounding_box"]["maxy"] boundary_points[1, 2] = m2l_data["bounding_box"]["upper"] model = GeologicalModel(boundary_points[0, :], boundary_points[1, :], rescale=rescale) # m2l_data['data']['val'] /= model.scale_factor model.set_model_data(m2l_data["data"]) if not skip_faults: faults = [] for f in m2l_data["max_displacement"].keys(): if model.data[model.data["feature_name"] == f].shape[0] == 0: continue if f in skip_features: continue fault_id = f overprints = [] try: overprint_id = m2l_data["fault_fault"][ m2l_data["fault_fault"][fault_id] == 1]["fault_id"].to_numpy() for i in overprint_id: overprints.append(i) logger.info("Adding fault overprints {}".format(f)) except: logger.info("No entry for %s in fault_fault_relations" % f) # continue fault_center = m2l_data["stratigraphic_column"]["faults"][f][ "FaultCenter"] fault_influence = m2l_data["stratigraphic_column"]["faults"][f][ "InfluenceDistance"] fault_extent = m2l_data["stratigraphic_column"]["faults"][f][ "HorizontalRadius"] fault_vertical_radius = m2l_data["stratigraphic_column"]["faults"][ f]["VerticalRadius"] fault_slip_vector = m2l_data["stratigraphic_column"]["faults"][f][ "FaultSlip"] faults.append( model.create_and_add_fault( f, -m2l_data["max_displacement"][f], faultfunction="BaseFault", fault_slip_vector=fault_slip_vector, fault_center=fault_center, fault_extent=fault_extent, fault_influence=fault_influence, fault_vectical_radius=fault_vertical_radius, # overprints=overprints, **fault_params, )) # for f in m2l_data['fault_intersection_angles']: # if f in m2l_data['max_displacement'].keys(): # f1_norm = m2l_data['stratigraphic_column']['faults'][f]['FaultNorm'] # for intersection in m2l_data['fault_intersection_angles'][f]: # if intersection[0] in m2l_data['max_displacement'].keys(): # f2_norm = m2l_data['stratigraphic_column']['faults'][intersection[0]]['FaultNorm'] # if intersection[2] < 30 and np.dot(f1_norm,f2_norm)>0: # logger.info('Adding splay {} to {}'.format(intersection[0],f)) # if model[f] is None: # logger.error('Fault {} does not exist, cannot be added as splay') # elif model[intersection[0]] is None: # logger.error('Fault {} does not exist') # else: # model[intersection[0]].builder.add_splay(model[f]) # else: # logger.info('Adding abut {} to {}'.format(intersection[0],f)) # model[intersection[0]].add_abutting_fault(model[f]) faults = m2l_data.get("fault_graph", None) if faults: for f in faults.nodes: f1_norm = m2l_data["stratigraphic_column"]["faults"][f][ "FaultNorm"] for e in faults.edges(f): data = faults.get_edge_data(*e) f2_norm = m2l_data["stratigraphic_column"]["faults"][ e[1]]["FaultNorm"] if float(data["angle"]) < 30 and np.dot(f1_norm, f2_norm) > 0: if model[f] is None or model[e[1]] is None: logger.error( "Fault {} does not exist, cannot be added as splay" ) elif model[e[1]] is None: logger.error("Fault {} does not exist") else: region = model[e[1]].builder.add_splay(model[f]) model[e[1]].splay[model[f].name] = region else: if model[f] is None or model[e[1]] is None: continue logger.info("Adding abut {} to {}".format(e[1], f)) model[e[1]].add_abutting_fault(model[f]) ## loop through all of the groups and add them to the model in youngest to oldest. group_features = [] for i in np.sort(m2l_data["groups"]["group number"].unique()): g = (m2l_data["groups"].loc[m2l_data["groups"]["group number"] == i, "group"].unique()[0]) group_features.append( model.create_and_add_foliation(g, **foliation_params)) # if the group was successfully added (not null) then lets add the base (0 to be unconformity) if group_features[-1] and unconformities: model.add_unconformity(group_features[-1], 0) model.set_stratigraphic_column(m2l_data["stratigraphic_column"]) if evaluate: model.update(verbose=True) return model
maximum=maximum, ) ############################## # The process input data can be used to directly build a geological model model = GeologicalModel.from_processor(processor) model.update() ############################## # Or build directly from the dataframe and processor attributes. model2 = GeologicalModel(processor.origin, processor.maximum) model2.data = processor.data model2.create_and_add_foliation("supergroup_0") model2.update() ############################## # Visualising model # ~~~~~~~~~~~~~~~~~ view = LavaVuModelViewer(model) view.add_model_surfaces() view.rotation = [-37.965614318847656, 13.706363677978516, 3.110347032546997] view.display() ############################## # Adding faults # ~~~~~~~~~~~~~ fault_orientations
viewer.display() displacement = 400 #INSERT YOUR DISPLACEMENT NUMBER HERE BEFORE # model = GeologicalModel(bb[0, :], bb[1, :]) model.set_model_data(data) fault = model.create_and_add_fault('fault', displacement, nelements=2000, steps=4, interpolatortype='PLI', buffer=2) strati = model.create_and_add_foliation('strati', nelements=30000, interpolatortype='PLI', cgw=0.03) model.update() viewer = LavaVuModelViewer(model) viewer.add_isosurface(strati, isovalue=0) # viewer.add_data(model.features[0][0]) viewer.add_data(strati) viewer.add_isosurface(fault, isovalue=0 # slices=[0,1]#nslices=10 ) viewer.add_points( model.data[model.data['feature_name'] == 'strati'][['X', 'Y', 'Z']], name='prefault') viewer.rotation = [-73.24819946289062, -86.82220458984375, -13.912878036499023] viewer.display()