Skip to content

Commit

Permalink
Merge pull request #14 from jpvantassel/dev
Browse files Browse the repository at this point in the history
For v0.5.2
  • Loading branch information
jpvantassel authored Mar 21, 2021
2 parents 8ca4f73 + 508fb7a commit ef76d75
Show file tree
Hide file tree
Showing 43 changed files with 147 additions and 1,249 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This license applies to hvsrpy a Python package for horizontal-to-vertical
spectral ratio processing.
Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> Joseph P. Vantassel, The University of Texas at Austin
[![DOI](https://zenodo.org/badge/219310971.svg)](https://zenodo.org/badge/latestdoi/219310971)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/jpvantassel/hvsrpy/blob/master/LICENSE.txt)
[![PyPI - License](https://img.shields.io/pypi/l/hvsrpy)](https://github.com/jpvantassel/hvsrpy/blob/master/LICENSE.txt)
[![CircleCI](https://circleci.com/gh/jpvantassel/hvsrpy.svg?style=svg)](https://circleci.com/gh/jpvantassel/hvsrpy)
[![Documentation Status](https://readthedocs.org/projects/hvsrpy/badge/?version=latest)](https://hvsrpy.readthedocs.io/en/latest/?badge=latest)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/jpvantassel/hvsrpy.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/jpvantassel/hvsrpy/context:python)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# -- Project information -----------------------------------------------------

project = 'hvsrpy'
copyright = '2019-2020, Joseph P. Vantassel'
copyright = '2019-2021, Joseph P. Vantassel'
author = 'Joseph P. Vantassel'

# The full version, including alpha/beta/rc tags
Expand Down
2 changes: 1 addition & 1 deletion docs/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
License Information
===================

Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
12 changes: 6 additions & 6 deletions examples/azimuthal_hvsrpy_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"This file is distributed as part of `hvsrpy`, a Python package for horizontal-to-vertical spectral ratio processing.\n",
"\n",
" Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
" Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
"\n",
" This program is free software: you can redistribute it and/or modify\n",
" it under the terms of the GNU General Public License as published by\n",
Expand All @@ -28,7 +28,7 @@
"---\n",
"\n",
"`hvsrpy` is a Python package for performing horizontal-to-vertical spectral ratio\n",
"(H/V) processing. `hvsrpy` was developed by Joseph P. Vantassel with\n",
"(HVSR) processing. `hvsrpy` was developed by Joseph P. Vantassel with\n",
"contributions from Dana M. Brannon under the supervision\n",
"of Professor Brady R. Cox at The University of Texas at Austin.\n",
"\n",
Expand Down Expand Up @@ -149,7 +149,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## H/V Settings\n",
"## HVSR Settings\n",
"---"
]
},
Expand All @@ -172,9 +172,9 @@
"# Maximum number of iterations to perform for rejection -> 50 is recommended.\n",
"n_iteration = 50\n",
"\n",
"# Distribution of f0 {\"lognormal\", \"normal\"}. Geopsy default \"normal\" -> \"log-normal\" is recommended.\n",
"# Distribution of f0 {\"lognormal\", \"normal\"}. Geopsy default \"normal\" -> \"lognormal\" is recommended.\n",
"distribution_f0 = \"lognormal\"\n",
"# Distribution of mean curve {\"lognormal\", \"normal\"}. Geopsy default \"log-normal\" -> \"log-normal\" is recommended.\n",
"# Distribution of mean curve {\"lognormal\", \"normal\"}. Geopsy default \"lognormal\" -> \"lognormal\" is recommended.\n",
"distribution_mc = \"lognormal\""
]
},
Expand Down Expand Up @@ -213,7 +213,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Elapsed Time: 1.83 seconds\n",
"Elapsed Time: 2.03 seconds\n",
"\n",
"Statistics after rejection considering azimuth:\n"
]
Expand Down
18 changes: 9 additions & 9 deletions examples/simple_hvsrpy_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"This file is distributed as part of `hvsrpy`, a Python package for horizontal-to-vertical spectral ratio processing.\n",
"\n",
" Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
" Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
"\n",
" This program is free software: you can redistribute it and/or modify\n",
" it under the terms of the GNU General Public License as published by\n",
Expand All @@ -28,7 +28,7 @@
"---\n",
"\n",
"`hvsrpy` is a Python package for performing horizontal-to-vertical spectral ratio\n",
"(H/V) processing. `hvsrpy` was developed by Joseph P. Vantassel with\n",
"(HVSR) processing. `hvsrpy` was developed by Joseph P. Vantassel with\n",
"contributions from Dana M. Brannon under the supervision of Professor Brady R.\n",
"Cox at The University of Texas at Austin.\n",
"\n",
Expand Down Expand Up @@ -158,7 +158,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## H/V Settings\n",
"## HVSR Settings\n",
"---"
]
},
Expand All @@ -182,9 +182,9 @@
"# Maximum number of iterations to perform for rejection -> 50 is recommended.\n",
"n_iteration = 50\n",
"\n",
"# Distribution of f0 {\"lognormal\", \"normal\"}. Geopsy default \"normal\" -> \"log-normal\" is recommended.\n",
"# Distribution of f0 {\"lognormal\", \"normal\"}. Geopsy default \"normal\" -> \"lognormal\" is recommended.\n",
"distribution_f0 = \"lognormal\"\n",
"# Distribution of mean curve {\"lognormal\", \"normal\"}. Geopsy default \"log-normal\" -> \"log-normal\" is recommended.\n",
"# Distribution of mean curve {\"lognormal\", \"normal\"}. Geopsy default \"lognormal\" -> \"lognormal\" is recommended.\n",
"distribution_mc = \"lognormal\""
]
},
Expand Down Expand Up @@ -223,7 +223,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Elapsed Time: 1.19 seconds\n",
"Elapsed Time: 0.36 seconds\n",
"\n",
"Statistics before rejection:\n"
]
Expand Down Expand Up @@ -500,12 +500,12 @@
"\n",
" print(\"\\nAnalysis summary:\") \n",
" display(pd.DataFrame(columns=[\"\"], index=[\"Window length\", \"No. of windows\", \"Number of iterations to convergence\", \"No. of rejected windows\"], \n",
" data=[f\"{windowlength}s\", str(sensor.ns.n_windows), f\"{c_iter} of {n_iteration} allowed\", str(sum(hv.rejected_window_indices))])) \n",
" data=[f\"{windowlength}s\", str(sensor.ns.nseries), f\"{c_iter} of {n_iteration} allowed\", str(sum(hv.rejected_window_indices))])) \n",
" print(\"\\nStatistics after rejection:\")\n",
" hv.print_stats(distribution_f0)\n",
" else:\n",
" display(pd.DataFrame(columns=[\"\"], index=[\"Window length\", \"No. of windows\"], \n",
" data=[f\"{windowlength}s\", str(sensor.ns.n_windows)]))\n",
" data=[f\"{windowlength}s\", str(sensor.ns.nseries)]))\n",
" hv.print_stats(distribution_f0)\n",
" fig.legend(loc=\"upper center\", bbox_to_anchor=(0.77, 0.4))\n",
" break\n",
Expand All @@ -518,7 +518,7 @@
" ax.plot(ctime.T, amp.T, linewidth=0.2, color='#888888')\n",
" ax.set_title(f\"Time Records ({name})\")\n",
" ax.set_yticks([-1, -0.5, 0, 0.5, 1])\n",
" ax.set_xlim(0, windowlength*timerecord.n_windows)\n",
" ax.set_xlim(0, windowlength*timerecord.nseries)\n",
" ax.set_ylim(-1, 1)\n",
" ax.set_xlabel('Time (s)')\n",
" ax.set_ylabel('Normalized Amplitude')\n",
Expand Down
12 changes: 6 additions & 6 deletions examples/spatial_hvsrpy_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"This file is distributed as part of `hvsrpy`, a Python package for horizontal-to-vertical spectral ratio processing.\n",
"\n",
" Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
" Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)\n",
"\n",
" This program is free software: you can redistribute it and/or modify\n",
" it under the terms of the GNU General Public License as published by\n",
Expand Down Expand Up @@ -378,21 +378,21 @@
" <tr>\n",
" <th>Fundamental Site Frequency, f0</th>\n",
" <td>0.58</td>\n",
" <td>0.15</td>\n",
" <td>0.16</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Fundamental Site Period, T0</th>\n",
" <td>1.73</td>\n",
" <td>0.15</td>\n",
" <td>1.74</td>\n",
" <td>0.16</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Lognormal Median Lognormal Standard Deviation\n",
"Fundamental Site Frequency, f0 0.58 0.15\n",
"Fundamental Site Period, T0 1.73 0.15"
"Fundamental Site Frequency, f0 0.58 0.16\n",
"Fundamental Site Period, T0 1.74 0.16"
]
},
"metadata": {},
Expand Down
14 changes: 0 additions & 14 deletions feature_requests.md

