FREQCOR_plot
Plotting utilities used across the FREQCOR processing pipeline.
Functions
Plots the histograms of the cut-off frequencies found with two different fitting methods (Lorentz and Gauss functions) and their corresponding probability density function and cumulative distribution function. |
|
Plot experimental and fitted transfer functions. |
|
Plot all individual half-hour (co)spectra on a single figure. |
|
Function to plot averaged, ideal and model cospectra. |
|
Plot mean (co)spectra for one class or for all classes. |
|
Plot an individual half-hour (co)spectrum. |
|
Plot cumulative step-wise filtering of fluxes and (co)spectra. |
|
Plot correction factors as a function of wind speed class. |
- FREQCOR_plot.plot_TF_unified(fun1, fun2, x, y, cofmat, denoising, plot, outputpath, norm_range, j_class=None, jrh_class=None, hh_name=None, pause=3, gas_type='co2', all_classes_data=None, file_tag=None, sps=None)[source]
Plot experimental and fitted transfer functions.
The function supports: - single-class plots (using x, y, cofmat), - multi-class plots (using all_classes_data).
- Parameters:
fun1 (
callable) – Transfer function models used for fitting (Lorentz and Gauss).fun2 (
callable) – Transfer function models used for fitting (Lorentz and Gauss).x (
array-like) – Frequency (Hz) and transfer function samples for a single class.y (
array-like) – Frequency (Hz) and transfer function samples for a single class.cofmat (
array-like) – Fit parameters for a single class.denoising (
dictorlist[dict]) – Denoising metadata (e.g., Aslan et al. 2021), for single- or multi-class mode.plot (
list[int]) – Plot configuration.outputpath (
str) – Output directory.norm_range (
list[float]) – Normalization range bounds in Hz.j_class (
int, optional) – Wind speed class index.jrh_class (
int, optional) – First-level class index (WD or RH class).hh_name (
str, optional) – Half-hour identifier.pause (
int, optional) – Pause duration (seconds) for interactive use.gas_type (
str, optional) – Gas label used for titles.all_classes_data (
dict, optional) – Multi-class container holding lists of x, y, cofmat, fnmat, etc.file_tag (
str, optional) – Output filename tag (required when saving is enabled).sps (
int, optional) – Input type selector used for titles: 1 = cospectra, 2 = spectra.
- Returns:
A figure is shown or saved depending on plot options.
- Return type:
- Raises:
ValueError – If saving is enabled and file_tag is missing.
- FREQCOR_plot.plot_cosp_unified(freq, Rcosv, Icosv, ws, denoising, zL=None, sps=None, j_class=None, jrh_class=None, plot=None, outputpath=None, gas_type='co2', all_classes_data=None, file_tag=None)[source]
Plot mean (co)spectra for one class or for all classes.
- Parameters:
freq (
array-like) – Natural frequencies (Hz).Rcosv (
array-like) – Real and ideal (co)spectra for a single class.Icosv (
array-like) – Real and ideal (co)spectra for a single class.ws (
float) – Mean wind speed for current class.denoising (
dictorlist[dict]) – Denoising metadata (e.g., Aslan et al. 2021), for single- or multi-class mode.zL (
float, optional) – Stability parameter. The default is None.sps (
int, optional) – Sampling frequency. The default is None.j_class (
int, optional) – Wind speed class number. The default is None.jrh_class (
int, optional) – First-level class index (WD or RH class). The default is None.plot (
list, optional) – Plot configuration. The default is None.outputpath (
str, optional) – Output directory. The default is None.gas_type (
str, optional) – Gas label used for titles. The default is ‘co2’.all_classes_data (
dict, optional) – Multi-class container holding lists of x, y, cofmat, fnmat, etc. The default is None.file_tag (
str, optional) – Output filename tag (required when saving is enabled). The default is None.
- Return type:
- Raises:
ValueError – If saving is enabled and file_tag is missing.
- FREQCOR_plot.plot_hh_cosp(freq, freqn, sps, zL, cosR, cosI, ws, i, plot, outputpath, pause=3, file_tag=None)[source]
Plot an individual half-hour (co)spectrum.
- Parameters:
freq (
array-like) – Natural frequencies (Hz).freqn (
pandas.DataFrame) – Normalized frequencies per half-hour.sps (
int) – Approach selector (cospectral or spectral).zL (
pandas.Series) – Stability parameter time series.cosR (
pandas.DataFrame) – Real and ideal (co)spectral matrices.cosI (
pandas.DataFrame) – Real and ideal (co)spectral matrices.ws (
pandas.Series) – Wind speed time series.i (
int) – Column index of the half-hour to plot.plot (
list[int]) – Plot configuration.outputpath (
str) – Output directory.pause (
int, optional) – Pause duration for interactive use.file_tag (
str, optional) – Output filename tag (required when saving is enabled).
- Return type:
- Raises:
ValueError – If saving is enabled and file_tag is missing.
- FREQCOR_plot.plot_av_ideals(av_cosp_k, plot, outputpath, stability, file_tag=None)[source]
Function to plot averaged, ideal and model cospectra.
- Parameters:
av_cosp_k (
pd.DataFrame) – [nspec,3]: DataFrame with log-binned frequencies and corresponding averaged values for the ideal, Kaimal and Massman cospectra.plot (
list) – User inputs on plotting preferences (choice of plots, saving options)outputpath (
str) – Name (date and hour) of the plotted half-hourstability (
list) – List of two strings identifying the stability regime of the data (unstable or stable).
- Return type:
None.
- FREQCOR_plot.hist_pdf_cof(cofmat_full, hist_Ldist, hist_Gdist, X_bound, plot, outputpath, file_tag=None)[source]
Plots the histograms of the cut-off frequencies found with two different fitting methods (Lorentz and Gauss functions) and their corresponding probability density function and cumulative distribution function.
- Parameters:
cofmat_full (
pd.DataFrame) – Cut-off frequencies for all the half-hours, for both fitting methods.hist_Ldist (
scipy.stats.rv_histogram) – Probability distribution of cut-off frequencies resulting from fitting Lorentz transfer function.hist_Gdist (
scipy.stats.rv_histogram) – Probability distribution of cut-off frequencies resulting from fitting Gauss transfer function.X_bound (
float) – Upper bound for the x-axis used to compute PDF/CDF.plot (
list[int]) – Plot configuration.outputpath (
str) – Output directory.file_tag (
str, optional) – Output filename tag (required when saving is enabled).
- Return type:
- Raises:
ValueError – If saving is enabled and file_tag is missing.
- FREQCOR_plot.plot_u_cf(all_data_cf, gss, plot, outputpath, stability, file_tag=None)[source]
Plot correction factors as a function of wind speed class.
- Parameters:
all_data_cf (
dict) – Per-class CF and wind speed data used for plotting.gss (
int) – Gas species selector.stability (
str) – Stability regime label.plot (
list[int]) – Plot configuration.outputpath (
str) – Output directory.file_tag (
str, optional) – Output filename tag (required when saving is enabled).
- Return type:
- Raises:
ValueError – If saving is enabled and file_tag is missing.
- FREQCOR_plot.plot_all_individual_cosp(freq, Rcos, Icos, plot, outputpath, gas_type='co2', file_tag=None)[source]
Plot all individual half-hour (co)spectra on a single figure.
- Parameters:
freq (
numpy array) – Frequency array with shape (n_freq,)Rcos (
numpy array) – Real part of the cospectrum with shape (n_spectra, n_freq)Icos (
numpy array) – Imaginary part of the cospectrum with shape (n_spectra, n_freq)plot (
list) – Plot configurationoutputpath (
str) – Path to save the plotgas_type (
str, optional) – Gas type (‘co2’ or ‘h2o’). The default is ‘co2’.
- Return type:
None.
- FREQCOR_plot.plot_stepwise_filtering(*, mask_history, step_names, fluxes_df, flux_col, cospectra_df, freq, outputpath, plot, init_valid_mask=None, step_plot_info=None, filename='filtering_steps.png')[source]
Plot cumulative step-wise filtering of fluxes and (co)spectra.
- Each row shows one filtering step:
blue: data retained up to this step
red: data removed at this step only
The last row shows the final retained data after all filters and reports availability relative to the initially valid dataset.
- Parameters:
mask_history (
listofpandas.Series) – Boolean masks (indexed by time) defining each filtering step. True = retained. All masks must align with fluxes_df.index and cospectra_df.columns.step_names (
listofstr) – Names of the filtering steps (same length as mask_history).fluxes_df (
pandas.DataFrame) – Flux time series (indexed by time).flux_col (
str) – Column of fluxes_df to plot.cospectra_df (
pandas.DataFrame) – (Co)spectra with frequency as rows and time as columns.freq (
array-like) – Frequency vector for the (co)spectra.outputpath (
str) – Directory where the figure is saved.init_valid_mask (
pandas.Series, optional) – Boolean mask of initially available data. Defaults to columns of cospectra_df that are not fully NaN.step_plot_info (
dict, optional) – Optional step-specific plotting info (e.g. flux thresholds, absolute (co)spectral limits, IQR statistics).filename (
str) – Output figure name.
Notes
Filtering is cumulative: each step operates only on data that passed all previous steps. Percentages shown per step refer to data entering that step.