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 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