chaotic_pfc.analysis.sweep_plotting¶
sweep_plotting.py¶
Figures for Lyapunov classification maps produced by
chaotic_pfc.sweep.
Three plot types are provided:
plot_heatmap_continuous()— raw λ_max heatmap.plot_classification_interleaved()— publication-style discrete classification (periodic / chaotic / unbounded) with gaps between orders.plot_difficulty_map()— heatmap of the number of Lyapunov iterations actually used at each grid point. Only meaningful when the sweep was run withadaptive=True; shows where the spectrum converges quickly (light) vs. where it needs the full budget (dark) — a “difficulty map” of the parameter space.
All three accept a SweepResult (or its
individual arrays for the first two) and optionally a save_path.
They return the matplotlib.figure.Figure so callers can
compose or display them. The module also re-uses the RC params from
chaotic_pfc.plotting, so sweep figures look consistent with the
rest of the pipeline.
Functions
|
Map raw λ_max values to discrete classes. |
|
Generate the standard figures for a sweep and save them to |
|
Generate both cross-sweep chaotic figures and save to out_dir. |
|
Density map: how many window × filter configurations are chaotic. |
|
Binary union of chaotic regions across all window × filter sweeps. |
|
Publication-style layout with gaps between adjacent orders. |
|
Heatmap of Lyapunov iterations actually used at each grid point. |
|
Continuous λ_max heatmap over the (N_z, ω_c/π) plane. |
- chaotic_pfc.analysis.sweep_plotting.classify(h)[source]¶
Map raw λ_max values to discrete classes.
Returns an array with the same shape as
hwhere each entry is:-1— periodic orbit (λ_max ≤ 0)0— chaotic orbit (λ_max > 0)2— unbounded / divergent (NaN inh)
The unusual integer codes match the
matplotlib.colors.BoundaryNormbins used below.
- chaotic_pfc.analysis.sweep_plotting.plot_heatmap_continuous(result=None, *, h=None, orders=None, cutoffs=None, save_path=None, data_slots=3, gap_slots=1)[source]¶
Continuous λ_max heatmap over the (N_z, ω_c/π) plane.
Uses the same interleaved-column layout as
plot_classification_interleaved()for visual consistency across the full figure set.- Parameters:
result (SweepResult | None) –
SweepResultto plot. Mutually exclusive with the(h, orders, cutoffs)triple.h (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Lyapunov grid, shape
(len(orders), len(cutoffs)).orders (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Filter orders (x-axis), shape
(len(orders),).cutoffs (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Cutoff frequencies (y-axis), shape
(len(cutoffs),).save_path (str | Path | None) – If provided, the figure is saved to this path via
_save().data_slots (int) – Interleaved-column parameters.
gap_slots (int) – Interleaved-column parameters.
- Return type:
- chaotic_pfc.analysis.sweep_plotting.plot_classification_interleaved(result=None, *, h=None, orders=None, cutoffs=None, save_path=None, data_slots=3, gap_slots=1, lang='pt')[source]¶
Publication-style layout with gaps between adjacent orders.
Each order occupies
data_slotscolumns of coloured data followed bygap_slotsblank columns, producing the striped appearance used in Baptista et al.- Parameters:
result (SweepResult | None) –
SweepResultto plot. Mutually exclusive with the(h, orders, cutoffs)triple.h (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Lyapunov grid, shape
(len(orders), len(cutoffs)).orders (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Filter orders (x-axis), shape
(len(orders),).cutoffs (ndarray[tuple[Any, ...], dtype[_ScalarT]] | None) – Cutoff frequencies (y-axis), shape
(len(cutoffs),).save_path (str | Path | None) – If provided, the figure is saved to this path via
_save().data_slots (int) – Number of colormap quantisation levels for chaotic/periodic.
gap_slots (int) – Number of white/yellow slots interleaved between classes.
lang (str) – Language for axis labels (
"pt"or"en").
- Return type:
- chaotic_pfc.analysis.sweep_plotting.plot_difficulty_map(result, *, save_path=None, cmap='viridis', data_slots=3, gap_slots=1)[source]¶
Heatmap of Lyapunov iterations actually used at each grid point.
A “difficulty map” of the parameter space: low values mean the spectrum estimate converged quickly (strongly chaotic or strongly stable points), high values mean the running estimate stayed within the convergence tolerance only after many iterations (typically fronteira points where |λ_max| ≈ 0). Diverged grid points are shown in the same light grey used for unbounded orbits in the classification figures, so the two layers can be visually overlaid.
Uses the same interleaved-column layout as
plot_classification_interleaved().- Parameters:
result (SweepResult) – A
SweepResultproduced withadaptive=True. The function relies onresult.n_iters_usedand onresult.metadata['Nmap_min']/result.metadata['Nmap']for the colour-bar limits.save_path (str | Path | None) – Optional path to write the figure to.
cmap (str) – Sequential matplotlib colormap name.
viridisis perceptually uniform and prints well in greyscale.data_slots (int) – Interleaved-column parameters.
gap_slots (int) – Interleaved-column parameters.
- Raises:
ValueError – If
resultwas produced withadaptive=False(the heatmap would be a single colour, which is misleading rather than informative). The error message points the user to theadaptive=Trueflag inrun_sweep().- Return type:
- chaotic_pfc.analysis.sweep_plotting.plot_chaotic_map(sweep_dir='data/sweeps', *, save_path=None, color='red', data_slots=3, gap_slots=1, lang='pt')[source]¶
Binary union of chaotic regions across all window × filter sweeps.
At each grid point, if any sweep has λ_max > 0 the cell is coloured; otherwise it is white. The result is a single-colour silhouette of the full chaotic envelope. The interleaved-column layout matches
plot_classification_interleaved().- Parameters:
sweep_dir (str | Path) – Root directory with
<Window> (<ft>)/variables_lyapunov.npzsubdirectories.save_path (str | Path | None) – If provided, saved as both
.svgand.png(bare stem).color (str) – Matplotlib colour for chaotic cells (default: project red).
data_slots (int) – Interleaved-column parameters.
gap_slots (int) – Interleaved-column parameters.
lang (str) – Language for labels (
"pt"or"en").
- Return type:
See also
plot_chaotic_densityHow many configurations agree on chaos at each grid point.
plot_classification_interleavedDiscrete-classification counterpart for a single sweep.
- chaotic_pfc.analysis.sweep_plotting.plot_chaotic_density(sweep_dir='data/sweeps', *, save_path=None, cmap='viridis', data_slots=3, gap_slots=1, lang='pt')[source]¶
Density map: how many window × filter configurations are chaotic.
At each grid point counts the number of sweeps (across all windows, filter types, and Kaiser β values) for which λ_max > 0. Darker colours mean more configurations agree on chaos; white means none do. The interleaved-column layout matches
plot_classification_interleaved().- Parameters:
sweep_dir (str | Path) – Root directory with
<Window> (<ft>)/variables_lyapunov.npzsubdirectories.save_path (str | Path | None) – If provided, saved as both
.svgand.png(bare stem).cmap (str) – Sequential matplotlib colormap (default
"viridis").data_slots (int) – Interleaved-column parameters.
gap_slots (int) – Interleaved-column parameters.
lang (str) – Language for labels (
"pt"or"en").
- Return type:
See also
plot_chaotic_mapBinary union map (chaotic or not).
- chaotic_pfc.analysis.sweep_plotting.plot_chaotic_all(sweep_dir='data/sweeps', *, out_dir='figures/sweeps', close_figures=True, lang='pt')[source]¶
Generate both cross-sweep chaotic figures and save to out_dir.
Produces
CHAOTIC_MAP_FILENAMEandCHAOTIC_DENSITY_FILENAMEas both.svgand.png. Returns the list of written paths.- Parameters:
- Return type:
list[Path]
- chaotic_pfc.analysis.sweep_plotting.plot_all(result, out_dir, *, fmt='svg', close_figures=True, lang='pt')[source]¶
Generate the standard figures for a sweep and save them to
out_dir/<fig>.{fmt}. Returns the list of written paths.Always produces the two classification figures listed in
FIGURE_FILENAMES. Additionally producesfig3_difficulty_map.{fmt}(seeDIFFICULTY_FIGURE_FILENAME) whenresultwas generated withadaptive=True: the figure is silently skipped for non-adaptive sweeps because it would be monochromatic and therefore uninformative.The output directory is created if it does not exist.