Skip to content

Major fixes for Earthquake Spectra Reviews#36

Merged
mouayed-nafeh merged 143 commits into
oq-vmtk-v1.0from
main
May 30, 2026
Merged

Major fixes for Earthquake Spectra Reviews#36
mouayed-nafeh merged 143 commits into
oq-vmtk-v1.0from
main

Conversation

@mouayed-nafeh
Copy link
Copy Markdown
Contributor

Summary

This pull request addresses the major revisions requested during the anonymous review process for the Earthquake Spectra submission. The changes focus on improving code quality, extending analysis capabilities, enhancing documentation, and strengthening verification and testing workflows across the OQ-VMTK framework.

Main Changes

Codebase Refactoring

  • Refactored the OQ-VMTK source code and demo scripts to comply with PEP8 standards using autopep8 and black formatting tools integrated through VS Code extensions.
  • Restructured Jupyter notebook demonstrations for improved readability, consistency, and usability.

Intensity Measure Selection

  • Implemented a new imselection method for identifying the optimal intensity measure (IM) from multiple candidates based on:

    • efficiency,
    • relative sufficiency, and
    • practicality criteria.

Documentation Improvements

  • Refactored and expanded the online documentation to reflect the updated code structure.
  • Added self-contained minimal working examples for each implemented method and workflow.

Visualization and Animation Features

  • Added animation support for graphical interpretation of:

    • static pushover analysis,
    • cyclic pushover analysis, and
    • nonlinear time-history analysis.

Modal Analysis Reporting

  • Implemented a graphical modal analysis report to illustrate the modal properties of idealized building classes for verification and validation purposes.

Analysis Framework Extensions

  • Expanded the modeller analysis wrappers to support:

    • incremental dynamic analysis (IDA),
    • registration of additional global and local response quantities, including hysteretic energy metrics.

Postprocessing Enhancements

  • Extended the postprocessor module to support multiple dynamic assessment procedures, including:

    • Modified Cloud Analysis,
    • Multiple Stripe Analysis (MSA), and
    • Incremental Dynamic Analysis (IDA),
      together with their associated fragility fitting strategies.

Testing and Quality Assurance

  • Added unit tests to improve reliability, regression checking, and overall quality assurance coverage.

Purpose

These updates collectively improve the maintainability, reproducibility, extensibility, and verification capabilities of the OQ-VMTK framework while directly addressing reviewer feedback for the Earthquake Spectra manuscript.

mouayed-nafeh and others added 30 commits November 4, 2025 17:18
OQ-VMTK v1.0.1 SLFGenerator Patch
…ility functions from IDA and vulnerability functions
vot4anto and others added 25 commits April 21, 2026 09:52
add GITHUB_TOKEN to avoid error on rate limit
## Summary

This branch introduces multiple changes to the OQ-VMTK workflow, mainly following a peer-review submission to Earthquake Spectra. This includes a suite of major feature additions, module-wide PEP8 refactoring, bug fixes, and CI/CD improvements. The changes span all core OQ-VMTK modules and bring the codebase to a more stable, maintainable, and feature-complete state.

---

## New Features

### Incremental Dynamic Analysis (IDA)
- Added `do_ida_analysis()` to `modeller.py` — runs nonlinear response history analyses at progressively scaled ground-motion intensities, supporting truncated and non-truncated hunt-and-fill procedures.
- Added `process_ida_results()` to `postprocessor.py` — post-processes IDA cloud data into fragility functions and vulnerability curves, including logistic regression and lognormal fitting.
- Added IDA plots to `plotter.py` — IDA stripe plots, fragility functions derived from IDA, and vulnerability function comparisons.
- Added `IncrementalDynamicAnalysis` demo notebook with the FEMA P695 far-field ground-motion record set (44 records, unscaled accelerations, time steps, and durations).

### Modified Cloud Analysis (MCA) — MCMC Extension
- Added a Markov Chain Monte Carlo (MCMC) method for MCA fragility derivation in `postprocessor.py`.
- Added classical and bootstrap MCA plotter functions in `plotter.py`.
- Updated the `ModifiedCloudAnalysis` demo notebook accordingly.

### IM Efficiency and Sufficiency Module (`imselection.py`)
- Created a new `imselection.py` module implementing:
  - **Efficiency**: dispersion-based IM ranking for MCA and IDA.
  - **Practicality**: slope-based linear regression metric.
  - **Proficiency**: combined efficiency + practicality metric (κ).
  - **RSM (Relative Sufficiency Metric)**: log-likelihood-based comparison of two IMs.
  - `compare_ims()`: convenience method to compute and tabulate all metrics across multiple IMs for a given analysis type.
- Added corresponding unit tests in `test_imselection.py`.

### RotDxx Spectral Calculations
- Added `get_rotdxx()` to `imcalculator.py` to compute RotD50/RotD100 and arbitrary rotation-percentile response spectra from two horizontal ground-motion components.

