Skip to content

Commit

Permalink
Merge 73b5959 into 777e86a
Browse files Browse the repository at this point in the history
  • Loading branch information
medlin01GA committed Dec 11, 2019
2 parents 777e86a + 73b5959 commit e5e2015
Show file tree
Hide file tree
Showing 45 changed files with 817 additions and 1,251 deletions.
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ is in your ``PYTHONPATH`` environment variable. E.g. in bash shell, if ``~/dev/
- ``export PYTHONPATH=~/dev/hiperseis:$PYTHONPATH``


Third Party Library Dependencies
================================

Certain modules require specific third party (non-Python) libraries to be installed
on the host system. For example, scripts that convert to sc3ml format also require Seiscomp3 to be
installed and to be visible in the PATH. In most cases, Python libraries that depend on third party
libraries will indicate their dependencies either during attempted installation, or when used at
runtime. Note that the following list includes indirect dependencies, i.e. dependencies that come
from Python libraries used by HiPerSeis.

Current third party dependencies (actual requirements may vary by platform or Python distribution):

- `HDF5 <http://hdfgroup.org/>`_
- MPI, for example `Open MPI <https://www.open-mpi.org/>`_
- `PROJ <https://proj.org/>`_
- `GEOS <https://trac.osgeo.org/geos>`_


License
===============

Expand Down
54 changes: 54 additions & 0 deletions docs/seismic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,57 @@ HiPerSeis Package: Seismic

.. automodule:: seismic.gps_corrections.relative_tt_residuals_plotter
:members:

**Receiver Functions**
======================

.. automodule:: seismic.receiver_fn.bulk_rf_report
:members:

.. automodule:: seismic.receiver_fn.extract_event_traces
:members:

.. automodule:: seismic.receiver_fn.generate_rf
:members:

.. automodule:: seismic.receiver_fn.plot_ccp
:members:

.. automodule:: seismic.receiver_fn.rf_3dmigrate
:members:

.. automodule:: seismic.receiver_fn.rf_deconvolution
:members:

.. automodule:: seismic.receiver_fn.rf_h5_file_event_iterator
:members:

.. automodule:: seismic.receiver_fn.rf_h5_file_station_iterator
:members:

.. automodule:: seismic.receiver_fn.rf_inversion_export
:members:

.. automodule:: seismic.receiver_fn.rf_network_dict
:members:

.. automodule:: seismic.receiver_fn.rf_plot_utils
:members:

.. automodule:: seismic.receiver_fn.rf_plot_vespagram
:members:

.. automodule:: seismic.receiver_fn.rf_process_io
:members:

.. automodule:: seismic.receiver_fn.rf_quality_filter
:members:

.. automodule:: seismic.receiver_fn.rf_stacking
:members:

.. automodule:: seismic.receiver_fn.rf_synthetic
:members:

.. automodule:: seismic.receiver_fn.rf_util
:members:
8 changes: 8 additions & 0 deletions seismic/gps_corrections/picks_reader_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def read_picks_ensemble(csv_file):
"""
df_raw_picks = pd.read_csv(csv_file, r'\s+', header=0, dtype=PICKS_TABLE_SCHEMA)
return df_raw_picks
# end func


def get_network_stations(df, netcode):
Expand All @@ -64,6 +65,7 @@ def get_network_stations(df, netcode):
:rtype: list(str)
"""
return sorted(df[df['net'] == netcode]['sta'].unique().tolist())
# end func


def get_network_location_mean(df, netcode):
Expand Down Expand Up @@ -94,6 +96,7 @@ def get_network_location_mean(df, netcode):
return (mean_lat, mean_lon)
else:
return (np.nan, np.nan)
# end func


def get_network_date_range(df, netcode):
Expand All @@ -115,6 +118,7 @@ def get_network_date_range(df, netcode):
return (obspy.UTCDateTime(min_date), obspy.UTCDateTime(max_date))
else:
return (None, None)
# end func


