File comparison

TRSFX.compare.corr_heatmap(df, output=None, title=None, vmin=0.2, vmax=1.0, cmap='RdYlBu_r', figsize=(10, 8), mask=True, **kwargs)

Plot and save a correlation matrix as a heatmap.

Parameters:
  • df (DataFrame) – Square correlation matrix with matching row/column labels

  • output (str | Path | None) – Output file path. Defaults to ./correlation_heatmap.png

  • title (str | None) – Plot title

  • vmin (float) – Minimum value for color scale

  • vmax (float) – Maximum value for color scale

  • cmap (str) – Matplotlib/seaborn colormap name

  • figsize (Tuple[int, int]) – Figure dimensions as (width, height) in inches

  • mask (bool) – If True, mask values outside [vmin, vmax] range

  • kwargs – Additional arguments passed to sns.heatmap

Returns:

Matplotlib figure object

Return type:

Figure

TRSFX.compare.map_correlation(mtz_files, labels=None, time_step=None, time_ranges=False, f=None, phi=None, d_min=None)

Compute pairwise map-map correlation matrix from MTZ files.

Parameters:
  • mtz_files (Sequence[str | Path]) – Sequence of paths to MTZ files containing map coefficients

  • labels (Optional[Sequence[str]]) – Labels for each file. If None, uses filenames as labels

  • f (str | None) – F column name. If None, auto-detected from first file

  • phi (str | None) – Phase column name. If None, auto-detected from first file

  • d_min (float | None) – Resolution cutoff in Angstroms. If None, uses all reflections

Returns:

Square correlation matrix with labels as row/column indices

Return type:

DataFrame

TRSFX.compare.trace(pattern, output_csv, start_idx=0, end_idx=None, log_space=False, plot=False)

Globs HDF5 files matching a pattern, computes frame-to-frame correlations for each, and streams results to a CSV.

Parameters:
  • pattern (str) – Glob pattern (e.g., “data/.h5” or “/path/to/*/*.h5”)

  • output_csv (Union[str, Path]) – Path for output CSV file

  • start_idx (int) – Start frame index for correlation calculation

  • end_idx (int) – End frame index for correlation calculation

  • log_space (bool) – If True, compute correlation on log10(data)

  • plot (bool) – If True, generate plots (saved next to -o output as .png)

Return type:

None