Skip to content

Problem with colorbar(s) while plotting spectrograms for Mediterranean Seismic Network (WM-Net) #1

@web-sys1

Description

@web-sys1

Hello @gthompson

I considered the script implementation using icewebPy script code. The next thing is to plot the spectrograms from the WM.AVE and WM.TIO stations, BHZ channel. However, there is the problem on the image I'm having, the folowing empty colorbar(s) overlaps the original one(s) and like the colorbar below in the image it doesn't look good at all.

WM sta BHZ specgram_2023-09-17T165004

How to reproduce the problem

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)

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)

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.

4 - Unscaled, decibel (dB) units

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

5 - Best overall scale, decibel (dB) units

  sgramfile = 'myspecgram_unscaled.png'
  spobj.plot(outfile=sgramfile, equal_scale=True, dbscale=True, title='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')

Here is my code:

import IceWeb
from obspy.clients.fdsn import Client
from obspy import UTCDateTime
import matplotlib.pyplot as plt
import sys

from obspy.imaging.cm import obspy_sequential

sys.path.append('C:Users/web/Desktop/iceweb/')

client = Client("GFZ")

tm = UTCDateTime("2023-09-17T16:50:04")
st = client.get_waveforms("WM", "AVE, TIO", "*", "BHZ", tm - 60*30, tm)

spobj = IceWeb.icewebSpectrogram(stream=st)

sgramfile = 'WM.sta.BHZ.specgram_2023-09-17T165004.png'

#spobj = spobj.precompute()
spobj.plot(outfile=sgramfile, equal_scale=True, fmax=10, dbscale=True, cmap=obspy_sequential, precompute=True, title='Equally Scaled')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions