gthompson / icewebPy

Python implementation of AVO IceWeb application including spectrogram browser
GNU General Public License v3.0
4 stars 1 forks source link

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

Open web-sys1 opened 1 year ago

web-sys1 commented 1 year ago

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')
gthompson commented 1 year ago

Who is this? I know how to fix this.

On Sun, Sep 17, 2023 at 13:29 Web Source (SRC) @.***> wrote:

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.

[image: WM sta BHZ specgram_2023-09-17T165004] https://user-images.githubusercontent.com/61905565/268517305-bea890a5-29d8-46eb-b64b-26f7fb14bf5f.png 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 IceWebfrom obspy.clients.fdsn import Clientfrom obspy import UTCDateTimeimport matplotlib.pyplot as pltimport sys from obspy.imaging.cm import obspy_sequential sys.path.append('/ncfspecs/iceweb/') client = Client("GFZ") tm = UTCDateTime("2023-09-17T16:50:04")st = client.get_waveforms("WM", "AVE, TIO", "", "BHZ", tm - 6030, 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')

— Reply to this email directly, view it on GitHub https://github.com/gthompson/icewebPy/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZCWAIUYZS53XDO5BQRHTX24XPJANCNFSM6AAAAAA43X4NE4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

web-sys1 commented 1 year ago

Now I'm running upper version of Python to 3.10 until recently. And my conda version of 23.5.2 I'm using.

Plus matplotlib=3.7.1, numpy from 1.22 to 1.25.1, obspy=1.4.0, scipy=1.11.1

web-sys1 commented 1 year ago

@gthompson it is possible to downgrade the versions for some of them?