Example 8 - Faulted Layers#

This example will show how to convert the geological map below using GemGIS to a GemPy model. This example is based on digitized data. The area is 2957 m wide (W-E extent) and 3715 m high (N-S extent). The vertical extent varies between 0 m and 1250 m. The model represents three faulted layers, red and yellow above a green basement. The map has been georeferenced with QGIS. The stratigraphic boundaries were digitized in QGIS. Strikes lines were digitized in QGIS as well and will be used to calculate orientations for the GemPy model. The contour lines were also digitized and will be interpolated with GemGIS to create a topography for the model.

Map Source: An Introduction to Geological Structures and Maps by G.M. Bennison

[1]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/cover_example08.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example08_2_0.png

Licensing#

Computational Geosciences and Reservoir Engineering, RWTH Aachen University, Authors: Alexander Juestel. For more information contact: alexander.juestel(at)rwth-aachen.de

This work is licensed under a Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/)

Import GemGIS#

If you have installed GemGIS via pip or conda, you can import GemGIS like any other package. If you have downloaded the repository, append the path to the directory where the GemGIS repository is stored and then import GemGIS.

[2]:
import warnings
warnings.filterwarnings("ignore")
import gemgis as gg

Importing Libraries and loading Data#

All remaining packages can be loaded in order to prepare the data and to construct the model. The example data is downloaded from an external server using pooch. It will be stored in a data folder in the same directory where this notebook is stored.

[3]:
import geopandas as gpd
import rasterio
[4]:
file_path = 'data/example08/'
gg.download_gemgis_data.download_tutorial_data(filename="example08_faulted_layers.zip", dirpath=file_path)
Downloading file 'example08_faulted_layers.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2Fexample08_faulted_layers.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\example\data\example08'.

Creating Digital Elevation Model from Contour Lines#

The digital elevation model (DEM) will be created by interpolating contour lines digitized from the georeferenced map using the SciPy Radial Basis Function interpolation wrapped in GemGIS. The respective function used for that is gg.vector.interpolate_raster().

