invert4geom.optimization
#
Module Contents#
Classes#
a class for finding the optimal depth and damping parameters to best fit a set of |
Functions#
|
custom optuna callback, only print trial if it's the best value yet. |
Number of available virtual or physical CPUs on this system, i.e. |
|
|
Run optuna optimization in parallel. Pre-define the study, storage, and objective |
|
Set up optuna optimization in parallel splitting up the number of trials over all |
|
Set up optuna optimization in parallel giving each available core 1 trial. |
|
find the best parameter values for fitting equivalent sources to a set of gravity |
Attributes#
- logging_callback(study, frozen_trial)[source]#
custom optuna callback, only print trial if it’s the best value yet.
- Parameters:
study (Any)
frozen_trial (optuna.trial.FrozenTrial)
- Return type:
None
- available_cpu_count()[source]#
Number of available virtual or physical CPUs on this system, i.e. user/real as output by time(1) when called with an optimally scaling userspace-only program
Adapted from https://stackoverflow.com/a/1006301/18686384
- Return type:
Any
- optuna_parallel(study_name, study_storage, objective, n_trials=100, maximize_cpus=True, parallel=True)[source]#
Run optuna optimization in parallel. Pre-define the study, storage, and objective function and input them here.
- optuna_max_cores(n_trials, optimize_study, study_name, study_storage, objective)[source]#
Set up optuna optimization in parallel splitting up the number of trials over all available cores.
- optuna_1job_per_core(n_trials, optimize_study, study_name, study_storage, objective)[source]#
Set up optuna optimization in parallel giving each available core 1 trial.
- class OptimalEqSourceParams(coordinates, data, damping_limits, depth_limits, **kwargs)[source]#
a class for finding the optimal depth and damping parameters to best fit a set of equivalent sources to the gravity data.
- Parameters:
coordinates (tuple[pandas.Series | nptyping.NDArray, pandas.Series | nptyping.NDArray, pandas.Series | nptyping.NDArray])
data (pandas.Series | nptyping.NDArray)
kwargs (Any)
- optimize_eq_source_params(coordinates, data, n_trials=0, damping_limits=(0, 10**3), depth_limits=(0, 10000000.0), sampler=None, parallel=False, fname='tmp', use_existing=False, **eq_kwargs)[source]#
find the best parameter values for fitting equivalent sources to a set of gravity data.
- Parameters:
coordinates (tuple[pd.Series | NDArray, pd.Series | NDArray,) – pd.Series | NDArray] easting, northing, and upwards coordinates of gravity data
data (pd.Series | NDArray) – gravity data values
n_trials (int, optional) – number of trials to perform / set of parameters to test, by default 0
damping_limits (tuple[float, float], optional) – lower and upper bounds of damping parameter, by default (0, 10**3)
depth_limits (tuple[float, float], optional) – lower and upper bounds of depth parameter, by default (0, 10e6)
sampler (optuna.samplers.BaseSampler | None, optional) – type of sampler to use, by default None
parallel (bool, optional) – if True, will run the trials in parallel, by default False
fname (str, optional) – path and filename to save the study results, by default “tmp”
use_existing (bool, optional) – if True, will continue a previously starting optimization, by default False
eq_kwargs (Any)
- Returns:
gives a dataframe of the tested parameter sets and associated scores, and the best resulting fitted equivalent sources.
- Return type:
tuple[pd.DataFrame, hm.EquivalentSources]