Skip to content

Commit

Permalink
Added solution to bug about the pre drilled with backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
EleniSmyrniou committed Jan 15, 2025
1 parent d566329 commit 781db5d
Show file tree
Hide file tree
Showing 5 changed files with 1,417 additions and 10 deletions.
35 changes: 26 additions & 9 deletions geolib_plus/gef_cpt/gef_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from geolib_plus.cpt_base_model import CptReader

from .validate_gef import validate_gef_cpt


class GefProperty(BaseModel):
gef_key: int
Expand Down Expand Up @@ -140,12 +138,33 @@ def get_line_from_data_that_ends_with(code_string: str, data: List[str]) -> str:
return next((line for line in data if line.endswith(code_string)), None)

@staticmethod
def get_pre_drill_depth(penetration_length: List) -> float:
def get_pre_drill_depth(gef_string: List, penetration_length: List) -> float:
"""
Gets the pre-drill depth from the penetration length
Gets the pre-drill depth from the penetration length. From the CUR document GEOTECHNICAL EXCHANGE FORMAT FOR
CPT-DATA Version 1.2, the pre-drill depth is defined as the #MEASUREMENTVAR = 13, [figure], m, pre-excavated
depth. If this does not exist, the pre-drill depth is set to the value of the first penetration length.
Args:
gef_string (List): List of strings from the gef file
penetration_length (List): List of penetration lengths
Returns:
float: The pre-drill depth
"""
penetration_length = np.array(penetration_length)
return min(penetration_length[penetration_length > 0])
# Collect the measurmentvar index
code_string = r"#MEASUREMENTVAR= 13"
line_found = next(
(i for i, val in enumerate(gef_string) if val.startswith(code_string)), None
)
if line_found:
idx_measurementvar = GefFileReader.get_line_index_from_data_starts_with(
code_string=r"#MEASUREMENTVAR= 13", data=gef_string
)
# Get the pre-drill depth
predrilled_z = float(gef_string[idx_measurementvar].split(",")[1])
else:
penetration_length = np.array(penetration_length)
predrilled_z = min(penetration_length[penetration_length > 0])
return predrilled_z

def map_error_codes_to_external_property_names(self) -> Dict:
"""
Expand Down Expand Up @@ -235,9 +254,7 @@ def read_gef(self, gef_file: Path, fct_a: float = 0.8) -> Dict:
self.read_column_data(data, idx_EOH)

# get pre drill depth from penetration length data
predrilled_z = self.get_pre_drill_depth(
self.property_dict["penetration_length"].values_from_gef
)
predrilled_z = self.get_pre_drill_depth(data, self.property_dict["penetration_length"].values_from_gef)

idx_name = GefFileReader.get_line_index_from_data_starts_with(
code_string=r"#TESTID=", data=data
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance_test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from geolib_plus.bro_xml_cpt import BroXmlCpt

cpt_file_xml = Path(
"D:\\bro_xml_viewer\\unit_testing\\unit_testing_files\\xml_example_1\\CPT000000006560_IMBRO_A.xml"
"test_files/cpt/bro_xml/xmls_with_various_formats/CPT000000129426.xml"
)
cpt = BroXmlCpt()
cpt.read(cpt_file_xml)
Expand Down
1 change: 1 addition & 0 deletions tests/test_files/compare_xml_gef/CPT000000217393.xml

Large diffs are not rendered by default.

Loading

0 comments on commit 781db5d

Please sign in to comment.