Esempio n. 1
0
    def test_parse_gef_type(self):
        s = r"#PROCEDURECODE= GEF-CPT-Report"
        v = utils.parse_gef_type(s)
        self.assertEqual(v, "cpt")

        h = {"PROCEDURECODE": [["GEF-CPT-Report"]]}
        v = utils.parse_gef_type(h)
        self.assertEqual(v, "cpt")
Esempio n. 2
0
    def __init__(self, path=None, string=None):
        """
        Base class of gef parser. It switches between the cpt or borehole parser.

        :param path:(str) Path of the .gef file to parse.
        :param string:(str) String to parse.
        """
        self.path = path
        self.df = None
        self.net_surface_area_quotient_of_the_cone_tip = None
        self.pre_excavated_depth = None

        if string is None:
            with open(path, encoding='utf-8', errors='ignore') as f:
                string = f.read()
        self.s = string

        end_of_header = utils.parse_end_of_header(self.s)
        header_s, data_s = self.s.split(end_of_header)
        self.zid = utils.parse_zid_as_float(header_s)
        self.x = utils.parse_xid_as_float(header_s)
        self.y = utils.parse_yid_as_float(header_s)
        self.file_date = utils.parse_file_date(header_s)

        t = utils.parse_gef_type(string)
        if t == "cpt":
            parsed = ParseCPT(header_s, data_s, self.zid)
        elif t == "bore":
            parsed = ParseBORE(header_s, data_s)
        else:
            raise ValueError(
                "The selected gef file is not a cpt nor a borehole. "
                "Check the REPORTCODE or the PROCEDURECODE.")
        self.__dict__.update(parsed.__dict__)
Esempio n. 3
0
    def __init__(self, path=None, string=None):
        """
        Base class of gef parser. It switches between the cpt or borehole parser.

        :param path:(str) Path of the .gef file to parse.
        :param string:(str) String to parse.
        """
        self.path = path
        self.s = string
        self.type = None

        if self.s is None:
            with open(path, encoding='utf-8', errors='ignore') as f:
                self.s = f.read()

        self.type = utils.parse_gef_type(self.s)
        if self.type == "cpt":
            parsed = ParseCPT(string=self.s)
        elif self.type == "bore":
            parsed = ParseBORE(string=self.s)
        else:
            raise ValueError(
                "The selected gef file is not a cpt nor a borehole. "
                "Check the REPORTCODE or the PROCEDURECODE.")

        self.__dict__.update(parsed.__dict__)
Esempio n. 4
0
    def __init__(self, path=None, string=None):
        """
        Base class of gef parser. It switches between the cpt or borehole parser.

        It takes as input either the path to the gef file or the gef file as string.

        Parameters
        ----------
        path: str
            Path to the *.gef file.
        string: str
            String version of the *.gef file.
        """
        self.path = path
        self.df = None
        self.net_surface_area_quotient_of_the_cone_tip = None
        self.pre_excavated_depth = None

        if string is None:
            with open(path, encoding="utf-8", errors="ignore") as f:
                string = f.read()
        self.s = string

        end_of_header = utils.parse_end_of_header(self.s)
        header_s, data_s = self.s.split(end_of_header)
        self.zid = utils.parse_zid_as_float(header_s)
        self.height_system = utils.parse_height_system(header_s)
        self.x = utils.parse_xid_as_float(header_s)
        self.y = utils.parse_yid_as_float(header_s)
        self.file_date = utils.parse_file_date(header_s)
        self.test_id = utils.parse_test_id(header_s)

        self.type = utils.parse_gef_type(string)
        if self.type == "cpt":
            parsed = ParseCPT(header_s, data_s, self.zid, self.height_system)
        elif self.type == "bore":
            parsed = ParseBORE(header_s, data_s)
        elif self.type == "borehole-report":
            raise ValueError(
                "The selected gef file is a GEF-BOREHOLE-Report. Can only parse "
                "GEF-CPT-Report and GEF-BORE-Report. Check the PROCEDURECODE."
            )
        else:
            raise ValueError(
                "The selected gef file is not a cpt nor a borehole. "
                "Check the REPORTCODE or the PROCEDURECODE."
            )

        self.__dict__.update(parsed.__dict__)
        self.df = self.df.dropna().reset_index(drop=True)
