Skip to content

Commit d81b957

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev
2 parents 5851edf + 883d733 commit d81b957

File tree

7 files changed

+39
-42
lines changed

7 files changed

+39
-42
lines changed

src/bedrock_ge/gi/ags/read.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ def ags3_to_dfs(ags3_data: str) -> Dict[str, pd.DataFrame]:
5454
"""Converts AGS 3 data to a dictionary of pandas DataFrames.
5555
5656
Args:
57-
ags_data (str): The AGS 3 data as a string.
57+
ags3_data (str): The AGS 3 data as a string.
5858
5959
Returns:
6060
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 3 data,
6161
and the corresponding value is a pandas DataFrame containing the data for that group.
6262
"""
63-
6463
# Initialize dictionary and variables used in the AGS 3 read loop
6564
ags3_dfs = {}
6665
line_type = "line_0"
@@ -154,7 +153,7 @@ def ags4_to_dfs(ags4_data: str) -> Dict[str, pd.DataFrame]:
154153
"""Converts AGS 4 data to a dictionary of pandas DataFrames.
155154
156155
Args:
157-
ags_data (str): The AGS 4 data as a string.
156+
ags4_data (str): The AGS 4 data as a string.
158157
159158
Returns:
160159
Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 4 data,

src/bedrock_ge/gi/ags/transform.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ def ags3_db_to_no_gis_brgi_db(
3030
various types of geotechnical data including project information, locations,
3131
samples, lab tests, and in-situ measurements.
3232
33+
The mapping process:
34+
1. Project Data: Converts AGS 3 'PROJ' group to Bedrock's 'Project' table
35+
2. Location Data: Converts AGS 3 'HOLE' group to Bedrock's 'Location' table
36+
3. Sample Data: Converts AGS 3 'SAMP' group to Bedrock's 'Sample' table
37+
4. Other Data: Handles lab tests, in-situ measurements, and miscellaneous tables
38+
3339
Args:
3440
ags3_db (Dict[str, pd.DataFrame]): A dictionary containing AGS 3 data tables,
3541
where keys are table names and values are pandas DataFrames.
3642
crs (CRS): Coordinate Reference System for the project data.
3743
3844
Returns:
3945
Dict[str, pd.DataFrame]: A dictionary containing Bedrock GI database tables,
40-
where keys are table names and values are transformed pandas DataFrames.
41-
42-
The mapping process:
43-
1. Project Data: Converts AGS 3 'PROJ' group to Bedrock's 'Project' table
44-
2. Location Data: Converts AGS 3 'HOLE' group to Bedrock's 'Location' table
45-
3. Sample Data: Converts AGS 3 'SAMP' group to Bedrock's 'Sample' table
46-
4. Other Data: Handles lab tests, in-situ measurements, and miscellaneous tables
46+
where keys are table names and values are transformed pandas DataFrames.
4747
4848
Note:
4949
The function creates a copy of the input database to avoid modifying the original data.

src/bedrock_ge/gi/ags/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def check_ags_proj_group(ags_proj: pd.DataFrame) -> bool:
55
"""Checks if the AGS 3 or AGS 4 PROJ group is correct.
66
77
Args:
8-
proj_df (pd.DataFrame): The DataFrame with the PROJ group.
8+
ags_proj (pd.DataFrame): The DataFrame with the PROJ group.
99
1010
Raises:
1111
ValueError: If AGS 3 of AGS 4 PROJ group is not correct.

