commit 5eda43559248e85b03d90dffb8e1633fdb0df565 Author: mmetz Date: Tue Jul 7 17:39:19 2020 +0200 ewrica: added sources module with extended pyrocko sources also loading and dumping is possible via sources functions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..99b97da --- /dev/null +++ b/.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/ + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0d6c531 --- /dev/null +++ b/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']} +) diff --git a/src/sources.py b/src/sources.py new file mode 100644 index 0000000..21dbe3a --- /dev/null +++ b/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)