Browse Source

ewrica: added tsumaps fm orientation data and loader

pull/3/head
mmetz 1 year ago
parent
commit
3b13d60d6c
  1. 1
      examples/create_ensemble_files.py
  2. 23
      setup.py
  3. 15
      src/data/README.md
  4. BIN
      src/data/tsumaps_all_params.mat
  5. 0
      src/dataset/__init__.py
  6. 17
      src/dataset/tsumaps.py
  7. 4
      src/util.py

1
examples/create_ensemble_files.py

@ -83,4 +83,3 @@ esrc.dump_sources_xml(mts, dump_header=True, filename='MTSource.xml')
esrc.dump_sources_xml(pdr, dump_header=True,
filename='PseudoDynamicRupture.xml')
esrc.dump_sources_xml(ids, dump_header=True, filename='IDSSource.xml')

23
setup.py

@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function
import os
# import sys
import os.path as op
from setuptools import setup
from setuptools.command.install import install
@ -24,13 +24,25 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def get_readme_paths():
paths = []
for (path, dirnames, filenames) in os.walk(
op.join(op.dirname(__file__), 'src')):
paths.extend(
[op.join(path.split('/', 1)[1], fn) for fn in filenames if
fn == 'README.md'])
return paths
class CustomInstallCommand(install):
def run(self):
install.run(self)
packages = [
'%s' % packname]
'%s' % packname,
'%s.dataset' % packname]
setup(
@ -62,7 +74,8 @@ setup(
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Operating System :: POSIX',
'Topic :: Games/Entertainment :: Simulation']
# package_data={
# packname: ['data/faults']}
'Topic :: Games/Entertainment :: Simulation'],
package_data={
packname: ['data/tsumaps_all_params.*',
] + get_readme_paths()}
)

15
src/data/README.md

@ -0,0 +1,15 @@
# Ewrica WP2 Data repository
Data that ships with `ewrica` is living in here.
## tsumaps_all_params.mat
usage of with exported probabalistic earthquake strike/dip/rake model from [TSUMAPS](http://www.tsumaps-neam.eu/) project (following [Selva et. al, 2016](https://academic.oup.com/gji/article/205/3/1780/656379). When loading via scipy.io.loadmat, the loaded dict consists of different keys:
* **latlon**: coordinates of the grid point in latitude, longitude [deg]
size: (n_points, 2)
* **fm**: tested focal mechanism values (triples of strike, dip, rake)
size: (n_fm, )
* **prob**: Probability of a certain focal mechanism at a given location
size: (n_points, n_fm)
At a certain location defined by `dict['latlon'][i, :]` in latitude and longitude, the probability of occurence of a focal mechanism `dict['fm'][j, :]` defined by its strike, dip and rake is given at `dict['prob'][i, j]`.

BIN
src/data/tsumaps_all_params.mat

0
src/dataset/__init__.py

17
src/dataset/tsumaps.py

@ -0,0 +1,17 @@
import os.path as op
from scipy import io as sio
from ewrica import util
def tsumaps_file():
name = 'tsumaps_all_params'
fn = util.data_file(op.join('%s.mat' % name))
if not op.exists(fn):
raise Exception('tsumaps file does not exist: %s' % fn)
return fn
def load():
return sio.loadmat(tsumaps_file())

4
src/util.py

@ -0,0 +1,4 @@
import os
def data_file(fn):
return os.path.join(os.path.split(__file__)[0], 'data', fn)
Loading…
Cancel
Save