08. Plotting data - RJbalikian/SPRIT-HVSR GitHub Wiki

Plotting of the input seismic data and the calculated HVSR data can be done in several ways. Plotting the data is also a key part of the manual noise removal process (which is done using sprit.remove_noise(hvsr_data, kind='manual').

For most of these, a key component plotting is the plot_type string specification. This is also explained in detail below

These plotting options are explained in detail below, but in summary, they include:

  • sprit.fetch_data(plot_input_stream=True)
  • sprit.plot_hvsr()
    • plot_type String Specification
  • sprit.get_report(hvsr_results, report_format='print')

plot_input_stream Option

The plot_input_stream parameter is part of the sprit.fetch_data() function. If set to True, an input plot is shown, showing the raw streams of each component, and a spectrogram of the Z component (by default). An example of that plot is shown below:

PlotOutput_plot_input_stream

plot_hvsr() Function

The sprit.plot_hvsr() function is the main plotting function in the sprit package. Many of the other plotting functions in the sprit package call this function as part of their implementation. There are many parameters that can be

plot_type String Specification

For plot_hvsr() and the functions and methods that utilize this function, plot_type can be passed as a parameter with a string specification of the kind of plot to use. Be default, this is plot_type='HVSR ann p C+ ann p SPEC'.

The parsing of this plot_type specification string is done in the following way:

  • Anywhere from 1-3 plots can be plotted at once. The three types of plots are:
    • HVSR plot: the main plot of the HVSR curve.
    • Component: the plot of the spectral power of each the 3 components of the measurement: Vertical (Z), East (E), and North (N). This plot may be superimposed on the HVSR plot or plotted separately (see below for details).
    • Spectrogram: a plot of the "spectrogram" of the amplitude of the H/V ratio over time, divided into windows of length ppsd_length (called in the generate_ppsds() function)
  • Customization parameters are placed in the string immediately after the chart it should be applied to. The customization parameters are explained below. If the parameter appears in :
    • HVSR [can also use 'hv' or 'h'] - case insensitive
      • p: shows a vertical line at the "best" peak frequency as calculated on the HVSR curve
      • pa: shows a horizontal line at the "best" peak amplitude
      • ann: annotates the "best" peak on the HVSR Curve (displays a text box with the frequency (and amplitude, if pa included) of that peak)
      • t: shows the H/V curves for each individual time window of the data (which are combined/averaged to get the main HVSR curve
      • tp: shows the peaks of each individual time window H/V curve as a semitransparent bar (when there are many peaks at the same frequency, the bars appear darker)
      • all: show all the peaks calculated on the HVSR curve, including those not calculated to be the "best" curve
      • testx: show the test results visually for any test, 1-6 (e.g., test2 would visualize test #2). Also, "tests" will show all the tests at once.
      • -s: do not display standard deviation windows around the main H/V curve (these are displayed by default)
    • Comp [can also use 'component', 'components', or 'c'] - case insensitive
      • '+' (no space after comp: e.g, comp+ or c+): if + is included, will put components on separate chart or subplot. Otherwise, puts it on the same chart/subplot as the HVSR plot (with a separate y-axis)
      • ann: same as HVSR
      • p: same as HVSR
      • -s: do not display standard deviation windows around the component power curves (these are displayed by default)
    • 'SPEC' - spectrogram style plot of the H/V curve over time
      • 'p' shows a horizontal dotted line at the frequency of the "best" peak
      • 'ann' annotates the frequency value of the "best" peak
      • 'all' shows all the peaks identified in check_peaks()
      • 'tp' shows all the peaks of the H/V curve at all time windows
    • 'AZ' - circular plot of calculated azimuthal HV curves, similar in style to SPEC plot. This is only used if azimuthal data has been calculated.
      • 'p' shows a point at each calculated (not interpolated) azimuth peak
      • 'g' shows grid lines at various angles
      • 'i' interpolates so that there is an interpolated azimuth at each degree interval (1 degree step)
        • This is the default, so usually 'i' is not needed.
      • '-i' prohibits interpolation (only shows the calculated azimuths, as determined by azimuth_angle (default = 30))

get_report() Function (and report() method)

The sprit.get_report() function uses the plot_hvsr() function to create plots. These plots can also be exported easily from the get_report() function. (hvsr_results, report_format='plot')

plot() Method

The plot() method is called on an existing HVSRData or HVSRBatch object, unlike the sprit.plot_hvsr() and sprit.get_report() functions, which need to have an HVSRData or HVSRBatch object passed to them.

For example:

hvsrData = sprit.run(datapath='sample', source='file')

#These will all produce the same plot:
#This is the plot() method called on a sprit data object
hvsrData.plot(**keyword_arguments)

#This is the plot_hvsr() function called directly from the sprit package, with a sprit object passed to it:
sprit.plot_hvsr(hvsr_data=hvsrData , **keyword_arguments)

#This is the get_report() function called directly from the sprit package, with a sprit object passed to it:
sprit.get_report(hvsr_results=hvsrData , **keyword_arguments)

All three of these plotting methods could be amended by passing plot_type with a valid plot_type string specification

Examples:

plot_type = 'HVSR ann p C+ ann p SPEC' (this is the default option) PlotOutput_plot_type_HVSR ann p C+ ann p SPEC

plot_type = 'hvsr p t ann c+ p ann' PlotOutput_plot_type_hvsr p t ann c+ p ann

plot_type = 'HVSR ann p C SPEC' PlotOutput_plot_type_HVSR ann p C SPEC

plot_type = 'HVSR tp ann t all p C+ ann p SPEC' PlotOutput_plot_type_HVSR tp ann t all p C+ ann p SPEC

Plotting Peak Tests

These are the second set of tests (those testing the validity of the peak itself). They are numbered 1-6 based on their order. They are as follows:

  1. “Clarity” or Prominence of Main Peak above a. There exist at least one frequency f-, lying between f0/4 and f0, such that A0 / A(f-) > 2
  2. “Clarity” or Prominence of Main Peak below a. There exist one frequency f+, lying between f0 and 4*f0, such that A0 / A(f+) > 2
  3. Peak is Large a. Amplitude of H/V peak is > 2
  4. Frequency stability of peak (Test 1) a. The main peak should appear at the same frequency (within a percentage ± 5%) on the H/V curves corresponding to mean + and - one standard deviation.
  5. Frequency stability of peak (Test 2) a. σf lower than a frequency dependent threshold ε(f)
  6. Amplitude stability of peak a. σA (f0) lower than a frequency dependent threshold θ(f)

Tests 1 and 2 are complementary

plot_type = 'HVSR test12

image

plot_type = 'HVSR test3

image

plot_type = 'HVSR test4

image

plot_type = 'HVSR test5

image

plot_type = 'HVSR test6

image

These correspond to the following test results (as reported in the print report):

  • Peak Tests: 5/6 passed (5/6 needed)
    1. ✔ Peak is prominent below Amp. of H/V Curve @1.007Hz (1.271) < 2.468 ✔
    2. ✔ Peak is prominent above H/V Curve at 11.23 Hz: 1.24 < 2.47 (f0/2) ✔
    3. ✔ Peak is large Amplitude of peak (4.94) > 2 ✔
    4. ✔ Peak freq. is stable over time 2.84 and 2.79 Hz within ±5% of 2.81 Hz ✔
    5. ✘ Stability of peak (Freq. StDev) St.Dev. of Peak Freq. (0.19) < 0.141 ✘
    6. ✔ Stability of peak (Amp. StDev) St.Dev. of Peak Amp. (0.015) < 0.20 ✔