Figure 3 numerical-data exporter and standalone reproduction
============================================================

Contents
--------
- export_fig3_artists.py: call at end of your existing scientific analysis script.
- reproduce_fig3.py: independent NumPy/Matplotlib plotter for every exported source.
- fig3_1ES0229_with_export.py: original pasted 1ES 0229+200 script with the export call appended (optional).

To export one source
--------------------
1. Put export_fig3_artists.py in the SAME directory as your existing scientific script.
2. Add this at the very end, after the figure has been drawn:

   from export_fig3_artists import export_source_figure
   export_source_figure(
       fig, ax, source_name2, z,
       flux_points_fermi, flux_points_hess,
       output_root=Path.home() / 'Desktop' / 'fig3_DL5_data'
   )

3. Run the original script with its working Gammapy environment and source-specific inputs.
4. Repeat with each source's OWN original analysis script. The exporter creates
   separate directories: ~/Desktop/fig3_DL5_data/<source>/
   It does not automatically run the fits for other sources.

To reproduce ALL exported source plots
-------------------------------------
Put reproduce_fig3.py anywhere and run:

   python reproduce_fig3.py --data ~/Desktop/fig3_DL5_data

Output is written to ~/Desktop/fig3_reproduced/ by default.
Requires only numpy and matplotlib.

Data format and scope
---------------------
- All plotted curves, butterfly polygons, error-bar segments, and markers are
  exported to two-column plain TXT files with full precision.
- fermi_flux_points.txt and hess_flux_points.txt also provide physical values,
  asymmetric errors, and upper-limit flags where available. Units are in headers.
- plot_metadata.json records plotting style, limits, source and redshift.
- Reproduction is a numerical replot, NOT a re-fit. No original FITS/Gammapy
  files are needed for the standalone plotter.
- The script recreates one SED plot per source. The publication's exact
  Figure 3a/3b source grouping and layout can be assembled after all sources
  have been exported and compared with the manuscript.
- The source script's HEGS and historical H.E.S.S. plotting sections are
  commented out, so those are NOT included as plotted data.
