From 5900a230b344b0aaca2286e2ab5347d6d429e8d6 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Thu, 17 Feb 2022 11:27:30 -0400 Subject: [PATCH] modules all missing --- bruges/attribute/complex.py | 1 - bruges/attribute/dipsteer.py | 3 +- bruges/attribute/energy.py | 1 - bruges/attribute/similarity.py | 125 ----------------------------- bruges/attribute/spectraldecomp.py | 3 +- bruges/attribute/test/dip_test.py | 1 - docs/_static/custom.css | 13 --- docs/conf.py | 23 ++++++ docs/post_process_html.py | 13 +-- setup.cfg | 13 ++- 10 files changed, 45 insertions(+), 151 deletions(-) delete mode 100644 bruges/attribute/similarity.py diff --git a/bruges/attribute/complex.py b/bruges/attribute/complex.py index 03bce9b..84929ba 100644 --- a/bruges/attribute/complex.py +++ b/bruges/attribute/complex.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Complex trace attributes. diff --git a/bruges/attribute/dipsteer.py b/bruges/attribute/dipsteer.py index 043a473..2f0dfc7 100644 --- a/bruges/attribute/dipsteer.py +++ b/bruges/attribute/dipsteer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ A dip attribute, probably most useful for guiding other attributes. @@ -8,7 +7,7 @@ from collections import namedtuple import numpy as np -from bruges.attribute import energy +from .energy import energy def dipsteer(data, diff --git a/bruges/attribute/energy.py b/bruges/attribute/energy.py index 61133bc..7c47389 100644 --- a/bruges/attribute/energy.py +++ b/bruges/attribute/energy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Mean-squared energy measurement. diff --git a/bruges/attribute/similarity.py b/bruges/attribute/similarity.py deleted file mode 100644 index 8143006..0000000 --- a/bruges/attribute/similarity.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Various methods to compute seismic similarity. - -:copyright: 2015 Joe Kington, SEG Tutorial https://library.seg.org/doi/pdf/10.1190/tle34121510.1 -:license: Apache 2.0 -""" -import numpy as np -from scipy.ndimage import generic_filter -from scipy.ndimage import gaussian_filter1d - - -def moving_window(traces, func, window): - """ - Helper function for multi-trace attribute generation. - This function applies a 3D function func to process a - region of shape `window` over a dataset `data`. - """ - wrapped = lambda x: func(x.reshape(window)) - return generic_filter(traces, wrapped, window) - - -def marfurt(traces): - """ - Marfurt, K., V. Sudhaker, A. Gersztenkorn, K. D. Crawford, and S. E. Nissen, 1999, - Coherency calculations in the presence of structural dip: GEOPHYSICS, 64, 104-111. - doi:10.1190/1.1444508 - """ - i, x, t = traces.shape - traces = traces.reshape(-1, t) - square_sums = np.sum(traces, axis=0)**2 - sum_squares = np.sum(traces**2, axis=0) - c = square_sums.sum() / (sum_squares.sum() + 1e-12) - return c / (i * x) - - -def gersztenkorn(traces): - """ - Gersztenkorn, A., and K. J. Marfurt, 1999, Eigenstructure‐based coherence - computations as an aid to 3-D structural and stratigraphic mapping: - GEOPHYSICS, 64, 1468-1479. doi:10.1190/1.1444651 - """ - # Stack traces in 3D traces into 2D array. - traces = traces.reshape(-1, traces.shape[-1]) - - # Calculate eigenvalues of covariance matrix. - cov = traces.dot(traces.T) - vals = np.linalg.eigvalsh(cov) - return vals.max() / (vals.sum() + 1e-12) - - -def gradients(traces, sigma): - grads = [] - for axis in range(3): - grad = gaussian_filter1d(traces, sigma, axis=axis, order=1) - grads.append(grad[..., np.newaxis]) - return np.concatenate(grads, axis=3) - - -def moving_window4d(grad, window, func): - """Applies the given function *func* over a moving *window*, reducing - the input *grad* array from 4D to 3D.""" - # Pad in the spatial dimensions, but leave the gradient dimension unpadded. - half_window = [(x // 2, x // 2) for x in window] + [(0, 0)] - padded = np.pad(grad, half_window, mode='reflect') - - out = np.empty(grad.shape[:3], dtype=float) - for i, j, k in np.ndindex(out.shape): - region = padded[i:i+window[0], j:j+window[1], k:k+window[2], :] - out[i,j,k] = func(region) - return out - - -def gst_coherence_calc(region): - region = region.reshape(-1, 3) - gst = region.T.dot(region) - eigs = np.sort(np.linalg.eigvalsh(gst))[::-1] - return (eigs[0]-eigs[1]) / (eigs[0]+eigs[1]) - - -def gradient_structure_tensor(seismic, window, sigma=1): - """ - Randen, T., E. Monsen, C. Singe, A. Abrahamsen, J. Hansen, T. Saeter, and J. Schlaf, 2000, - Three-dimensional texture attributes for seismic data analysis, 70th Annual International Meeting, - SEG, Expanded Abstracts, 668-671. - """ - grad = gradients(seismic, sigma) - return moving_window4d(grad, window, gst_coherence_calc) - - -def similarity(traces, duration, dt, step_out=1, kind='gst', sigma=1): - """ - Compute similarity for a seismic section using one of various methods. - - Expects time or depth to be in the last axis of a 2D or 3D input. - - :param traces: A 2D or 3D NumPy array arranged as (cdp, twt) or - (iline, xline, twt). - :param duration: The length in seconds of the window trace kernel - used to calculate the similarity. - :keyword dt (default=1): The sample interval of the traces in sec. - (eg. 0.001, 0.002, ...). Will default to one, allowing - duration to be given in samples. - :keyword step_out (default=1): - The number of adjacent traces to the kernel to compute similarity over. - :keyword kind (default='gst'): - The method to use for the computation. Can be "marfurt", "gersztenkorn" - or "gst" (gradient structure tensor). - :keyword sigma (default=1): - The width of the Gaussian function used to compute gradients. - """ - if traces.ndim == 2: - window = 2*step_out+1, int(duration / dt) - elif traces.ndim == 3: - window = 2*step_out+1, int(duration / dt), 2*step_out+1 - else: - raise NotImplementedError("Expected 2D or 3D seismic data.") - - methods = { - "marfurt": moving_window(traces, marfurt, window), - "gersztenkorn": moving_window(traces, gersztenkorn, window), - "gst": gradient_structure_tensor(traces, window, sigma) - } - - return methods[kind] diff --git a/bruges/attribute/spectraldecomp.py b/bruges/attribute/spectraldecomp.py index 45c97f9..d58fc89 100644 --- a/bruges/attribute/spectraldecomp.py +++ b/bruges/attribute/spectraldecomp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Spectral decomposition @@ -6,7 +5,7 @@ :license: Apache 2.0 """ import numpy as np -from bruges.attribute import spectrogram +from .spectrogram import spectrogram def spectraldecomp(data, diff --git a/bruges/attribute/test/dip_test.py b/bruges/attribute/test/dip_test.py index 024af20..d835138 100644 --- a/bruges/attribute/test/dip_test.py +++ b/bruges/attribute/test/dip_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import unittest import numpy as np diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 5a3170d..15a39c1 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -18,19 +18,6 @@ blockquote div.line { line-height: 125%; } -/* Adds the Agile logo in the footer. */ -.related-information:before{ - display: block; - width:48px; - content: url('agile-open-logo-nocircle-grey_40px.png'); - float: left; - margin-top: -4px; -} - -.related-information { - padding-left: 0px; -} - /* Adds the GitHub ribbon. */ #forkongithub a { background:rgb(158, 158, 158); diff --git a/docs/conf.py b/docs/conf.py index f7d109b..de72ba8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -75,9 +75,32 @@ def setup(app): # directories to ignore when looking for source files. exclude_patterns = ['_build', 'notebooks'] +# Entire logo SVG +# +# +# +# +# +# +# +# html_theme_options = { "sidebar_hide_name": True, + "footer_icons": [ + { + "name": "Agile", + "url": "https://code.agilescientific.com", + "html": """ + + + + + + """, + "class": "", + }, + ], } # -- Options for HTML output ------------------------------------------------- diff --git a/docs/post_process_html.py b/docs/post_process_html.py index 33a2b20..72b44f6 100644 --- a/docs/post_process_html.py +++ b/docs/post_process_html.py @@ -8,13 +8,16 @@ def simplify_credits(html): """ Replace the credit part of the HTML footer. Return the new text. """ - s = r"Created using ." - pattern = re.compile(s, flags=re.DOTALL) + s = r'@pradyunsg\'s' + pattern = re.compile(s) + html = pattern.sub(r'', html) - new_s = 'CC BY 4.0' - new_s += ' | Created using Sphinx & Furo' + s = r'Copyright © 2022, Agile Scientific' + pattern = re.compile(s) + new_s = '© 2022, Agile Scientific | CC BY' + html = pattern.sub(new_s, html) - return pattern.sub(new_s, html) + return html def main(path): diff --git a/setup.cfg b/setup.cfg index 8bbfc09..b3dc9aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,18 @@ classifiers = Operating System :: OS Independent [options] -packages = bruges +packages = + bruges + bruges.attribute + bruges.filters + bruges.models + bruges.noise + bruges.reflection + bruges.petrophysics + bruges.rockphysics + bruges.transform + bruges.unit + bruges.util python_requires = >=3.6 install_requires = numpy