@@ -135,7 +135,8 @@ def __init__(
135135 self .deformation_history = DeformationHistory (project = self )
136136 self .loop_filename = loop_project_filename
137137 self .overwrite_lpf = overwrite_loopprojectfile
138-
138+ self .active_thickness = None
139+
139140 # initialise the dataframes to store data in
140141 self .fault_orientations = pandas .DataFrame (
141142 columns = ["ID" , "DIPDIR" , "DIP" , "X" , "Y" , "Z" , "featureId" ]
@@ -370,7 +371,7 @@ def get_sampler(self, datatype: Datatype):
370371 return self .samplers [datatype ].sampler_label
371372
372373 @beartype .beartype
373- def set_minimum_fault_length (self , length : float ):
374+ def set_minimum_fault_length (self , length : Union [ float , int ] ):
374375 """
375376 Set the cutoff length for faults to ignore
376377
@@ -392,6 +393,35 @@ def get_minimum_fault_length(self) -> float:
392393 """
393394 return float (self .map_data .config .fault_config ['minimum_fault_length' ])
394395
396+ @beartype .beartype
397+ def set_active_thickness (self , thickness_calculator : ThicknessCalculator ):
398+ """
399+ Sets the active_thickness attribute based on the provided thickness_calculator.
400+ Args:
401+ thickness_calculator (object or str): The thickness calculator object or its label.
402+ If an object is provided, it should have a 'thickness_calculator_label' attribute.
403+ Returns:
404+ None
405+ Raises:
406+ ValueError: If the thickness calculator label cannot be determined.
407+ """
408+
409+ try :
410+ label = thickness_calculator .thickness_calculator_label
411+ except AttributeError :
412+ raise ValueError ("The provided thickness calculator object does not have a 'thickness_calculator_label' attribute." )
413+ self .active_thickness = label
414+
415+ @beartype .beartype
416+ def get_active_thickness (self ) -> str :
417+ """
418+ Retrieves the active_thickness attribute.
419+
420+ Returns:
421+ str: The label of the active thickness calculator.
422+ """
423+ return self .active_thickness
424+
395425 # Processing functions
396426 def sample_map_data (self ):
397427 """
@@ -597,7 +627,9 @@ def calculate_unit_thicknesses(self):
597627 self .stratigraphic_column .stratigraphicUnits [stddev_col_name ] = repeated_result [:, 2 ]
598628
599629 self .thickness_calculator_labels = labels
600-
630+ if self .active_thickness is None :
631+ self .active_thickness = labels [0 ]
632+
601633 def calculate_fault_orientations (self ):
602634 if self .map_data .get_map_data (Datatype .FAULT_ORIENTATION ) is not None :
603635 logger .info (f"Calculating fault orientations using { self .fault_orientation .label } " )
@@ -700,7 +732,7 @@ def save_into_projectfile(self):
700732 file_exists = False
701733 logger .info (f"\n Existing file '{ self .loop_filename } ' was successfully deleted." )
702734 except Exception as e :
703- logger .errow (f"\n Failed to delete existing file '{ self .loop_filename } ': { e } " )
735+ logger .error (f"\n Failed to delete existing file '{ self .loop_filename } ': { e } " )
704736 raise e
705737 else :
706738 logger .error (
@@ -764,51 +796,28 @@ def save_into_projectfile(self):
764796 stratigraphic_data = numpy .zeros (
765797 len (self .stratigraphic_column .stratigraphicUnits ), LPF .stratigraphicLayerType
766798 )
799+ stratigraphic_thicknesses = numpy .zeros (
800+ len (self .stratigraphic_column .stratigraphicUnits ), LPF .stratigraphicThicknessType )
801+
767802 stratigraphic_data ["layerId" ] = self .stratigraphic_column .stratigraphicUnits ["layerId" ]
768803 stratigraphic_data ["minAge" ] = self .stratigraphic_column .stratigraphicUnits ["minAge" ]
769804 stratigraphic_data ["maxAge" ] = self .stratigraphic_column .stratigraphicUnits ["maxAge" ]
770805 stratigraphic_data ["name" ] = self .stratigraphic_column .stratigraphicUnits ["name" ]
771806 stratigraphic_data ["group" ] = self .stratigraphic_column .stratigraphicUnits ["group" ]
772807 stratigraphic_data ["enabled" ] = 1
773808
774- # Length of the column (number of rows in stratigraphicUnits)
775- column_len = len (self .stratigraphic_column .stratigraphicUnits )
776-
777- # Function to retrieve a column if it exists, otherwise return a list of default values
778- def get_column_or_default (column_name , default_value , length ):
779- return list (
780- self .stratigraphic_column .stratigraphicUnits .get (
781- column_name , [default_value ] * length
782- )
783- )
784-
785- # Get the current list of thickness calculator labels dynamically
786- thickness_labels = self .thickness_calculator_labels
787-
788- # Define a constant for the maximum number of calculators (5 as per your requirement)
789- MAX_CALCULATORS = 5
790-
791- # Create lists for mean, median, and stddev values for each calculator dynamically
792- thickness_mean_list = [
793- get_column_or_default (f'{ label } _mean' , 0 , column_len ) for label in thickness_labels
794- ]
795- thickness_median_list = [
796- get_column_or_default (f'{ label } _median' , 0 , column_len ) for label in thickness_labels
797- ]
798- thickness_stddev_list = [
799- get_column_or_default (f'{ label } _stddev' , 0 , column_len ) for label in thickness_labels
800- ]
801-
802- # Pad with zeros if the number of calculators is less than MAX_CALCULATORS
803- for _ in range (MAX_CALCULATORS - len (thickness_mean_list )):
804- thickness_mean_list .append ([0 ] * column_len )
805- thickness_median_list .append ([0 ] * column_len )
806- thickness_stddev_list .append ([0 ] * column_len )
807-
808- # Zip these lists into tuples for each stratigraphic row dynamically, ensuring each tuple has exactly 5 elements
809- stratigraphic_data ["ThicknessMean" ] = list (zip (* thickness_mean_list [:MAX_CALCULATORS ]))
810- stratigraphic_data ["ThicknessMedian" ] = list (zip (* thickness_median_list [:MAX_CALCULATORS ]))
811- stratigraphic_data ["ThicknessStdDev" ] = list (zip (* thickness_stddev_list [:MAX_CALCULATORS ]))
809+ stratigraphic_thicknesses ['name' ]= self .stratigraphic_column .stratigraphicUnits ["name" ]
810+
811+ # store all of the thickness estimates in a separate table
812+ for i , label in enumerate (self .thickness_calculator_labels ):
813+ stratigraphic_thicknesses [f'thickness{ i + 1 } _mean' ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ label } _mean' ,0 )
814+ stratigraphic_thicknesses [f'thickness{ i + 1 } _median' ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ label } _median' ,0 )
815+ stratigraphic_thicknesses [f'thickness{ i + 1 } _stddev' ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ label } _stddev' ,0 )
816+
817+ # store the active thickness calculator as the default thickness
818+ stratigraphic_data ["ThicknessMean" ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ self .active_thickness } _mean' ,0 )
819+ stratigraphic_data ["ThicknessMedian" ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ self .active_thickness } _median' ,0 )
820+ stratigraphic_data ["ThicknessStdDev" ] = self .stratigraphic_column .stratigraphicUnits .get (f'{ self .active_thickness } _stddev' ,0 )
812821
813822 # Assign colours to startigraphic data
814823 stratigraphic_data ["colour1Red" ] = [
@@ -828,21 +837,28 @@ def get_column_or_default(column_name, default_value, length):
828837 stratigraphic_data ["colour2Blue" ] = [
829838 int (a * 0.95 ) for a in stratigraphic_data ["colour1Blue" ]
830839 ]
831-
840+
841+ n_thick_calcs = len (self .thickness_calculator_labels )
832842 # get thickness calculator labels, and fill up with None if empty values up to 5 placeholders
833843 while len (self .thickness_calculator_labels ) < 5 :
834844 self .thickness_calculator_labels .append ("None" )
835845
836- thickness_calculator_labels = [tuple (self .thickness_calculator_labels [:5 ])]
846+ headers = 'name;' + ';' .join ([f'{ l } _mean;{ l } _median;{ l } _stddev' for l in self .thickness_calculator_labels [:5 ]])
847+ headers = headers .split (';' ) # split into list
837848
838849 # save into LPF
839850 LPF .Set (
840851 self .loop_filename ,
841852 "stratigraphicLog" ,
842853 data = stratigraphic_data ,
843- thickness_calculator_data = thickness_calculator_labels ,
844- verbose = True ,
854+ verbose = False ,
845855 )
856+ LPF .Set (self .loop_filename ,
857+ "stratigraphicThicknesses" ,
858+ data = stratigraphic_thicknesses ,
859+ headers = headers ,
860+ ncols = 1 + 3 * n_thick_calcs , # index and mean, median, stddev for each thickness calculator
861+ verbose = False )
846862
847863 # Save contacts
848864 contacts_data = numpy .zeros (len (self .map_data .sampled_contacts ), LPF .contactObservationType )
0 commit comments