pycsa.wrappers.diagnostics

Diagnostic wrapper module to ease setting up the CSA building blocks

Classes

delaunay_metrics(params, tri[, writer])

Helper class for evaluation of the CSA on a Delaunay triangulated domain.

diag_plotter(params, nhi, nhj)

Helper class to plot CSA-computed data

class pycsa.wrappers.diagnostics.delaunay_metrics(params, tri, writer=None)

Helper class for evaluation of the CSA on a Delaunay triangulated domain.

__init__(params, tri, writer=None)
Parameters:
update_quad(idx, uw_ref, uw_fa)

Store the computed idealised pseudo-momentum fluxes on a quadrilateral grid, i.e., the reference grid.

Parameters:
  • idx (str or int) – index of the cell

  • uw_ref (array-like) – 2D array the size of a dense (truncated) spectral space containing the reference idealised pseudo-momentum fluxes

  • uw_fa (array-like) – 2D array the size of a dense (truncated) spectral space containing the first-approximation’s idealised pseudo-momentum fluxes

get_rel_err(triangle_pair)

Method to get the relative error explicitly before wrappers.diagnostics.delaunay_metrics.end() is called.

Parameters:

triangle_pair (list) – a list containing the index pair in int for the Delaunay triangles corresponding to a quadrilateral grid cell

Returns:

the relative error of the CSA on the Delaunay triangles against the FFT-computed reference

Return type:

float

update_pair(triangle_pair, store_error=True)

Update metric computation instance with the data from the newly computed triangle pair

Parameters:
  • triangle_pair (list) – a list containing the index pair in int for the Delaunay triangles corresponding to a quadrilateral grid cell

  • store_error (bool, optional) – keep a list of the errors for each triangle pair, by default True. Otherwise, the errors are discarded and only the average error is stored.

end(verbose=False)

Ends the metric computation

Parameters:

verbose (bool, optional) – prints the average errors computed, by default False

class pycsa.wrappers.diagnostics.diag_plotter(params, nhi, nhj)

Helper class to plot CSA-computed data

__init__(params, nhi, nhj)
Parameters:
  • params (pycsa.config.params.params) – instance of the user-defined parameter class

  • nhi (int) – number of harmonics in the first horizontal direction

  • nhj (int) – number of harmonics in the second horizontal direction

show(rect_idx, sols, kls=None, v_extent=None, dfft_plot=False, output_fig=True, fs=(14.0, 4.0), ir_args=None, fn=None, phys_lbls=None)

Plots the data

Parameters:
  • rect_idx (int) – index of the quadrilateral grid cell

  • sols (tuple) –

    contains the data for plotting:
    computed CSA spectrum,
    computed idealised pseudo-momentum fluxes,
    the reconstructed physical data)

    sols is the tuple returned by wrappers.interface.first_appx.do() and wrappers.interface.second_appx.do()

  • kls (list, optional) – list of size 2, each element is a vector containing the (k,l)-wavenumbers, by default None. Only required to plot FFT spectra.

  • v_extent (list, optional) – [z_min, z_max] the vertical extent of the physical reconstruction, by default None

  • dfft_plot (bool, optional) – toggles whether a spectrum is the full FFT spectral space or the dense truncated CSA spectrum, By default False, i.e. plot CSA spectrum.

  • output_fig (bool, optional) – toggles writing figure output, by default True

  • fs (tuple, optional) – figure size, by default (14.0,4.0)

  • ir_args (list, optional) –

    additional user-defined arguments:
    [title of the physical reconstruction panel,
    title of the power spectrum panel,
    title of the idealised pseudo-momentum flux panel,
    vertical extent of the power spectrum,
    vertical extent of the idealised pseudo-momentum flux spectrum]

    By default None

  • fn (str, optional) – output filename, by default None

  • phys_lbls (list, optional) – axis labels for the physical plot, by default None