### Structural Analysis Animations
- Added animations of SPO, CPO, and NRHA results (deformed shape over time/steps) directly from `modeller.py` via `do_spo_analysis()`, `do_cpo_analysis()`, and `do_nrha_analysis()`.
- Added `plot_modes()` to `plotter.py` for animated mode shape visualisation.
- Updated all relevant demo notebooks with animated GIF outputs.

### Calibration — Displacement-Based Design
- Updated `calibration.py` to a displacement-based design methodology.
- Renamed internal variables: `pflag` → `pFlag`, `floor_heights` → `storey_heights` across `modeller.py`, `calibration.py`, and all dependents.

### AAL and AADP
- Refactored `calculate_average_annual_loss()` and `calculate_average_annual_damage_probability()` methods in `postprocessor.py`.
- Added COV calculation methods and DS threshold variability as an input argument for NLTHA post-processing.

---

## Bug Fixes

| Module | Fix |
|---|---|
| `postprocessor.py` | Fixed `NoneType` export for non-lognormal fragility methods |
| `postprocessor.py` | Stabilised logistic regression when bootstrap produces too few collapses |
| `postprocessor.py` | Fixed out-of-bound beta values |
| `slfgenerator.py` | Fixed sampling bug |
| `plotter.py` | Fixed `RecursionError` in `_show()` — changed `self._show()` to `plt.show()` |
| `imcalculator.py` | Fixed multiple bugs in IM calculation class |
| `modeller.py` | General stability fixes for analysis routines and node displacement/acceleration storage |
| `modeller.py` | Fixed `openseespy` import to be OS-conditional |

---

## Deprecation and Warning Fixes

- Replaced `.values[0]` scalar extraction with `.item()` to resolve NumPy `DeprecationWarning`.
- Replaced chained `fillna` assignment with direct assignment to resolve Pandas `DeprecationWarning`.
- Suppressed `FigureCanvasAgg UserWarning` from `plt.show()` in headless (CI) environments.
- Fixed Flake8 unterminated string literal issues across source and test files.

---

## PEP8 Refactoring

All core modules were refactored for PEP8 compliance and improved readability:

- `modeller.py`, `calibration.py`, `postprocessor.py`, `plotter.py`
- `imcalculator.py` (renamed class from `IMCalculator` to `imcalculator`)
- `slfgenerator.py` (renamed from `slf_generator.py`)
- `units.py`, `utilities.py`
- All demo notebooks: IDA, MSA, MCA, NRHA, CA, Pushover, ModalAnalysis, ModelCompilation, SLF, IM Processing
- All unit tests updated accordingly.

---

## CI/CD and Dependency Updates

- Added macOS ARM64 (`macos_arm_test.yml`) GitHub Actions workflow.
- Upgraded CI to Node.js 20 actions (replaced deprecated v3 actions).
- Added `GITHUB_TOKEN` to workflows to avoid API rate-limiting.
- Added Python 3.13 support in `pyproject.toml` and CI workflows.
- Pinned `scipy>=1.15.3` to resolve installation issue.
- Added `statsmodels` wheel for macOS ARM64.
- Added platform-specific requirements files for Linux, Windows, and macOS ARM64.

---

## Documentation and Demos

- Updated `README.md` with new feature descriptions and usage guidance.
- Updated Sphinx `conf.py` and documentation pages for all new modules.
- Updated `CITATION.cff`.
- Added `README.md` files for IDA, MSA, MCA, ModalAnalysis, and ModelCompilation demos.
- Updated `.gitignore` to exclude `ipynb_checkpoints`.
- Relocated input ground-motion records into organised `in/records/` subdirectories within each demo.

---

## Files Changed (source)

| File | Change |
|---|---|
| `openquake/vmtk/modeller.py` | Added IDA, animations, modal plotting, variable renames, PEP8 |
| `openquake/vmtk/postprocessor.py` | Added IDA/MCA/MCMC post-processing, AAL/AADP refactor, bug fixes |
| `openquake/vmtk/plotter.py` | Added IDA/MCA plots, animations, mode shapes, PEP8 |
| `openquake/vmtk/imcalculator.py` | Added RotDxx, PEP8 refactor, renamed class |
| `openquake/vmtk/imselection.py` | **New** — IM efficiency/sufficiency module |
| `openquake/vmtk/calibration.py` | Displacement-based design, variable renames, PEP8 |
| `openquake/vmtk/slfgenerator.py` | Sampling bug fix, PEP8 |
| `openquake/vmtk/units.py` | PEP8 refactor |
| `openquake/vmtk/utilities.py` | PEP8 refactor |
@mouayed-nafeh mouayed-nafeh requested a review from K-Aljawhari May 29, 2026 08:36
@mouayed-nafeh mouayed-nafeh self-assigned this May 29, 2026
@mouayed-nafeh mouayed-nafeh added the enhancement New feature or request label May 29, 2026
@mouayed-nafeh mouayed-nafeh merged commit 93ef660 into oq-vmtk-v1.0 May 30, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants