def test_create_formations(): formations = gp.Surfaces(values_array=np.arange(1, 8).reshape(-1, 1), properties_names=np.array(['density'])) # formations.set_surfaces_names(['MainFault', 'SecondaryReservoir','Seal', # 'Reservoir', 'Overlying']) return formations
def test_restricting_wrapper(): from gempy.core.model import RestrictingWrapper surface = gp.Surfaces(gp.core.data_modules.stack.Series(gp.core.data_modules.stack.Faults())) s = RestrictingWrapper(surface) print(s) with pytest.raises(AttributeError): print(s.add_surfaces)
def test_set_formation_names(self, test_create_formations): test_create_formations.set_surfaces_names(['MainFault', 'SecondaryReservoir', 'Seal', 'Reservoir', 'Overlying']) print(test_create_formations) formations = gp.Surfaces(values_array=np.arange(1, 8).reshape(-1, 1), properties_names=np.array(['density'])) formations.set_surfaces_names(['MainFault', 'SecondaryReservoir', 'Seal', 'Reservoir', 'Overlying']) print(formations) formations = gp.Surfaces(values_array=np.arange(1, 2).reshape(-1, 1), properties_names=np.array(['density'])) formations.set_surfaces_names(['MainFault', 'SecondaryReservoir', 'Seal', 'Reservoir', 'Overlying']) print(formations)
# voxel will have after discretization. This may be useful for example in # the case we want to map a specific geophysical property (such as # density) to a given unit. By default both are the same since to # discretize lithological units the value is arbitrary. # # %% # From an empty df # ^^^^^^^^^^^^^^^^ # # The Surfaces class needs to have an associate series object. This will # limit the name of the series since they are a ``pandas.Categorical``\ . # # %% surfaces = gp.Surfaces(series) # %% # We can set any number of formations by passing a list with the names. By # default they will take the name or the first series. # # %% surfaces.set_surfaces_names(['foo', 'foo2', 'foo5']) # %% series # %% # We can add new formations: #
def loop2gempy_(test_data_name, tmp_path, vtk_path, orientations_file, contacts_file, groups_file, dtm_reproj_file, bbox, model_base, model_top, vtk): import gempy as gp from gempy import plot geo_model = gp.create_model(test_data_name) # If depth coordinates are much smaller than XY the whole system of equations becomes very unstable. Until # I fix it properly in gempy this is a handcrafted hack ve = (bbox[0] - bbox[2]) / (model_base - model_top) if ve < 3: ve = 0 else: print('The vertical exageration is: ', ve) gp.init_data(geo_model, extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base*ve, model_top*ve], resolution = (50,50,50), path_o = orientations_file, path_i = contacts_file, default_values=True); # Show example lithological points #gp.get_data(geo_model, 'surface_points').head() # Show example orientations #gp.get_data(geo_model, 'orientations').head() # Plot some of this data #gp.plot.plot_data(geo_model, direction='z') geo_model.modify_surface_points(geo_model.surface_points.df.index, Z=geo_model.surface_points.df['Z']*ve) # Load reprojected topgraphy to model fp = dtm_reproj_file geo_model.set_topography(source='gdal',filepath=fp) contents=np.genfromtxt(groups_file,delimiter=',',dtype='U100') ngroups=len(contents) faults = gp.Faults() series = gp.Series(faults) #series.df #display(ngroups,contents) groups = [] for i in range (0,ngroups): groups.append(contents[i].replace("\n","")) series.add_series(contents[i].replace("\n","")) print(contents[i].replace("\n","")) series.delete_series('Default series') #series # Load surfaces and assign to series surfaces = gp.Surfaces(series) print(ngroups,groups) for i in range(0,ngroups): contents=np.genfromtxt(tmp_path+groups[i]+'.csv',delimiter=',',dtype='U100') nformations=len(contents.shape) if(nformations==1): for j in range (1,len(contents)): surfaces.add_surface(str(contents[j]).replace("\n","")) d={groups[i]:str(contents[j]).replace("\n","")} surfaces.map_series({groups[i]:(str(contents[j]).replace("\n",""))}) #working but no gps else: for j in range (1,len(contents[0])): surfaces.add_surface(str(contents[0][j]).replace("\n","")) d={groups[i]:str(contents[0][j]).replace("\n","")} surfaces.map_series({groups[i]:(str(contents[0][j]).replace("\n",""))}) #working but no gps # Set Interpolation Data id_only_one_bool = geo_model.surface_points.df['id'].value_counts() == 1 id_only_one = id_only_one_bool.index[id_only_one_bool] single_vals = geo_model.surface_points.df[geo_model.surface_points.df['id'].isin(id_only_one)] for idx, vals in single_vals.iterrows(): geo_model.add_surface_points(vals['X'], vals['Y'], vals['Z'], vals['surface']) geo_model.update_structure() gp.set_interpolation_data(geo_model, compile_theano=True, theano_optimizer='fast_compile', verbose=[]) # Provide summary data on model #geo_model.additional_data.structure_data #Calculate Model gp.compute_model(geo_model) # Extract surfaces to visualize in 3D renderers #gp.plot.plot_section(geo_model, 49, direction='z', show_data=False) ver, sim = gp.get_surfaces(geo_model) # import winsound # duration = 700 # milliseconds # freq = 1100 # Hz # winsound.Beep(freq, duration) # winsound.Beep(freq, duration) # winsound.Beep(freq, duration) #Visualise Model gp.plot.plot_3D(geo_model, render_data=False) #Save model as vtk if(vtk): gp.plot.export_to_vtk(geo_model, path=vtk_path, name=test_data_name+'.vtk', voxels=False, block=None, surfaces=True) return geo_model
def test_map_formations_from_series2(self, test_create_series): formations = gp.Surfaces() formations.map_formations_from_series(test_create_series) print(formations)
def create_surfaces(create_series): series = create_series surfaces = gp.Surfaces(series) surfaces.set_surfaces_names(['foo', 'foo2', 'foo5']) print(series) # We can add new surfaces: surfaces.add_surface(['feeeee']) print(surfaces) # The column surface is also a pandas.Categories. # This will be important for the Data clases (SurfacePoints and Orientations) print(surfaces.df['surface']) ### Set values # To set the values we do it with the following method surfaces.set_surfaces_values([2, 2, 2, 5]) print(surfaces) # #### Set values with a given name: # We can give specific names to the properties (i.e. density) surfaces.add_surfaces_values([[2, 2, 2, 6], [2, 2, 1, 8]], ['val_foo', 'val2_foo']) print(surfaces) ### Delete surfaces values # # To delete a full propery: surfaces.delete_surface_values(['val_foo', 'value_0']) # #### One of the surfaces must be set be the basement: surfaces.set_basement() print(surfaces) # #### Set surface values # # We can also use set values instead adding. This will delete the previous properties and add the new one surfaces.set_surfaces_values([[2, 2, 2, 6], [2, 2, 1, 8]], ['val_foo', 'val2_foo']) print(surfaces) # The last property is the correspondant series that each surface belong to. `series` and `surface` # are pandas categories. To get a overview of what this mean # check https://pandas.pydata.org/pandas-docs/stable/categorical.html. print(surfaces.df['series']) print(surfaces.df['surface']) # ### Map series to surface # To map a series to a surface we can do it by passing a dict: # If a series does not exist in the `Series` object, we rise a warning and we set those surfaces to nans d = {"foo7": 'foo', "booX": ('foo2', 'foo5', 'fee')} surfaces.map_series(d) surfaces.map_series({"foo7": 'foo', "boo": ('foo2', 'foo5', 'fee')}) print(surfaces) # An advantage of categories is that they are order so no we can tidy the df by series and surface surfaces.df.sort_values(by='series', inplace=True) # If we change the basement: surfaces.set_basement() # Only one surface can be the basement: print(surfaces) # ### Modify surface name surfaces.rename_surfaces({'foo2': 'lala'}) print(surfaces) surfaces.df.loc[2, 'val_foo'] = 22 print(surfaces) # We can use `set_is_fault` to choose which of our series are faults: return surfaces