Skip to content

Commit

Permalink
- fixed restarting vtk in plotdata
Browse files Browse the repository at this point in the history
- improved set_formations to be more consistent to qgrid
- passing formation number from the formation df instead interfaces
  • Loading branch information
Leguark committed May 20, 2018
1 parent a6df37d commit f3452a2
Show file tree
Hide file tree
Showing 4 changed files with 971 additions and 10 deletions.
30 changes: 23 additions & 7 deletions gempy/data_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,18 @@ def __init__(self,

if path_o or path_i:
self.import_data_csv(path_i=path_i, path_o=path_o)
# else:
# if dummy_orientation:
# self.orientations.at[0, ['X', 'Y', 'Z', 'dip', 'azimuth', 'polarity', 'formation']] =\
# [(self.extent[1] - self.extent[0]) / 2,
# (self.extent[3] - self.extent[2]) / 2,
# (self.extent[5] - self.extent[4]) / 2,
# 0, 0, 1,
# 'dummy']



self.fault_relation = None
self.formations = None
self.faults = None

# If not provided set default series
self.update_df()
Expand All @@ -116,11 +125,8 @@ def __init__(self,

self.order_table()


self.potential_at_interfaces = 0

self.fault_relation = None

# Set dtypes
#self.interfaces['formation'] = self.interfaces['formation'].astype('category')
# self.interfaces['formation_number'] = self.interfaces['formation_number'].astype('int')
Expand Down Expand Up @@ -169,6 +175,8 @@ def set_basement(self):
else:
self.modify_interface((drop_basement.index[drop_basement])[0], formation='basement', order_series=n_series, formation_number = n_formation)

self.order_table()

def calculate_gradient(self):
"""
Calculate the gradient vector of module 1 given dip and azimuth to be able to plot the orientations
Expand Down Expand Up @@ -755,6 +763,7 @@ def update_df(self, series_distribution=None, order=None):


self.set_basement()

self.set_series(series_distribution=series_distribution, order=order)

faults_series = self.count_faults()
Expand All @@ -770,12 +779,16 @@ def update_df(self, series_distribution=None, order=None):

def set_formations(self, formation_values = None, formation_order = None):


self.interfaces['formation'] = self.interfaces['formation'].astype('category')
self.orientations['formation'] = self.orientations['formation'].astype('category')

if formation_order is None:
if self._formation_values_set is False:
formation_order = self.interfaces['formation'].cat.remove_unused_categories().cat.categories
if self.formations is None:
#if self._formation_values_set is False:
formation_order = self.interfaces['formation'].cat.categories
else:
formation_order = self.formations.index
# try:
# # Check if there is already a df
# formation_order = self.formations.index
Expand Down Expand Up @@ -810,6 +823,9 @@ def set_formations(self, formation_values = None, formation_order = None):
self.interfaces['formation_value'] = self.interfaces['formation'].map(self.formations.iloc[:, 0])
self.orientations['formation_value'] = self.orientations['formation'].map(self.formations.iloc[:, 0])

self.interfaces['formation'].cat.set_categories(formation_order, inplace=True)
self.orientations['formation'].cat.set_categories(formation_order, inplace=True)

def _set_formation_number(self, formation_order=None):
"""
Set a unique number to each formation. NOTE: this method is getting deprecated since the user does not need
Expand Down
2 changes: 1 addition & 1 deletion gempy/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def __init__(self, interp_data, **kwargs):
#
def prepare_data_frame(self, geo_data_res, **kwargs):

self.formation_number = geo_data_res.interfaces['formation_number'].unique().astype('int32')
self.formation_number = geo_data_res.formations['formation_number'].values.squeeze().astype('int32')
self.formation_value = geo_data_res.formations['value'].values.squeeze().astype(self.dtype)

# We hide the scaled copy of DataManagement object from the user.
Expand Down
7 changes: 5 additions & 2 deletions gempy/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def close(self):
self.vv.close_window()

def restart(self):
self.vv.close_window()
try:
self.vv.close_window()
except AttributeError:
pass

self.vv = vtkVisualization(self.geo_data, bg_color=self.bg_color)

Expand Down Expand Up @@ -108,7 +111,7 @@ def plot_data_3D(self, **kwargs):
Returns:
None
"""

self.restart()
self.vv.set_interfaces()
self.vv.set_orientations()
self.vv.render_model(**kwargs)
Expand Down
Loading

0 comments on commit f3452a2

Please sign in to comment.