Soil Processing

This module defines the SoilDataProcessor class which provides helper routines for processing soil data. It is used to transform coordinates, combine raw and processed DataFrames, and extract/convert in-situ test detail data.

class owimetadatabase_preprocessor.soil.processing.soil_pp.SoilDataProcessor

Bases: object

Helper class for processing soil data.

static transform_coord(df: DataFrame, longitude: float, latitude: float, target_srid: str) Tuple[DataFrame, float, float]

Transform coordinates from EPSG:4326 to the target SRID.

The input DataFrame must contain the keys ‘easting’ and ‘northing’. The function transforms these to new columns ‘easting [m]’ and ‘ northing [m]’. In addition, the central point (longitude, latitude) is also transformed.

Parameters:
  • df – Input DataFrame with ‘easting’ and ‘northing’ columns.

  • longitude – Longitude of the central point (in decimal degrees).

  • latitude – Latitude of the central point (in decimal degrees).

  • target_srid – Target SRID as a string (e.g. “25831”).

Returns:

A tuple containing: - The updated DataFrame with transformed coordinates. - The transformed easting of the central point. - The transformed northing of the central point.

static combine_dfs(dfs: Dict[str, DataFrame]) DataFrame

Combine two DataFrames (usually raw and processed data) along the common column “z [m]”.

If the merge fails, the method returns the ‘rawdata’ DataFrame as a fallback.

Parameters:

dfs – Dictionary of DataFrames with keys “rawdata” and “processeddata”.

Returns:

The merged DataFrame if successful; otherwise, returns the “rawdata” DataFrame.

static process_insitutest_dfs(df: DataFrame, cols: List[str]) Dict[str, DataFrame]

Process the in-situ test detail DataFrame by extracting specified columns.

Each specified column is assumed to contain nested data (such as a dictionary or list) in its first row. The method attempts to convert these nested structures into new DataFrames and also applies numerical conversion where applicable.

Parameters:
  • df – The input DataFrame containing in-situ test details.

  • cols – A list of column names to extract from the DataFrame.

Returns:

A dictionary mapping each column name (as key) to its processed DataFrame.

static gather_data_entity(df: DataFrame) Dict[str, DataFrame | int | str | float | None]

Gather the data for the closest entity to a certain point in 2D.

Parameters:

df – Pandas dataframe with the data according to the specified search criteria

Returns:

Dictionary with the following keys:

  • ’data’: Pandas dataframe with the test location data for each location in the specified search area

  • ’id’: ID of the closest test location

  • ’title’: Title of the closest test location

  • ’offset [m]’: Offset in meters from the specified point

static process_cpt(df_sum: DataFrame, df_raw: DataFrame, **kwargs)
static convert_to_profile(df_sum, df_detail, profile_title, drop_info_cols)
static fulldata_processing(unitdata, row, selected_depths, func_get_details, depthcol, **kwargs)
static partialdata_processing(unitdata, row, selected_depths, selected_tests)
static objects_to_list(selected_obj, func_get_detail, data_type)
class owimetadatabase_preprocessor.soil.processing.soil_pp.SoilprofileProcessor

Bases: object

Helper class for processing required inputs from a given dataframe for soil-strucutre interaction modeling.

The class defines a database of keys (LATERAL_SOIL_KEYS) to be used by the lateral() method. For each available option (e.g. “apirp2geo”, “pisa”), the dictionary contains lists of mandatory and, optionally, optional keys. If any mandatory keys are missing in the provided DataFrame, an error is raised. Otherwise, the DataFrame is filtered to include the mandatory keys and any optional keys that are present.

LATERAL_SSI_KEYS: Dict[str, Dict[str, List[str | Tuple[str, str]]]] = {'apirp2geo': {'mandatory': ['Depth from [m]', 'Depth to [m]', 'Soil type', ('Total unit weight', '[kN/m3]'), ('Su', '[kPa]'), ('Phi', '[deg]'), ('epsilon50', '[-]')], 'optional': [('Dr', '[-]')]}, 'pisa': {'mandatory': ['Depth from [m]', 'Depth to [m]', 'Soil type', ('Total unit weight', '[kN/m3]'), ('Gmax', '[kPa]'), ('Su', '[kPa]'), ('Dr', '[-]')], 'optional': []}}
AXIAL_SSI_KEYS: Dict[str, Dict[str, List[str | Tuple[str, str]]]] = {'cpt': {'mandatory': [], 'optional': []}}
classmethod get_available_options(loading: str = 'lateral') list[str]

Return a list of available lateral soil reaction modeling options.

Parameters:

loading – String specifying the type of loading (default=’lateral’).

Returns:

List of available options for the specified loading type.

Raises:

ValueError – If the provided loading type is not supported.

classmethod lateral(df: DataFrame, option: str, mudline: float | None = None, pw: float = 1.025) DataFrame

Process soil profile data to ensure that the required inputs for lateral soil reaction modeling are present based on the specified option.

The method uses a pre-defined set of keys stored in the LATERAL_SSI_KEYS dictionary. Each option defines two categories: - mandatory: columns that must be present in the DataFrame. - optional: columns that will be included if they are present.

Available options: {“apirp2geo”, “pisa”}.

If any mandatory key defined for the selected option is missing from the DataFrame, a KeyError will be raised. The returned DataFrame will include the mandatory keys and any optional keys that exist in the input.

Parameters:
  • df – DataFrame containing the soil profile data.

  • option – String specifying the option to model the lateral soil reaction. The option must be one of the available options (e.g., “apirp2geo” or “pisa”).

  • mudline – float, sea bed level in mLAT coordinates (default=None).

  • pw – float, sea water density (default=1.025 t/m3)

Returns:

Filtered DataFrame containing only the required columns.

Raises:
  • NotImplementedError – If the provided option is not supported.

  • KeyError – If one or more mandatory columns are missing.