disdrodb.summary package#

Submodules#

disdrodb.summary.routines module#

Utilities to create summary statistics.

disdrodb.summary.routines.create_l2_dataframe(ds)[source][source]#

Create pandas Dataframe for L2 analysis.

disdrodb.summary.routines.create_nd_dataframe(ds, variables=None)[source][source]#

Create pandas Dataframe with N(D) data.

disdrodb.summary.routines.create_station_summary(data_source, campaign_name, station_name, parallel=False, data_archive_dir=None, temporal_resolution='1MIN')[source][source]#

Create summary figures and tables for a DISDRODB station.

disdrodb.summary.routines.create_table_dsd_summary(df)[source][source]#

Create table with integral DSD parameters statistics.

disdrodb.summary.routines.create_table_events_summary(df, temporal_resolution)[source][source]#

Create table with events statistics.

disdrodb.summary.routines.create_table_rain_summary(df, temporal_resolution)[source][source]#

Create rainy table summary.

disdrodb.summary.routines.define_filename(prefix, extension, data_source, campaign_name, station_name, temporal_resolution)[source][source]#

Define filename for summary files.

disdrodb.summary.routines.define_lognorm_max_value(value)[source][source]#

Round up to next nice number: 90->100, 400->500, 1200->2000.

disdrodb.summary.routines.fit_powerlaw(x, y, xbins, quantile=0.5, min_counts=10, x_in_db=False, use_ransac=True)[source][source]#

Fit a power-law relationship y = a * x**b to binned median values.

This function bins x into intervals defined by xbins, computes the median of y in each bin (robust to outliers), and fits a power-law model using the RANSAC or Levenberg-Marquardt algorithm. Optionally, x can be converted from decibel units to linear scale automatically before fitting.

Parameters:
  • x (array_like) – Independent variable values. Must be positive and finite after filtering.

  • y (array_like) – Dependent variable values. Must be positive and finite after filtering.

  • xbins (array_like) – Bin edges for grouping x values (passed to pandas.cut).

  • quantile (float, optional) – Quantile of y to compute in each bin (between 0 and 1). For example: 0.5 = median, 0.25 = lower quartile, 0.75 = upper quartile. Default is 0.5 (median)

  • x_in_db (bool, optional) – If True, converts x values from decibels (dB) to linear scale using disdrodb.idecibel(). Default is False.

  • use_ransac (bool, optional) – Whether to fit the powerlaw using the Random Sample Consensus (RANSAC) algorithm or using the Levenberg-Marquardt algorithm. The default is True. To fit with RANSAC, scikit-learn must be installed.

Returns:

  • params (tuple of float) – Estimated parameters (a, b) of the power-law relationship.

  • params_std (tuple of float) – One standard deviation uncertainties (a_std, b_std) estimated from the covariance matrix of the fit. Parameters standard deviation is currently not available if fitting with the RANSAC algorithm.

Notes

  • This implementation uses median statistics within bins, which reduces the influence of outliers.

  • Both x and y are filtered to retain only positive, finite values before binning.

  • Fitting is performed on the bin centers (midpoints between bin edges).

See also

predict_from_powerlaw

Predict values from the fitted power-law parameters.

inverse_powerlaw_parameters

Compute parameters of the inverse power law.

Examples

>>> import numpy as np
>>> x = np.linspace(1, 50, 200)
>>> y = 2 * x**1.5 + np.random.normal(0, 5, size=x.size)
>>> xbins = np.arange(0, 60, 5)
>>> (a, b), (a_std, b_std) = fit_powerlaw(x, y, xbins)
disdrodb.summary.routines.fit_powerlaw_with_ransac(x, y)[source][source]#

Fit powerlaw relationship with RANSAC algorithm.

disdrodb.summary.routines.generate_station_summary(ds, summary_dir_path, data_source, campaign_name, station_name, temporal_resolution)[source][source]#

Generate station summary using L2E dataset.

disdrodb.summary.routines.get_symbol_str(symbol, pol='')[source][source]#

Generate symbol string with optional polarization subscript.

Parameters:
  • symbol (str) – The base symbol (e.g., ‘A’, ‘Z’, ‘z’)

  • pol (str, optional) – Polarization identifier (e.g., ‘H’, ‘V’)

Returns:

LaTeX formatted symbol string

Return type:

str

disdrodb.summary.routines.inverse_powerlaw_parameters(a, b)[source][source]#

Compute parameters of the inverse power-law relationship.

Given a model y = a * x**b, this returns parameters (A, B) such that the inverse relation x = A * y**B holds.

Parameters:
  • a (float) – Power-law coefficient in y = a * x**b.

  • b (float) – Power-law exponent in y = a * x**b.