src/bedrock_ge/gi/concatenate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def concatenate_databases(
2222
Returns:
2323
dict: A dictionary of concatenated pandas DataFrames.
2424
"""
25-
2625
# Create a new dict to store the concatenated dataframes
2726
concatenated_dict = {key: df.dropna(axis=1, how="all") for key, df in db1.items()}
2827

src/bedrock_ge/gi/gis_geometry.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def calculate_gis_geometry(
2828
2929
Returns:
3030
Dict[str, gpd.GeoDataFrame]: Dictionary containing the Bedrock GI database tables
31-
with added GIS geometry. All tables are converted to GeoDataFrames with
32-
appropriate CRS and geometry columns.
31+
with added GIS geometry. All tables are converted to GeoDataFrames with
32+
appropriate CRS and geometry columns.
3333
3434
Raises:
3535
ValueError: If the projects in the database use different Coordinate Reference Systems (CRS).
@@ -109,12 +109,12 @@ def calculate_location_gis_geometry(
109109
crs (pyproj.CRS): The Coordinate Reference System (CRS) to use for the GIS geometry.
110110
111111
Returns:
112-
gpd.GeoDataFrame: The GIS geometry for the given GI locations, with *additional* columns:
113-
longitude: The longitude of the location in the WGS84 CRS.
114-
latitude: The latitude of the location in the WGS84 CRS.
115-
wgs84_ground_level_height: The height of the ground level of the location in the WGS84 CRS.
116-
elevation_at_base: The elevation at the base of the location.
117-
geometry: The GIS geometry of the location.
112+
gpd.GeoDataFrame: The GIS geometry for the given GI locations, with additional columns:
113+
- longitude: The longitude of the location in the WGS84 CRS.
114+
- latitude: The latitude of the location in the WGS84 CRS.
115+
- wgs84_ground_level_height: The height of the ground level of the location in the WGS84 CRS.
116+
- elevation_at_base: The elevation at the base of the location.
117+
- geometry: The GIS geometry of the location.
118118
"""
119119
# Calculate Elevation at base of GI location
120120
brgi_location["elevation_at_base"] = (
@@ -156,8 +156,7 @@ def calculate_location_gis_geometry(
156156
def calculate_wgs84_coordinates(
157157
from_crs: CRS, easting: float, northing: float, elevation: Union[float, None] = None
158158
) -> Tuple:
159-
"""Transforms coordinates from an arbitrary Coordinate Reference System (CRS) to
160-
the WGS84 CRS, which is the standard for geodetic coordinates.
159+
"""Transforms coordinates from an arbitrary Coordinate Reference System (CRS) to the WGS84 CRS, which is the standard for geodetic coordinates.
161160
162161
Args:
163162
from_crs (pyproj.CRS): The pyproj.CRS object of the CRS to transform from.
@@ -231,10 +230,10 @@ def calculate_in_situ_gis_geometry(
231230
crs (CRS): The Coordinate Reference System of the in-situ data.
232231
233232
Returns:
234-
gpd.GeoDataFrame: The GIS geometry for the given in-situ data, with *additional* columns:
235-
elevation_at_top: The elevation at the top of the in-situ data.
236-
elevation_at_base: The elevation at the base of the in-situ data.
237-
geometry: The GIS geometry of the in-situ data.
233+
gpd.GeoDataFrame: The GIS geometry for the given in-situ data, with additional columns:
234+
- elevation_at_top: The elevation at the top of the in-situ data.
235+
- elevation_at_base: The elevation at the base of the in-situ data.
236+
- geometry: The GIS geometry of the in-situ data.
238237
"""
239238
location_child = brgi_in_situ.copy()
240239

src/bedrock_ge/gi/validate.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def check_brgi_database(brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]):
2020
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BRGI) database (which is a dictionary of DataFrames).
2121
22-
This function checks that all tables in the BGI database conform to their respective schemas
22+
This function checks that all tables in the BRGI database conform to their respective schemas
2323
and that all foreign key relationships are properly maintained. It validates the following tables:
2424
- Project
2525
- Location
@@ -28,21 +28,22 @@ def check_brgi_database(brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]
2828
- Lab_TESTY (not yet implemented)
2929
3030
Args:
31-
brgi_db (Dict): A dictionary containing the BGI database tables, where keys are table names
32-
and values are the corresponding data tables (DataFrame or GeoDataFrame).
31+
brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
32+
containing the BRGI database tables, where keys are table names and
33+
values are the corresponding data tables (DataFrame or GeoDataFrame).
3334
3435
Returns:
3536
bool: True if all tables are valid and relationships are properly maintained.
3637
3738
Example:
3839
```python
39-
brgi_geodb = {
40+
brgi_db = {
4041
"Project": project_df,
4142
"Location": location_gdf,
4243
"Sample": sample_gdf,
43-
"InSitu_ISPT": in_situ_ispt_gdf
44+
"InSitu_ISPT": in_situ_ispt_gdf,
4445
}
45-
check_brgi_database(brgi_geodb)
46+
check_brgi_database(brgi_db)
4647
```
4748
"""
4849
for table_name, table in brgi_db.items():
@@ -82,16 +83,17 @@ def check_no_gis_brgi_database(
8283
):
8384
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BGI) database without GIS geometry.
8485
85-
This function performs the same validation as check_brgi_database but uses schemas that don't require
86-
GIS geometry. It validates the following tables:
86+
This function performs the same validation as `check_brgi_database` but uses schemas
87+
that don't require GIS geometry. It validates the following tables:
8788
- Project (never has GIS geometry)
8889
- Location (without GIS geometry)
8990
- Sample (without GIS geometry)
9091
- InSitu_TESTX (without GIS geometry)
9192
- Lab_TESTY (not yet implemented)
9293
9394
Args:
94-
brgi_db (Dict): A dictionary containing the Bedrock GI database tables, where keys are table names
95+
brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
96+
containing the Bedrock GI database tables, where keys are table names
9597
and values are the corresponding data tables (DataFrame or GeoDataFrame).
9698
9799
Returns:
@@ -103,7 +105,7 @@ def check_no_gis_brgi_database(
103105
"Project": projects_df,
104106
"Location": locations_df,
105107
"Sample": samples_df,
106-
"InSitu_measurements": insitu_df
108+
"InSitu_measurements": insitu_df,
107109
}
108110
check_no_gis_brgi_database(brgi_db)
109111
```

src/bedrock_ge/gi/write.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ def write_gi_db_to_gpkg(
1212
"""Writes a database with Bedrock Ground Investigation data to a GeoPackage file.
1313
1414
Writes a dictionary of DataFrames containing Bedrock Ground Investigation data to a
15-
GeoPackage file. Each DataFrame will be saved in a separate table named by the keys
16-
of the dictionary.
15+
[GeoPackage file](https://www.geopackage.org/). Each DataFrame will be saved in a
16+
separate table named by the keys of the dictionary.
1717
1818
Args:
19-
brgi_dfs (dict): A dictionary where keys are brgi table names and values are DataFrames
19+
brgi_db (dict): A dictionary where keys are brgi table names and values are DataFrames
2020
with brgi data.
2121
gpkg_path (str): The name of the output GeoPackage file.
2222
2323
Returns:
2424
None
2525
"""
26-
2726
# Create a GeoDataFrame from the dictionary of DataFrames
2827
for sheet_name, brgi_table in brgi_db.items():
2928
sanitized_table_name = sanitize_table_name(sheet_name)
@@ -56,7 +55,6 @@ def write_gi_db_to_excel(
5655
Returns:
5756
None
5857
"""
59-
6058
# Create an Excel writer object
6159
with pd.ExcelWriter(excel_path, engine="openpyxl") as writer:
6260
for sheet_name, df in gi_db.items():
@@ -78,7 +76,7 @@ def sanitize_table_name(sheet_name):
7876
sheet_name (str): The original sheet name.
7977
8078
Returns:
81-
sanitized_name (str): A sanitized sheet name with invalid characters and spaces replaced.
79+
sanitized_name: A sanitized sheet name with invalid characters and spaces replaced.
8280
"""
8381
# Trim to a maximum length of 31 characters
8482
trimmed_name = sheet_name.strip()[:31]

0 commit comments

Comments
 (0)