[5]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/dem_example08.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example08_10_0.png
[6]:
topo = gpd.read_file(file_path + 'topo8.shp')
topo.head()
[6]:
id Z geometry
0 None 800 LINESTRING (8.360 333.390, 94.504 303.527, 184...
1 None 700 LINESTRING (2954.497 1855.274, 2918.891 1755.3...
2 None 900 LINESTRING (3.765 3486.274, 124.368 3510.394, ...
3 None 800 LINESTRING (3.191 3280.676, 105.416 3314.559, ...
4 None 700 LINESTRING (3.191 2934.376, 53.729 2986.062, 1...

Interpolating the contour lines#

[7]:
topo_raster = gg.vector.interpolate_raster(gdf=topo, value='Z', method='rbf', res=10)

Plotting the raster#

[8]:
import matplotlib.pyplot as plt

fix, ax = plt.subplots(1, figsize=(10, 10))
topo.plot(ax=ax, aspect='equal', column='Z', cmap='gist_earth')
im = plt.imshow(topo_raster, origin='lower', extent=[0, 2957, 0, 3715], cmap='gist_earth')
cbar = plt.colorbar(im)
cbar.set_label('Altitude [m]')
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2957)
ax.set_ylim(0, 3715)
[8]:
(0.0, 3715.0)
../../_images/getting_started_example_example08_15_1.png

Saving the raster to disc#

After the interpolation of the contour lines, the raster is saved to disc using gg.raster.save_as_tiff(). The function will not be executed as a raster is already provided with the example data.

gg.raster.save_as_tiff(raster=topo_raster, path=file_path + 'raster8.tif', extent=[0, 2957, 0, 3715], crs='EPSG:4326', overwrite_file=True)

Opening Raster#

The previously computed and saved raster can now be opened using rasterio.

[9]:
topo_raster = rasterio.open(file_path + 'raster8.tif')

Interface Points of stratigraphic boundaries#

The interface points will be extracted from LineStrings digitized from the georeferenced map using QGIS. It is important to provide a formation name for each layer boundary. The vertical position of the interface point will be extracted from the digital elevation model using the GemGIS function gg.vector.extract_xyz(). The resulting GeoDataFrame now contains single points including the information about the respective formation.

[10]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/interfaces_example08.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example08_21_0.png
[11]:
interfaces = gpd.read_file(file_path + 'interfaces8.shp')
interfaces.head()
[11]:
id formation geometry
0 None C LINESTRING (1714.018 3708.526, 1663.480 3610.8...
1 None B LINESTRING (1352.212 3709.675, 1318.903 3630.4...
2 None C LINESTRING (2089.608 876.100, 2059.744 795.698...
3 None B LINESTRING (1757.665 920.895, 1725.504 829.007...
4 None F1 LINESTRING (8.360 1153.485, 131.259 1129.364, ...

Extracting Z coordinate from Digital Elevation Model#

[12]:
interfaces_coords = gg.vector.extract_xyz(gdf=interfaces, dem=topo_raster)
interfaces_coords = interfaces_coords.sort_values(by='formation', ascending=False)
interfaces_coords.head()
[12]:
formation geometry X Y Z
113 F1 POINT (2953.348 1017.951) 2953.35 1017.95 745.77
101 F1 POINT (1681.858 944.441) 1681.86 944.44 567.06
90 F1 POINT (8.360 1153.485) 8.36 1153.48 1003.28
91 F1 POINT (131.259 1129.364) 131.26 1129.36 968.30
92 F1 POINT (265.644 1098.352) 265.64 1098.35 909.05

Plotting the Interface Points#

[13]:
fig, ax = plt.subplots(1, figsize=(10, 10))

interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')
interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')
plt.grid()
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2957)
ax.set_ylim(0, 3715)
[13]:
(0.0, 3715.0)
../../_images/getting_started_example_example08_26_1.png

Orientations from Strike Lines#

Strike lines connect outcropping stratigraphic boundaries (interfaces) of the same altitude. In other words: the intersections between topographic contours and stratigraphic boundaries at the surface. The height difference and the horizontal difference between two digitized lines is used to calculate the dip and azimuth and hence an orientation that is necessary for GemPy. In order to calculate the orientations, each set of strikes lines/LineStrings for one formation must be given an id number next to the altitude of the strike line. The id field is already predefined in QGIS. The strike line with the lowest altitude gets the id number 1, the strike line with the highest altitude the the number according to the number of digitized strike lines. It is currently recommended to use one set of strike lines for each structural element of one formation as illustrated.

[14]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/orientations_example08.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example08_28_0.png
[15]:
strikes = gpd.read_file(file_path + 'strikes8.shp')
strikes.head()
[15]:
id formation Z geometry
0 1 B1 500 LINESTRING (1645.103 652.699, 1651.420 479.261)
1 1 C1 500 LINESTRING (2151.632 301.230, 2144.740 877.823)
2 1 C 600 LINESTRING (1148.337 2886.709, 1154.654 2403.152)
3 2 C 700 LINESTRING (1390.115 3204.869, 1390.690 2132.659)
4 1 B 600 LINESTRING (654.443 2938.970, 658.463 2486.999)

Calculate Orientations for each formation#

[16]:
orientations_f1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'F1'].sort_values(by='Z', ascending=True).reset_index())
orientations_f1
[16]:
dip azimuth Z geometry polarity formation X Y
0 64.17 180.06 550.00 POINT (2142.443 936.831) 1.00 F1 2142.44 936.83
1 65.03 180.15 650.00 POINT (2034.906 985.072) 1.00 F1 2034.91 985.07
2 65.86 180.16 750.00 POINT (1907.556 1031.877) 1.00 F1 1907.56 1031.88
3 70.31 180.05 850.00 POINT (1732.539 1074.232) 1.00 F1 1732.54 1074.23
4 66.70 180.12 950.00 POINT (1559.676 1118.740) 1.00 F1 1559.68 1118.74
[17]:
orientations_c = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'C'].sort_values(by='Z', ascending=True).reset_index())
orientations_c
[17]:
dip azimuth Z geometry polarity formation X Y
0 22.97 269.85 650.00 POINT (1270.949 2656.847) 1.00 C 1270.95 2656.85
[18]:
orientations_c1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'C1'].sort_values(by='Z', ascending=True).reset_index())
orientations_c1
[18]:
dip azimuth Z geometry polarity formation X Y
0 23.26 269.27 550.00 POINT (2265.629 516.591) 1.00 C1 2265.63 516.59
[19]:
orientations_b = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B'].sort_values(by='Z', ascending=True).reset_index())
orientations_b
[19]:
dip azimuth Z geometry polarity formation X Y
0 22.35 269.26 650.00 POINT (778.778 2702.073) 1.00 B 778.78 2702.07
1 22.74 269.74 750.00 POINT (1023.571 2506.812) 1.00 B 1023.57 2506.81
[20]:
orientations_b1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B1'].sort_values(by='Z', ascending=True).reset_index())
orientations_b1
[20]:
dip azimuth Z geometry polarity formation X Y
0 22.32 269.37 550.00 POINT (1771.304 559.376) 1.00 B1 1771.30 559.38

Merging Orientations#

[21]:
import pandas as pd
orientations = pd.concat([orientations_f1, orientations_c, orientations_c1, orientations_b, orientations_b1]).reset_index()
orientations['formation'] = ['F1', 'F1', 'F1', 'F1', 'F1', 'C', 'C', 'B', 'B', 'B']
orientations = orientations[orientations['formation'].isin(['F1', 'C', 'B'])]
orientations
[21]:
index dip azimuth Z geometry polarity formation X Y
0 0 64.17 180.06 550.00 POINT (2142.443 936.831) 1.00 F1 2142.44 936.83
1 1 65.03 180.15 650.00 POINT (2034.906 985.072) 1.00 F1 2034.91 985.07
2 2 65.86 180.16 750.00 POINT (1907.556 1031.877) 1.00 F1 1907.56 1031.88
3 3 70.31 180.05 850.00 POINT (1732.539 1074.232) 1.00 F1 1732.54 1074.23
4 4 66.70 180.12 950.00 POINT (1559.676 1118.740) 1.00 F1 1559.68 1118.74
5 0 22.97 269.85 650.00 POINT (1270.949 2656.847) 1.00 C 1270.95 2656.85
6 0 23.26 269.27 550.00 POINT (2265.629 516.591) 1.00 C 2265.63 516.59
7 0 22.35 269.26 650.00 POINT (778.778 2702.073) 1.00 B 778.78 2702.07
8 1 22.74 269.74 750.00 POINT (1023.571 2506.812) 1.00 B 1023.57 2506.81
9 0 22.32 269.37 550.00 POINT (1771.304 559.376) 1.00 B 1771.30 559.38

Plotting the Orientations#

[22]:
fig, ax = plt.subplots(1, figsize=(10, 10))

interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')
interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')
orientations.plot(ax=ax, color='red', aspect='equal')
plt.grid()
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2957)
ax.set_ylim(0, 3715)
[22]:
(0.0, 3715.0)
../../_images/getting_started_example_example08_39_1.png

GemPy Model Construction#

The structural geological model will be constructed using the GemPy package.

[23]:
import gempy as gp
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

Creating new Model#

[24]:
geo_model = gp.create_model('Model8')
geo_model
[24]:
Model8  2022-04-05 09:57

Initiate Data#

[25]:
gp.init_data(geo_model, [0, 2957, 0, 3715, 0, 1250], [100, 100, 100],
             surface_points_df=interfaces_coords[interfaces_coords['Z'] != 0],
             orientations_df=orientations,
             default_values=True)
Active grids: ['regular']
[25]:
Model8  2022-04-05 09:57

Model Surfaces#

[26]:
geo_model.surfaces
[26]:
surface series order_surfaces color id
0 F1 Default series 1 #015482 1
1 C Default series 2 #9f0052 2
2 B Default series 3 #ffbe00 3

Mapping the Stack to Surfaces#

[27]:
gp.map_stack_to_surfaces(geo_model,
                         {
                          'Fault1': ('F1'),
                          'Strata1': ('C', 'B'),
                         },
                         remove_unused_series=True)
geo_model.add_surfaces('A')
geo_model.set_is_fault(['Fault1'])
Fault colors changed. If you do not like this behavior, set change_color to False.
[27]:
order_series BottomRelation isActive isFault isFinite
Fault1 1 Fault True True False
Strata1 2 Erosion True False False

Showing the Number of Data Points#

[28]:
gg.utils.show_number_of_data_points(geo_model=geo_model)
[28]:
surface series order_surfaces color id No. of Interfaces No. of Orientations
0 F1 Fault1 1 #527682 1 24 5
1 C Strata1 1 #9f0052 2 43 2
2 B Strata1 2 #ffbe00 3 47 3
3 A Strata1 3 #728f02 4 0 0

Loading Digital Elevation Model#

[29]:
geo_model.set_topography(
    source='gdal', filepath=file_path + 'raster8.tif')
Cropped raster to geo_model.grid.extent.
depending on the size of the raster, this can take a while...
storing converted file...
Active grids: ['regular' 'topography']
[29]:
Grid Object. Values:
array([[  14.785     ,   18.575     ,    6.25      ],
       [  14.785     ,   18.575     ,   18.75      ],
       [  14.785     ,   18.575     ,   31.25      ],
       ...,
       [2952.00506757, 3690.03360215,  931.20074463],
       [2952.00506757, 3700.02016129,  933.94940186],
       [2952.00506757, 3710.00672043,  936.69573975]])

Plotting Input Data#

[30]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
../../_images/getting_started_example_example08_55_0.png
[31]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
../../_images/getting_started_example_example08_56_0.png
[31]:
<gempy.plot.vista.GemPyToVista at 0x26187de3df0>

Setting the Interpolator#

[32]:
gp.set_interpolator(geo_model,
                    compile_theano=True,
                    theano_optimizer='fast_compile',
                    verbose=[],
                    update_kriging=False
                    )
Compiling theano function...
Level of Optimization:  fast_compile
Device:  cpu
Precision:  float64
Number of faults:  1
Compilation Done!
Kriging values:
                    values
range             4909.95
$C_o$           573989.86
drift equations    [3, 3]
[32]:
<gempy.core.interpolator.InterpolatorModel at 0x26186170bb0>

Computing Model#

[33]:
sol = gp.compute_model(geo_model, compute_mesh=True)

Plotting Cross Sections#

[34]:
gp.plot_2d(geo_model, direction=['x', 'x', 'y', 'y'], cell_number=[25, 75, 25, 75], show_topography=True, show_data=False)
[34]:
<gempy.plot.visualization_2d.Plot2D at 0x261896b5c40>
../../_images/getting_started_example_example08_62_1.png

Plotting 3D Model#

[35]:
gpv = gp.plot_3d(geo_model, image=False, show_topography=True,
                 plotter_type='basic', notebook=True, show_lith=True)
../../_images/getting_started_example_example08_64_0.png
[ ]: