Processing¶
SoilDataProcessor ¶
Helper routines for processing soil API payloads.
Examples:
>>> import pandas as pd
>>> from owi.metadatabase.soil.processing import SoilDataProcessor
>>> raw = pd.DataFrame({"z [m]": [0.0], "qc": [5.0]})
>>> proc = pd.DataFrame({"z [m]": [0.0], "qt": [5.1]})
>>> SoilDataProcessor.combine_dfs({"rawdata": raw, "processeddata": proc}).shape
(1, 3)
Functions¶
transform_coord
staticmethod
¶
Transform coordinates from EPSG:4326 to a target SRID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input data containing |
required |
longitude
|
float
|
Longitude of the reference point in decimal degrees. |
required |
latitude
|
float
|
Latitude of the reference point in decimal degrees. |
required |
target_srid
|
str
|
Target EPSG code (for example |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, float, float]
|
Updated DataFrame, transformed easting, and transformed northing. |
Examples:
>>> import pandas as pd
>>> df = pd.DataFrame({"easting": [2.0], "northing": [50.0]})
>>> out, east, north = SoilDataProcessor.transform_coord(df, 2.0, 50.0, "25831")
>>> {"easting [m]", "northing [m]"}.issubset(set(out.columns))
True
>>> isinstance(east, float) and isinstance(north, float)
True
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
combine_dfs
staticmethod
¶
Merge raw and processed in-situ test tables on depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dfs
|
dict[str, DataFrame]
|
Dictionary containing |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Merged DataFrame, or raw data if merge fails. |
Examples:
>>> import pandas as pd
>>> raw = pd.DataFrame({"z [m]": [0.0], "qc": [5.0]})
>>> proc = pd.DataFrame({"z [m]": [0.0], "qt": [5.1]})
>>> SoilDataProcessor.combine_dfs({"rawdata": raw, "processeddata": proc}).columns.tolist()
['z [m]', 'qc', 'qt']
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
process_insitutest_dfs
staticmethod
¶
Extract nested in-situ test payloads as flat DataFrames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
In-situ test detail table with nested columns. |
required |
cols
|
list[str]
|
Column names to extract and convert. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame]
|
Processed tables keyed by source column name. |
Examples:
>>> import pandas as pd
>>> detail = pd.DataFrame({"rawdata": [[{"z [m]": 0.0, "qc": 5.0}]]})
>>> out = SoilDataProcessor.process_insitutest_dfs(detail, ["rawdata"])
>>> list(out.keys())
['rawdata']
>>> out["rawdata"].shape[0]
1
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
gather_data_entity
staticmethod
¶
Select the closest entity and return metadata with the full table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Candidate entities, including |
required |
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame | int | str | float | None]
|
Dictionary containing selected id/title/offset and input data. |
Examples:
>>> import pandas as pd
>>> inp = pd.DataFrame({"id": [2, 1], "title": ["B", "A"], "offset [m]": [5.0, 1.0]})
>>> out = SoilDataProcessor.gather_data_entity(inp)
>>> int(out["id"])
1
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
process_cpt
staticmethod
¶
Create a PCPTProcessing object from CPT summary and raw data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_sum
|
DataFrame
|
CPT summary table containing the CPT title. |
required |
df_raw
|
DataFrame
|
CPT raw measurement table. |
required |
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
PCPTProcessing or None
|
Processed CPT object, or |
Examples:
>>> import pandas as pd
>>> df_sum = pd.DataFrame({"title": ["CPT-1"]})
>>> df_raw = pd.DataFrame({"z [m]": [0.0], "qc": [1.0]})
>>> obj = SoilDataProcessor.process_cpt(df_sum, df_raw)
>>> obj is None or obj.__class__.__name__ == 'PCPTProcessing'
True
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
convert_to_profile
staticmethod
¶
Convert soil profile detail records to a Groundhog profile object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_sum
|
DataFrame
|
Soil profile summary table. |
required |
df_detail
|
DataFrame
|
Soil profile detail table containing |
required |
profile_title
|
str or None
|
Title override for the output profile. |
required |
drop_info_cols
|
bool
|
If |
required |
Returns:
| Type | Description |
|---|---|
SoilProfile or None
|
Converted profile, or |
Examples:
>>> import pandas as pd
>>> df_sum = pd.DataFrame({"location_name": ["LOC"], "title": ["Profile"]})
>>> layers = [{
... "start_depth": 0.0,
... "end_depth": 1.0,
... "soiltype_name": "SAND",
... "totalunitweight": 18.0,
... "soilparameters": {},
... "id": 1,
... "profile": 1,
... "soilprofile_name": "P",
... "soilunit": None,
... "description": "",
... "soilunit_name": "",
... }]
>>> df_detail = pd.DataFrame({"soillayer_set": [layers]})
>>> profile = SoilDataProcessor.convert_to_profile(df_sum, df_detail, "Demo", True)
>>> profile is None or profile.__class__.__name__ == 'SoilProfile'
True
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
fulldata_processing
staticmethod
¶
Filter full test data to the selected depth ranges for one location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unitdata
|
DataFrame
|
Accumulator DataFrame. |
required |
row
|
Series
|
Row describing the current location. |
required |
selected_depths
|
DataFrame
|
Depth intervals per location. |
required |
func_get_details
|
Callable
|
Function returning detail data with a |
required |
depthcol
|
str
|
Name of the depth column in the returned data. |
required |
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered and annotated unit data. |
Examples:
>>> import pandas as pd
>>> row = pd.Series({"location_name": "LOC", "projectsite_name": "P", "test_type_name": "CPT"})
>>> selected = pd.DataFrame({"location_name": ["LOC"], "start_depth": [0.0], "end_depth": [1.0]})
>>> def _get_details(**kwargs):
... return {"rawdata": pd.DataFrame({"z [m]": [0.5, 2.0], "qc": [1, 2]})}
>>> out = SoilDataProcessor.fulldata_processing(pd.DataFrame(), row, selected, _get_details, "z [m]")
>>> out.shape[0]
1
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
partialdata_processing
staticmethod
¶
Append selected tests whose point depth falls in selected intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unitdata
|
DataFrame
|
Accumulator DataFrame. |
required |
row
|
Series
|
Current test row with |
required |
selected_depths
|
DataFrame
|
Depth intervals per location. |
required |
selected_tests
|
DataFrame
|
Candidate tests. |
required |
Returns:
| Type | Description |
|---|---|
None
|
The function mutates |
Examples:
>>> import pandas as pd
>>> unit = pd.DataFrame()
>>> row = pd.Series({"id": 1, "depth": 0.5, "location_name": "LOC"})
>>> depth = pd.DataFrame({"location_name": ["LOC"], "start_depth": [0.0], "end_depth": [1.0]})
>>> tests = pd.DataFrame({"id": [1], "qc": [10]})
>>> SoilDataProcessor.partialdata_processing(unit, row, depth, tests)
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
objects_to_list
staticmethod
¶
Load and georeference profile/CPT objects from summary rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_obj
|
DataFrame
|
Summary rows selected by the user. |
required |
func_get_detail
|
Callable
|
API method that returns a detail dictionary. |
required |
data_type
|
str
|
Target key in the detail dictionary ( |
required |
Returns:
| Type | Description |
|---|---|
list
|
List of loaded objects with position set. |
Examples:
>>> import pandas as pd
>>> selected = pd.DataFrame(
... columns=[
... "projectsite_name",
... "location_name",
... "title",
... "easting",
... "northing",
... "elevation",
... "test_type_name",
... ]
... )
>>> SoilDataProcessor.objects_to_list(selected, lambda **k: {}, "soilprofile")
[]
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
SoilprofileProcessor ¶
Prepare soil profile inputs for SSI workflows.
Notes
The class keeps central key registries for different SSI methods and uses them to validate and subset user-provided DataFrames.
Examples:
Functions¶
get_available_options
classmethod
¶
Return available processing options for a loading family.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loading
|
str
|
Loading family to query ( |
"lateral"
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Option names configured for the selected loading family. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
Source code in src/owi/metadatabase/soil/processing/soil_pp.py
lateral
classmethod
¶
Prepare a soil profile table for lateral SSI workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Source soil profile data. |
required |
option
|
str
|
Lateral option name, such as |
required |
mudline
|
float or None
|
Seabed level in mLAT. |
None
|
pw
|
float
|
Seawater density in t/m³. |
1.025
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered profile containing required and optional keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
ValueError
|
If mandatory columns are missing. |
Examples:
>>> import pandas as pd
>>> data = pd.DataFrame({
... "Depth from [m]": [0.0], "Depth to [m]": [1.0], "Soil type": ["SAND"],
... "Total unit weight [kN/m3]": [18.0], "Su [kPa]": [10.0], "Phi [deg]": [30.0],
... "epsilon50 [-]": [0.02], "Dr [-]": [0.6]
... })
>>> out = SoilprofileProcessor.lateral(data, "apirp2geo")
>>> "Submerged unit weight [kN/m3]" in out.columns
True