Esempio n. 5
0
    def __init__(self, path=None, string=None):
        """
        Base class of gef parser. It switches between the cpt or borehole parser.

        It takes as input either the path to the gef file or the gef file as string.

        Parameters
        ----------
        path: str
            Path to the *.gef file.
        string: str
            String version of the *.gef file.

        """
        self.path = path
        self.df = None
        self.net_surface_area_quotient_of_the_cone_tip = None
        self.pre_excavated_depth = None

        if string is None:
            with open(path, encoding="utf-8", errors="ignore") as f:
                string = f.read()

        self.s = string

        if USE_RUST_PARSED_HEADERS:
            # Use the Rust optimized header parser
            self._data, self._headers = gef.parse(string)
        else:
            # Use the fallback python regex parser
            end_of_header = utils.parse_end_of_header(string)
            self._headers, self._data = string.split(end_of_header)

        self.zid = utils.parse_zid_as_float(self._headers)
        self.height_system = utils.parse_height_system(self._headers)
        self.x = utils.parse_xid_as_float(self._headers)
        self.y = utils.parse_yid_as_float(self._headers)
        self.file_date = utils.parse_file_date(self._headers)
        self.test_id = utils.parse_test_id(self._headers)
        self.type = utils.parse_gef_type(self._headers)
Esempio n. 6
0
 def test_parse_gef_type(self):
     s = r"#PROCEDURECODE= GEF-CPT-Report"
     v = utils.parse_gef_type(s)
     self.assertEqual(v, 'cpt')
Esempio n. 7
0
    def __init__(self, path=None, string=None):
        """
        Parser of the borehole file.

        :param path:(str) Path of the .gef file to parse.
        :param string:(str) String to parse.
        """
        self.path = path
        self.s = string
        self.zid = None  # ground level
        self.x = None
        self.y = None
        self.type = None
        self.end_depth_of_penetration_test = None
        self.project_id = None
        self.column_separator = None
        self.record_separator = None
        self.file_date = None
        self.project_id = None
        self.type = None

        # List of all the possible measurement variables

        if self.s is None:
            with open(path, encoding='utf-8', errors='ignore') as f:
                self.s = f.read()

        end_of_header = utils.parse_end_of_header(self.s)
        header_s, data_s = self.s.split(end_of_header)

        columns_number = utils.parse_columns_number(header_s)
        self.file_date = utils.parse_file_date(header_s)
        self.project_id = utils.parse_project_type(header_s, self.type)
        self.type = utils.parse_gef_type(header_s)
        self.x = utils.parse_xid_as_float(header_s)
        self.y = utils.parse_yid_as_float(header_s)
        self.zid = utils.parse_zid_as_float(header_s)
        column_separator = utils.parse_column_separator(header_s)
        record_separator = utils.parse_record_separator(header_s)
        data_s_rows = data_s.split(record_separator)
        data_rows_soil = self.extract_soil_info(data_s_rows, columns_number,
                                                column_separator)
        df_column_info = self.parse_data_column_info(header_s, data_s,
                                                     column_separator,
                                                     columns_number)
        df_soil_type = self.parse_data_soil_type(data_rows_soil)
        df_soil_code = self.parse_data_soil_code(data_rows_soil)
        df_soil_quantified = self.data_soil_quantified(data_rows_soil)
        df_additional_info = self.parse_add_info_as_string(data_rows_soil)
        df_bore_more_info = pd.concat([
            df_column_info, df_soil_code, df_soil_type, df_soil_quantified,
            df_additional_info
        ],
                                      axis=1,
                                      sort=False)
        self.df = df_bore_more_info[[
            'depth_top', 'depth_bottom', 'Soil_code', 'Gravel', 'Sand', 'Clay',
            'Loam', 'Peat', 'Silt'
        ]]
        self.df.columns = [
            'depth_top', 'depth_bottom', 'soil_code', 'G', 'S', 'C', 'L', 'P',
            'S'
        ]