This file was deleted.

2 changes: 1 addition & 1 deletion hvsrpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of hvsrpy a Python package for horizontal-to-vertical
# spectral ratio processing.
# Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
# Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
28 changes: 16 additions & 12 deletions hvsrpy/hvsr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of hvsrpy, a Python package for horizontal-to-vertical
# spectral ratio processing.
# Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
# Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -40,7 +40,7 @@ class Hvsr():
curve/time window and each column a frequency.
frq : ndarray
Vector of frequencies corresponds to each column.
n_windows : int
nseries : int
Number of windows in `Hvsr` object.
valid_window_indices : ndarray
Boolean array indicating valid windows.
Expand Down Expand Up @@ -137,10 +137,10 @@ def __init__(self, amplitude, frequency, find_peaks=True,
msg = f"Size of amplitude={self.amp.size} and frequency={self.frq.size} must be compatable."
raise ValueError(msg)

self.n_windows = self.amp.shape[0]
self.valid_window_indices = np.ones(self.n_windows, dtype=bool)
self._main_peak_frq = np.zeros(self.n_windows)
self._main_peak_amp = np.zeros(self.n_windows)
self.nseries = self.amp.shape[0]
self.valid_window_indices = np.ones(self.nseries, dtype=bool)
self._main_peak_frq = np.zeros(self.nseries)
self._main_peak_amp = np.zeros(self.nseries)

self.f_low = None if f_low is None else float(f_low)
if self.f_low is None:
Expand Down Expand Up @@ -233,7 +233,7 @@ def update_peaks(self, **kwargs):
peak_indices, _ = self.find_peaks(self.amp[self.valid_window_indices, self.i_low:self.i_high],
starting_index=self.i_low,
**kwargs)
valid_indices = np.zeros(self.n_windows, dtype=bool)
valid_indices = np.zeros(self.nseries, dtype=bool)
valid_count = 0
for c_window, valid in enumerate(self.valid_window_indices):
if not valid:
Expand Down Expand Up @@ -410,7 +410,7 @@ def std_curve(self, distribution='lognormal'):
If `distribution` does not match the available options.
"""
if self.n_windows == 1:
if self.nseries == 1:
msg = "The standard deviation of the mean curve is not defined for a single window."
raise ValueError(msg)
else:
Expand Down Expand Up @@ -508,7 +508,7 @@ def reject_windows(self, n=2, max_iterations=50,
lower_bound = self.nstd_f0_frq(-n, distribution_f0)
upper_bound = self.nstd_f0_frq(+n, distribution_f0)

valid_indices = np.zeros(self.n_windows, dtype=bool)
valid_indices = np.zeros(self.nseries, dtype=bool)
for c_window, (c_valid, c_peak) in enumerate(zip(self.valid_window_indices, self._main_peak_frq)):
if not c_valid:
continue
Expand Down Expand Up @@ -687,6 +687,10 @@ def fclean(number, decimals=4):

def _hvsrpy_style_lines(self, distribution_f0, distribution_mc):
"""Lines for hvsrpy-style file."""
# Correct distribution
distribution_f0 = self.correct_distribution(distribution_f0)
distribution_mc = self.correct_distribution(distribution_mc)

# f0 from windows
mean_f = self.mean_f0_frq(distribution_f0)
sigm_f = self.std_f0_frq(distribution_f0)
Expand All @@ -700,7 +704,7 @@ def _hvsrpy_style_lines(self, distribution_f0, distribution_mc):
_min = self.nstd_curve(-1, distribution_mc)
_max = self.nstd_curve(+1, distribution_mc)

n_rejected = self.n_windows - sum(self.valid_window_indices)
n_rejected = self.nseries - sum(self.valid_window_indices)
rejection = "False" if self.meta.get(
'Performed Rejection') is None else "True"
lines = [
Expand All @@ -709,12 +713,12 @@ def _hvsrpy_style_lines(self, distribution_f0, distribution_mc):
f"# Method (),{self.meta.get('method')}",
f"# Azimuth (),{self.meta.get('azimuth')}",
f"# Window Length (s),{self.meta.get('Window Length')}",
f"# Total Number of Windows (),{self.n_windows}",
f"# Total Number of Windows (),{self.nseries}",
f"# Frequency Domain Window Rejection Performed (),{rejection}",
f"# Lower frequency limit for peaks (Hz),{self.f_low}",
f"# Upper frequency limit for peaks (Hz),{self.f_high}",
f"# Number of Standard Deviations Used for Rejection () [n],{self.meta.get('n')}",
f"# Number of Accepted Windows (),{self.n_windows-n_rejected}",
f"# Number of Accepted Windows (),{self.nseries-n_rejected}",
f"# Number of Rejected Windows (),{n_rejected}",
f"# Distribution of f0 (),{distribution_f0}"]

Expand Down
28 changes: 14 additions & 14 deletions hvsrpy/hvsr_rotated.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of hvsrpy, a Python package for horizontal-to-vertical
# spectral ratio processing.
# Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
# Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -430,7 +430,7 @@ def print_stats(self, distribution_f0, places=2): # pragma: no cover

def _hvsrpy_style_lines(self, distribution_f0, distribution_mc):
"""Lines for hvsrpy-style file."""

# Correct distribution
distribution_f0 = Hvsr.correct_distribution(distribution_f0)
distribution_mc = Hvsr.correct_distribution(distribution_mc)

Expand All @@ -449,14 +449,14 @@ def _hvsrpy_style_lines(self, distribution_f0, distribution_mc):

rejection = "False" if self.meta.get('Performed Rejection') is None else "True"

n_windows = self.hvsrs[0].n_windows
nseries = self.hvsrs[0].nseries
n_accepted = sum([sum(hvsr.valid_window_indices) for hvsr in self.hvsrs])
n_rejected = self.azimuth_count*n_windows - n_accepted
n_rejected = self.azimuth_count*nseries - n_accepted
lines = [
f"# hvsrpy output version {__version__}",
f"# File Name (),{self.meta.get('File Name')}",
f"# Window Length (s),{self.meta.get('Window Length')}",
f"# Total Number of Windows per Azimuth (),{n_windows}",
f"# Total Number of Windows per Azimuth (),{nseries}",
f"# Total Number of Azimuths (),{self.azimuth_count}",
f"# Frequency Domain Window Rejection Performed (),{rejection}",
f"# Lower frequency limit for peaks (Hz),{self.hvsrs[0].f_low}",
Expand All @@ -476,28 +476,28 @@ def fclean(number, decimals=4):
ci_68_upper_t = np.exp(np.log(mean_t) + sigm_t)

lines += [
f"# Median f0 (Hz) [LMf0,AZ],{fclean(mean_f)}",
f"# Lognormal standard deviation f0 () [SigmaLNf0,AZ],{fclean(sigm_f)}",
f"# Median f0 (Hz) [LMf0AZ],{fclean(mean_f)}",
f"# Lognormal standard deviation f0 () [SigmaLNf0AZ],{fclean(sigm_f)}",
f"# 68 % Confidence Interval f0 (Hz),{fclean(ci_68_lower_f)},to,{fclean(ci_68_upper_f)}",
f"# Median T0 (s) [LMT0,AZ],{fclean(mean_t)}",
f"# Lognormal standard deviation T0 () [SigmaLNT0,AZ],{fclean(sigm_t)}",
f"# Median T0 (s) [LMT0AZ],{fclean(mean_t)}",
f"# Lognormal standard deviation T0 () [SigmaLNT0AZ],{fclean(sigm_t)}",
f"# 68 % Confidence Interval T0 (s),{fclean(ci_68_lower_t)},to,{fclean(ci_68_upper_t)}",
]

else:
lines += [
f"# Mean f0 (Hz) [f0,AZ],{fclean(mean_f)}",
f"# Standard deviation f0 (Hz) [Sigmaf0,AZ],{fclean(sigm_f)}",
f"# Mean f0 (Hz) [f0AZ],{fclean(mean_f)}",
f"# Standard deviation f0 (Hz) [Sigmaf0AZ],{fclean(sigm_f)}",
f"# 68 % Confidence Interval f0 (Hz),{fclean(ci_68_lower_f)},to,{fclean(ci_68_upper_f)}",
f"# Mean T0 (s) [LMT0,AZ],NAN",
f"# Standard deviation T0 () [SigmaT0,AZ],NAN",
f"# Mean T0 (s) [LMT0AZ],NAN",
f"# Standard deviation T0 () [SigmaT0AZ],NAN",
f"# 68 % Confidence Interval T0 (s),NAN",
]

c_type = "Median" if distribution_mc == "lognormal" else "Mean"
lines += [
f"# {c_type} Curve Distribution (),{distribution_mc}",
f"# {c_type} Curve Peak Frequency (Hz) [f0mc,AZ],{fclean(mc_peak_frq)}",
f"# {c_type} Curve Peak Frequency (Hz) [f0mcAZ],{fclean(mc_peak_frq)}",
f"# {c_type} Curve Peak Amplitude (),{fclean(mc_peak_amp)}",
f"# Frequency (Hz),{c_type} Curve,1 STD Below {c_type} Curve,1 STD Above {c_type} Curve",
]
Expand Down
2 changes: 1 addition & 1 deletion hvsrpy/hvsr_spatial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of hvsrpy, a Python package for horizontal-to-vertical
# spectral ratio processing.
# Copyright (C) 2019-2020 Joseph P. Vantassel (jvantassel@utexas.edu)
# Copyright (C) 2019-2021 Joseph P. Vantassel (jvantassel@utexas.edu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
Loading

0 comments on commit ef76d75

Please sign in to comment.