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.2.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.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ground_motion_tools-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a61e3861bd54f5ade373b51b0ecd0b60ee34ec2e4e1fca525dcc9f937cf276ff
MD5 792807304203c276b838e246034b0f89
BLAKE2b-256 96c07518ca6bd03ba3cae1acfa1b2c89410f6a812436eb5e58f9ec9287af91a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ground_motion_tools-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b1bea8812f6dfa69923143bd817275000da19dd334799b0613d6b804c31d58d
MD5 8ad6d7f15a7545102abc8c86219f7a35
BLAKE2b-256 806c4bc30d19b5f3bd2e56ca264f9d57a1665a57c2eeeb54d231e856d33328a1

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