# -*- coding: utf-8 -*-
"""
===============================================================================
Copyright © 2021 Kouadio K.Laurent
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
===============================================================================
.. _module-Structural::`pycsamt.geodrill.geoCore.structural`
:synopsis:class for geological structural analysis
contains some conventional structure can populate the data
Created on Sat Nov 28 21:19:13 2020
@author: @Daniel03
"""
import os, warnings
import numpy as np
from pycsamt.ff.processing.callffunc import set_stratum_on_dict as strato
from pycsamt.utils import exceptions as CSex
from pycsamt.utils._csamtpylog import csamtpylog
_logger=csamtpylog.get_csamtpy_logger(__name__)
#---- End import modules --------
[docs]class geo_pattern:
"""
Singleton class to deal with geopattern with other modules. It is and exhaustive pattern
dict, can be add and change. This pattern will be depreacted later , to create for pyCSAMT,
its owwn geological pattern in coformity with the conventional geological swatches .
deal with USGS(US Geological Survey ) swatches- references and FGDC (Digital cartographic
Standard for Geological Map Symbolisation -FGDCgeostdTM11A2_A-37-01cs2.eps)
make _pattern:{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
/ - diagonal hatching
\ - back diagonal
| - vertical
- - horizontal
+ - crossed
x - crossed diagonal
o - small circle
O - large circle
. - dots
* - stars
"""
pattern={
"basement rocks" : ['.+++++.', (.25, .5, .5)],
"igneous rocks": ['.o.o.', (1., 1., 1.)],
"duricrust" : ['+.+',(1., .2, .36)],
"gravel" : ['oO',(.75,.86,.12)],
"sand": ['....',(.23, .36, .45)],
"conglomerate" : ['.O.', (.55, 0., .36)],
"dolomite" : ['.-.', (0., .75, .23)],
"limestone" : ['//.',(.52, .23, .125)],
"permafrost" : ['o.', (.2, .26, .75)],
"metamorphic rocks" : ['*o.', (.2, .2, .3)],
"tills" : ['-.', (.7, .6, .9)],
"standstone ": ['..', (.5, .6, .9)],
"lignite coal": ['+/.',(.5, .5, .4)],
"coal": ['*.', (.8, .9, 0.)],
"shale" : ['=', (0., 0., 0.7)],
"clay" : ['=.',(.9, .8, 0.8)],
"saprolite" : ['*/',(.3, 1.2, .4)],
"sedimentary rocks": ['...',(.25, 0., .25)],
"fresh water" : ['.-.',(0., 1.,.2)],
"salt water" : ['o.-',(.2, 1., .2)],
"massive sulphide" : ['.+O',(1.,.5, .5 )],
"sea water" : ['.--',(.0, 1., 0.)],
"ore minerals" : ['--|',(.8, .2, .2)],
"graphite" : ['.++.',(.2, .7, .7)],
}
[docs]class Structure :
"""
Class for typical geological strutural conventions
for AGSO_STCODES . All geological structural informations are
geostructral object.
Holds the following information:
========================== =============== ===================================
Attributes Type Explanation
========================== =============== ===================================
boudin_axis geos_obj boudin
fold_axial_plane geos_obj axial plam of structural fold.
banding_gneissosity geos_obj gneissossity of boudin plan
s_fabric geos_obj fabric plan
fault_plane geos_obj fault plan
fracture_joint_set geos_obj fracture joint
undifferentiated_plane geos_obj unnamed geological structure
sharp_contact geos_obj sharp contact `various discrepancy`
contact `stratigraphy discrepancy`
fracture or fault discrepancies
========================== =============== ====================================
More attributes can be added by inputing a key word dictionary
:Example:
>>> from pycsamt.geodrill.geoCore.structural import Structure
>>> structural=Structure()
>>> boudin=boudin_axis()
>>> print(boudin.code)
>>> print(structural.boudin_axis.name)
>>> print(structural.boudin_axis.color)
"""
_logger.info('Set Structural main geological informations. ')
def __init__(self, **kwargs):
self.boudin_axis =boudin_axis()
self.fold_axial_plane=fold_axial_plane()
self.banding_gneissosity=banding_gneissosity()
self.s_fabric=s_fabric()
self.fault_plane=fault_plane()
self.fracture_joint_set=fracture_joint_set()
self.undifferentiated_plane=undifferentiated_plane()
self.sharp_contact=sharp_contact()
for keys in list(kwargs.keys()):
setattr(self, keys, kwargs[keys])
#====================================================
# geological structural objects
#=====================================================
[docs]class boudin_axis(object):
"""
Special class for boudins_axis
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
self._set_boudin_axis()
def _set_boudin_axis(self):
"""
methode to populates attributes
"""
baxis=strato()[1]
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class fold_axial_plane(object):
"""
Special class for fold_axial_plane
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_fold_axial_plane()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_fold_axial_plane(self):
"""
Methode to populates attributes.
"""
baxis=strato()[1]
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class banding_gneissosity(object):
"""
Special class for banding_gneissosity
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_banding_gneissosity()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_banding_gneissosity(self):
"""
methode to populates attributes
"""
baxis=strato()[1]
# print(baxis)
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class s_fabric(object):
"""
Special class for s_fabric
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_s_fabric()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_s_fabric(self):
"""methode to populates attributes"""
baxis=strato()[1]
# print(baxis)
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class fault_plane(object):
"""
Special class for fault_plane
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_fault_plane()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_fault_plane(self):
"""
methode to populates attributes
"""
baxis=strato()[1]
# print(baxis)
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class fracture_joint_set(object):
"""
Special class for fracture_joint_set
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_fracture_joint_set()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_fracture_joint_set(self):
"""methode to populates attributes
"""
baxis=strato()[1]
# print(baxis)
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]class undifferentiated_plane(object):
"""
Special class for undifferentiated_plane
Holds the following information:
================= ============= ========================================
Attributes Type Explanation
================= ============= ========================================
code str conventional code
label str named label
size str drawing size
pattern str drawing pattern
density str elmts density
thickness str drawing thickness
color str color set
================= ============= ========================================
More attributes can be added by inputing a key word dictionary
"""
def __init__(self, **kwargs):
self.code =None
self.label=None
self.name=None
self.pattern=None
self.size =None
self.density=None
self.thickness=None
self.color =None
self._set_undifferentiated_plane()
for keys in list(kwargs.keys()):
self.__setattr__(keys, kwargs[keys])
def _set_undifferentiated_plane(self):
"""
methode to populates attributes
"""
baxis=strato()[1]
# print(baxis)
for keys, values in baxis.items():
if keys == self.__class__.__name__:
self.code =values.__getitem__('code')
self.label=values.__getitem__('label')
self.name=values.__getitem__('name')
self.pattern=values.__getitem__('pattern')
self.size=values.__getitem__('size')
self.color=values.__getitem__('color')
self.density=values.__getitem__('density')
self.thickess=values.__getitem__('thickness')
[docs]def get_color_palette (RGB_color_palette):
"""
Convert RGB color into matplotlib color palette. In the RGB color system two bits
of data are used for each color, red, green, and blue. That means that each color runs
on a scale from 0 to 255. Black would be 00,00,00, while white would be 255,255,255.
Matplotlib has lots of pre-defined colormaps for us . They are all normalized to 255,
so they run from 0 to 1. So you need only normalize data, then we can manually
select colors from a color map
:param RGB_color_palette: str value of RGB value
:type RGB_color_palette: str
:returns: rgba, tuple of (R, G, B)
:rtype: tuple
:Example:
>>> from pycsamt.geodrill.geoCore.structural import get_color_palette
>>> get_color_palette (RGB_color_palette ='R128B128')
"""
def ascertain_cp (cp):
if cp >255. :
warnings.warn(' !RGB value is range 0 to 255 pixels , '
'not beyond !. Your input values is = {0}.'.format(cp))
raise CSex.pyCSAMTError_parameter_number('Error color RGBA value ! '
'RGB value provided is = {0}.'
' It is larger than 255 pixels.'.format(cp))
return cp
if isinstance(RGB_color_palette,(float, int, str)):
try :
float(RGB_color_palette)
except :
RGB_color_palette= RGB_color_palette.lower()
else : return ascertain_cp(float(RGB_color_palette))/255.
rgba = np.zeros((3,))
if 'r' in RGB_color_palette :
knae = RGB_color_palette .replace('r', '').replace('g', '/').replace('b', '/').split('/')
try :
_knae = ascertain_cp(float(knae[0]))
except :
rgba[0]=1.
else : rgba [0] = _knae /255.
if 'g' in RGB_color_palette :
knae = RGB_color_palette .replace('g', '/').replace('b', '/').split('/')
try :
_knae =ascertain_cp(float(knae[1]))
except :
rgba [1]=1.
else :rgba[1]= _knae /255.
if 'b' in RGB_color_palette :
knae = knae = RGB_color_palette .replace('g', '/').split('/')
try :
_knae =ascertain_cp(float(knae[1]))
except :
rgba[2]=1.
else :rgba[2]= _knae /255.
return tuple(rgba)
if __name__=="__main__":
# structural=Structure()
# boudin=boudin_axis()
# # print(boudin.code)
# print(structural.boudin_axis.name)
# print(structural.boudin_axis.color)
geoformation_obj =Geo_formation()
DATA = geoformation_obj._AGS0_DATA
rgb= geoformation_obj.amphibolite['color']
print(rgb)