Multiple_Damping_Curves#
- class PySeismoSoil.class_curves.Multiple_Damping_Curves(filename_or_list_of_curves: str | list[numpy.ndarray], *, sep: str = '\t')[source]#
Bases:
Multiple_Curves
Class implementation of multiple damping curves.
Its behavior is similar to a list, but with a more stringent requirement: all elements are of the same data type, i.e., Damping_Curve.
- The list-like behaviors available are:
indexing: foo[3]
slicing: foo[:4]
setting values: foo[2] = …
length: len(foo)
deleting item: del foo[2]
checking existance: bar in foo
appending: foo.append(bar)
- Parameters:
filename_or_list_of_curves (str | list[np.ndarray]) – A file name of a validly formatted “curve file”, or a list of 2-column numpy arrays, which are in (strain [%], damping [%]) format.
sep (str) – Delimiter of the file to be imported. If
filename_or_list_of_curves
is a list, this parameter has no effect.
- curves#
A list of Damping_Curve objects.
- Type:
list[Damping_Curve]
- n_layer#
The number of soil layers (i.e., the length of the list).
- Type:
int
- Raises:
TypeError – When
filename_or_list_of_curves
has unrecognizable type
Methods Summary
append
(item)Append another curve item to the curves.
get_all_H4_x_params
([use_scipy, pop_size, ...])Obtain the H4_x parameters from the damping curve data (for all the curves), using the genetic algorithm provided in DEAP.
get_all_HH_x_params
([use_scipy, pop_size, ...])Obtain the HH_x parameters from the damping curve data (for all the curves), using the genetic algorithm provided in DEAP.
get_curve_matrix
([GGmax_filler_value, ...])Produce a full "curve matrix" based on the damping data defined in objects of this class.
plot
([plot_interpolated, fig, ax, title, ...])Plot multiple curves together on one figure.
Methods Documentation
- append(item) None #
Append another curve item to the curves.
- get_all_H4_x_params(use_scipy: bool = True, pop_size: int = 800, n_gen: int = 100, lower_bound_power: float = - 4, upper_bound_power: float = 6, eta: float = 0.1, seed: float = 0, show_fig: bool = False, verbose: bool = False, parallel: bool = False, n_cores: int | None = None, save_txt: bool = False, txt_filename: str | None = None, sep: str | None = None, save_fig: bool = False, fig_filename: str | None = None, dpi: float = 100) MKZ_Param_Multi_Layer [source]#
Obtain the H4_x parameters from the damping curve data (for all the curves), using the genetic algorithm provided in DEAP.
- Parameters:
use_scipy (bool) – Whether to use the “differential_evolution” algorithm implemented in scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html) to perform optimization. If
False
, use the algorithm in the DEAP package.pop_size (int) – The number of individuals in a generation.
n_gen (int) – Number of generations that the evolution lasts.
lower_bound_power (float) – The 10-based power of the lower bound of all the 9 parameters. For example, if your desired lower bound is 0.26, then set this parameter to be numpy.log10(0.26).
upper_bound_power (float) – The 10-based power of the upper bound of all the 9 parameters.
eta (float) – Crowding degree of the mutation or crossover. A high
eta
will produce children resembling to their parents, while a loweta
will produce solutions much more different.seed (float) – Seed value for the random number generator.
show_fig (bool) – Whether to show the curve fitting results as a figure.
verbose (bool) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool) – Whether to use parallel computing across layers, i.e., calculate multiple layers simultaneously.
n_cores (int | None) – Number of CPU cores to use. If None, all cores are used. No effects if the parallelization options are set to
False
.save_txt (bool) – Whether to save the results as a “HH_x_STATION_NAME.txt” file.
txt_filename (str | None) – File name of the text file to save HH parameters. If the object is created via a “curve” text file, then txt_filename can be
None
and the output filename will be determined automatically.sep (str | None) – Delimiter to separate columns of data in the output file.
save_fig (bool) – Whether to save damping fitting figures to hard drive.
fig_filename (str | None) – Full file name of the figure. If the object is created via a “curve” text file, then
fig_filename
can be None, and the output figure name will be determined automatically.dpi (float) – Figure resolution
- Returns:
H4_x_param – The best parameters for each soil layer found in the optimization.
- Return type:
- get_all_HH_x_params(use_scipy: bool = True, pop_size: int = 800, n_gen: int = 100, lower_bound_power: float = - 4, upper_bound_power: float = 6, eta: float = 0.1, seed: float = 0, show_fig: bool = False, verbose: bool = False, parallel: bool = False, n_cores: int | None = None, save_txt: bool = False, txt_filename: str | None = None, sep: str | None = None, save_fig: bool = False, fig_filename: str | None = None, dpi: float = 100) HH_Param_Multi_Layer [source]#
Obtain the HH_x parameters from the damping curve data (for all the curves), using the genetic algorithm provided in DEAP.
- Parameters:
use_scipy (bool) – Whether to use the “differential_evolution” algorithm implemented in scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html) to perform optimization. If
False
, use the algorithm in the DEAP package.pop_size (int) – The number of individuals in a generation.
n_gen (int) – Number of generations that the evolution lasts.
lower_bound_power (float) – The 10-based power of the lower bound of all the 9 parameters. For example, if your desired lower bound is 0.26, then set this parameter to be numpy.log10(0.26).
upper_bound_power (float) – The 10-based power of the upper bound of all the 9 parameters.
eta (float) – Crowding degree of the mutation or crossover. A high
eta
will produce children resembling to their parents, while a loweta
will produce solutions much more different.seed (float) – Seed value for the random number generator.
show_fig (bool) – Whether to show the curve fitting results as a figure.
verbose (bool) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool) – Whether to use parallel computing across layers, i.e., calculate multiple layers simultaneously.
n_cores (int | None) – Number of CPU cores to use. If None, all cores are used. No effects if the parallelization options are set to
False
.save_txt (bool) – Whether to save the results as a “HH_x_STATION_NAME.txt” file.
txt_filename (str | None) – File name of the text file to save HH parameters. If the object is created via a “curve” text file, then txt_filename can be None and the output filename will be determined automatically.
sep (str | None) – Delimiter to separate columns of data in the output file.
save_fig (bool) – Whether to save damping fitting figures to hard drive.
fig_filename (str | None) – Full file name of the figure. If the object is created via a “curve” text file, then fig_filename can be None, and the output figure name will be determined automatically.
dpi (float) – Figure resolution.
- Returns:
HH_x_param – The best parameters for each soil layer found in the optimization.
- Return type:
- get_curve_matrix(GGmax_filler_value: float = 1.0, save_to_file: bool = False, full_file_name: str | None = None) ndarray [source]#
Produce a full “curve matrix” based on the damping data defined in objects of this class.
- The “curve matrix” will be in the following format:
strain [%]
G/Gmax
strain [%]
damping [%]
strain [%]
G/Gmax
…
…
…
…
…
…
…
…
Since this class only defines damping curves, not G/Gmax curves, G/Gmax will be filled with some dummy values.
- Parameters:
GGmax_filler_value (float) – A dummy value to fill all the G/Gmax curves.
save_to_file (bool) – Whether to save the “curve matrix” as a text file.
full_file_name (str | None) – Full file name to save to the hard drive. It can be
None
ifsave_to_file
is set toFalse
.
- Returns:
curve_matrix – A matrix containing damping curves in the above-mentioned format.
- Return type:
np.ndarray
- plot(plot_interpolated: bool = True, fig: matplotlib.figure.Figure | None = None, ax: matplotlib.axes._axes.Axes | None = None, title: str | None = None, xlabel: str | None = 'Strain [%]', ylabel: str | None = 'Damping [%]', figsize: tuple[float, float] = (3, 3), dpi: float = 100, **kwargs_to_matplotlib: dict[Any, Any]) tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes] [source]#
Plot multiple curves together on one figure.
- Parameters:
plot_interpolated (bool) – Whether to plot the interpolated curve or the raw data.
fig (Figure | None) – Figure object. If None, a new figure will be created.
ax (Axes | None) – Axes object. If None, a new axes will be created.
title (str | None) – Title of plot.
xlabel (str | None) – X label of plot.
ylabel (str | None) – Y label of plot.
figsize (tuple[float, float]) – Figure size in inches, as a tuple of two numbers. The figure size of
fig
(if notNone
) will override this parameter.dpi (float) – Figure resolution. The dpi of
fig
(if notNone
) will override this parameter.**kwargs_to_matplotlib (dict[Any, Any]) – Keyword arguments to be passed to
matplotlib.pyplot.plot()
.
- Returns:
fig (Figure) – The figure object being created or being passed into this function.
ax (Axes) – The axes object being created or being passed into this function.