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_CurvesClass 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, default='t') – Delimiter of the file to be imported. If
filename_or_list_of_curvesis 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_curveshas unrecognizable type
Attributes Summary
The number of soil layers (i.e., the length of the list).
Methods Summary
append(item)Append another curve item to the curves.
get_all_H4_x_params(*[, use_scipy, ...])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, ...])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.
Attributes Documentation
- n_layer: int#
The number of soil layers (i.e., the length of the list).
Methods Documentation
- 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, default=True) – 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, default=800) – The number of individuals in a generation.
n_gen (int, default=100) – Number of generations that the evolution lasts.
lower_bound_power (float, default=-4) – 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, default=6) – The 10-based power of the upper bound of all the 9 parameters.
eta (float, default=0.1) – Crowding degree of the mutation or crossover. A high
etawill produce children resembling to their parents, while a lowetawill produce solutions much more different.seed (float, default=0) – Seed value for the random number generator.
show_fig (bool, default=False) – Whether to show the curve fitting results as a figure.
verbose (bool, default=False) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool, default=False) – Whether to use parallel computing across layers, i.e., calculate multiple layers simultaneously.
n_cores (int | None, default=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, default=False) – Whether to save the results as a “H4_x_STATION_NAME.txt” file. The file has one column per layer, with the rows gamma_ref, 0, s, beta (the format that
MKZ_Param_Multi_Layerreads). Gmax is not saved.txt_filename (str | None, default=None) – File name of the text file to save H4 parameters. If the object is created via a “curve” text file, then
txt_filenamecan beNoneand the output filename will be determined automatically.sep (str | None, default=None) – Delimiter to separate columns of data in the output file.
save_fig (bool, default=False) – Whether to save damping fitting figures to hard drive.
fig_filename (str | None, default=None) – Full file name of the figure. If the object is created via a “curve” text file, then
fig_filenamecan be None, and the output figure name will be determined automatically.dpi (float, default=100) – 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, default=True) – 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, default=800) – The number of individuals in a generation.
n_gen (int, default=100) – Number of generations that the evolution lasts.
lower_bound_power (float, default=-4) – 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, default=6) – The 10-based power of the upper bound of all the 9 parameters.
eta (float, default=0.1) – Crowding degree of the mutation or crossover. A high
etawill produce children resembling to their parents, while a lowetawill produce solutions much more different.seed (float, default=0) – Seed value for the random number generator.
show_fig (bool, default=False) – Whether to show the curve fitting results as a figure.
verbose (bool, default=False) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool, default=False) – Whether to use parallel computing across layers, i.e., calculate multiple layers simultaneously.
n_cores (int | None, default=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, default=False) – Whether to save the results as a “HH_x_STATION_NAME.txt” file.
txt_filename (str | None, default=None) – File name of the text file to save HH parameters. If the object is created via a “curve” text file, then
txt_filenamecan be None and the output filename will be determined automatically.sep (str | None, default=None) – Delimiter to separate columns of data in the output file.
save_fig (bool, default=False) – Whether to save damping fitting figures to hard drive.
fig_filename (str | None, default=None) – Full file name of the figure. If the object is created via a “curve” text file, then
fig_filenamecan be None, and the output figure name will be determined automatically.dpi (float, default=100) – 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, default=1.0) – A dummy value to fill all the G/Gmax curves.
save_to_file (bool, default=False) – Whether to save the “curve matrix” as a text file.
full_file_name (str | None, default=None) – Full file name to save to the hard drive. It can be
Noneifsave_to_fileis 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: Figure | None = None, ax: 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[Figure, Axes][source]#
Plot multiple curves together on one figure.
- Parameters:
plot_interpolated (bool, default=True) – Whether to plot the interpolated curve or the raw data.
fig (Figure | None, default=None) – Figure object. If None, a new figure will be created.
ax (Axes | None, default=None) – Axes object. If None, a new axes will be created.
title (str | None, default=None) – Title of plot.
xlabel (str | None, default='Strain [%]') – X label of plot.
ylabel (str | None, default='Damping [%]') – Y label of plot.
figsize (tuple[float, float], default=(3, 3)) – Figure size in inches, as a tuple of two numbers. The figure size of
fig(if notNone) will override this parameter.dpi (float, default=100) – 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.