Esempio n. 8
0
    def __init__(self, path=None, string=None):
        """
        Parser of the cpt file.

        :param path:(str) Path of the .gef file to parse.
        :param string:(str) String to parse.
        """
        self.path = path
        self.zid = None  # ground level
        self.x = None
        self.y = None
        self.type = None
        self.file_date = None
        self.project_id = None
        self.s = string
        self.column_void = None

        # List of all the possible measurement variables
        self.nom_surface_area_cone_tip = None
        self.nom_surface_area_friction_element = None
        self.net_surface_area_quotient_of_the_cone_tip = None
        self.net_surface_area_quotient_of_the_friction_casing = None
        self.distance_between_cone_and_centre_of_friction_casing = None
        self.friction_present = None
        self.ppt_u1_present = None
        self.ppt_u2_present = None
        self.ppt_u3_present = None
        self.inclination_measurement_present = None
        self.use_of_back_flow_compensator = None
        self.type_of_cone_penetration_test = None
        self.pre_excavated_depth = None
        self.groundwater_level = None
        self.water_depth_offshore_activities = None
        self.end_depth_of_penetration_test = None
        self.stop_criteria = None
        self.zero_measurement_cone_before_penetration_test = None
        self.zero_measurement_cone_after_penetration_test = None
        self.zero_measurement_friction_before_penetration_test = None
        self.zero_measurement_friction_after_penetration_test = None
        self.zero_measurement_ppt_u1_before_penetration_test = None
        self.zero_measurement_ppt_u2_before_penetration_test = None
        self.zero_measurement_ppt_u3_before_penetration_test = None
        self.zero_measurement_ppt_u1_after_penetration_test = None
        self.zero_measurement_ppt_u2_after_penetration_test = None
        self.zero_measurement_ppt_u3_after_penetration_test = None
        self.zero_measurement_inclination_before_penetration_test = None
        self.zero_measurement_inclination_after_penetration_test = None
        self.zero_measurement_cone_after_penetration_test = None
        self.zero_measurement_inclination_ns_before_penetration_test = None
        self.zero_measurement_inclination_ns_after_penetration_test = None
        self.zero_measurement_inclination_ew_before_penetration_test = None
        self.zero_measurement_inclination_ew_after_penetration_test = None
        self.mileage = None

        if self.s is None:
            with open(path, encoding='utf-8', errors='ignore') as f:
                self.s = f.read()

        end_of_header = utils.parse_end_of_header(self.s)
        header_s, data_s = self.s.split(end_of_header)

        self.file_date = utils.parse_file_date(header_s)
        self.project_id = utils.parse_project_type(header_s, self.type)
        self.zid = utils.parse_zid_as_float(header_s)
        self.type = utils.parse_gef_type(header_s)
        self.x = utils.parse_xid_as_float(header_s)
        self.y = utils.parse_yid_as_float(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)

        # first dataframe with only the parsed data
        self.df_first = self.parse_data(header_s, data_s)
        # second dataframe with the correction of the pre excavated depth
        self.df_second = self.correct_pre_excavated_depth(
            self.df_first, self.pre_excavated_depth)
        # definition of the zeros dataframe and addition of the depth to the main dataframe
        df_depth = pd.DataFrame(np.zeros(len(self.df_second.index)),
                                columns=['depth'])
        df_nap_zeros = pd.DataFrame(np.zeros(len(self.df_second.index)),
                                    columns=['elevation_respect_to_NAP'])
        self.df_with_depth = pd.concat([self.df_second, df_depth],
                                       axis=1,
                                       sort=False)
        # correction of the depth with the inclination if present
        self.df_correct_depth_with_inclination = self.correct_depth_with_inclination(
            self.df_with_depth)
        # definition of the elevation respect to the nap and concatenation with the previous dataframe
        df_nap = self.calculate_elevation_respect_to_nap(
            df_nap_zeros, self.zid,
            self.df_correct_depth_with_inclination['depth'],
            len(self.df_second.index))
        self.df = pd.concat([self.df_correct_depth_with_inclination, df_nap],
                            axis=1,
                            sort=False)