Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix t0 for NMO correction #96

Merged
merged 8 commits into from Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 22 additions & 23 deletions Notebooks/GPR_TBL4_DOI_Resolution.ipynb
Expand Up @@ -23,9 +23,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
Expand Down Expand Up @@ -62,16 +60,21 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bb181e611fac4b169310edf8a99e4792"
}
"model_id": "939fe164aae44aed869231a9df22d4e9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=3.0, continuous_update=False, description='$\\\\sigma$ [mS/m]', max=5.0,…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function gpgLabs.GPR.GPR_zero_offset.GPRWidgetWaveRegime>"
"<function gpgLabs.GPR.GPR_zero_offset.GPRWidgetWaveRegime(sig, epsr, fc, x1, d1, R1, x2, d2, R2)>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -110,16 +113,21 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3d46e876098a49d595a07ff511daabd2"
}
"model_id": "89228aede5c54d3d8423e8244b46fa01",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatText(value=9.0, description='epsr'), FloatSlider(value=-1.5, description='sigma', m…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function gpgLabs.GPR.Attenuation.WaveVelandSkindWidgetTBL>"
"<function gpgLabs.GPR.Attenuation.WaveVelandSkindWidgetTBL(epsr, sigma)>"
]
},
"execution_count": 3,
Expand All @@ -130,34 +138,25 @@
"source": [
"AttenuationWidgetTBL()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
114 changes: 93 additions & 21 deletions Notebooks/Seis_NMO.ipynb

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions Notebooks/Seis_Refraction.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Notebooks/SeismicApplet.ipynb
Expand Up @@ -27,15 +27,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d8fc8d3aeb634ef4b2ae655aa1e204f8",
"model_id": "4d6e0fc0035544f58ad2503d6ef6a20e",
"version_major": 2,
"version_minor": 0
},
Expand Down
64 changes: 46 additions & 18 deletions gpgLabs/Seismic/NMOwidget.py
Expand Up @@ -14,7 +14,7 @@
from IPython.html.widgets import interact, interactive, IntSlider, widget, FloatText, FloatSlider, fixed
pass
# except Exception, e:
except Exception as e:
except Exception as e:
from ipywidgets import interact, interactive, IntSlider, widget, FloatText, FloatSlider, fixed


Expand Down Expand Up @@ -44,6 +44,7 @@ def ViewWiggle(syndat, obsdat):
ax[1].set_ylabel("Time (s)")
ax[1].set_title("Noisy CMP gather")


def NoisyNMOWidget(t0, v, syndat, timdat):
syndata = np.load(syndat)
time_data = np.load(timdat)
Expand All @@ -70,11 +71,12 @@ def NoisyNMOWidget(t0, v, syndat, timdat):
ax1.invert_yaxis()
ax2.invert_yaxis()
wiggle(syndata, ax = ax1, **kwargs)
t_reflector = 0.49
toffset = np.sqrt(xorig**2/v**2+t0**2)-t0
wiggle(syndata, ax = ax2, manthifts=toffset, **kwargs)
wiggle(syndata, ax = ax2, manthifts=toffset+t0-t_reflector, **kwargs)

ax1.axis(extent)
ax2.axis(extent)
ax2.axis(extent)
ax1.plot(xorig, time, 'r', lw=2)

ax1.set_xlabel("Offset (m)")
Expand All @@ -83,9 +85,9 @@ def NoisyNMOWidget(t0, v, syndat, timdat):
ax2.set_ylabel("Time (s)")
ax1.set_title("CMP gather")
ax2.set_title("NMO corrected CMP gather")
singletrace = NMOstack(syndata, xorig, time_data, v)
# singletrace = singletrace

singletrace = NMOstack(syndata, xorig, time_data, v)
# singletrace = singletrace

kwargs = {
'skipt':1,
Expand All @@ -94,6 +96,7 @@ def NoisyNMOWidget(t0, v, syndat, timdat):
'sampr': 0.004,
'ax': ax3,
'clip' : 10,
'manthifts': np.r_[t0-t_reflector]
}
extent = [singletrace.min(), singletrace.max(), time_data.max(), time_data.min()]
ax3.invert_yaxis()
Expand All @@ -107,6 +110,7 @@ def NoisyNMOWidget(t0, v, syndat, timdat):

plt.show()


def CleanNMOWidget(t0, v, syndat, timdat):
syndata = np.load(syndat)
time_data = np.load(timdat)
Expand Down Expand Up @@ -134,11 +138,12 @@ def CleanNMOWidget(t0, v, syndat, timdat):
ax1.invert_yaxis()
ax2.invert_yaxis()
wiggle(syndata, ax = ax1, **kwargs)
toffset = np.sqrt(xorig**2/v**2+t0**2)-t0
wiggle(syndata, ax = ax2, manthifts=toffset, **kwargs)
toffset = np.sqrt(xorig**2/v**2+t0**2) - t0
t_reflector = 0.39
wiggle(syndata, ax = ax2, manthifts=toffset+t0-t_reflector, **kwargs)

ax1.axis(extent)
ax2.axis(extent)
ax2.axis(extent)
ax1.plot(xorig, time, 'r', lw=2)

ax1.set_xlabel("Offset (m)")
Expand All @@ -147,17 +152,17 @@ def CleanNMOWidget(t0, v, syndat, timdat):
ax2.set_ylabel("Time (s)")
ax1.set_title("CMP gather")
ax2.set_title("NMO corrected CMP gather")

