Skip to content

Latest commit

 

History

History
148 lines (93 loc) · 4.34 KB

README.md

File metadata and controls

148 lines (93 loc) · 4.34 KB

icewebPy

Python re-implementation of AVO IceWeb application including spectrogram browser. Some minimal examples follow.

Creating an icewebSpectrogram object

Assuming you have this repository at /path/to/repo and an ObsPy Stream object (st), and that it is in units of m/s.

import sys
sys.path.append('/path/to/repo')
import IceWeb

spobj = IceWeb.icewebSpectrogram(stream=st)

Plotting Options:

We plot an icewebSpectrogram object by calling the plot method. Here is the function prototype:

    def plot(self, outfile=None, secsPerFFT=None, fmin=0.5, fmax=20.0, log=False, cmap=pqlx, clim=None, \
                      equal_scale=False, title=None, add_colorbar=True, precompute=False, dbscale=True)

1 - Unscaled, amplitude units

All we have to do is create an instance of an icewebSpectrogram object, and then call the plot method. Each spectrogram is individually scaled to make best use of the colormap.

  sgramfile = 'myspecgram_unscaled.png'
  spobj.plot(outfile=sgramfile)

2005-05-01-1344-36S MVO___025_sgram

2 - Best overall scale, amplitude units

As in 1, but we want to choose the best overall spectral amplitude scale so all spectrogram plots are scaled (colored) the same:

  sgramfile = 'myspecgram_scaled.png'
  spobj.plot(outfile=sgramfile, equal_scale=True)

2005-05-01-1344-36S MVO___025_sgram_scaled

3 - Fixed overall scale, amplitude units

As in 2, but we want to provide our own scale (colormap) limits. This is the default for AVO North spectrograms:

sgramfile = 'myspecgram_fixed.png'
spobj.plot(outfile=sgramfile, clim=[1e-8, 1e-5])

Note that the scale here is in units of m/s/Hz.

2005-05-01-1344-36S MVO___025_sgram_fixed

4 - Unscaled, decibel (dB) units

  sgramfile = 'myspecgram_unscaled.png'
  spobj.plot(outfile=sgramfile, dbscale=True, title='Unscaled')

2005-05-01-1344-36S MVO___025_sgram

5 - Best overall scale, decibel (dB) units

  sgramfile = 'myspecgram_unscaled.png'
  spobj.plot(outfile=sgramfile, equal_scale=True, dbscale=True, title='Scaled')

2005-05-01-1344-36S MVO___025_sgram_scaled

6 - Fixed overall scale, decibel (dB) units

  sgramfile = 'myspecgram_unscaled.png'
  spobj.plot(outfile=sgramfile, clim=[1e-8, 1e-5], dbscale=True, title='Fixed')

2005-05-01-1344-36S MVO___025_sgram_fixed

Changing the colormap

To change the colormap, pass the optional cmap name:value pair to the plot method.

The default colormap is pqlx. Other options are viridis_white_r, obspy_divergent, obspy_sequential

  from obspy.imaging.cm obspy_sequential
  spobj.plot(..., cmap=obspy_sequential )

2005-05-01-1344-36S MVO___025_sgram_fixed

Making the y-scale logarithmic

  spobj.plot(..., log=True )

2005-05-01-1344-36S MVO___025_sgram_fixed

Changing the frequency limits on the y-axis

  spobj.plot(..., fmin = 0.0, fmax = 10.0 )

Adding a title

  spobj.plot(..., title = 'Montserrat 2005-05-31 13:46:36' )

Removing colorbars

  spobj.plot(..., add_colorbar = False)

Pre-computing the spectral data

If plotting the same seismic data as spectrograms in different ways, it can be useful to pre-compute the spectrograms:

  spobj = IceWeb.icewebSpectrogram(stream=st)
  spobj = spobj.precompute()
  
  # plot same data in 4 different ways
  spobj.plot(dbscale=False)
  spobj.plot(dbscale=False, equal_scale=True)
  spobj.plot(dbscale=True)
  spobj.plot(dbscale=True, equal_scale=True)

Glenn Thompson, 2021/06/22