-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jpvantassel/dev
For v0.5.2
- Loading branch information
Showing
43 changed files
with
147 additions
and
1,249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ([email protected]) | ||
Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
|
||
GNU GENERAL PUBLIC LICENSE | ||
Version 3, 29 June 2007 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
License Information | ||
=================== | ||
|
||
Copyright (C) 2019-2020 Joseph P. Vantassel ([email protected]) | ||
Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
|
||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ([email protected])\n", | ||
" Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected])\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", | ||
|
@@ -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", | ||
|
@@ -149,7 +149,7 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## H/V Settings\n", | ||
"## HVSR Settings\n", | ||
"---" | ||
] | ||
}, | ||
|
@@ -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\"" | ||
] | ||
}, | ||
|
@@ -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" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ([email protected])\n", | ||
" Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected])\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", | ||
|
@@ -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", | ||
|
@@ -158,7 +158,7 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## H/V Settings\n", | ||
"## HVSR Settings\n", | ||
"---" | ||
] | ||
}, | ||
|
@@ -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\"" | ||
] | ||
}, | ||
|
@@ -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" | ||
] | ||
|
@@ -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", | ||
|
@@ -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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ([email protected])\n", | ||
" Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected])\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", | ||
|
@@ -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": {}, | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ([email protected]) | ||
# Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
# | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ([email protected]) | ||
# Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
# | ||
# 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 | ||
|
@@ -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. | ||
|
@@ -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: | ||
|
@@ -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: | ||
|
@@ -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: | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 = [ | ||
|
@@ -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}"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ([email protected]) | ||
# Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
# | ||
# 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 | ||
|
@@ -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) | ||
|
||
|
@@ -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}", | ||
|
@@ -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", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ([email protected]) | ||
# Copyright (C) 2019-2021 Joseph P. Vantassel ([email protected]) | ||
# | ||
# 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 | ||
|
Oops, something went wrong.