Skip to main content

No project description provided

Project description

Ground-Motion-Tools

The main functions of this programme include:

  1. reading and writing seismic waves in various formats
  2. seismic wave processing, such as the calculation of Fourier spectra, filtering, down-sampling, normalisation
  3. ground vibration response spectrum calculation
  4. ground shaking IM index calculation

Installation

pip install ground-motion-tools

Examples

Read

from ground_motion_tools import read_from_kik, read_from_single, read_from_peer

file_path = "your kik file path"

# read from kik
gm_data1, time_step1 = read_from_kik(file_path)

# read from peer
gm_data2, time_step2 = read_from_peer(file_path)

# read from single
gm_data3, time_step3 = read_from_single(file_path, 1, None, 0)

Write

from ground_motion_tools import read_from_peer, save_to_single

ori_file = "your origin ground motion file"
desc_file = "your target ground motion file"
gm_data, time_step = read_from_peer(file_path=ori_file)
save_to_single(desc_file, gm_data, time_step)

# The single file is like following.
"""
Time Step: 0.02
data1
data2
data3
...
"""

Process

from ground_motion_tools import *
from matplotlib import pyplot as plt

gm_data, time_step = read_from_kik("your acc file path")

# calculate vel, disp from acc
acc, vel, disp = gm_data_fill(gm_data, time_step, GMDataEnum.ACC)

# fourier_spectrum
gm_data, time_step = read_from_kik("your acc file path")
x, y1, y2 = fourier(gm_data, time_step)
plt.plot(x, y1)
plt.show()

# butter_worth_filter
filtered_gm_data = butter_worth_filter(gm_data, time_step, 4, 0.1, 25)

# downsample
down_sampled = down_sample(gm_data, time_step, 0.02)

# length_normalize
normalized_wave = length_normalize(gm_data, 1000)

Spectrum

from ground_motion_tools import *
import numpy as np

# one ground motion
gm_data, time_step = read_from_kik("your acc file path")
acc_spectrum, vel_spectrum, disp_spectrum, _, _ = get_spectrum(gm_data, time_step)

# The programme supports batch calculations
gm_data_many = np.zeros((100, gm_data.shape[0]))
for i in range(100):
    gm_data_many[i, :] = gm_data
acc_spectrum, vel_spectrum, disp_spectrum, _, _ = get_spectrum(gm_data_many, time_step)

Intensity measures

from ground_motion_tools import *
import numpy as np

IM_WITHOUT_SPECTRUM = [GMIMEnum.PGA, GMIMEnum.PGV, GMIMEnum.PGD]
IM_SPECTRUM = [GMIMEnum.ASI, GMIMEnum.HI, GMIMEnum.VSI]

# one ground motion
gm_data, time_step = read_from_kik("your acc file path")

# Some IM metrics related to response spectra can consume a lot of time to calculate
im_without_spectrum = GMIntensityMeasures(gm_data, time_step).get_im(IM_WITHOUT_SPECTRUM)
im_with_spectrum = GMIntensityMeasures(gm_data, time_step).get_im(IM_WITHOUT_SPECTRUM + IM_SPECTRUM)

# The programme supports batch calculations.
batch_gm_data = np.zeros((1000, gm_data.shape[0]))
for i in range(1000):
    batch_gm_data[i, :] = gm_data
im_without_spectrum_batch = GMIntensityMeasures(batch_gm_data, time_step).get_im(IM_WITHOUT_SPECTRUM)
im_with_spectrum_batch = GMIntensityMeasures(batch_gm_data, time_step).get_im(IM_WITHOUT_SPECTRUM + IM_SPECTRUM)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ground_motion_tools-0.2.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ground_motion_tools-0.2.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file ground_motion_tools-0.2.1.tar.gz.

File metadata

  • Download URL: ground_motion_tools-0.2.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.7 Windows/10

File hashes

Hashes for ground_motion_tools-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3d5821eb5e2c65c8d2bc6eafb17e278dadd673ec29cb8e499b2220292494ae09
MD5 ab494a0a30909aba06bce46a470113ee
BLAKE2b-256 3b2e4910bd59e95b2314250f70f08c3a1b0ccf40dd2b73f4468ae0f28806678f

See more details on using hashes here.

File details

Details for the file ground_motion_tools-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ground_motion_tools-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd4f9652c77885cb5420c677e77ecc27ec177cb864ea5e3a4acb480feaecb242
MD5 b641172fecc6dedb381063639bb1597d
BLAKE2b-256 42ca083bb8061174fdaac2a78f2e7acd970b6422c1a0e07f29d27a246e533418

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page