This release is a pre-release and may not be stable for production use.
dsmpy
Python package for computation of synthetic waveforms in spherically homogeneous transversely isotropic (VTI) media using the Direct Solution Method (DSM; Kawai et al. 2006).
Documentation and tutorials can be found here.
INSTALLATION
Requirements
- As
dsmpyrelies on mpi4py, you need to have a working MPI implementation installed (see mpi4py documentation) - gfotran >= 4.8
Using pip
- In a shell, type
pip install dsmpy
This will download the dsmpy package and required dependencies from the PyPI repository.
- Check that dsmpy has been installed succesfully:
python -c "import dsmpy"
Note: Fortran sources for the DSM will be compiled during the installation (using numpy.f2py and the GNU Fortran compiler). If you get compilation errors, check the following:
- gfortran >= 4.8 is required for succesful compilation, because of the optimization flag '-Ofast'
- If you have gfortran <4.8, you should change the compiler flag from '-Ofast' to '-O3' in
<path_of_dsmpy_folder>/pydsm/__init__.py
GETTING STARTED
To get started, you should at least run python test_tipsv.py and python test_tish.psv located in in <path_of_pydsm_folder>/pydsm/tests. These scripts check dsmpy against pre-computed synthetics using the DSM (Fortran).
EXAMPLES
- Running dsmpy using an input file (run on multiple CPUs).
A template input file is in
<path_of_pydsm_folder>/dsmpy/tests/input_files/template.txt:
sac_files ~/git/dsmpy/tests/sac_files/*T
output_folder ~/git/dsmpy/tests/sac_files
# duration of synthetics (in seconds)
tlen 3276.8
# number of points of frequency-domain synthetics
# minimum period Tmin = tlen / nspc (s)
nspc 256
# sampling frequency for time-domain synthetics
sampling_hz 20
# prem, ak135
seismic_model prem
# 0: P-SV+SH, 1: P-SV, 2: SH (default: 0)
mode 0
# 0: quiet, 1: talkative, 2: debug (default: 0)
verbose 0
To run this input file on 2 CPUs:
- open a Terminal
- change the current directory to the dsmpy directory
- paste:
mpiexec -n 2 python pydsm/main.py tests/input_files/template.txt
- Running dsmpy from a python script. Below is an example of python script using dsmpy to compute synthetics:
from dsmpy import dsm, seismicmodel
from dsmpy.event import Event
from dsmpy.station import Station
from dsmpy.utils.cmtcatalog import read_catalog
# load gcmt catalog
catalog = read_catalog()
# get event from catalog
event = Event.event_from_catalog(
catalog, '200707211534A')
# define station FCC
stations = [
Station(
name='FCC', network='CN',
latitude=58.7592, longitude=-94.0884),
]
# load (anisotropic) PREM model
seismic_model = seismicmodel.SeismicModel.prem()
tlen = 3276.8 # duration of synthetics (s)
nspc = 256 # number of points in frequency domain
sampling_hz = 20 # sampling frequency for sythetics
# create input parameters for pydsm
input = dsm.PyDSMInput.input_from_arrays(
event, stations, seismic_model, tlen, nspc, sampling_hz)
# compute synthetics in frequency domain calling DSM Fortran
output = dsm.compute(input)
output.to_time_domain() # perform inverse FFT
output.filter(freq=0.04) # apply a 25 seconds low-pass filter
us = output.us # synthetics. us.shape = (3,nr,tlen)
ts = output.ts # time points [0, tlen]
# brackets can be used to access component and station
u_Z_FCC = output['Z', 'FCC_CN']
# to plot a three-component record section, use
output.plot()
plt.show()
# to write synthetics to SAC files, use
output.write(root_path='.', format='sac')
- Running dsmpy using a (Fortran) DSM input file. Methods are provided to run dsmpy using an input file for the (Fortran) DSM:
from pydsm import dsm, rootdsm_sh
parameter_file = rootdsm_sh + 'AK135_SH.inf'
inputs = dsm.PyDSMInput.input_from_file(parameter_file, mode=2)
outputs = dsm.compute(inputs, mode=2)
outputs.to_time_domain()
us = outputs.us # us.shape = (3,nr,tlen)
ts = outputs.ts # len(ts) = tlen
stations = outputs.stations # len(stations) = nr
components = outputs.components # len(components) = 3
Metadata
Release files for dsmpy 1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dsmpy-1.0a2.tar.gz | 3.5 MB | Without provenance | Details for dsmpy-1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dsmpy-1.0a2-cp37-cp37m-macosx_10_14_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.14+ x86-64 | Details for dsmpy-1.0a2-cp37-cp37m-macosx_10_14_x86_64.whl |
Total release size: 4.1 MB
Release files / dsmpy-1.0a2.tar.gz
| Download URL | dsmpy-1.0a2.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
166dd2b87d75470fb38bd626bdfd1f84e939b1daf8c43d1b6d1eed710c759b8e
|
|
BLAKE2b-256 checksum How to use checksums |
e4239c095f5b02f98572cad418b49bda524d1acebb7fcde9c889e84293d68c32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.6
|
Release files / dsmpy-1.0a2-cp37-cp37m-macosx_10_14_x86_64.whl
| Download URL | dsmpy-1.0a2-cp37-cp37m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 630.3 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
97f26f518907fea7c4ac342cadf1381bdbae1818f6aa3951f48a72395fd53cd4
|
|
BLAKE2b-256 checksum How to use checksums |
c465b3a53c700c17fdc8783b2a074b421fc8c010d35d9ed3382b74037e63837a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.6
|
Security for dsmpy 1.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.