Skip to content

Commit a854dba

Browse files
authored
fix: Plot simple table kr (#207)
1 parent 6fa3c60 commit a854dba

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

geos-trame/src/geos/trame/app/ui/plotting.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
3-
# SPDX-FileContributor: Lionel Untereiner
3+
# SPDX-FileContributor: Lionel Untereiner, Jacques Franc
44
from typing import Any
55

66
import matplotlib.pyplot as plt
@@ -57,42 +57,41 @@ def _figure_size( self ) -> dict:
5757
"dpi": dpi,
5858
}
5959

60-
@staticmethod
61-
def _inverse_gaz( x: np.ndarray ) -> np.ndarray:
62-
return 1 - x
63-
6460
def _permeability( self, **kwargs: Any ) -> Figure:
6561
# read data
6662
assert self.source.input_file is not None
63+
if self.source.input_file is None:
64+
return Figure
65+
water_x = np.array( [] )
66+
water_y = np.array( [] )
67+
gaz_x = np.array( [] )
68+
gaz_y = np.array( [] )
6769
for f in self.source.plots():
6870
for t in f.table_function:
6971
if t.name == "waterRelativePermeabilityTable":
7072
fileX = t.coordinate_files.strip( "{(.+)}" ).strip()
7173
assert fileX is not None and t.voxel_file is not None
72-
self.water_x = np.loadtxt( self.source.input_file.path + "/" + fileX )
73-
self.water_y = np.loadtxt( self.source.input_file.path + "/" + t.voxel_file )
74+
water_x = np.loadtxt( self.source.input_file.path + "/" + fileX )
75+
water_y = np.loadtxt( self.source.input_file.path + "/" + t.voxel_file )
7476

7577
if t.name == "gasRelativePermeabilityTable":
7678
fileX = t.coordinate_files.strip( "{(.+)}" ).strip()
7779
assert fileX is not None and t.voxel_file is not None
78-
7980
gaz_x = np.loadtxt( self.source.input_file.path + "/" + fileX )
80-
self.gaz_x = self._inverse_gaz( gaz_x )
81-
self.gaz_y = np.loadtxt( self.source.input_file.path + "/" + t.voxel_file )
81+
gaz_x = 1. - gaz_x
82+
gaz_y = np.loadtxt( self.source.input_file.path + "/" + t.voxel_file )
8283

8384
# make drawing
8485
plt.close( "all" )
8586
fig, ax = plt.subplots( **kwargs )
8687

87-
if ( self.water_x is not None and self.water_y is not None and self.gaz_x is not None
88-
and self.gaz_y is not None ):
89-
np.random.seed( 0 )
90-
ax.plot( self.water_x, self.water_y, label="water" )
91-
ax.plot( self.gaz_x, self.gaz_y, label="gaz" )
88+
if all( a.size > 0 for a in [ gaz_x, gaz_y, water_x, water_y ] ):
89+
ax.plot( water_x, water_y, '+-', label="water" )
90+
ax.plot( gaz_x, gaz_y, '+-', label="gaz" )
9291

9392
ax.set_xlabel( "Water saturation" )
9493
ax.set_ylabel( "Relative permeability" )
95-
ax.set_title( "Matplotlib Plot Rendered in D3!", size=14 )
94+
ax.set_title( "Relative Permeabilities", size=14 )
9695
ax.grid( color="lightgray", alpha=0.7 )
9796
plt.xlim( [ 0, 1 ] )
9897
plt.ylim( [ 0, 1 ] )

0 commit comments

Comments
 (0)