|
1 | 1 | # SPDX-License-Identifier: Apache-2.0 |
2 | 2 | # SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. |
3 | | -# SPDX-FileContributor: Lionel Untereiner |
| 3 | +# SPDX-FileContributor: Lionel Untereiner, Jacques Franc |
4 | 4 | from typing import Any |
5 | 5 |
|
6 | 6 | import matplotlib.pyplot as plt |
@@ -57,42 +57,41 @@ def _figure_size( self ) -> dict: |
57 | 57 | "dpi": dpi, |
58 | 58 | } |
59 | 59 |
|
60 | | - @staticmethod |
61 | | - def _inverse_gaz( x: np.ndarray ) -> np.ndarray: |
62 | | - return 1 - x |
63 | | - |
64 | 60 | def _permeability( self, **kwargs: Any ) -> Figure: |
65 | 61 | # read data |
66 | 62 | 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( [] ) |
67 | 69 | for f in self.source.plots(): |
68 | 70 | for t in f.table_function: |
69 | 71 | if t.name == "waterRelativePermeabilityTable": |
70 | 72 | fileX = t.coordinate_files.strip( "{(.+)}" ).strip() |
71 | 73 | 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 ) |
74 | 76 |
|
75 | 77 | if t.name == "gasRelativePermeabilityTable": |
76 | 78 | fileX = t.coordinate_files.strip( "{(.+)}" ).strip() |
77 | 79 | assert fileX is not None and t.voxel_file is not None |
78 | | - |
79 | 80 | 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 ) |
82 | 83 |
|
83 | 84 | # make drawing |
84 | 85 | plt.close( "all" ) |
85 | 86 | fig, ax = plt.subplots( **kwargs ) |
86 | 87 |
|
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" ) |
92 | 91 |
|
93 | 92 | ax.set_xlabel( "Water saturation" ) |
94 | 93 | ax.set_ylabel( "Relative permeability" ) |
95 | | - ax.set_title( "Matplotlib Plot Rendered in D3!", size=14 ) |
| 94 | + ax.set_title( "Relative Permeabilities", size=14 ) |
96 | 95 | ax.grid( color="lightgray", alpha=0.7 ) |
97 | 96 | plt.xlim( [ 0, 1 ] ) |
98 | 97 | plt.ylim( [ 0, 1 ] ) |
|
0 commit comments