Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cec6e0f
feat: Add JSON I/O functionality for surface points
flohorovicic Mar 19, 2025
1e86bcd
feat: Add orientation data loading functionality
flohorovicic Mar 19, 2025
8d031e6
feat: Add horizontal stratigraphic model tutorial
flohorovicic Mar 19, 2025
7790956
fix: Update JSON loading to use surface names from series data - Add …
flohorovicic Mar 19, 2025
74ef1d3
fix: Update horizontal stratigraphic tutorial with correct data and m…
flohorovicic Mar 19, 2025
8e580d8
fix: correct IDs and positions for fault and rock1 in multiple series…
flohorovicic Mar 19, 2025
3eb7dc0
Added .json input file
flohorovicic Mar 19, 2025
5c2b339
Updated .json input file
flohorovicic Mar 19, 2025
430a5ac
Adjustments in stack-mapping for more flexible handling of faults
flohorovicic Mar 19, 2025
2f5a6b5
Added modules __init__ and minor changes in json module
flohorovicic Mar 19, 2025
04e87a1
fix: Fix metadata handling in JSON I/O for proper preservation when l…
flohorovicic Mar 22, 2025
1df8dac
Updated .gitignore (only to ignore files generated by new tutorial)
flohorovicic Mar 22, 2025
1c60ddd
Extended functionality to save .json and adjusted tests. Simple model…
flohorovicic Mar 23, 2025
427092e
Added structural relations to .json and fixed error in second example
flohorovicic Mar 23, 2025
3fd2106
Fixed problem with loading of surface layer stack
flohorovicic Mar 23, 2025
9caa992
Fixed stratigraphic pile handling in JSON I/O by reverting to working…
flohorovicic Mar 23, 2025
c5ddb5a
Included name-id mapping in .json
flohorovicic Mar 24, 2025
e6d8c23
Fix JSON serialization for NumPy types and update example data
flohorovicic Mar 24, 2025
f80c4b0
Adjusted date format
flohorovicic Mar 24, 2025
c06aa90
Simplified required json input further and added "minimal working exa…
flohorovicic Mar 25, 2025
2a2c46b
Simplified minimal input even further: now only points and orientatio…
flohorovicic Mar 25, 2025
c4f60aa
Updated minimal json examples and comparison to minimal GemPy model
flohorovicic Mar 25, 2025
e6f9794
Additional fixes to get defaults right
flohorovicic Mar 25, 2025
558a185
Added default nugget value to minimize input even further
flohorovicic Mar 25, 2025
f9862ed
Updated tests and fixed code to pass tests.
flohorovicic Mar 28, 2025
bf069e9
fix: Update fault model example with correct series mapping and visua…
flohorovicic Apr 5, 2025
77a9625
Improve scalar field visualization in fault model example - Add prope…
flohorovicic Apr 6, 2025
5948e42
Example model for a combination of series and faults from json
flohorovicic Apr 6, 2025
a615e8d
Add combination model JSON files to gitignore
flohorovicic Apr 6, 2025
56ac045
fix: preserve colors when loading models from JSON - Added color pres…
flohorovicic Apr 6, 2025
e35ec32
test: update JSON I/O tests to verify color preservation - Added colo…
flohorovicic Apr 6, 2025
986d6c8
Added TODOs for PR.
javoha Apr 11, 2025
27b2292
Added TODOs for PR.
javoha Apr 11, 2025
bb3dc7a
fix: ensure NotRequired import works for both Python 3.11+ and earlie…
flohorovicic Apr 27, 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
Prev Previous commit
Next Next commit
Simplified minimal input even further: now only points and orientatio…
…ns requried; standard stack created by default based on point/ orientation ids.
  • Loading branch information
flohorovicic authored and Leguark committed May 1, 2025
commit 2a2c46b40663601f2f467424390bcdd07b037e3b
12 changes: 4 additions & 8 deletions examples/tutorials/z_other_tutorials/json_io/05_minimal_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@
"orientations": [
{"x": 500.0, "y": 500.0, "z": 600.0, "G_x": 0.0, "G_y": 0.0, "G_z": 1.0, "id": 1, "nugget": 0.01, "polarity": 1},
{"x": 500.0, "y": 500.0, "z": 400.0, "G_x": 0.0, "G_y": 0.0, "G_z": 1.0, "id": 0, "nugget": 0.01, "polarity": 1},
],
"series": [
{
"name": "Strat_Series",
"surfaces": ["surface_1", "surface_2"]
# structural_relation will default to "ONLAP"
# colors are optional
}
]
# series will be automatically created with default values:
# - name: "Strat_Series"
# - surfaces: ["surface_0", "surface_1"] (based on unique IDs)
# - structural_relation: "ERODE"
}

# %%
Expand Down
53 changes: 33 additions & 20 deletions gempy/modules/json_io/json_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ def load_model_from_json(file_path: str):
if not JsonIO._validate_json_schema(data):
raise ValueError("Invalid JSON schema")

# Get unique surface IDs from surface points and orientations
surface_ids = set(sp['id'] for sp in data['surface_points'])
surface_ids.update(ori['id'] for ori in data['orientations'])

# Create default series if not provided
if 'series' not in data:
data['series'] = [{
'name': 'Strat_Series',
'surfaces': [f'surface_{id}' for id in sorted(surface_ids)],
'structural_relation': 'ERODE'
}]

# Get surface names from series data
surface_names = []
for series in data['series']:
Expand Down Expand Up @@ -409,8 +421,8 @@ def _validate_json_schema(data: Dict[str, Any]) -> bool:
Returns:
bool: True if valid, False otherwise
"""
# Check required top-level keys (metadata, grid_settings, and interpolation_options are optional)
required_keys = {'surface_points', 'orientations', 'series'}
# Check required top-level keys (metadata, grid_settings, interpolation_options, and series are optional)
required_keys = {'surface_points', 'orientations'}
if not all(key in data for key in required_keys):
return False

Expand Down Expand Up @@ -442,27 +454,28 @@ def _validate_json_schema(data: Dict[str, Any]) -> bool:
if not isinstance(ori['polarity'], int):
return False

# Validate series
if not isinstance(data['series'], list):
return False

for series in data['series']:
# Only name and surfaces are required
required_series_keys = {'name', 'surfaces'}
if not all(key in series for key in required_series_keys):
return False
if not isinstance(series['name'], str):
# Validate series if present
if 'series' in data:
if not isinstance(data['series'], list):
return False
if not isinstance(series['surfaces'], list):
return False
# Validate optional fields if present
if 'structural_relation' in series and not isinstance(series['structural_relation'], str):
return False
if 'colors' in series:
if not isinstance(series['colors'], list):

for series in data['series']:
# Only name and surfaces are required
required_series_keys = {'name', 'surfaces'}
if not all(key in series for key in required_series_keys):
return False
if not isinstance(series['name'], str):
return False
if not isinstance(series['surfaces'], list):
return False
if not all(isinstance(color, str) for color in series['colors']):
# Validate optional fields if present
if 'structural_relation' in series and not isinstance(series['structural_relation'], str):
return False
if 'colors' in series:
if not isinstance(series['colors'], list):
return False
if not all(isinstance(color, str) for color in series['colors']):
return False

# Validate grid settings if present
if 'grid_settings' in data:
Expand Down