Browse Source

ewrica: added sources module with extended pyrocko sources

also loading and dumping is possible via sources functions
pull/3/head
mmetz 1 year ago
commit
5eda435592
  1. 40
      .gitignore
  2. 0
      README.md
  3. 0
      setup.cfg
  4. 68
      setup.py
  5. 48
      src/sources.py

40
.gitignore

@ -0,0 +1,40 @@
/build/
/dist/
/doc/build/
/ewrica.egg-info/
/src/info.py
/evalresp-3.3.0/
/libmseed/
__pycache__/
*.py[cod]
*~
*.swp
*.so
.cache/
/tags
/scratch/
*.sublime-*
/htmlcov/
/.coverage
/.coverage.*
*.log
*.err_log
.vagrant
/test/example_run_dir/
/test/data/
/maintenance/**/ewrica.git/
/maintenance/conda/miniconda?.sh
/maintenance/conda/miniconda?/
/maintenance/vagrant/*/*.out
/maintenance/vagrant/*/example_run_dir
/maintenance/mattermost_webhook.link
/maintenance/pypirc
/maintenance/pip/ewrica/
/maintenance/pip/wheels/

0
README.md

0
setup.cfg

68
setup.py

@ -0,0 +1,68 @@
from __future__ import absolute_import, division, print_function
import os
# import sys
from setuptools import setup
from setuptools.command.install import install
try:
import numpy
except ImportError:
class numpy():
def __init__(self):
pass
@classmethod
def get_include(self):
return ''
packname = 'ewrica'
version = '2020.07.06'
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
class CustomInstallCommand(install):
def run(self):
install.run(self)
packages = [
'%s' % packname]
setup(
cmdclass={'install': CustomInstallCommand},
name=packname,
version=version,
author='mmetz',
author_email='mmetz@gfz-potsdam.de',
description='Tools for Usage in EWRICA project',
long_description=read('README.md'),
license='GPLv3',
keywords=[
'pyrocko', 'ewrica'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4',
install_requires=[],
extras_require={
'console_scripts': ['PyQt5']
},
packages=packages,
package_dir={'ewrica': 'src'},
# entry_points=entry_points,
classifiers=[
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Development Status :: 1 - Planning',
'Intended Audience :: Other Audience',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Operating System :: POSIX',
'Topic :: Games/Entertainment :: Simulation']
# package_data={
# packname: ['data/faults']}
)

48
src/sources.py

@ -0,0 +1,48 @@
from pyrocko import gf, guts
class SourceWithMagnitude(gf.SourceWithMagnitude):
misfit = guts.Float.T(
default=0.0,
help='Misfit value of the source')
def base_key(self):
return gf.SourceWithMagnitude.base_key(self) + (self.misfit,)
class DCSource(gf.DCSource):
misfit = guts.Float.T(
default=0.0,
help='Misfit value of the source')
def base_key(self):
return gf.DCSource.base_key(self) + (self.misfit,)
class MTSource(gf.MTSource):
misfit = guts.Float.T(
default=0.0,
help='Misfit value of the source')
def base_key(self):
return gf.MTSource.base_key(self) + (self.misfit,)
class PseudoDynamicRupture(gf.PseudoDynamicRupture):
misfit = guts.Float.T(
default=0.0,
help='Misfit value of the source')
def base_key(self):
return gf.PseudoDynamicRupture.base_key(self) + (self.misfit,)
def load_sources(**kwargs):
return guts.load_all(**kwargs)
def dump_sources(sources, **kwargs):
if not isinstance(sources, list):
sources = [sources]
return guts.dump_all(sources, **kwargs)
Loading…
Cancel
Save