Returns:

  • A (float) – Coefficient of the inverse power-law model.

  • B (float) – Exponent of the inverse power-law model.

disdrodb.summary.routines.is_latex_engine_available() bool[source][source]#

Determine whether the Tectonic TeX/LaTeX engine is installed and accessible.

Returns:

True if tectonic is found, False otherwise.

Return type:

bool

disdrodb.summary.routines.plot_ADP_KDP_ZDR(df, adp, kdp, zdr, y_lim=(0, 0.015), zdr_lim=(0, 6), cmap=None, norm=None, add_colorbar=True, title=None, ax=None, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of ADP/KDP vs ZDR.

References

Ryzhkov, A., P. Zhang, and J. Hu, 2025. Suggested Modifications for the S-Band Polarimetric Radar Rainfall Estimation Algorithm. J. Hydrometeor., 26, 1053-1062. https://doi.org/10.1175/JHM-D-25-0014.1.

disdrodb.summary.routines.plot_A_KDP(df, a, kdp, log_a=True, log_kdp=False, a_lim=(0.001, 10), kdp_lim=None, pol='', ax=None, cmap=None, norm=None, add_colorbar=True, add_fit=True, title=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of k(H/V) vs KDP.

disdrodb.summary.routines.plot_A_KDP_ZDR(df, a, kdp, zdr, y_lim=(0, 0.05), zdr_lim=(0, 3), cmap=None, norm=None, add_colorbar=True, pol='', title=None, ax=None, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of k/KDP vs ZDR.

References

Ryzhkov, A., P. Zhang, and J. Hu, 2025. Suggested Modifications for the S-Band Polarimetric Radar Rainfall Estimation Algorithm. J. Hydrometeor., 26, 1053-1062. https://doi.org/10.1175/JHM-D-25-0014.1.

disdrodb.summary.routines.plot_A_R(df, a, r, cmap=None, norm=None, add_colorbar=True, add_fit=True, pol='', title=None, ax=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of A vs R.

disdrodb.summary.routines.plot_A_Z(df, a, z, cmap=None, norm=None, add_colorbar=True, add_fit=True, pol='', title=None, ax=None, a_lim=(0.0001, 10), z_lim=(0, 70), figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of A vs Z.

disdrodb.summary.routines.plot_KDP_Z(df, kdp, z, z_lim=(0, 70), log_kdp=False, kdp_lim=None, cmap=None, norm=None, add_colorbar=True, add_fit=True, pol='', title=None, ax=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of KDP vs Z.

disdrodb.summary.routines.plot_KDP_Z_ZDR(df, kdp, z, zdr, y_lim=None, zdr_lim=(0, 5), z_linear=True, cmap=None, norm=None, add_colorbar=True, title=None, ax=None, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of (KDP/Z) vs ZDR with log-scale y-axis (no fit).

disdrodb.summary.routines.plot_KED_R(df, log_r=True, log_ked=False, add_fit=True, cmap=None, norm=None, add_colorbar=True, title=None, ax=None, legend_fontsize=14, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of KED vs R.

disdrodb.summary.routines.plot_KEF_R(df, log_r=True, log_kef=True, add_fit=True, cmap=None, norm=None, add_colorbar=True, title=None, ax=None, legend_fontsize=14, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of KEF vs R.

disdrodb.summary.routines.plot_KEF_Z(df, z='Z', log_kef=True, add_fit=True, pol='', cmap=None, norm=None, add_colorbar=True, title=None, ax=None, legend_fontsize=14, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of KEF vs Z.

disdrodb.summary.routines.plot_R_KDP(df, kdp, r, kdp_lim=None, r_lim=None, cmap=None, norm=None, add_colorbar=True, log_scale=False, add_fit=True, title=None, ax=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of KDP vs R.

disdrodb.summary.routines.plot_R_Z(df, z, r, cmap=None, norm=None, add_colorbar=True, add_fit=True, pol='', title=None, ax=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of Z vs R.

disdrodb.summary.routines.plot_TKE_Z(df, z='Z', log_tke=True, add_fit=True, cmap=None, norm=None, add_colorbar=True, title=None, ax=None, legend_fontsize=14, figsize=(8, 8), dpi=300)[source][source]#

Create a 2D histogram of TKE vs Z.

disdrodb.summary.routines.plot_ZDR_Z(df, z, zdr, zdr_lim=(0, 2.5), z_lim=(0, 70), cmap=None, norm=None, add_colorbar=True, add_fit=True, pol='', title=None, ax=None, figsize=(8, 8), dpi=300, legend_fontsize=14)[source][source]#

Create a 2D histogram of Zdr vs Z.

disdrodb.summary.routines.plot_dmax_relationships(df, diameter_bin_edges, dmax='Dmax', diameter_max=10, norm_vmax=None, dpi=300)[source][source]#

Plot 2x2 subplots showing relationships between Dmax and precipitation parameters.

Parameters:
  • df (DataFrame) – Input dataframe containing the precipitation data

  • dmax (str, default "Dmax") – Column name for maximum diameter

  • vmax (float, default 10) – Maximum value for Dmax axis limits

  • dpi (int, default 300) – Resolution for the figure

disdrodb.summary.routines.plot_dsd_density(df_nd, diameter_bin_edges, figsize=(8, 8), dpi=300)[source][source]#

Plot N(D) ~ D density.

disdrodb.summary.routines.plot_dsd_params_density(df, log_dm=False, lwc=True, log_normalize=False, figsize=(10, 10), dpi=300)[source][source]#

Generate a figure with various DSD relationships.

All histograms are computed first, then normalized, and finally plotted together.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing DSD parameters (Dm, Nt, Nw, LWC/W, R, sigma_m, M2, M3, M4, M6)

  • log_dm (bool, optional) – If True, use linear scale for Dm axes. If False, use log scale. Default is True.

  • lwc (bool, optional) – If True, use Liquid Water Content (W). If False, use Rain Rate (R). Default is True.

  • figsize (tuple, optional) – Figure size (width, height) in inches. Default is (18, 18).

Returns:

  • fig (matplotlib.figure.Figure) – The figure object containing all subplots

  • axes (numpy.ndarray) – Array of all subplot axes

disdrodb.summary.routines.plot_dsd_params_relationships(df, add_nt=False, dpi=300)[source][source]#

Create a figure illustrating the relationships between DSD parameters.

disdrodb.summary.routines.plot_dsd_with_dense_lines(drop_number_concentration, r, figsize=(8, 8), dpi=300)[source][source]#

Plot N(D) ~ D using dense lines.

disdrodb.summary.routines.plot_kinetic_energy_relationships(df)[source][source]#

Create a 2x2 multipanel figure showing kinetic energy relationships.

disdrodb.summary.routines.plot_normalized_dsd_density(df_nd, x='D/D50', figsize=(8, 8), dpi=300)[source][source]#

Plot normalized DSD N(D)/Nw ~ D/D50 (or D/Dm) density.

disdrodb.summary.routines.plot_radar_relationships(df, band)[source][source]#

Create 3x3 multipanel figure with radar relationships.

disdrodb.summary.routines.predict_from_inverse_powerlaw(x, a, b)[source][source]#

Predict values from the inverse power-law relationship.

Given parameters a and b from x = a * y**b, this function computes y given x.

Parameters:
  • x (array_like) – Values of x (independent variable in the original power law).

  • a (float) – Power-law coefficient of the inverse power-law model.

  • b (float) – Power-law exponent of the inverse power-law model.

Returns:

y – Predicted dependent variable values.

Return type:

ndarray

disdrodb.summary.routines.predict_from_powerlaw(x, a, b)[source][source]#

Predict values from a power-law relationship y = a * x**b.

Parameters:
  • x (array_like) – Independent variable values.

  • a (float) – Power-law coefficient.

  • b (float) – Power-law exponent.

Returns:

y – Predicted dependent variable values.

Return type:

ndarray

Notes

This function does not check for invalid (negative or zero) x values. Ensure that x is compatible with the model before calling.

disdrodb.summary.routines.prepare_latex_table_dsd_summary(df)[source][source]#

Prepare a DataFrame with DSD statistics for LaTeX table output.

disdrodb.summary.routines.prepare_latex_table_events_summary(df)[source][source]#

Prepare a DataFrame with events statistics for LaTeX table output.

disdrodb.summary.routines.prepare_summary_dataset(ds, velocity_method='theoretical_velocity', source='drop_number')[source][source]#

Prepare the L2E or L2M dataset to be converted to a dataframe.

disdrodb.summary.routines.save_table_to_pdf(df: DataFrame, filepath: str, index=True, caption=None, fontsize: str = '\\tiny', orientation: str = 'landscape') None[source][source]#

Render a pandas DataFrame as a well-formatted table in PDF via LaTeX.

Parameters:
  • df (pd.DataFrame) – The data to render.

  • filepath (str) – File path where write the final PDF (e.g. ‘<…>/table.pdf’).

  • caption (str, optional) – LaTeX caption for the table environment.

  • fontsize (str, optional) – LaTeX font-size command to wrap the table (e.g. ‘\small’). The default is ‘\tiny’.

  • orientation ({'portrait', 'landscape'}) – Page orientation. If ‘landscape’, the table will be laid out horizontally. The default is ‘landscape’.

Module contents#

DISDRODB Summary Module.