@@ -47,7 +47,7 @@ class StratigraphicUnit(StratigraphicColumnElement):
4747 A class to represent a stratigraphic unit.
4848 """
4949
50- def __init__ (self , * , uuid = None , name = None , colour = None , thickness = None ):
50+ def __init__ (self , * , uuid = None , name = None , colour = None , thickness = None , data = None ):
5151 """
5252 Initializes the StratigraphicUnit with a name and an optional description.
5353 """
@@ -57,6 +57,7 @@ def __init__(self, *, uuid=None, name=None, colour=None, thickness=None):
5757 colour = rng .random (3 )
5858 self .colour = colour
5959 self .thickness = thickness
60+ self .data = data
6061 self .element_type = StratigraphicColumnElementType .UNIT
6162
6263 def to_dict (self ):
@@ -137,6 +138,18 @@ def from_dict(cls, data):
137138 )
138139 uuid = data .get ("uuid" , None )
139140 return cls (uuid = uuid , name = name , unconformity_type = unconformity_type )
141+ class StratigraphicGroup :
142+ """
143+ A class to represent a group of stratigraphic units.
144+ This class is not fully implemented and serves as a placeholder for future development.
145+ """
146+
147+ def __init__ (self , name = None , units = None ):
148+ """
149+ Initializes the StratigraphicGroup with a name and an optional list of units.
150+ """
151+ self .name = name
152+ self .units = units if units is not None else []
140153
141154
142155class StratigraphicColumn :
@@ -150,13 +163,15 @@ def __init__(self):
150163 Initializes the StratigraphicColumn with a name and a list of layers.
151164 """
152165 self .order = [StratigraphicUnit (name = 'Basement' , colour = 'grey' , thickness = np .inf ),StratigraphicUnconformity (name = 'Base Unconformity' , unconformity_type = UnconformityType .ERODE )]
166+ self .group_mapping = {}
153167 def clear (self ):
154168 """
155169 Clears the stratigraphic column, removing all elements.
156170 """
157171 self .order = [StratigraphicUnit (name = 'Basement' , colour = 'grey' , thickness = np .inf ),StratigraphicUnconformity (name = 'Base Unconformity' , unconformity_type = UnconformityType .ERODE )]
172+ self .group_mapping = {}
158173
159- def add_unit (self , name , colour , thickness = None , where = 'top' ):
174+ def add_unit (self , name ,* , colour = None , thickness = None , where = 'top' ):
160175 unit = StratigraphicUnit (name = name , colour = colour , thickness = thickness )
161176
162177 if where == 'top' :
@@ -178,7 +193,7 @@ def remove_unit(self, uuid):
178193 return True
179194 return False
180195
181- def add_unconformity (self , name , unconformity_type = UnconformityType .ERODE , where = 'top' ):
196+ def add_unconformity (self , name , * , unconformity_type = UnconformityType .ERODE , where = 'top' ):
182197 unconformity = StratigraphicUnconformity (
183198 uuid = None , name = name , unconformity_type = unconformity_type
184199 )
@@ -226,31 +241,41 @@ def get_elements(self):
226241
227242 def get_groups (self ):
228243 groups = []
229- group = []
244+ i = 0
245+ group = StratigraphicGroup (
246+ name = (
247+ f'Group_{ i } '
248+ if f'Group_{ i } ' not in self .group_mapping
249+ else self .group_mapping [f'Group_{ i } ' ]
250+ )
251+ )
230252 for e in self .order :
231253 if isinstance (e , StratigraphicUnit ):
232- group .append (e )
254+ group .units . append (e )
233255 else :
234- if group :
256+ if group . units :
235257 groups .append (group )
236- group = []
258+ i += 1
259+ group = StratigraphicGroup (
260+ name = (
261+ f'Group_{ i } '
262+ if f'Group_{ i } ' not in self .group_mapping
263+ else self .group_mapping [f'Group_{ i } ' ]
264+ )
265+ )
237266 if group :
238267 groups .append (group )
239268 return groups
240269
241270 def get_unitname_groups (self ):
242- groups = []
271+ groups = self .get_groups ()
272+ groups_list = []
243273 group = []
244- for e in self .order :
245- if isinstance (e , StratigraphicUnit ):
246- group .append (e .name )
247- else :
248- if group :
249- groups .append (group )
250- group = []
251- if group :
252- groups .append (group )
253- return groups
274+ for g in groups :
275+ group = [u .name for u in g .units if isinstance (u , StratigraphicUnit )]
276+ groups_list .append (group )
277+ return groups_list
278+
254279
255280 def __getitem__ (self , uuid ):
256281 """
@@ -289,7 +314,6 @@ def update_element(self, unit_data: Dict):
289314 unit_data .get ('unconformity_type' , element .unconformity_type .value )
290315 )
291316
292-
293317 def __str__ (self ):
294318 """
295319 Returns a string representation of the stratigraphic column, listing all elements.
@@ -320,20 +344,20 @@ def from_dict(cls, data):
320344 element = StratigraphicUnit .from_dict (element_data )
321345 column .add_element (element )
322346 return column
323-
347+
324348 def get_isovalues (self ) -> Dict [str , float ]:
325349 """
326350 Returns a dictionary of isovalues for the stratigraphic units in the column.
327351 """
328352 surface_values = {}
329353 for g in reversed (self .get_groups ()):
330354 v = 0
331- for u in g :
332- surface_values [u .name ] = v
355+ for u in g . units :
356+ surface_values [u .name ] = { 'value' : v , 'group' : g . name , 'colour' : u . colour }
333357 v += u .thickness
334358 return surface_values
335-
336- def plot (self , ax = None , ** kwargs ):
359+
360+ def plot (self ,* , ax = None , ** kwargs ):
337361 import matplotlib .pyplot as plt
338362 from matplotlib import cm
339363 from matplotlib .patches import Polygon
0 commit comments