singletrace = NMOstack(syndata, xorig, time_data, v)
# singletrace = singletrace

singletrace = NMOstack(syndata, xorig, time_data, v)
# singletrace = singletrace
kwargs = {
'skipt':1,
'scale': 2.,
'lwidth': 1.,
'sampr': 0.004,
'ax': ax3,
'clip' : 10,
'manthifts': np.r_[t0-t_reflector]
}
extent = [singletrace.min(), singletrace.max(), time_data.max(), time_data.min()]
ax3.invert_yaxis()
Expand All @@ -168,13 +173,14 @@ def CleanNMOWidget(t0, v, syndat, timdat):
ax3.set_xlim(-4.5, 4.5)
ax3.set_xticks([-4.5, 0., 4.5])
ax3.set_title("Stacked trace")
plt.show()

plt.show();

def HyperbolicFun(t0, x, velocity):
time = np.sqrt(x**2/velocity**2+t0**2)
return time


def NMOstackthree(dat, tintercept, v1, v2, v3, timdat):
data = np.load(dat)
time = np.load(timdat)
Expand All @@ -186,12 +192,14 @@ def NMOstackthree(dat, tintercept, v1, v2, v3, timdat):
traces[itry,:] = NMOstack(data, xorig, time, vtemp[itry])

fig, ax = plt.subplots(1, 3, figsize=(10, 8))
t_reflector = 0.49
kwargs = {
'skipt':1,
'scale': 2.,
'lwidth': 1.,
'sampr': 0.004,
'clip' : 10,
'manthifts': np.r_[t_reflector-tintercept]
}
for i in range(3):
extent = [traces[i,:].min(), traces[i,:].max(), time.max(), time.min()]
Expand All @@ -203,6 +211,7 @@ def NMOstackthree(dat, tintercept, v1, v2, v3, timdat):
ax[i].set_ylabel("Time (s)")
ax[i].set_title(("Velocity = %6.1f")%(vtemp[i]))


def NMOstack(data, xorig, time, v):
if np.isscalar(v):
v = np.ones_like(time)*v
Expand All @@ -216,6 +225,7 @@ def NMOstack(data, xorig, time, v):
singletrace[i] = (mkvc(data)[sub2ind(data.shape, np.c_[np.arange(data.shape[0]), indmin])]).sum()
return singletrace


def NMOstackSingle(data, tintercept, v, timeFile):
dx = 20.
xorig = np.arange(38)*dx
Expand All @@ -240,11 +250,12 @@ def NMOstackSingle(data, tintercept, v, timeFile):
ax.set_ylabel("Time (s)")


def clipsign (value, clip):
def clipsign(value, clip):
clipthese = abs(value) > clip
return value * ~clipthese + np.sign(value)*clip*clipthese

def wiggle (traces, skipt=1,scale=1.,lwidth=.1,offsets=None,redvel=0., manthifts=None, tshift=0.,sampr=1.,clip=10., dx=1., color='black',fill=True,line=True, ax=None):

def wiggle(traces, skipt=1,scale=1.,lwidth=.1,offsets=None,redvel=0., manthifts=None, tshift=0.,sampr=1.,clip=10., dx=1., color='black',fill=True,line=True, ax=None):

ns = traces.shape[1]
ntr = traces.shape[0]
Expand Down Expand Up @@ -280,6 +291,7 @@ def wiggle (traces, skipt=1,scale=1.,lwidth=.1,offsets=None,redvel=0., manthifts
trace[j] = 0
ax.fill(i*dx + clipsign(trace / scale, clip), t - shifts[i], color=color, linewidth=0)


def sub2ind(shape, subs):
"""
Extracted from SimPEG for temporary use (https://github.com/simpeg)
Expand All @@ -297,6 +309,7 @@ def sub2ind(shape, subs):
inds = np.ravel_multi_index(subs.T, shape, order='F')
return mkvc(inds)


def mkvc(x, numDims=1):
"""
Extracted from SimPEG for temporary use (https://github.com/simpeg)
Expand Down Expand Up @@ -332,10 +345,25 @@ def mkvc(x, numDims=1):
elif numDims == 3:
return x.flatten(order='F')[:, np.newaxis, np.newaxis]


def InteractClean(cleanDataFile, cleanTimeFile):
clean = interactive(CleanNMOWidget, t0 = (0.2, 0.8, 0.01), v = (1000., 5000., 100.), syndat = fixed(cleanDataFile), timdat = fixed(cleanTimeFile))
return clean
clean = interactive(
CleanNMOWidget,
t0=FloatSlider(min=0.2, max=0.8, step=0.01, continuous_update=False),
v=FloatSlider(
min=1000., max=5000., step=100., continuous_update=False
),
syndat=fixed(cleanDataFile),
timdat=fixed(cleanTimeFile)
)
return clean


def InteractNosiy(noisyDataFile, noisyTimeFile):
noisy = interactive(NoisyNMOWidget, t0 = (0.1, 0.6, 0.01), v = (800., 2500., 100.), syndat = fixed(noisyDataFile), timdat = fixed(noisyTimeFile))
noisy = interactive(
NoisyNMOWidget,
t0=FloatSlider(min=0.1, max=0.6, step=0.01, continuous_update=False),
v=FloatSlider(min=800., max=2500., step=100., continuous_update=False),
syndat=fixed(noisyDataFile),
timdat=fixed(noisyTimeFile))
return noisy