def get_station_date_range(df, netcode, statcode):
Expand All @@ -140,6 +144,7 @@ def get_station_date_range(df, netcode, statcode):
return (obspy.UTCDateTime(min_date), obspy.UTCDateTime(max_date))
else:
return (None, None)
# end func


def compute_matching_network_mask(df, net_dict):
Expand All @@ -165,6 +170,7 @@ def compute_matching_network_mask(df, net_dict):
for n, s in zip(net_dict['net'], net_dict['sta']):
mask = (mask | ((_df['net'] == n) & (_df['sta'] == s)))
return mask
# end func


def get_overlapping_date_range(df, network_1, network_2):
Expand Down Expand Up @@ -217,6 +223,7 @@ def get_overlapping_date_range(df, network_1, network_2):
obspy.UTCDateTime(df_masked['originTimestamp'].max()))

return (None, None)
# end func


def generate_large_events_catalog(df_picks, min_magnitude=8.0, min_record_count=400, label_historical_events=True):
Expand Down Expand Up @@ -266,3 +273,4 @@ def generate_large_events_catalog(df_picks, min_magnitude=8.0, min_record_count=
significant_events.loc['2016-08-24', 'name'] = '2016 Myanmar earthquake'

return significant_events
# end func
126 changes: 6 additions & 120 deletions seismic/inventory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,15 @@ The purpose of this package is to provide tools and workflow for
## Requirements

The Python library requirements for using the tools and workflow of this package
are listed in `requirements_common.txt` for all platforms, plus additional platform
specific requirements listed in `requirements_linux.txt` for Linux and
`requirements_win32.txt` for Windows. The package is written for Python version 2.7
are listed in `requirements.txt`. The package is written for Python version 2.7
or >=3.5. To install the library requirements, run

&nbsp;&nbsp;&nbsp;&nbsp;`pip install -r requirements_common.txt`
&nbsp;&nbsp;&nbsp;&nbsp;`pip install -r requirements.txt`

followed by platform-specific requirements:
Scripts that convert inventory files to sc3ml format also require Seiscomp3 to be installed on the
host system and to be visible in the PATH. The installation of Seiscomp3 generally requires admin
privileges and configuration by a knowledgable user.

&nbsp;&nbsp;&nbsp;&nbsp;`pip install -r requirements_linux.txt` (for Linux)

OR

&nbsp;&nbsp;&nbsp;&nbsp;`pip install -r requirements_win32.txt` (for Windows)

Scripts that convert to sc3ml format also require Seiscomp3 to be installed on the host
system and to be visible in the PATH. The installation of Seiscomp3 requires
admin privileges and configuration by a knowledgable user.

### Performance note

Expand Down Expand Up @@ -142,7 +133,7 @@ to force a regeneration of the `.pkl` file.
## Future development roadmap <a name="future"></a>

Agenda for future development:
* Factor our the STN file readers into a separate module so that any reader can be
* Factor out the STN file readers into a separate module so that any reader can be
substituted, as long as it generates Pandas DataFrame output, to support arbitrary
input file formats.
* Performance improvements reading files in function `engd2stxml.read_isc()`. E.g. change
Expand All @@ -159,111 +150,6 @@ Python 3.6.7 (default, Dec 5 2018, 15:02:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
```

Obspy (standard release):
```
'1.1.0'
```

Obspy (custom):
```
'1.1.1rc1.post0+552.g8478dae0aa.obspy.master'
```

Python libraries (via `pip freeze`):
```
arrow==0.13.0
astroid==2.1.0
backcall==0.1.0
basemap==1.2.0
bleach==3.1.0
certifi==2018.11.29
chardet==3.0.4
ciso8601==2.1.1
Click==7.0
cycler==0.10.0
dask==1.1.0
decorator==4.3.2
defusedxml==0.5.0
dill==0.2.9
entrypoints==0.3
future==0.17.1
graphviz==0.10.1
h5py==2.9.0
idna==2.8
ipykernel==5.1.0
ipython==7.2.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
isort==4.3.4
jedi==0.13.2
Jinja2==2.10
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
line-profiler==2.1.2
llvmlite==0.27.0
lxml==4.3.0
MarkupSafe==1.1.0
matplotlib==3.0.2
mccabe==0.6.1
mistune==0.8.4
nbconvert==5.4.0
nbformat==4.4.0
notebook==5.7.4
numba==0.42.0
numexpr==2.6.9
numpy==1.16.1
-e git+https://github.com/obspy/obspy.git@8478dae0aac6d647171ab3092c48384ac666d5be#egg=obspy
pandas==0.24.1
pandoc==1.0.2
pandocfilters==1.4.2
parso==0.3.2
pexpect==4.6.0
pickleshare==0.7.5
ply==3.11
proj==0.1.0
prometheus-client==0.5.0
prompt-toolkit==2.0.8
ptyprocess==0.6.0
Pygments==2.3.1
pyimgur==0.6.0
pylint==2.2.2
pyparsing==2.3.1
pyproj==1.9.6
pyshp==2.0.1
python-dateutil==2.7.5
pytz==2018.9
pyzmq==17.1.2
qtconsole==4.4.3
requests==2.21.0
rope==0.11.0
Rtree==0.8.3
scikit-learn==0.20.2
scipy==1.2.0
seaborn==0.9.0
Send2Trash==1.5.0
six==1.12.0
SQLAlchemy==1.2.17
tables==3.4.4
terminado==0.8.1
testpath==0.4.2
tornado==5.1.1
tqdm==4.30.0
traitlets==4.3.2
typed-ast==1.2.0
urllib3==1.24.1
versioneer==0.18
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2
wrapt==1.11.1
xlrd==1.2.0
```

Seiscomp3 fdsnxml2inv converter:
```
fdsnxml2inv: Jakarta 2017.124
Expand Down
68 changes: 45 additions & 23 deletions seismic/inventory/generate_network_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,58 @@
"""

import os
import sys
import click

import pandas as pd

from seismic.inventory.plotting import save_network_local_plots, save_station_local_plots

try:
import tqdm
show_progress = True
except:
except ImportError:
show_progress = False
print("Run 'pip install tqdm' to see progress bar.")
# end try

@click.command()
@click.option('--plot-type', type=click.Option(['network', 'station']), default='network',
help='Whether to plot on map per network or one map per station')
@click.argument('inventory-h5-file', type=click.Path(exists=True, dir_okay=False), required=True)
def main(inventory_h5_file, plot_type):
"""Generate map plots of station locations for an inventory of stations.
Arguments:
:param inventory_h5_file: Name of input HDF5 file containing a station inventory
:type inventory_h5_file: str or Path
:param plot_type: Type of plots to make - per network or per station
:type plot_type: str
"""
# Set up file names
print("Loading file {0}".format(inventory_h5_file))
basename, _ = os.path.splitext(inventory_h5_file)
_, basename = os.path.split(basename)
folder_name = "plots." + basename
print("Saving plots to {0}".format(folder_name))

# Read inventory from hdf5 file
db = pd.read_hdf(inventory_h5_file, mode='r', key='inventory')

if show_progress:
pbar = tqdm.tqdm(total=len(db), ascii=True)
progressor = pbar.update
else:
progressor = None
# end if

# Save network plots to files
plot_functor = {'network': save_network_local_plots, 'station': save_station_local_plots}
plot_functor[plot_type](db, folder_name, progressor=progressor)
if show_progress:
pbar.close()
# end if
# end main

# Set up file names
infile_name = sys.argv[1]
print("Loading file {0}".format(infile_name))
basename, _ = os.path.splitext(infile_name)
_, basename = os.path.split(basename)
folder_name = "plots." + basename
print("Saving plots to {0}".format(folder_name))

# Read inventory from hdf5 file
db = pd.read_hdf(infile_name, mode='r', key='inventory')

if show_progress:
pbar = tqdm.tqdm(total=len(db), ascii=True)
progressor = pbar.update
else:
progressor = None

# Save network plots to files
save_network_local_plots(db, folder_name, progressor=progressor)
if show_progress:
pbar.close()
if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter
# end if
Loading

0 comments on commit e5e2015

Please sign in to comment.