def set_geometric_data(geo_model: Model, surface_points_df=None, orientations_df=None, **kwargs): """ Function to set directly pandas.Dataframes to the gempy geometric data objects Args: geo_model: [s0] surface_points_df: A pn.Dataframe object with X, Y, Z, and surface columns orientations_df: A pn.Dataframe object with X, Y, Z, surface columns and pole or orientation columns **kwargs: Returns: Modified df """ r_ = None if surface_points_df is not None: geo_model.set_surface_points(surface_points_df, **kwargs) r_ = 'surface_points' elif orientations_df is not None: geo_model.set_orientations(orientations_df, **kwargs) r_ = 'data' if r_ == 'surface_points' else 'orientations' else: raise AttributeError('You need to pass at least one dataframe') return get_data(geo_model, itype=r_)
def save_model(model: Model, name=None, path=None): try: model.grid.topography.topo = None except AttributeError: pass model.save_model(name, path) return True
def map_series_to_surfaces(geo_model: Model, mapping_object: Union[dict, pn.Categorical] = None, set_series=True, sort_geometric_data: bool = True, remove_unused_series=True): """""" geo_model.map_series_to_surfaces(mapping_object, set_series, sort_geometric_data, remove_unused_series) return geo_model.surfaces
def compute_model(model: Model, output=None, compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True) -> Solution: """ Computes the geological model and any extra output given in the additional data option. Args: model (:class:`Model`): [s0] output (str {'geology', 'gravity'}): Compute the lithologies or gravity compute_mesh (bool): if True compute marching cubes: [s1] reset_weights (bool): Not Implemented reset_scalar (bool): Not Implemented reset_block (bool): Not Implemented sort_surfaces (bool): if True call Model.set_surface_order_from_solution: [s2] debug (bool): if True, the computed interpolation are not stored in any object but instead returned set_solutions (bool): Default True. If True set the results into the :class:`Solutions` linked object. Returns: :class:`Solutions` """ # TODO: Assert frame by frame that all data is like is supposed. Otherwise, assert model.additional_data.structure_data.df.loc['values', 'len surfaces surface_points'].min() > 1, \ 'To compute the model is necessary at least 2 interface points per layer' assert len(model.interpolator.len_series_i) == len(model.interpolator.len_series_o),\ 'Every Series/Fault need at least 1 orientation and 2 surfaces points.' if output is not None: warnings.warn('Argument output has no effect anymore and will be deprecated in GemPy 2.2.' 'Set the output only in gempy.set_interpolator.', DeprecationWarning,) i = model.interpolator.get_python_input_block(append_control=True, fault_drift=None) model.interpolator.reset_flow_control_initial_results(reset_weights, reset_scalar, reset_block) sol = model.interpolator.theano_function(*i) if debug is True or set_solutions is False: return sol elif set_solutions is True: # Set geology: if model.grid.active_grids[0] is np.True_: model.solutions.set_solution_to_regular_grid(sol, compute_mesh=compute_mesh) if model.grid.active_grids[1] is np.True_: model.solutions.set_solution_to_custom(sol) if model.grid.active_grids[2] is np.True_: model.solutions.set_solution_to_topography(sol) if model.grid.active_grids[3] is np.True_: model.solutions.set_solution_to_sections(sol) # Set gravity model.solutions.fw_gravity = sol[12] # TODO: Set magnetcs and set topology if sort_surfaces: model.set_surface_order_from_solution() return model.solutions
def update_additional_data(model: Model, update_structure=True, update_kriging=True): warnings.warn( 'This function is going to be deprecated. Use Model.update_additional_data instead', DeprecationWarning) return model.update_additional_data(update_structure, update_kriging)
def create_model(project_name='default_project'): """Create a Model object Returns: Model """ return Model(project_name)
def init_data(geo_model: Model, extent: Union[list, ndarray] = None, resolution: Union[list, ndarray] = None, **kwargs) -> Model: """ Create a :class:`gempy.core.model.Model` object and initialize some of the main functions such as: - Grid :class:`gempy.core.data.GridClass`: To regular grid. - read_csv: SurfacePoints and orientations: From csv files - set_values to default Args: geo_model (:class:Model): [s0] extent (list or array): [x_min, x_max, y_min, y_max, z_min, z_max]. Extent for the visualization of data and default of for the grid class. resolution (list or array): [nx, ny, nz]. Resolution for the visualization of data and default of for the grid class. project_name (str) Keyword Args: path_i: Path to the data bases of surface_points. Default os.getcwd(), path_o: Path to the data bases of orientations. Default os.getcwd() Returns: :class:`gempy.data_management.InputData` """ if extent is None or resolution is None: warnings.warn( 'Regular grid won\'t be initialize, you will have to create a gridafterwards. See gempy.set_grid' ) else: geo_model.set_regular_grid(extent, resolution) if 'path_i' in kwargs or 'path_o' in kwargs: read_csv(geo_model, **kwargs) if 'surface_points_df' in kwargs: geo_model.set_surface_points(kwargs['surface_points_df'], **kwargs) return geo_model
def create_model(project_name='default_project'): """sss Create Model Object Args: a: agag Returns: Model """ return Model(project_name)
def load_model_pickle(path): """ Read InputData object from python pickle. Args: path (str): path where save the pickle Returns: :class:`Model` """ return Model.load_model_pickle(path)
def map_series_to_surfaces(geo_model: Model, mapping_object: Union[dict, pn.Categorical] = None, set_series=True, sort_geometric_data: bool = True, remove_unused_series=True): """ Map the series (column) of the Surface object accordingly to the mapping_object Args: geo_model: mapping_object: set_series: sort_data: remove_unused_series: quiet: Returns: """ geo_model.map_series_to_surfaces(mapping_object, set_series, sort_geometric_data, remove_unused_series) return geo_model.surfaces
def compute_model_at(new_grid: Union[ndarray], model: Model, **kwargs): """ This function does the same as :func:`gempy.core.gempy_front.compute_model` plus the addion functionallity of passing a given array of points where evaluate the model instead of using the :class:`gempy.core.data.GridClass`. Args: model: new_grid (:class:`_np.array`): 2D array with XYZ (columns) coorinates kwargs: `compute_model` arguments Returns: gempy.core.data.Solution """ # #TODO create backup of the mesh and a method to go back to it # set_grid(model, Grid('custom_grid', custom_grid=new_grid)) model.grid.deactivate_all_grids() model.set_custom_grid(new_grid) # Now we are good to compute the model again only in the new point sol = compute_model(model, set_solutions=False, **kwargs) return sol
def compute_model_at(new_grid: Union[ndarray], model: Model, **kwargs): """ This function creates a new custom grid and deactivate all the other grids and compute the model there: This function does the same as :func:`compute_model` plus the addition functionallity of passing a given array of points where evaluate the model instead of using the :class:`gempy.core.data.GridClass`. Args: kwargs: :func:`compute_model` arguments Returns: :class:`Solution` """ # #TODO create backup of the mesh and a method to go back to it # set_grid(model, Grid('custom_grid', custom_grid=new_grid)) model.grid.deactivate_all_grids() model.set_custom_grid(new_grid) # Now we are good to compute the model again only in the new point sol = compute_model(model, set_solutions=False, **kwargs) return sol
def get_data(model: Model, itype='data', numeric=False): """ Method to return the data stored in :class:`DataFrame` within a :class:`gempy.interpolator.InterpolatorData` object. Args: model (:class:`gempy.core.model.Model`) itype(str {'all', 'surface_points', 'orientations', 'surfaces', 'series', 'faults', 'faults_relations', additional data}): input data type to be retrieved. numeric (bool): if True it only returns numerical properties. This may be useful due to memory issues verbosity (int): Number of properties shown Returns: pandas.core.frame.DataFrame """ return model.get_data(itype=itype, numeric=numeric)
def activate_interactive_df(geo_model: Model, plot_object=None): """ Experimental: Activate the use of the QgridModelIntegration: TODO evaluate the use of this functionality Notes: Since this feature is for advance levels we will keep only object oriented functionality. Should we add in the future, TODO: copy docstrings to QgridModelIntegration Args: geo_model: [s0] plot_object: GemPy plot object (so far only vtk is available) Returns: :class:`QgridModelIntegration` """ try: from gempy.core.qgrid_integration import QgridModelIntegration except ImportError: raise ImportError('qgrid package is not installed. No interactive dataframes available.') geo_model.qi = QgridModelIntegration(geo_model, plot_object) return geo_model.qi
def set_interpolator(geo_model: Model, type='geo', compile_theano: bool = True, theano_optimizer=None, verbose: list = None, grid='shared', **kwargs): """ Method to create a graph and compile the theano code to compute the interpolation. Args: geo_model (:class:`Model`): [s0] type (str:{geo, grav}): type of interpolation. compile_theano (bool): [s1] theano_optimizer (str {'fast_run', 'fast_compile'}): [s2] verbose: kwargs: - pos_density (Optional[int]): Only necessary when type='grav'. Location on the Surfaces().df where density is located (starting on id being 0). Returns: """ if theano_optimizer is not None: geo_model.additional_data.options.df.at[ 'values', 'theano_optimizer'] = theano_optimizer if verbose is not None: geo_model.additional_data.options.df.at['values', 'verbosity'] = verbose # TODO add kwargs geo_model.rescaling.rescale_data() update_additional_data(geo_model) geo_model.surface_points.sort_table() geo_model.orientations.sort_table() # The graph object contains all theano methods. Therefore is independent to which side # of the graph we compile: geo_model.interpolator.create_theano_graph(geo_model.additional_data, inplace=True, **kwargs) if type == 'geo': if compile_theano is True: geo_model.interpolator.set_all_shared_parameters(reset_ctrl=True) geo_model.interpolator.compile_th_fn_geo(inplace=True, grid=grid) else: if grid == 'shared': geo_model.interpolator.set_theano_shared_grid(grid) elif type == 'grav': pos_density = kwargs.get('pos_density', 1) tz = kwargs.get('tz', 'auto') # First we need to upgrade the interpolator object: print( 'Interpolator object upgraded from InterpolatorModel to InterpolatorGravity.' ) geo_model.interpolator = InterpolatorGravity( geo_model.surface_points, geo_model.orientations, geo_model.grid, geo_model.surfaces, geo_model.series, geo_model.faults, geo_model.additional_data, **kwargs) if tz is 'auto' and geo_model.grid.centered_grid is not None: print('Calculating the tz components for the centered grid...') tz = geo_model.interpolator.calculate_tz() print('Done') # Set the shared parameters for this piece of tree geo_model.interpolator.set_theano_shared_tz_kernel(tz) geo_model.interpolator.set_all_shared_parameters(reset_ctrl=True) if compile_theano is True: geo_model.interpolator.compile_th_fn_grav(density=None, pos_density=pos_density, inplace=True) return geo_model.interpolator
def compute_model(model: Model, output='geology', compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True) -> Solution: """ Computes the geological model and any extra output given in the additional data option. Args: model (:class:`gempy.core.model.Model`) compute_mesh (bool): If true compute polydata Returns: gempy.core.data.Solution """ # TODO: Assert frame by frame that all data is like is supposed. Otherwise, assert model.additional_data.structure_data.df.loc['values', 'len surfaces surface_points'].min() > 1, \ 'To compute the model is necessary at least 2 interface points per layer' if output == 'geology': assert model.interpolator.theano_function is not None, 'You need to compile the theano function first' i = model.interpolator.get_python_input_block(append_control=True, fault_drift=None) model.interpolator.reset_flow_control_initial_results( reset_weights, reset_scalar, reset_block) sol = model.interpolator.theano_function(*i) elif output == 'gravity': assert isinstance(model.interpolator_gravity, InterpolatorGravity), 'You need to set the gravity interpolator' \ 'first. See `Model.set_gravity_interpolator' i = model.interpolator_gravity.get_python_input_block( append_control=True, fault_drift=None) # TODO So far I reset all shared parameters to be sure. In the future this should be optimize as interpolator model.interpolator_gravity.set_theano_shared_tz_kernel() model.interpolator_gravity.set_all_shared_parameters(reset=True) sol = model.interpolator_gravity.theano_function(*i) set_solutions = False else: raise NotImplementedError( 'Only geology and gravity are implemented so far') if debug is True or set_solutions is False: return sol elif set_solutions is True: if model.grid.active_grids[0] is np.True_: model.solutions.set_solution_to_regular_grid( sol, compute_mesh=compute_mesh) # TODO @elisa elaborate this if model.grid.active_grids[2] is np.True_: l0, l1 = model.grid.get_grid_args('topography') model.solutions.geological_map = sol[0][:, l0:l1] if sort_surfaces: model.set_surface_order_from_solution() return model.solutions
def save_model_to_pickle(model: Model, path=None): model.save_model_pickle(path) return True
def get_additional_data(model: Model): return model.get_additional_data()
def set_interpolator(geo_model: Model, output: list = None, compile_theano: bool = True, theano_optimizer=None, verbose: list = None, grid=None, type_=None, update_structure=True, update_kriging=True, **kwargs): """ Method to create a graph and compile the theano code to compute the interpolation. Args: geo_model (:class:`Model`): [s0] output (list[str:{geo, grav}]): type of interpolation. compile_theano (bool): [s1] theano_optimizer (str {'fast_run', 'fast_compile'}): [s2] verbose: kwargs: - pos_density (Optional[int]): Only necessary when type='grav'. Location on the Surfaces().df where density is located (starting on id being 0). - Vs - pos_magnetics - Returns: """ # output = list(output) if output is None: output = ['geology'] if type(output) is not list: raise TypeError('Output must be a list.') # TODO Geology is necessary for everthing? if 'gravity' in output and 'geology' not in output: output.append('geology') if 'magnetics' in output and 'geology' not in output: output.append('geology') if type_ is not None: warnings.warn('type warn is going to be deprecated. Use output insted', FutureWarning) output = type_ if theano_optimizer is not None: geo_model.additional_data.options.df.at[ 'values', 'theano_optimizer'] = theano_optimizer if verbose is not None: geo_model.additional_data.options.df.at['values', 'verbosity'] = verbose geo_model.interpolator.create_theano_graph(geo_model.additional_data, inplace=True, output=output, **kwargs) # TODO add kwargs geo_model.rescaling.rescale_data() update_additional_data(geo_model, update_structure=update_structure, update_kriging=update_kriging) geo_model.surface_points.sort_table() geo_model.orientations.sort_table() if 'gravity' in output: pos_density = kwargs.get('pos_density', 1) tz = kwargs.get('tz', 'auto') geo_model.interpolator.set_theano_shared_gravity(tz, pos_density) # if tz is 'auto' and geo_model.grid.centered_grid is not None: # print('Calculating the tz components for the centered grid...') # #tz = geo_model.interpolator.calculate_tz() # from gempy.assets.geophysics import GravityPreprocessing # g = GravityPreprocessing(geo_model.grid.centered_grid) # tz = g.set_tz_kernel() # print('Done') # # # Set the shared parameters for this piece of tree # # TODO: gravity_interpolator methods should be inherited by interpolator # # geo_model.interpolator.theano_graph.tz.set_value(tz.astype(geo_model.interpolator.dtype)) # geo_model.interpolator.theano_graph.pos_density.set_value(pos_density) # geo_model.interpolator.theano_graph.lg0.set_value(geo_model.grid.get_grid_args('centered')[0]) # geo_model.interpolator.theano_graph.lg1.set_value(geo_model.grid.get_grid_args('centered')[1]) if 'magnetics' in output: pos_magnetics = kwargs.get('pos_magnetics', 1) Vs = kwargs.get('Vs', 'auto') incl = kwargs.get('incl') decl = kwargs.get('decl') B_ext = kwargs.get('B_ext', 52819.8506939139e-9) geo_model.interpolator.set_theano_shared_magnetics( Vs, pos_magnetics, incl, decl, B_ext) if 'topology' in output: # This id is necessary for topology id_list = geo_model.surfaces.df.groupby('isFault').cumcount() + 1 geo_model.add_surface_values(id_list, 'topology_id') geo_model.interpolator.set_theano_shared_topology() # TODO it is missing to pass to theano the position of topology_id if compile_theano is True: geo_model.interpolator.set_all_shared_parameters(reset_ctrl=True) geo_model.interpolator.compile_th_fn_geo(inplace=True, grid=grid) else: if grid == 'shared': geo_model.interpolator.set_theano_shared_grid(grid) return geo_model.interpolator
def save_model(model: Model, name=None, path=None): model.save_model(name, path) return True
def compute_model(model: Model, output=None, compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True) -> Solution: """ Computes the geological model and any extra output given in the additional data option. Args: model (:class:`Model`): [s0] output (str {'geology', 'gravity'}): Compute the lithologies or gravity compute_mesh (bool): if True compute marching cubes: [s1] reset_weights (bool): Not Implemented reset_scalar (bool): Not Implemented reset_block (bool): Not Implemented sort_surfaces (bool): if True call Model.set_surface_order_from_solution: [s2] debug (bool): if True, the computed interpolation are not stored in any object but instead returned set_solutions (bool): Default True. If True set the results into the :class:`Solutions` linked object. Returns: :class:`Solutions` """ # TODO: Assert frame by frame that all data is like is supposed. Otherwise, assert model.additional_data.structure_data.df.loc['values', 'len surfaces surface_points'].min() > 1, \ 'To compute the model is necessary at least 2 interface points per layer' assert len(model.interpolator.len_series_i) == len(model.interpolator.len_series_o),\ 'Every Series/Fault need at least 1 orientation and 2 surfaces points.' if output is not None: warnings.warn( 'Argument output has no effect anymore and will be deprecated in GemPy 2.2.' 'Set the output only in gempy.set_interpolator.', DeprecationWarning, ) # if output is None: # # If output is not passed we check for the type of interpolator. If that also fail # # we try simply geology # try: # output = model.interpolator._type # except AttributeError: # output = 'geology' # # if output == 'geology': # assert model.interpolator.theano_function is not None, 'You need to compile the theano function first' # i = model.interpolator.get_python_input_block(append_control=True, fault_drift=None) # model.interpolator.reset_flow_control_initial_results(reset_weights, reset_scalar, reset_block) # # sol = model.interpolator.theano_function(*i) # elif output == 'gravity': # model.set_active_grid('centered', reset=False) # try: # i = model.interpolator.get_python_input_grav(append_control=True, fault_drift=None) # sol = model.interpolator.theano_function(*i) # # except AttributeError: # i = model.interpolator_gravity.get_python_input_grav() # sol = model.interpolator_gravity.theano_function(*i) # # # assert isinstance(model.interpolator_gravity, InterpolatorGravity), 'You need to set the gravity interpolator' \ # # 'first. See `Model.set_gravity_interpolator' # # # # model.set_active_grid('centered') # # model.interpolator_gravity.modify_results_matrices_pro() # # model.interpolator_gravity.set_theano_shared_structure() # # # # # TODO So far I reset all shared parameters to be sure. In the future this should be optimize as interpolator # # model.interpolator_gravity.set_theano_shared_tz_kernel() # # # model.interpolator_gravity.set_all_shared_parameters(reset_ctrl=True) # # sol = model.interpolator_gravity.theano_function(*i) # # #set_solutions = False # else: # raise NotImplementedError('Only geology and gravity are implemented so far') i = model.interpolator.get_python_input_block(append_control=True, fault_drift=None) model.interpolator.reset_flow_control_initial_results( reset_weights, reset_scalar, reset_block) sol = model.interpolator.theano_function(*i) if debug is True or set_solutions is False: return sol elif set_solutions is True: # Set geology: if model.grid.active_grids[0] is np.True_: model.solutions.set_solution_to_regular_grid( sol, compute_mesh=compute_mesh) if model.grid.active_grids[1] is np.True_: model.solutions.set_solution_to_custom(sol) if model.grid.active_grids[2] is np.True_: model.solutions.set_solution_to_topography(sol) if model.grid.active_grids[3] is np.True_: model.solutions.set_solution_to_sections(sol) # if output == 'gravity': # Set gravity model.solutions.fw_gravity = sol[12] # TODO: Set magnetcs and set topology if sort_surfaces: model.set_surface_order_from_solution() return model.solutions
def set_interpolator(geo_model: Model, output: list = None, compile_theano: bool = True, theano_optimizer=None, verbose: list = None, grid=None, type_=None, update_structure=True, update_kriging=True, **kwargs): """ Method to create a graph and compile the theano code to compute the interpolation. Args: geo_model (:class:`gempy.core.model.Project`): [s0] output (list[str:{geo, grav}]): type of interpolation. compile_theano (bool): [s1] theano_optimizer (str {'fast_run', 'fast_compile'}): [s2] verbose: update_kriging (bool): reset kriging values to its default. update_structure (bool): sync Structure instance before setting theano graph. Keyword Args: - pos_density (Optional[int]): Only necessary when type='grav'. Location on the Surfaces().df where density is located (starting on id being 0). - Vs - pos_magnetics Returns: """ # output = list(output) if output is None: output = ['geology'] if type(output) is not list: raise TypeError('Output must be a list.') # TODO Geology is necessary for everthing? if 'gravity' in output and 'geology' not in output: output.append('geology') if 'magnetics' in output and 'geology' not in output: output.append('geology') if type_ is not None: warnings.warn('type warn is going to be deprecated. Use output insted', FutureWarning) output = type_ if theano_optimizer is not None: geo_model._additional_data.options.df.at['values', 'theano_optimizer'] = theano_optimizer if verbose is not None: geo_model._additional_data.options.df.at['values', 'verbosity'] = verbose if 'dtype' in kwargs: geo_model._additional_data.options.df.at['values', 'dtype'] = kwargs['dtype'] if 'device' in kwargs: geo_model._additional_data.options.df.at['values', 'device'] = kwargs['device'] # TODO add kwargs geo_model._rescaling.rescale_data() geo_model.update_additional_data(update_structure=update_structure, update_kriging=update_kriging) geo_model.update_to_interpolator() geo_model._surface_points.sort_table() geo_model._orientations.sort_table() geo_model._interpolator.create_theano_graph(geo_model._additional_data, inplace=True, output=output, **kwargs) if 'gravity' in output: pos_density = kwargs.get('pos_density', 1) tz = kwargs.get('tz', 'auto') if geo_model._grid.centered_grid is not None: geo_model._interpolator.set_theano_shared_gravity(tz, pos_density) if 'magnetics' in output: pos_magnetics = kwargs.get('pos_magnetics', 1) Vs = kwargs.get('Vs', 'auto') incl = kwargs.get('incl') decl = kwargs.get('decl') B_ext = kwargs.get('B_ext', 52819.8506939139e-9) if geo_model._grid.centered_grid is not None: geo_model._interpolator.set_theano_shared_magnetics(Vs, pos_magnetics, incl, decl, B_ext) if 'topology' in output: # This id is necessary for topology id_list = geo_model._surfaces.df.groupby('isFault').cumcount() + 1 geo_model.add_surface_values(id_list, 'topology_id') geo_model._interpolator.set_theano_shared_topology() # TODO it is missing to pass to theano the position of topology_id if compile_theano is True: geo_model._interpolator.set_all_shared_parameters(reset_ctrl=True) geo_model._interpolator.compile_th_fn_geo(inplace=True, grid=grid) else: if grid == 'shared': geo_model._interpolator.set_theano_shared_grid(grid) print('Kriging values: \n', geo_model._additional_data.kriging_data) return geo_model._interpolator
def read_csv(geo_model: Model, path_i=None, path_o=None, **kwargs): if path_i is not None or path_o is not None: geo_model.read_data(path_i, path_o, **kwargs) return True
def compute_model(model: Model, output='geology', compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True) -> Solution: """ Computes the geological model and any extra output given in the additional data option. Args: model (:class:`Model`): [s0] output (str {'geology', 'gravity'}): Compute the lithologies or gravity compute_mesh (bool): if True compute marching cubes: [s1] reset_weights (bool): Not Implemented reset_scalar (bool): Not Implemented reset_block (bool): Not Implemented sort_surfaces (bool): if True call Model.set_surface_order_from_solution: [s2] debug (bool): if True, the computed interpolation are not stored in any object but instead returned set_solutions (bool): Default True. If True set the results into the :class:`Solutions` linked object. Returns: :class:`Solutions` """ # TODO: Assert frame by frame that all data is like is supposed. Otherwise, assert model.additional_data.structure_data.df.loc['values', 'len surfaces surface_points'].min() > 1, \ 'To compute the model is necessary at least 2 interface points per layer' assert len(model.interpolator.len_series_i) == len(model.interpolator.len_series_o),\ 'Every Series/Fault need at least 1 orientation and 2 surfaces points.' if output == 'geology': assert model.interpolator.theano_function is not None, 'You need to compile the theano function first' i = model.interpolator.get_python_input_block(append_control=True, fault_drift=None) model.interpolator.reset_flow_control_initial_results( reset_weights, reset_scalar, reset_block) sol = model.interpolator.theano_function(*i) elif output == 'gravity': model.set_active_grid('centered', reset=False) i = model.interpolator.get_python_input_grav(append_control=True, fault_drift=None) sol = model.interpolator.theano_function(*i) # assert isinstance(model.interpolator_gravity, InterpolatorGravity), 'You need to set the gravity interpolator' \ # 'first. See `Model.set_gravity_interpolator' # # model.set_active_grid('centered') # model.interpolator_gravity.modify_results_matrices_pro() # model.interpolator_gravity.set_theano_shared_structure() # # # TODO So far I reset all shared parameters to be sure. In the future this should be optimize as interpolator # model.interpolator_gravity.set_theano_shared_tz_kernel() # # model.interpolator_gravity.set_all_shared_parameters(reset_ctrl=True) # sol = model.interpolator_gravity.theano_function(*i) #set_solutions = False else: raise NotImplementedError( 'Only geology and gravity are implemented so far') if debug is True or set_solutions is False: return sol elif set_solutions is True: if model.grid.active_grids[0] is np.True_: model.solutions.set_solution_to_regular_grid( sol, compute_mesh=compute_mesh) if model.grid.active_grids[1] is np.True_: l0, l1 = model.grid.get_grid_args('custom') model.solutions.custom = sol[0][:, l0:l1] if model.grid.active_grids[2] is np.True_: l0, l1 = model.grid.get_grid_args('topography') model.solutions.geological_map = sol[0][:, l0:l1] model.solutions.geological_map_scalfield = sol[3][:, l0:l1].astype( float) if model.grid.active_grids[3] is np.True_: l0, l1 = model.grid.get_grid_args('sections') model.solutions.sections = sol[0][:, l0:l1] model.solutions.sections_scalfield = sol[3][:, l0:l1].astype(float) if output == 'gravity': model.solutions.fw_gravity = sol[6] if sort_surfaces: model.set_surface_order_from_solution() return model.solutions