Name | eqsig JSON |
Version |
1.2.17
JSON |
| download |
home_page | None |
Summary | Signal processing for field and experimental data for earthquake engineering |
upload_time | 2024-09-03 20:39:26 |
maintainer | None |
docs_url | None |
author | Maxim Millen |
requires_python | >=3 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. image:: https://travis-ci.org/eng-tools/eqsig.svg?branch=master
:target: https://travis-ci.org/eng-tools/eqsig
:alt: Testing Status
.. image:: https://img.shields.io/pypi/v/eqsig.svg
:target: https://pypi.python.org/pypi/eqsig
:alt: PyPi version
.. image:: https://coveralls.io/repos/github/eng-tools/eqsig/badge.svg
:target: https://coveralls.io/github/eng-tools/eqsig
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://github.com/eng-tools/eqsig/blob/master/LICENSE
:alt: License
.. image:: https://eng-tools.github.io/static/img/ecp-badge.svg
:target: https://eng-tools.github.io
:alt: ECP project
.. image:: https://zenodo.org/badge/125842866.svg
:target: https://zenodo.org/badge/latestdoi/125842866
:alt: DOI
.. image:: https://pepy.tech/badge/eqsig
:target: https://pepy.tech/project/eqsig
*****
eqsig
*****
A Python package for seismic signal processing.
Features
========
This package provides common functions for computing ground motion parameters and performing signal processing.
The functions are implemented on either numpy arrays or on a signal object that uses caching to avoid expensive
recalculation of widely used parameters.
* Compute the acceleration response spectrum and elastic response time series using the fast Nigam and Jennings (1968) algorithm.
* Compute the Fourier amplitude spectrum (using the scipy.signal.fft algorithm)
* Compute the smooth Fourier amplitude spectrum according to Konno and Ohmachi (1998)
* Compute velocity and displacement from acceleration time series
* Compute peak ground motion quantities (PGA, PGV, PGD)
* Compute common ground motion intensity measures (Arias intensity, CAV, CAV_dp5, significant duration, bracketed duration, dominant period)
* Compute signal features (zero crossings, global peaks, local peaks)
* Compute rotated ground motion or intensity measure from two ground motion components
* Resampling of ground motion through interpolation or periodic resampling
* Butterworth filter (using scipy), running average, polynomial fitting
* Fast loading of, and saving of, plain text to and from Signal objects
How to Use
==========
[Eqsig documentation](https://eqsig.readthedocs.io)
Examples
--------
Generate response spectra
_________________________
.. code-block:: python
import numpy as np
import matplotlib.pyplot as plt
import eqsig.single
bf, sub_fig = plt.subplots()
a = np.loadtxt("<path-to-acceleration-time-series>")
dt = 0.005 # time step of acceleration time series
periods = np.linspace(0.2, 5, 100) # compute the response for 100 periods between T=0.2s and 5.0s
record = eqsig.AccSignal(a * 9.8, dt)
record.generate_response_spectrum(response_times=periods)
times = record.response_times
sub_fig.plot(times, record.s_a, label="eqsig")
plt.show()
Generate Stockwell transform
____________________________
.. code-block:: python
import numpy as np
import matplotlib.pyplot as plt
import eqsig
from matplotlib import rc
rc('font', family='Helvetica', size=9, weight='light')
plt.rcParams['pdf.fonttype'] = 42
dt = 0.01
time = np.arange(0, 10, dt)
f1 = 0.5
factor = 10.
f2 = f1 * factor
acc = np.cos(2 * np.pi * time * f1) + factor / 5 * np.cos(2 * np.pi * time * f2)
asig = eqsig.AccSignal(acc, dt)
asig.swtf = eqsig.stockwell.transform(asig.values)
bf, ax = plt.subplots(nrows=2, sharex=True, figsize=(5.0, 4.0))
ax[0].plot(asig.time, asig.values, lw=0.7, c='b', label='Signal')
in_pcm = eqsig.stockwell.plot_stock(ax[1], asig)
ax[1].set_ylim([0.0, 10])
ax[0].set_xlim([0, 10])
ax[0].set_ylabel('Amplitude [$m/s^2$]', fontsize=8)
ax[1].set_ylabel('$\it{Stockwell}$\nFrequency [Hz]', fontsize=8)
ax[-1].set_xlabel('Time [s]', fontsize=8)
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
cbaxes = inset_axes(ax[1], width="20%", height="3%", loc='upper right')
cbaxes.set_facecolor([1, 1, 1])
cb = plt.colorbar(in_pcm, cax=cbaxes, orientation='horizontal')
cb.outline.set_edgecolor('white')
cbaxes.tick_params(axis='both', colors='white')
ax[0].legend(loc='upper right')
for sp in ax:
sp.tick_params(axis='both', which='major', labelsize=8)
plt.tight_layout()
plt.show()
.. image:: ./examples/stockwell-example.png
:width: 400
:alt: Output from example
Useful material
===============
*
Contributing
============
How do I get set up?
--------------------
1. Run ``pip install -r requirements.txt``
Package conventions
-------------------
* A function that calculates a property that takes a Signal object as an input, should be named as `calc_<property>`,
if the calculation has multiple different implementations, then include the citation as author and year
as well `calc_<property>_<author>_<year>`
* If the function takes a raw array then it should contain the word array (or values or vals).
Testing
-------
Tests are run with pytest
* Locally run: ``pytest`` on the command line.
* Tests are run on every push using travis, see the ``.travis.yml`` file
Deployment
----------
To deploy the package to pypi.com you need to:
1. Push to the *pypi* branch. This executes the tests on circleci.com
2. Create a git tag and push to github, run: ``trigger_deploy.py`` or manually:
.. code:: bash
git tag 0.5.2 -m "version 0.5.2"
git push --tags origin pypi
Documentation
-------------
Built via Sphinx following: https://codeandchaos.wordpress.com/2012/07/30/sphinx-autodoc-tutorial-for-dummies/
For development mode
1. cd to docs
2. Run ``make html``
Docstrings follow numpy convention (in progress): https://numpydoc.readthedocs.io/en/latest/format.html
To fix long_description in setup.py: ``pip install collective.checkdocs``, ``python setup.py checkdocs``
Release instructions
--------------------
On zenodo.org use the github integration tool, click on the eqsig package and click create new release.
History
=======
1.2.11 (2024-03-28)
-------------------
* Added tol threshold for zero crossing and peak indices algorithms
1.2.10 (2020-11-24)
-------------------
* Adjusted `eqsig.stockwell.plot_stock`, since min freq was out by factor of 0.5.
1.2.5 (2020-11-24)
-------------------
* Added `gen_ricker_wavelet_asig` to create an acceleration signal that is a Ricker wavelet
* Added `eqsig.sdof.calc_input_energy_spectrum` to compute the input energy into an SDOF
* Can now load a Signal with a scale factor by passing in the keyword `m=<scale factor>`
* The left interpolation function interp_left now returns the same size as x, which can be a scalar, and if `y` is None then assumes index (0,1,2,...,n)
1.2.4 (2020-07-20)
-------------------
* Fixed issue with computation of surface energy spectra
* Support for numpy==1.19
1.2.3 (2020-05-05)
-------------------
* Fixed docs for generation of FAS, changed kwarg `n_plus` to `p2_plus` since this adds to the power of 2.
1.2.2 (2020-05-05)
-------------------
* Switched to numpy for computing the Fourier amplitude spectrum
1.2.1 (2020-05-05)
-------------------
* Added `response_period_range` to AccSignal object initial inputs to define response periods using an upper and lower limit
* Improved speed of surface energy calculation `calc_surface_energy` and returns correct size based on input dimensions
* Removed global import of scipy - done at function level
* Added an `interp_left` function to interpolate an array and take lower value
* Fixed issue with inverse of stockwell transform `stockwell.itransform`, it no longer doubles the time step
* Increased speed of stockwell transform `stockwell.transform`.
* Added `remove_poly` function to remove a polynomial fit from an array
* Added option to access `fa_frequencies` and `smooth_fa_frequencies` as `fa_freqs` and `smooth_fa_freqs`.
* Added option for computing smoothed FAS with extra zero padding
* Added function for computing smoothed fas using a custom smoothing matrix.
1.2.0 (2019-11-03)
-------------------
* Added `interp2d` fast interpolation of a 2D array to obtain a new 2D array
* No longer raises warning when period is 0.0 for computing response spectrum
* Fixed issue with computation of smoothed response spectrum for dealing with zeroth frequency
* Increased speed of`generate_smooth_fa_spectrum`
* Can now directly set `AccSignal.smooth_fa_frequencies`
* Deprecated `AccSignal.smooth_freq_points` and `AccSignal.smooth_freq_range` will be removed in later version
1.1.2 (2019-10-31)
-------------------
* More accuracy in `calc_surface_energy` - now interpolates between time steps. More tests added.
1.1.1 (2019-10-29)
-------------------
* Fixed issue in `get_zero_crossings_array_indices` where it would fail if array did not contain any zeros.
* Added calculation of equivalent number of cycles and equivalent uniform amplitude using power law relationship as intensity measures
* Added function `get_n_cyc_array` to compute number of cycles series from a loading series
* Added intensity measure `im.calc_unit_kinetic_energy()` to compute the cumulative change in kinetic energy according to Millen et al. (2019)
* Added `surface.py` with calculation of surface energy and cumulative change in surface energy time series versus depth from surface
1.1.0 (2019-10-08)
-------------------
* Fixed issue with second order term in sdof response spectrum calculation which effected high frequency response, updated example to show difference
1.0.0 (2019-07-01)
-------------------
* First production release
Raw data
{
"_id": null,
"home_page": null,
"name": "eqsig",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": null,
"author": "Maxim Millen",
"author_email": "mmi46@uclive.ac.nz",
"download_url": "https://files.pythonhosted.org/packages/54/82/82128c6fd726b488775144974234a1e5be9fc36106d6efa1b5577887e1ef/eqsig-1.2.17.tar.gz",
"platform": null,
"description": ".. image:: https://travis-ci.org/eng-tools/eqsig.svg?branch=master\n :target: https://travis-ci.org/eng-tools/eqsig\n :alt: Testing Status\n\n.. image:: https://img.shields.io/pypi/v/eqsig.svg\n :target: https://pypi.python.org/pypi/eqsig\n :alt: PyPi version\n\n.. image:: https://coveralls.io/repos/github/eng-tools/eqsig/badge.svg\n :target: https://coveralls.io/github/eng-tools/eqsig\n\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg\n :target: https://github.com/eng-tools/eqsig/blob/master/LICENSE\n :alt: License\n\n.. image:: https://eng-tools.github.io/static/img/ecp-badge.svg\n :target: https://eng-tools.github.io\n :alt: ECP project\n\n.. image:: https://zenodo.org/badge/125842866.svg\n :target: https://zenodo.org/badge/latestdoi/125842866\n :alt: DOI\n\n.. image:: https://pepy.tech/badge/eqsig\n :target: https://pepy.tech/project/eqsig\n\n*****\neqsig\n*****\n\nA Python package for seismic signal processing.\n\nFeatures\n========\n\nThis package provides common functions for computing ground motion parameters and performing signal processing.\nThe functions are implemented on either numpy arrays or on a signal object that uses caching to avoid expensive\nrecalculation of widely used parameters.\n\n* Compute the acceleration response spectrum and elastic response time series using the fast Nigam and Jennings (1968) algorithm.\n* Compute the Fourier amplitude spectrum (using the scipy.signal.fft algorithm)\n* Compute the smooth Fourier amplitude spectrum according to Konno and Ohmachi (1998)\n* Compute velocity and displacement from acceleration time series\n* Compute peak ground motion quantities (PGA, PGV, PGD)\n* Compute common ground motion intensity measures (Arias intensity, CAV, CAV_dp5, significant duration, bracketed duration, dominant period)\n* Compute signal features (zero crossings, global peaks, local peaks)\n* Compute rotated ground motion or intensity measure from two ground motion components\n* Resampling of ground motion through interpolation or periodic resampling\n* Butterworth filter (using scipy), running average, polynomial fitting\n* Fast loading of, and saving of, plain text to and from Signal objects\n\n\nHow to Use\n==========\n\n[Eqsig documentation](https://eqsig.readthedocs.io)\n\nExamples\n--------\n\nGenerate response spectra\n_________________________\n\n.. code-block:: python\n\n import numpy as np\n import matplotlib.pyplot as plt\n import eqsig.single\n\n bf, sub_fig = plt.subplots()\n a = np.loadtxt(\"<path-to-acceleration-time-series>\")\n dt = 0.005 # time step of acceleration time series\n periods = np.linspace(0.2, 5, 100) # compute the response for 100 periods between T=0.2s and 5.0s\n record = eqsig.AccSignal(a * 9.8, dt)\n record.generate_response_spectrum(response_times=periods)\n times = record.response_times\n\n sub_fig.plot(times, record.s_a, label=\"eqsig\")\n plt.show()\n\n\nGenerate Stockwell transform\n____________________________\n\n.. code-block:: python\n\n import numpy as np\n import matplotlib.pyplot as plt\n import eqsig\n\n from matplotlib import rc\n rc('font', family='Helvetica', size=9, weight='light')\n plt.rcParams['pdf.fonttype'] = 42\n\n\n dt = 0.01\n time = np.arange(0, 10, dt)\n f1 = 0.5\n factor = 10.\n f2 = f1 * factor\n acc = np.cos(2 * np.pi * time * f1) + factor / 5 * np.cos(2 * np.pi * time * f2)\n\n asig = eqsig.AccSignal(acc, dt)\n\n asig.swtf = eqsig.stockwell.transform(asig.values)\n\n bf, ax = plt.subplots(nrows=2, sharex=True, figsize=(5.0, 4.0))\n\n ax[0].plot(asig.time, asig.values, lw=0.7, c='b', label='Signal')\n\n in_pcm = eqsig.stockwell.plot_stock(ax[1], asig)\n ax[1].set_ylim([0.0, 10])\n ax[0].set_xlim([0, 10])\n\n ax[0].set_ylabel('Amplitude [$m/s^2$]', fontsize=8)\n ax[1].set_ylabel('$\\it{Stockwell}$\\nFrequency [Hz]', fontsize=8)\n ax[-1].set_xlabel('Time [s]', fontsize=8)\n\n from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n cbaxes = inset_axes(ax[1], width=\"20%\", height=\"3%\", loc='upper right')\n cbaxes.set_facecolor([1, 1, 1])\n cb = plt.colorbar(in_pcm, cax=cbaxes, orientation='horizontal')\n cb.outline.set_edgecolor('white')\n cbaxes.tick_params(axis='both', colors='white')\n\n ax[0].legend(loc='upper right')\n for sp in ax:\n sp.tick_params(axis='both', which='major', labelsize=8)\n\n plt.tight_layout()\n plt.show()\n\n.. image:: ./examples/stockwell-example.png\n :width: 400\n :alt: Output from example\n\nUseful material\n===============\n\n*\n\nContributing\n============\n\nHow do I get set up?\n--------------------\n\n1. Run ``pip install -r requirements.txt``\n\n\nPackage conventions\n-------------------\n\n* A function that calculates a property that takes a Signal object as an input, should be named as `calc_<property>`,\n if the calculation has multiple different implementations, then include the citation as author and year\n as well `calc_<property>_<author>_<year>`\n* If the function takes a raw array then it should contain the word array (or values or vals).\n\n\nTesting\n-------\n\nTests are run with pytest\n\n* Locally run: ``pytest`` on the command line.\n\n* Tests are run on every push using travis, see the ``.travis.yml`` file\n\n\nDeployment\n----------\n\nTo deploy the package to pypi.com you need to:\n\n1. Push to the *pypi* branch. This executes the tests on circleci.com\n\n2. Create a git tag and push to github, run: ``trigger_deploy.py`` or manually:\n\n.. code:: bash\n\n git tag 0.5.2 -m \"version 0.5.2\"\n git push --tags origin pypi\n\n\nDocumentation\n-------------\n\nBuilt via Sphinx following: https://codeandchaos.wordpress.com/2012/07/30/sphinx-autodoc-tutorial-for-dummies/\n\nFor development mode\n\n 1. cd to docs\n 2. Run ``make html``\n\nDocstrings follow numpy convention (in progress): https://numpydoc.readthedocs.io/en/latest/format.html\n\nTo fix long_description in setup.py: ``pip install collective.checkdocs``, ``python setup.py checkdocs``\n\n\nRelease instructions\n--------------------\n\nOn zenodo.org use the github integration tool, click on the eqsig package and click create new release.\n\nHistory\n=======\n\n1.2.11 (2024-03-28)\n-------------------\n* Added tol threshold for zero crossing and peak indices algorithms\n\n1.2.10 (2020-11-24)\n-------------------\n* Adjusted `eqsig.stockwell.plot_stock`, since min freq was out by factor of 0.5.\n\n1.2.5 (2020-11-24)\n-------------------\n* Added `gen_ricker_wavelet_asig` to create an acceleration signal that is a Ricker wavelet\n* Added `eqsig.sdof.calc_input_energy_spectrum` to compute the input energy into an SDOF\n* Can now load a Signal with a scale factor by passing in the keyword `m=<scale factor>`\n* The left interpolation function interp_left now returns the same size as x, which can be a scalar, and if `y` is None then assumes index (0,1,2,...,n)\n\n1.2.4 (2020-07-20)\n-------------------\n* Fixed issue with computation of surface energy spectra\n* Support for numpy==1.19\n\n1.2.3 (2020-05-05)\n-------------------\n* Fixed docs for generation of FAS, changed kwarg `n_plus` to `p2_plus` since this adds to the power of 2.\n\n1.2.2 (2020-05-05)\n-------------------\n* Switched to numpy for computing the Fourier amplitude spectrum\n\n1.2.1 (2020-05-05)\n-------------------\n\n* Added `response_period_range` to AccSignal object initial inputs to define response periods using an upper and lower limit\n* Improved speed of surface energy calculation `calc_surface_energy` and returns correct size based on input dimensions\n* Removed global import of scipy - done at function level\n* Added an `interp_left` function to interpolate an array and take lower value\n* Fixed issue with inverse of stockwell transform `stockwell.itransform`, it no longer doubles the time step\n* Increased speed of stockwell transform `stockwell.transform`.\n* Added `remove_poly` function to remove a polynomial fit from an array\n* Added option to access `fa_frequencies` and `smooth_fa_frequencies` as `fa_freqs` and `smooth_fa_freqs`.\n* Added option for computing smoothed FAS with extra zero padding\n* Added function for computing smoothed fas using a custom smoothing matrix.\n\n\n1.2.0 (2019-11-03)\n-------------------\n\n* Added `interp2d` fast interpolation of a 2D array to obtain a new 2D array\n* No longer raises warning when period is 0.0 for computing response spectrum\n* Fixed issue with computation of smoothed response spectrum for dealing with zeroth frequency\n* Increased speed of`generate_smooth_fa_spectrum`\n* Can now directly set `AccSignal.smooth_fa_frequencies`\n* Deprecated `AccSignal.smooth_freq_points` and `AccSignal.smooth_freq_range` will be removed in later version\n\n1.1.2 (2019-10-31)\n-------------------\n\n* More accuracy in `calc_surface_energy` - now interpolates between time steps. More tests added.\n\n\n1.1.1 (2019-10-29)\n-------------------\n\n* Fixed issue in `get_zero_crossings_array_indices` where it would fail if array did not contain any zeros.\n* Added calculation of equivalent number of cycles and equivalent uniform amplitude using power law relationship as intensity measures\n* Added function `get_n_cyc_array` to compute number of cycles series from a loading series\n* Added intensity measure `im.calc_unit_kinetic_energy()` to compute the cumulative change in kinetic energy according to Millen et al. (2019)\n* Added `surface.py` with calculation of surface energy and cumulative change in surface energy time series versus depth from surface\n\n\n1.1.0 (2019-10-08)\n-------------------\n\n* Fixed issue with second order term in sdof response spectrum calculation which effected high frequency response, updated example to show difference\n\n1.0.0 (2019-07-01)\n-------------------\n\n* First production release\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Signal processing for field and experimental data for earthquake engineering",
"version": "1.2.17",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "548282128c6fd726b488775144974234a1e5be9fc36106d6efa1b5577887e1ef",
"md5": "ad5b5a112d156345f25a07893cefe185",
"sha256": "1dc3158499cc83f56ea8d3227d9a1952d47a2812b5daa589e46088b0def41fce"
},
"downloads": -1,
"filename": "eqsig-1.2.17.tar.gz",
"has_sig": false,
"md5_digest": "ad5b5a112d156345f25a07893cefe185",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 72588,
"upload_time": "2024-09-03T20:39:26",
"upload_time_iso_8601": "2024-09-03T20:39:26.711086Z",
"url": "https://files.pythonhosted.org/packages/54/82/82128c6fd726b488775144974234a1e5be9fc36106d6efa1b5577887e1ef/eqsig-1.2.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-03 20:39:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "eqsig"
}