Example #1
0
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()
Example #2
0
def test_intrusion_builder():

    model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
    model.data = data
    model.nsteps = [10, 10, 10]

    intrusion_data = data[data['feature_name'] == 'tabular_intrusion']
    frame_data = model.data[model.data["feature_name"] ==
                            'tabular_intrusion_frame'].copy()

    conformable_feature = model.create_and_add_foliation('stratigraphy')

    intrusion_network_parameters = {'type': 'interpolated', 'contact': 'roof'}
    interpolator = model.get_interpolator(interpolatortype='FDI')

    intrusion_frame_builder = IntrusionFrameBuilder(
        interpolator, name='tabular_intrusion_frame', model=model)

    # -- create intrusion network

    intrusion_frame_builder.set_intrusion_network_parameters(
        intrusion_data, intrusion_network_parameters)
    intrusion_network_geometry = intrusion_frame_builder.create_intrusion_network(
    )

    # -- create intrusion frame using intrusion network points and flow/inflation measurements
    intrusion_frame_builder.set_intrusion_frame_data(
        frame_data, intrusion_network_geometry)

    ## -- create intrusion frame
    intrusion_frame_builder.setup()
    intrusion_frame = intrusion_frame_builder.frame

    # -- create intrusion builder to simulate distance thresholds along frame coordinates
    intrusion_builder = IntrusionBuilder(intrusion_frame,
                                         model=model,
                                         name="tabular intrusion")
    intrusion_builder.lateral_extent_model = rectangle_function  #intrusion_lateral_extent_model
    intrusion_builder.vertical_extent_model = parallelepiped_function  #intrusion_vertical_extent_model

    intrusion_builder.set_data_for_extent_simulation(intrusion_data)
    intrusion_builder.build_arguments = {
        "lateral_extent_sgs_parameters": {},
        "vertical_extent_sgs_parameters": {}
    }

    intrusion_feature = intrusion_builder.feature
    intrusion_builder.update()

    assert len(intrusion_feature._lateral_simulated_thresholds) > 0
    assert len(intrusion_feature._growth_simulated_thresholds) > 0
Example #3
0
def test_create_and_add_fault():
    model = GeologicalModel([0, 0, 0], [1, 1, 1])
    data = pd.DataFrame(
        [
            [0.5, 0.5, 0.5, 0, 1, 0, 0, "fault", 0],
            # [0.5, 0.5, 0.5, 0, 1, 0, 0, "fault", 0],

            [0.5, 0.5, 0.5, 1, 0, 0, 1, "fault", 0],
            [0.5, 0.5, 0.5, 0, 0, 1, 2, "fault", 0],
        ],
        columns=["X", "Y", "Z", "nx", "ny", "nz", "coord", "feature_name", "val"],
    )
    model.data = data
    model.create_and_add_fault(
        "fault",
        1,
        nelements=1e4,
        # force_mesh_geometry=True
    )
    assert isinstance(model["fault"], FaultSegment)
Example #4
0
images = {}
for v in [1, 5, 1 / 5]:
    v_data = np.zeros((1, 4))
    v_data[0, :3] += 0.1
    data = pd.DataFrame(v_data, columns=["X", "Y", "Z", "val"])
    data["feature_name"] = "test"
    data["feature_name"] = "test"
    data["nx"] = np.nan
    data["ny"] = np.nan
    data["nz"] = np.nan
    data.loc[3, :] = [0, 0, 0, np.nan, "test", v, 0, 0]
    # data.loc[3,['nx','ny','nz']]/=np.linalg.norm(data.loc[3,['nx','ny','nz']])
    # data.loc[4,:] = [0,0,1,np.nan,'test',1,0,0]
    model = GeologicalModel(np.zeros(3), np.ones(3) * 10)
    model.data = data
    model.create_and_add_foliation("test",
                                   nelements=1e4,
                                   interpolatortype="FDI")
    view = LavaVuModelViewer(model)
    view.add_isosurface(model["test"], slices=[0, 1], name="test")
    view.add_data(model["test"])
    view.rotate([-92.68915557861328, 2.879497528076172, 1.5840799808502197])
    view.xmin = 0
    view.ymin = 0
    view.zmin = 0
    view.xmax = 10
    view.ymax = 10
    view.zmax = 10
    images[v] = view.image_array()
fig, ax = plt.subplots(1, 3, figsize=(30, 10))
    stratigraphic_order=order,
    origin=origin,
    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
# ~~~~~~~~~~~~~
Example #6
0
def test_intrusion_freame_builder():
    model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
    model.data = data
    model.nsteps = [10, 10, 10]

    intrusion_data = data[data['feature_name'] == 'tabular_intrusion']
    frame_data = model.data[model.data["feature_name"] ==
                            'tabular_intrusion_frame'].copy()

    conformable_feature = model.create_and_add_foliation('stratigraphy')

    intrusion_network_parameters = {
        'type': 'shortest path',
        'contact': 'roof',
        'delta_c': [2],
        'contact_anisotropies': [conformable_feature],
        'shortest_path_sequence': [conformable_feature],
        'shortest_path_axis': 'X'
    }
    delta_c = intrusion_network_parameters.get('delta_c')[0]
    # -- get variables for intrusion frame interpolation
    interpolatortype = "FDI"
    nelements = 1e2
    weights = [0, 0, 0]
    interpolator = model.get_interpolator(interpolatortype=interpolatortype)

    intrusion_frame_builder = IntrusionFrameBuilder(
        interpolator, name='tabular_intrusion_frame', model=model)

    # -- create intrusion network

    intrusion_frame_builder.set_intrusion_network_parameters(
        intrusion_data, intrusion_network_parameters)
    intrusion_network_geometry = intrusion_frame_builder.create_intrusion_network(
    )

    keys = list(intrusion_frame_builder.anisotropies_series_parameters.keys())
    # #test if points lie in the contact of interest
    mean = intrusion_frame_builder.anisotropies_series_parameters[keys[0]][1]
    # mean = -10
    stdv = intrusion_frame_builder.anisotropies_series_parameters[keys[0]][2]
    evaluated_inet_points = conformable_feature.evaluate_value(
        model.scale(intrusion_network_geometry[:, :3]))

    assert np.all(
        np.logical_and((mean - stdv * delta_c) <= evaluated_inet_points,
                       (mean + stdv * delta_c) >= evaluated_inet_points))

    # -- create intrusion frame using intrusion network points and flow/inflation measurements
    intrusion_frame_builder.set_intrusion_frame_data(
        frame_data, intrusion_network_geometry)

    ## -- create intrusion frame
    intrusion_frame_builder.setup(
        nelements=nelements,
        w2=weights[0],
        w1=weights[1],
        gxygz=weights[2],
    )

    intrusion_frame = intrusion_frame_builder.frame

    assert isinstance(intrusion_frame, StructuralFrame)