Plotting#

The pyFBS package offers wrapper functions for creating interactive plots aimed at a user-friendly display of quantities common for structural dynamic analyses. Wrapper functions utilize the Altair python package and are designed to distinctly present important analysis results to the reader.

Tip

All plots presented within this tutorial are interactive for you to try them out! Use mouse scroll to zoom in/out on figures, hoover mouse tip over plots to see the interactive tool-tip messages, and explore capabilities of such plotting.

Plotting FRFs#

For plotting frequency response functions (also known as a holy grail in pyFBS) several types of plots can be exploited, depending on the size of the FRF matrix. Commonly, FRFs are measured for several excitation points, while the output is measured using multiple transducers. Full FRF matrix can be neatly displayed using the following function by passing frequency vector and 3D FRF matrix:

pyFBS.plot_FRF(freq, FRF_matrix)

Tip

To many FRFs? Click on corresponding circles to display individual FRF only. By holding shift while clicking, multiple FRFs can be displayed.

When directly comparing two or more FRFs (or other quantities such as responses etc.), plot_frequency_response can be used. Required arguments are frequency vector and 3D FRF matrix, composed of FRFs you want to display. You can manually insert labels to easily differentiate between curves:

o = 3
i = 0

pyFBS.plot_frequency_response(freq,
            np.hstack((MK.FRF_noise[:,o:o+1,i:i+1], MK.FRF[:,o:o+1,i:i+1], Y_B_exp[:,o:o+1,i:i+1])),
            labels=('Num. FRF + noise', 'Num. FRF', 'Exp. FRF'))

Note

Even if you are plotting a single FRF, FRF data must be in a form of a 3D matrix. This is due to the optimization of the wrappers for plotting multiple functions.

Tip

Click on labels in the legend to show/hide individual curves.

Plotting coherence#

You can use plot_coh to neatly plot frequency dependant coherence criterion between two functions:

pyFBS.plot_coh(freq, vpt.overall_impact, color='firebrick', title='Overall Impact Consistency')

For cases where you compare several pairs of functions, you can use plot_coh_group. On the left, you can see averaged coherence value for each pair, while on the right, frequency dependant coherence is plotted:

pyFBS.plot_coh_group(freq, coh_data)

Tip

Circle sizes are proportional to the averaged coherence value to quickly differentiate between the DoFs with high and low coherence.

Commonly used plots#

For simple plotting of curves on a linear scale, the following wrapper can be used:

pyFBS.comparison_plot(time_data, np.expand_dims(acc_data, axis=(1,2)),
                     x_label='Time', y_label='Acceleration', labels='acc1')

All of us use barcharts for multiple purposes quite frequently. How about a barchart plot with an interactive mouse tool-tip to quickly assess bar values? We got you there:

pyFBS.barchart(np.arange(1,10,1), vpt_AB.specific_impact,
                color='firebrick', title='Specific Impact Consistency')

Tip

Barchart plot is very useful for assessing channel/impact consistency in VPT.

Another commonly used plot is an image-show plot. Pass a 2D matrix with real entries and define a colormap of your own (we prefer jet):

pyFBS.imshow(coh_crit)

Tip

Using imshow, you can quickly estimate FRF matrix reciprocity.

Similar to imshow is a contour plot. Required arguments in this case are x and y coordinates (1D array with real entries) and z values in form of a 2D array with real entries.

pyFBS.contour_plot(time, freq, np.abs(Acc_f_dB))

Tip

Contour plot wrapper is perfect to use for run-up diagrams, as you can see from the example above.

That’s a wrap!

Want to know more, see a potential application? Contact us at info.pyfbs@gmail.com!