Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b4548f2
feat: Add JSON I/O functionality for surface points
flohorovicic Mar 19, 2025
e27ca15
feat: Add orientation data loading functionality
flohorovicic Mar 19, 2025
cb34e62
feat: Add horizontal stratigraphic model tutorial
flohorovicic Mar 19, 2025
f91fa03
fix: Update JSON loading to use surface names from series data - Add …
flohorovicic Mar 19, 2025
9b78ac2
fix: Update horizontal stratigraphic tutorial with correct data and m…
flohorovicic Mar 19, 2025
49b4f25
fix: correct IDs and positions for fault and rock1 in multiple series…
flohorovicic Mar 19, 2025
1e7b405
Added .json input file
flohorovicic Mar 19, 2025
c926296
Updated .json input file
flohorovicic Mar 19, 2025
f82abf2
Adjustments in stack-mapping for more flexible handling of faults
flohorovicic Mar 19, 2025
0f1734b
Added modules __init__ and minor changes in json module
flohorovicic Mar 19, 2025
6cf9a44
fix: Fix metadata handling in JSON I/O for proper preservation when l…
flohorovicic Mar 22, 2025
4c1d177
Updated .gitignore (only to ignore files generated by new tutorial)
flohorovicic Mar 22, 2025
61b7dec
Extended functionality to save .json and adjusted tests. Simple model…
flohorovicic Mar 23, 2025
6a40125
Added structural relations to .json and fixed error in second example
flohorovicic Mar 23, 2025
2a7d8f8
Fixed problem with loading of surface layer stack
flohorovicic Mar 23, 2025
e6fade1
Fixed stratigraphic pile handling in JSON I/O by reverting to working…
flohorovicic Mar 23, 2025
660ae65
Included name-id mapping in .json
flohorovicic Mar 24, 2025
1637ddb
Fix JSON serialization for NumPy types and update example data
flohorovicic Mar 24, 2025
e31bda4
Adjusted date format
flohorovicic Mar 24, 2025
c92878b
Simplified required json input further and added "minimal working exa…
flohorovicic Mar 25, 2025
6d1e029
Simplified minimal input even further: now only points and orientatio…
flohorovicic Mar 25, 2025
84d3332
Updated minimal json examples and comparison to minimal GemPy model
flohorovicic Mar 25, 2025
0386163
Additional fixes to get defaults right
flohorovicic Mar 25, 2025
360a103
Added default nugget value to minimize input even further
flohorovicic Mar 25, 2025
36fec0d
Updated tests and fixed code to pass tests.
flohorovicic Mar 28, 2025
949f7e0
fix: Update fault model example with correct series mapping and visua…
flohorovicic Apr 5, 2025
601e523
Improve scalar field visualization in fault model example - Add prope…
flohorovicic Apr 6, 2025
94f6fd3
Example model for a combination of series and faults from json
flohorovicic Apr 6, 2025
593dbbd
Add combination model JSON files to gitignore
flohorovicic Apr 6, 2025
a4f4264
fix: preserve colors when loading models from JSON - Added color pres…
flohorovicic Apr 6, 2025
cb5693c
test: update JSON I/O tests to verify color preservation - Added colo…
flohorovicic Apr 6, 2025
0e95fb7
Added TODOs for PR.
javoha Apr 11, 2025
369ef46
Added TODOs for PR.
javoha Apr 11, 2025
20ad605
fix: ensure NotRequired import works for both Python 3.11+ and earlie…
flohorovicic Apr 27, 2025
9d9f304
[BUG] Ensure compatibility with older Python versions
Leguark May 1, 2025
040d84a
Merge branch 'main' into fork/flohorovicic/feature/json_io
Leguark May 1, 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
Improve scalar field visualization in fault model example - Add prope…
…r visualization, fix surface points plotting, add colorbar and labels
  • Loading branch information
flohorovicic committed Apr 6, 2025
commit 601e5238240eff2dff4437644ba2df8f41c41510
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@
# Compute the geological model
gp.compute_model(model)

# Print scalar field values to verify they are calculated
print("\nScalar Field Values (Fault Series):")
print(f"Shape: {model.solutions.raw_arrays.scalar_field_matrix.shape}")
print(f"Min value: {model.solutions.raw_arrays.scalar_field_matrix[0].min()}")
print(f"Max value: {model.solutions.raw_arrays.scalar_field_matrix[0].max()}")
print(f"Mean value: {model.solutions.raw_arrays.scalar_field_matrix[0].mean()}")

# %%
# Save the computed model to a new JSON file
computed_json_file = tutorial_dir / "multiple_series_faults_computed.json"
Expand Down Expand Up @@ -183,36 +190,63 @@
plt.close()

# Plot 3: Scalar field of the fault
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
gpv.plot_2d(
model,
cell_number=25,
direction='y',
show_scalar=True,
show_data=True,
series_n=0, # Fault series
show_results=False,
ax=ax
)
plt.title("Fault Scalar Field - Y Direction")
plt.figure(figsize=(10, 8))
ax = plt.gca()

# Get scalar field values and reshape to grid
scalar_field = model.solutions.raw_arrays.scalar_field_matrix[0].reshape(50, 50, 50)

# Plot middle slice in Y direction
middle_slice = scalar_field[:, 25, :]
im = ax.imshow(middle_slice.T,
extent=[0, 1000, 0, 1000],
origin='lower',
cmap='RdBu',
aspect='equal')

# Add colorbar
plt.colorbar(im, ax=ax, label='Scalar Field Value')

# Plot surface points
fault_element = model.structural_frame.get_element_by_name("fault")
if fault_element and fault_element.surface_points is not None:
fault_points_coords = fault_element.surface_points.xyz

# Filter points near the slice (Y around 500)
mask = np.abs(fault_points_coords[:, 1] - 500) < 100
filtered_points = fault_points_coords[mask]

if len(filtered_points) > 0:
ax.scatter(filtered_points[:, 0], filtered_points[:, 2],
c='red', s=50, label='Surface Points')
ax.legend()

ax.set_xlabel('X')
ax.set_ylabel('Z')
ax.set_title('Fault Scalar Field - Y Direction (Middle Slice)')

# Save plot
plt.savefig('fault_scalar_field.png', dpi=300, bbox_inches='tight')
plt.close()

# Plot 4: 3D visualization
# Note: 3D plotting requires interactive backend
try:
import pyvista as pv
p = pv.Plotter(notebook=False, off_screen=True)
gpv.plot_3d(
model,
show_data=True,
show_surfaces=True,
show_boundaries=True,
plotter=p
)
p.screenshot('model_3d.png', transparent_background=False)
p.close()
except Exception as e:
print(f"Could not create 3D plot: {e}")
print("\nPlot saved as fault_scalar_field.png")

# Plot 4: 3D visualization (optional)
PLOT_3D = False # Set to True to enable 3D plotting

if PLOT_3D:
try:
import pyvista as pv
p = pv.Plotter(notebook=False, off_screen=True)
gpv.plot_3d(
model,
show_data=True,
show_surfaces=True,
show_boundaries=True,
plotter=p
)
p.screenshot('model_3d.png', transparent_background=False)
p.close()
except Exception as e:
print(f"Could not create 3D plot: {e}")
# %%