Repository navigation
Conversation
- `MKZ_Param_Multi_Layer()` now reads files and 2D arrays with `from_files=True`, i.e., in the format of the H4 parameter files (gamma_ref, 0, s, beta), as its docstring says. Before, it read them as (gamma_ref, s, beta, Gmax), so each layer got s = 0 and flat curves. Gmax (not in the files) is set to 1.0, as documented now. - `MKZ_Param_Multi_Layer.serialize_to_2D_array()` (and so `save_txt()`) and `Multiple_Damping_Curves.get_all_H4_x_params(save_txt=True)` now write the same format (`to_files=True`), so a saved file loads back with the same parameters. - Tests: fix the expected parameters of layer 1 of H4_G_IWTH04.txt (they had s = 0), check the curve values in `test_construct_curves`, and add round-trip tests for `save_txt()` and `get_all_H4_x_params(save_txt=True)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7fK8T2pPLf3tPCnMCKL1T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7fK8T2pPLf3tPCnMCKL1T
This was referenced Oct 11, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #79. One of the four P0 fixes from #114, based on #74's branch (
2026-10-10-parametrize-tests).Problem
H4 parameter files (
H4_G_*.txt,H4_x_*.txt) store each layer asgamma_ref, b (always 0), s, beta.MKZ_Param_Multi_Layer()read files and 2D arrays withoutfrom_files=True, so every layer gots = 0,beta= the file'ss, andGmax= the file'sbeta. Withs = 0, G/Gmax is a constant (0.5296 for every strain in layer 1 ofH4_G_IWTH04.txt), and damping is about 0.save_txt()andget_all_H4_x_params(save_txt=True)wrotegamma_ref, s, beta, Gmaxinstead of the file layout.Reading and writing were wrong in the same way, so a file written by the library loaded back unchanged. That is why the existing round-trip tests passed.
Changes
PySeismoSoil/class_parameters.py:MKZ_Param_Multi_Layer.__init__()reads files and 2D arrays withfrom_files=True. The class docstring already said the array has the file format; its table now shows the actual rows.MKZ_Param_Multi_Layer.serialize_to_2D_array()writes the file layout (to_files=True), sosave_txt()does too.PySeismoSoil/class_curves.py:get_all_H4_x_params()serializes withfunctools.partial(mkz.serialize_params_to_array, to_files=True).PySeismoSoil/helper_site_response.py: thefunc_serializedocstring offit_all_damping_curves()mentionsto_files=Truefor H4 files.CHANGELOG.md: a "Fixed" entry.MKZ_Param_Multi_Layerfrom a file or array, so no printed results changed (only timings, folder names, object addresses, and image bytes).Tests
All of these fail on the old library code (5 failed) and pass with the fix:
test_mkz_param_multi_layer__test_contents_of_list_elements: the old benchmark[0.000856, 0, 0.88832, 1.7492]encodeds = 0. The test now expects layer 1 ofH4_G_IWTH04.txtread in its file layout:gamma_ref=0.00085636, s=0.88832, beta=1.7492, Gmax=1.0.test_mkz_param_multi_layer__save_txt_and_load_back(new):serialize_to_2D_array()and thesave_txt()file have the rowsgamma_ref, 0, s, beta, and both load back with the same parameters (Gmax = 1.0).test_construct_curves[from_H4_G_parameters]/[from_H4_x_parameters]: these checked only shapes. They now also compare the values of one layer with the curve from that layer's column read withfrom_files=True. The HH cases get the same check.tests/test_class_curves.py::test_get_all_H4_x_params__saved_file_loads_back(new): the saved file has the file layout and loads back viaMKZ_Param_Multi_Layer().Testing
CI runs only on PRs into
main, so it does not run here. These were run locally on Python 3.13:python -m pytest tests: 243 passed.pre-commit run -aandpydoclint PySeismoSoil: pass.tox -e run-notebooks: all 14 notebooks ran without errors.Notes for review
get_all_H4_x_params(save_txt=True)orMKZ_Param_Multi_Layer.save_txt()before this fix are in the old layout (gamma_ref, s, beta, Gmax), and will now load wrongly without an error. Files in the documented H4 layout, such as the ones intests/files/and those made by MATLAB SeismoSoil, now load correctly. ShouldMKZ_Param_Multi_Layer()reject a file whose second row is not 0? That would catch old files, but it is not part of this PR.Nonlinear_SimulationacceptsMKZ_Param_Multi_LayerforG_param/xi_paramaccording to its docstring. But it writesserialize_to_2D_array()intoHH_G.dat/HH_x.dat, which the Fortran kernel reads as 9 HH parameters per layer. So MKZ parameters do not work there with either layout.padlen#77, amplify_motion() applies the transfer function one frequency bin too high, because _get_freq_interval() starts its frequency array at df instead of 0 #78, Damping_Calibration.get_H4_x_param() returns HH parameters instead of H4 (MKZ) parameters #60 in Fix Damping_Calibration.get_H4_x_param() returning HH parameters #115) are in separate PRs on the same base, and change different library files. All of them re-run the notebooks and add a "Fixed" group toCHANGELOG.md, so whichever merges second will conflict there. To resolve: keep both entries and re-run the notebooks. Fix Damping_Calibration.get_H4_x_param() returning HH parameters #115 (Damping_Calibration.get_H4_x_param() returns HH parameters instead of H4 (MKZ) parameters #60) callsget_all_H4_x_params(), and the two compose in either order.main, merging this PR will not close MKZ_Param_Multi_Layer() reads H4 parameter files in the wrong row order, so s is 0 and the G/Gmax curves are flat #79 automatically.🤖 Generated with Claude Code
https://claude.ai/code/session_01W7fK8T2pPLf3tPCnMCKL1T
Generated by Claude Code