MKZ_Param_Multi_Layer#

class PySeismoSoil.class_parameters.MKZ_Param_Multi_Layer(filename_or_data: str | numpy.ndarray | list[dict[str, float]] | list[PySeismoSoil.class_parameters.MKZ_Param], *, sep: str = '\t')[source]#

Bases: Param_Multi_Layer

Class implementation of multiple sets of MKZ parameters for multiple layers.

Its behavior is similar to a list, but with a more stringent requirement: all elements are of the same data type, i.e., MKZ_Param.

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

Parameters:
  • filename_or_data (MKZ_Param_Input) –

    A file name of a validly formatted “parameter file” (such as “H4_G_SITE_NAME.txt” or “H4_x_SITE_NAME.txt”), i.e., having the following format:

    param_layer_1

    param_layer_2

    param_layer_3

    …

    gamma_ref

    gamma_ref

    gamma_ref

    …

    0

    0

    0

    …

    s

    s

    s

    …

    beta

    beta

    beta

    …

    or a 2D numpy array containing the data of the format above, or a list containing MKZ parameter data (dictionaries or MKZ_Param objects). The 2nd row (“b”) is always 0, for historical reasons. This format has no Gmax, so when reading a file or a 2D array, Gmax of each layer is set to 1.0 (Gmax does not affect the G/Gmax or damping curves).

  • sep (str, default='t') – Delimiter of the file to be imported. If filename_or_data is not a file name, sep has no effect.

param_list#

A list of MKZ model parameters.

Type:

list[MKZ_Param]

n_layer#

The number of soil layers (i.e., the length of the list).

Type:

int

Raises:
  • TypeError – When then type of filename_or_data is not valid

  • ValueError – When a column of the file or the 2D array is not valid H4 parameters: it does not have 4 values, it has NaN (for example, from an empty cell or a trailing delimiter in the file), or its 2nd value (“b”) is not 0. H4 files written by PySeismoSoil 0.7.1 or earlier (with MKZ_Param_Multi_Layer.save_txt() or get_all_H4_x_params(save_txt=True)) have the rows gamma_ref, s, beta, Gmax instead, so they raise this error. The error message says how to convert them.

Attributes Summary

n_layer

The number of soil layers (i.e., the length of the list).

Methods Summary

construct_curves([strain_in_pct, curve_type])

Construct G/Gmax and damping curves from parameter values.

save_txt(filename[, precision, sep])

Save data as text file.

serialize_to_2D_array()

Serialize the parameter data to a 2D numpy array in the H4 file layout.

Attributes Documentation

n_layer: int#

The number of soil layers (i.e., the length of the list).

Methods Documentation

construct_curves(strain_in_pct: np.ndarray = array([0.01, 0.01151395, 0.01325711, 0.01526418, 0.01757511, 0.0202359, 0.02329952, 0.02682696, 0.03088844, 0.0355648, 0.04094915, 0.04714866, 0.05428675, 0.06250552, 0.07196857, 0.08286428, 0.09540955, 0.10985411, 0.12648552, 0.14563485, 0.16768329, 0.19306977, 0.22229965, 0.25595479, 0.29470517, 0.33932218, 0.39069399, 0.44984327, 0.51794747, 0.59636233, 0.68664885, 0.79060432, 0.91029818, 1.04811313, 1.20679264, 1.38949549, 1.59985872, 1.84206997, 2.12095089, 2.44205309, 2.8117687, 3.23745754, 3.72759372, 4.29193426, 4.94171336, 5.68986603, 6.55128557, 7.54312006, 8.68511374, 10.]), curve_type: str | None = None) → tuple[Multiple_GGmax_Curves, Multiple_Damping_Curves]#

Construct G/Gmax and damping curves from parameter values.

Parameters:
  • strain_in_pct (np.ndarray, default=STRAIN_RANGE_PCT) – Strain array. Must be a 1D numpy array. Unit: %

  • curve_type (str | None, default=None) – Either “ggmax” or “xi” for option to calculate only one of them. “None” will be returned for the other curve object in this case.

Returns:

  • mgc (Multiple_GGmax_Curves) – G/Gmax curves for each soil layer.

  • mdc (Multiple_Damping_Curves) – Damping curves for each soil layer.

save_txt(filename: str, precision: str = '%.6g', sep: str = '\t', **kw_to_savetxt: dict[Any, Any]) → None#

Save data as text file.

Parameters:
  • filename (str) – File name (including path) of the output file.

  • precision (str, default=hlp.PARAM_FILE_PRECISION) – Precision of the numbers to be saved. The default ('%.6g') is the same as in the files that the curve-fitting methods (such as get_all_HH_x_params()) save.

  • sep (str, default='t') – Delimiter identifier.

  • **kw_to_savetxt (dict[Any, Any]) – Additional keyword arguments to pass to numpy.savetxt().

serialize_to_2D_array() → ndarray[source]#

Serialize the parameter data to a 2D numpy array in the H4 file layout.

Each column is one layer, with the rows gamma_ref, 0, s, beta (see the class docstring). This layout has no Gmax. If the Gmax of any layer is not 1.0, one UserWarning names those layers (or says that it is every layer).

Returns:

param_2D_array – A 2D numpy array whose columns are parameters of each layer.

Return type:

np.ndarray