Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d55523e
fix: add check for missing/invalid args in project
AngRodrigues Dec 17, 2024
596ddb3
chore: add mention to issue
AngRodrigues Dec 17, 2024
3345bbe
chore: clear warnings
AngRodrigues Jan 7, 2025
b1a94bd
chore: make warnings clear
AngRodrigues Jan 7, 2025
1bb6e47
chore: make warnings clear
AngRodrigues Jan 7, 2025
27ea51d
tests: bypass the necessary dataset requirement
AngRodrigues Jan 7, 2025
c9da10d
fix: skip required file checks if using loop server data
AngRodrigues Jan 7, 2025
713abff
fix: make the config check through project
AngRodrigues Jan 7, 2025
b52d540
tests: add tests for config checks
AngRodrigues Jan 7, 2025
6322872
style: style fixes by ruff and autoformatting by black
AngRodrigues Jan 7, 2025
554ed6a
fiz: actually use libmamba on build
AngRodrigues Jan 7, 2025
f9752b2
revert previous commit
AngRodrigues Jan 7, 2025
9be3ac6
fix: add init commit
AngRodrigues Jan 8, 2025
29466fe
style: style fixes by ruff and autoformatting by black
AngRodrigues Jan 8, 2025
848f31c
tests: add tests for data_checks for each datatype
AngRodrigues Jan 8, 2025
0257a55
Merge branch 'fix/add_data_checks' of https://github.com/Loop3D/map2l…
AngRodrigues Jan 8, 2025
c68ce9a
fix: actually abort the process if validation fails
AngRodrigues Jan 8, 2025
b9663d6
Merge branch 'fix--162' of https://github.com/Loop3D/map2loop into fi…
AngRodrigues Jan 8, 2025
06ff551
fix: add config check step to project
AngRodrigues Jan 8, 2025
6529bf8
fix: add extra checks for config dictionary
AngRodrigues Jan 8, 2025
ce44489
tests: add config test and reorganise
AngRodrigues Jan 8, 2025
0a85eac
fix: add data checks for fold data and update tests accordingly
AngRodrigues Jan 8, 2025
9eb8fed
Merge branch 'master' of https://github.com/Loop3D/map2loop into fix/…
AngRodrigues Jan 13, 2025
273b82d
typos from merging
AngRodrigues Jan 13, 2025
04b43f1
chore: another typo
AngRodrigues Jan 13, 2025
fc2e393
fix: remove kwargs from project
AngRodrigues Jan 13, 2025
e919f94
chore: refactor geometry checks
AngRodrigues Jan 13, 2025
0002262
chore: update tests for geometry refactor
AngRodrigues Jan 13, 2025
b066a22
chore: refactor id checks
AngRodrigues Jan 14, 2025
141c39f
Merge branch 'master' of https://github.com/Loop3D/map2loop into fix/…
AngRodrigues Jan 14, 2025
9001a08
chore: refactor mandatory fields for str and geo
AngRodrigues Jan 14, 2025
652281c
finalise refactor
AngRodrigues Jan 14, 2025
d1f67a9
chore: finalise details
AngRodrigues Jan 14, 2025
1c42d2e
docs: comment typo
lachlangrose Jan 20, 2025
93fcbd0
add test cases as examples
lachlangrose May 1, 2025
6d0143a
make valid
lachlangrose May 1, 2025
84a1ec2
add warning back as info
lachlangrose May 1, 2025
ae6bf3d
making messages less repetitive
lachlangrose May 1, 2025
406b994
style: style fixes by ruff and autoformatting by black
lachlangrose May 1, 2025
7082b7f
Merge branch 'master' into fix/add_data_checks
lachlangrose May 1, 2025
99fa9da
tests: updating tests after adding geometry validation
lachlangrose May 1, 2025
da9ff10
Merge branch 'fix/add_data_checks' of github.com:Loop3D/map2loop into…
lachlangrose May 1, 2025
85687d3
missed fold
lachlangrose May 1, 2025
f629b2d
fix: remove duplicate functions
lachlangrose May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
403 changes: 403 additions & 0 deletions docs/examples/plot_data_checks_on_fault.py

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions docs/examples/plot_data_checks_on_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# %%
import geopandas as gpd
from map2loop.mapdata import MapData
from map2loop import data_checks
import shapely.geometry


# Mock Datatype Enum
class Datatype:
GEOLOGY = 0
STRUCTURE = 1


# Mock Config class
class MockConfig:
def __init__(self):
self.structure_config = {
"dipdir_column": "DIPDIR",
"dip_column": "DIP",
"description_column": "DESCRIPTION",
"overturned_column": "OVERTURNED",
"objectid_column": "ID",
}


# Mock data for the structure dataset
valid_structure_data = {
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": [45.0, 135.0],
"DIP": [30.0, 45.0],
"DESCRIPTION": ["Description1", "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}

# Create a GeoDataFrame for valid structure data
valid_structure_gdf = gpd.GeoDataFrame(valid_structure_data, crs="EPSG:4326")


# Instantiate the MapData class with the mock config and data
map_data = MapData()
map_data.config = MockConfig()

# Test with valid structure data
map_data.raw_data = [None] * len(Datatype.__dict__)
map_data.raw_data[Datatype.STRUCTURE] = valid_structure_gdf
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print("Test 1 - Valid Data:")
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data with invalid geometry
invalid_geometry_structure_data = valid_structure_data.copy()
invalid_geometry_structure_data["geometry"] = [
shapely.geometry.Point(0, 0),
shapely.geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 1), (0, 0)]), # Invalid geometry
]
invalid_geometry_structure_gdf = gpd.GeoDataFrame(invalid_geometry_structure_data, crs="EPSG:4326")


# Test with invalid geometry
map_data.raw_data[Datatype.STRUCTURE] = invalid_geometry_structure_gdf
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print("\nTest 3 - Invalid Geometry:")
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data with missing required columns
missing_column_structure_data = valid_structure_data.copy()
del missing_column_structure_data["DIPDIR"]
missing_column_structure_gdf = gpd.GeoDataFrame(missing_column_structure_data, crs="EPSG:4326")

# Test with missing required column
map_data.raw_data[Datatype.STRUCTURE] = missing_column_structure_gdf
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print("\nTest 2 - Missing Required Column:")
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = {
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": ["A", "B"],
"DIP": [30.0, 45.0],
"DESCRIPTION": ["Description1", "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = gpd.GeoDataFrame(
{
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": ["A", "B"],
"DIP": [30.0, 45.0],
"DESCRIPTION": ["Description1", "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}
)

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = gpd.GeoDataFrame(
{
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": [None, 3],
"DIP": [30.0, 45.0],
"DESCRIPTION": ["Description1", "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}
)

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = gpd.GeoDataFrame(
{
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": [5, 3],
"DIP": [120.0, 45.0],
"DESCRIPTION": ["Description1", "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}
)

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = gpd.GeoDataFrame(
{
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": [5, 3],
"DIP": [90, 45.0],
"DESCRIPTION": [None, "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 2],
}
)

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
# Mock data for the structure dataset
invalid_structure_data = gpd.GeoDataFrame(
{
"geometry": [shapely.geometry.Point(0, 0), shapely.geometry.Point(1, 1)],
"DIPDIR": [5, 3],
"DIP": [90, 45.0],
"DESCRIPTION": [None, "Description2"],
"OVERTURNED": ["Yes", "No"],
"ID": [1, 1],
}
)

map_data.raw_data[Datatype.STRUCTURE] = invalid_structure_data
validity_check, message = data_checks.check_structure_fields_validity(map_data)
print(f"Validity Check: {validity_check}, Message: {message}")

# %%
Loading