def compute_model_at(new_grid: Union[ndarray], model: Project, **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 plus the addition functionallity of :func:`compute_model` passing a given array of points where evaluate the model instead of using the :class:`gempy.core.data.GridClass`. Args: new_grid: model (Project): 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)) warnings.warn( 'compute_model_at will be deprecated in GemPy 2.2.' 'Use argument `at` in compute_model instead', DeprecationWarning) 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(model: Project, output=None, at: np.ndarray = None, compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True, **kwargs) -> Solution: """Computes the geological model and any extra output given in the additional data option. Args: model (Project): [s0] output (str {'geology', 'gravity'}): Compute the lithologies or gravity at (np.ndarray): 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 Project.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. **kwargs: Keyword Args: compute_mesh_options (dict): options for the marching cube function. 1) rescale: True Returns: :class:`Solutions` """ # Check config # ------------ assert model._interpolator.theano_function is not None, 'You need to compile' \ 'graph before. See `gempy.set_interpolator`.' 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 at is not None: model._grid.deactivate_all_grids() model.set_custom_grid(at) # ------------ 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: model.solutions.set_values_to_surface_points(sol) if model._grid.active_grids[0] is np.True_: model.solutions.set_solution_to_regular_grid( sol, compute_mesh=compute_mesh, **kwargs) 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: [X] Set magnetcs and [ ] set topology @A.Schaaf probably it should populate the topology object? model.solutions.fw_magnetics = sol[13] if sort_surfaces: model.set_surface_order_from_solution() return model.solutions
def compute_model(model: Project, output=None, at: np.ndarray = None, compute_mesh=True, reset_weights=False, reset_scalar=False, reset_block=False, sort_surfaces=True, debug=False, set_solutions=True, **kwargs) -> Solution: """Computes the geological model and any extra output given in the additional data option. Args: model (Project): [s0] output (str {'geology', 'gravity'}): Compute the lithologies or gravity at (np.ndarray): 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 Project.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. **kwargs: Keyword Args: compute_mesh_options (dict): options for the marching cube function. 1) rescale: True Returns: :class:`Solutions` """ # Check config # ------------ _check_valid_model_input(model) 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 at is not None: model._grid.deactivate_all_grids() model.set_custom_grid(at) # ------------ 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: model.solutions.set_solutions(sol, compute_mesh, sort_surfaces, **kwargs) if sort_surfaces: model.set_surface_order_from_solution() return model.solutions