Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added solution to bug about the pre drilled with backwards compatibility #42

Merged
merged 6 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 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 @@ -236,7 +255,7 @@ def read_gef(self, gef_file: Path, fct_a: float = 0.8) -> Dict:

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

idx_name = GefFileReader.get_line_index_from_data_starts_with(
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