def test_parse_cpt_class(self): s = r"#MEASUREMENTTEXT= 6, NEN 5140 / klasse onbekend, sondeernorm en kwaliteitsklasse" v = utils.parse_cpt_class(s) self.assertEqual(v, None) s = r"#MEASUREMENTTEXT= 6, NEN-EN-ISO22476-1 / klasse 2 / TE2, gehanteerde norm en klasse en type sondering" v = utils.parse_cpt_class(s) self.assertEqual(v, 2) s = r"#MEASUREMENTTEXT= 6, Norm : NEN 5140; Klasse : 2, De norm waaraan deze sondering moet voldoen." v = utils.parse_cpt_class(s) self.assertEqual(v, 2) s = r"#MEASUREMENTTEXT= 6, Norm : NEN 5140; class : 2, De norm waaraan deze sondering moet voldoen." v = utils.parse_cpt_class(s) self.assertEqual(v, 2)
def __init__(self, header_s, data_s, zid, height_system): """ Parser of the cpt file. :param header_s: (str) Header of the file :param data_s: (str) Data of the file :param zid: (flt) Z attribute. """ self.type = "cpt" self.project_id = utils.parse_project_type(header_s, "cpt") self.cone_id = utils.parse_cone_id(header_s) self.cpt_class = utils.parse_cpt_class(header_s) self.column_void = utils.parse_column_void(header_s) self.nom_surface_area_cone_tip = utils.parse_measurement_var_as_float( header_s, 1 ) self.nom_surface_area_friction_element = utils.parse_measurement_var_as_float( header_s, 2 ) self.net_surface_area_quotient_of_the_cone_tip = utils.parse_measurement_var_as_float( header_s, 3 ) self.net_surface_area_quotient_of_the_friction_casing = utils.parse_measurement_var_as_float( header_s, 4 ) self.distance_between_cone_and_centre_of_friction_casing = utils.parse_measurement_var_as_float( header_s, 5 ) self.friction_present = utils.parse_measurement_var_as_float(header_s, 6) self.ppt_u1_present = utils.parse_measurement_var_as_float(header_s, 7) self.ppt_u2_present = utils.parse_measurement_var_as_float(header_s, 8) self.ppt_u3_present = utils.parse_measurement_var_as_float(header_s, 9) self.inclination_measurement_present = utils.parse_measurement_var_as_float( header_s, 10 ) self.use_of_back_flow_compensator = utils.parse_measurement_var_as_float( header_s, 11 ) self.type_of_cone_penetration_test = utils.parse_measurement_var_as_float( header_s, 12 ) self.pre_excavated_depth = utils.parse_measurement_var_as_float(header_s, 13) self.groundwater_level = utils.parse_measurement_var_as_float(header_s, 14) self.water_depth_offshore_activities = utils.parse_measurement_var_as_float( header_s, 15 ) self.end_depth_of_penetration_test = utils.parse_measurement_var_as_float( header_s, 16 ) self.stop_criteria = utils.parse_measurement_var_as_float(header_s, 17) self.zero_measurement_cone_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 20 ) self.zero_measurement_cone_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 21 ) self.zero_measurement_friction_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 22 ) self.zero_measurement_friction_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 23 ) self.zero_measurement_ppt_u1_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 24 ) self.zero_measurement_ppt_u1_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 25 ) self.zero_measurement_ppt_u2_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 26 ) self.zero_measurement_ppt_u2_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 27 ) self.zero_measurement_ppt_u3_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 28 ) self.zero_measurement_ppt_u3_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 29 ) self.zero_measurement_inclination_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 30 ) self.zero_measurement_inclination_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 31 ) self.zero_measurement_inclination_ns_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 32 ) self.zero_measurement_inclination_ns_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 33 ) self.zero_measurement_inclination_ew_before_penetration_test = utils.parse_measurement_var_as_float( header_s, 34 ) self.zero_measurement_inclination_ew_after_penetration_test = utils.parse_measurement_var_as_float( header_s, 35 ) self.mileage = utils.parse_measurement_var_as_float(header_s, 41) self.df = ( self.parse_data(header_s, data_s) .pipe(self.replace_column_void, self.column_void) .pipe(self.correct_pre_excavated_depth, self.pre_excavated_depth) .pipe(self.correct_depth_with_inclination) .pipe(lambda df: df.assign(depth=np.abs(df["depth"].values))) .pipe(self.calculate_elevation_with_respect_to_nap, zid, height_system) .pipe(self.calculate_friction_number) )
def __init__(self, path=None, string=None): """ Parser of the cpt file. Parameters ---------- path: str Path to the *.gef file. string: str String version of the *.gef file. """ super().__init__(path=path, string=string) if not self.type == "cpt": raise ValueError("The selected gef file is not a cpt. " "Check the REPORTCODE or the PROCEDURECODE.") self.project_id = utils.parse_project_type(self._headers, "cpt") self.cone_id = utils.parse_cone_id(self._headers) self.cpt_class = utils.parse_cpt_class(self._headers) self.column_void = utils.parse_column_void(self._headers) self.nom_surface_area_cone_tip = utils.parse_measurement_var_as_float( self._headers, 1) self.nom_surface_area_friction_element = utils.parse_measurement_var_as_float( self._headers, 2) self.net_surface_area_quotient_of_the_cone_tip = ( utils.parse_measurement_var_as_float(self._headers, 3)) self.net_surface_area_quotient_of_the_friction_casing = ( utils.parse_measurement_var_as_float(self._headers, 4)) self.distance_between_cone_and_centre_of_friction_casing = ( utils.parse_measurement_var_as_float(self._headers, 5)) self.friction_present = utils.parse_measurement_var_as_float( self._headers, 6) self.ppt_u1_present = utils.parse_measurement_var_as_float( self._headers, 7) self.ppt_u2_present = utils.parse_measurement_var_as_float( self._headers, 8) self.ppt_u3_present = utils.parse_measurement_var_as_float( self._headers, 9) self.inclination_measurement_present = utils.parse_measurement_var_as_float( self._headers, 10) self.use_of_back_flow_compensator = utils.parse_measurement_var_as_float( self._headers, 11) self.type_of_cone_penetration_test = utils.parse_measurement_var_as_float( self._headers, 12) self.pre_excavated_depth = utils.parse_measurement_var_as_float( self._headers, 13) self.groundwater_level = utils.parse_measurement_var_as_float( self._headers, 14) self.water_depth_offshore_activities = utils.parse_measurement_var_as_float( self._headers, 15) self.end_depth_of_penetration_test = utils.parse_measurement_var_as_float( self._headers, 16) self.stop_criteria = utils.parse_measurement_var_as_float( self._headers, 17) self.zero_measurement_cone_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 20)) self.zero_measurement_cone_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 21)) self.zero_measurement_friction_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 22)) self.zero_measurement_friction_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 23)) self.zero_measurement_ppt_u1_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 24)) self.zero_measurement_ppt_u1_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 25)) self.zero_measurement_ppt_u2_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 26)) self.zero_measurement_ppt_u2_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 27)) self.zero_measurement_ppt_u3_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 28)) self.zero_measurement_ppt_u3_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 29)) self.zero_measurement_inclination_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 30)) self.zero_measurement_inclination_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 31)) self.zero_measurement_inclination_ns_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 32)) self.zero_measurement_inclination_ns_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 33)) self.zero_measurement_inclination_ew_before_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 34)) self.zero_measurement_inclination_ew_after_penetration_test = ( utils.parse_measurement_var_as_float(self._headers, 35)) self.mileage = utils.parse_measurement_var_as_float(self._headers, 41) column_names = determine_column_names(self._headers) self.df = ( self.parse_data(self._headers, self._data, column_names).lazy(). pipe(replace_column_void, self.column_void).pipe( correct_pre_excavated_depth, self.pre_excavated_depth).with_column( correct_depth_with_inclination(column_names)).select( # Remove None values since they throw an error [ expr for expr in [ pl.all().exclude(["depth", "friction_number"]), col("depth").abs(), calculate_friction_number(column_names), self.calculate_elevation_with_respect_to_nap( self.zid, self.height_system), ] if expr is not None ]).collect())