.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/flarelist_demo.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_gallery_flarelist_demo.py: =============== Flare List Demo =============== How to search, combine and explore STIX L3 flare list products. This example uses :class:`~stixpy.net.client.STIXClient` (a Fido client) to find three months of L3 flare list files, loads each one as a :class:`~stixpy.product.sources.flarelist.FlareList` product, concatenates them into a single catalogue, plots the peak count time series, then filters for X-class flares close to the Earth-facing solar limb and plots their locations. Imports .. GENERATED FROM PYTHON SOURCE LINES 16-25 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from sunpy.net import attrs as a from stixpy.net.client import STIXClient from stixpy.product import Product .. GENERATED FROM PYTHON SOURCE LINES 26-31 Search three months of flare list data. The flare list test products are currently hosted on a separate URL from the rest of the STIX archive, so we instantiate :class:`~stixpy.net.client.STIXClient` with that ``source``. .. GENERATED FROM PYTHON SOURCE LINES 31-41 .. code-block:: Python client = STIXClient(source="https://pub099.cs.technik.fhnw.ch/testing/p311_comp_test") results = client.search( a.Time("2024-09-01T01:00:00", "2024-11-30T23:59"), a.Instrument.stix, a.stix.DataType.flarelist, ) print(results) .. rst-class:: sphx-glr-script-out .. code-block:: none Start Time End Time Instrument Level DataType DataProduct Ver Request ID ----------------------- ----------------------- ---------- ----- --------- ---------------- --- ---------- 2024-09-01T00:00:00.000 2024-10-01T00:47:10.000 STIX L3 FLARELIST flarelist-sdcloc V02 - 2024-10-01T00:00:00.000 2024-11-01T00:05:46.000 STIX L3 FLARELIST flarelist-sdcloc V02 - 2024-11-01T00:00:00.000 2024-11-30T23:48:24.000 STIX L3 FLARELIST flarelist-sdcloc V02 - .. GENERATED FROM PYTHON SOURCE LINES 42-43 Download the matching files and load each one as a FlareList product .. GENERATED FROM PYTHON SOURCE LINES 43-47 .. code-block:: Python paths = client.fetch(results) products = [Product(p) for p in paths] .. rst-class:: sphx-glr-script-out .. code-block:: none Files Downloaded: 0%| | 0/3 [00:00 Start: 2024-09-01 00:06:44 End: 2024-11-30 23:48:24 Center:2024-10-16 11:57:34 Duration:90.98726238425925 days or 2183.6942972222223 hours or 131021.65783333333 minutes or 7861299.47 seconds 7025 flares .. GENERATED FROM PYTHON SOURCE LINES 54-57 Inspect the available columns. ``flares.data`` is an :class:`~astropy.table.QTable` — each column carries its own unit and a short description loaded from the FITS header. .. GENERATED FROM PYTHON SOURCE LINES 57-66 .. code-block:: Python print(f"{'Column':<26s} {'Unit':<10s} Description") print("-" * 90) for name in flares.data.colnames: info = flares.data[name].info unit = "" if info.unit is None else str(info.unit) desc = info.description or "" print(f"{name:<26s} {unit:<10s} {desc}") .. rst-class:: sphx-glr-script-out .. code-block:: none Column Unit Description ------------------------------------------------------------------------------------------ flare_id unique flare id for flarelist SDCFlareListManager start_UTC start time of flare duration s duration of flare end_UTC end time of flare peak_UTC flare peak time att_in was attenuator in during flare bkg_baseline ct background baseline at 4-10 keV GOES_class GOES class of the GOES XRS data at time of flare - not derived from STIX data. Do not use when flare isn't visible to Earth goes_min_class_est min GOES class estimate derived from STIX data goes_max_class_est max GOES class estimate derived from STIX data goes_mean_class_est mean GOES class estimate derived from STIX data GOES_flux W / m2 GOES flux of the GOES XRS data at time of flare- not derived from STIX data. Do not use when the flare isn't visible to Earth goes_min_flux_est W / m2 min GOES flux estimate derived from STIX data goes_max_flux_est W / m2 max GOES flux estimate derived from STIX data goes_mean_flux_est W / m2 mean GOES flux estimate derived from STIX data lc_peak ct counts in 4s peak window from quicklook lightcurve lc_bgk_peak ct background counts in 4s peak windowfrom quicklook lightcurve energy_index energy band index soop_encoded_type campaign ID soop_id SOOP ID soop_type name of the SOOP campaign anc_ephemeris_path Path to the daily ancillary ephemeris file cpd_path Path to the CPD file used for flare location estimation _position_status Status of the flare position calculation _position_message Message describing the status of the flare position calculation location_icrs deg,deg,km Flare location in ICRS coordinates at 'location_time_UTC' solo_location_icrs deg,deg,km Solar Orbiter location in ICRS coordinates at 'location_time_UTC' sidelobes_ratio Ratio of sidelobes in the STIX image used to assess imaging quality rcr_at_peak max rcr level at flare location estimation time range, > 0 attenuator in place visible_from_earth Whether the flare location is visible from Earth (not occulted by the Sun) location_time_UTC time center used for flare location estimation in UTC location_duration s duration of the flare location estimation time range time_shift s Time(Sun to Earth) - Time(Sun to S/C) sun_disc_size arcsec Apparent photospheric solar radius location_hgs deg,deg,km Flare location in Heliographic Stonyhurst coordinates at 'location_time_UTC' solo_location_hgs deg,deg,km Solar Orbiter location in Heliographic Stonyhurst coordinates at 'location_time_UTC' .. GENERATED FROM PYTHON SOURCE LINES 67-68 Plot the timeline of peak counts per energy band across all three months .. GENERATED FROM PYTHON SOURCE LINES 68-73 .. code-block:: Python flares.plot_timeseries() plt.title(f"STIX peak counts — {len(flares)} flares (Sep–Nov 2024)") plt.tight_layout() .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_001.png :alt: STIX peak counts — 7025 flares (Sep–Nov 2024) :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 74-79 Filter the catalogue for M- and X-class flares close to the Earth-facing limb. Seen from Earth the solar limb maps to HGS longitude ±90°. We keep flares whose absolute HGS longitude exceeds 70° and whose GOES classification starts with ``"M"`` or ``"X"``. .. GENERATED FROM PYTHON SOURCE LINES 79-86 .. code-block:: Python lon = flares.flare_location_hgs.lon.deg is_strong = np.array([str(g).strip().upper().startswith(("M", "X")) for g in flares.goes_class]) near_limb = np.isfinite(lon) & (np.abs(lon) > 70) mask = is_strong & near_limb print(f"Selected {mask.sum()} M/X-class limb flares of {len(flares)} total.") .. rst-class:: sphx-glr-script-out .. code-block:: none Selected 185 M/X-class limb flares of 7025 total. .. GENERATED FROM PYTHON SOURCE LINES 87-90 A boolean mask can be applied directly to the FlareList; the result is a new FlareList with the matching rows. Plot the filtered locations from Earth's point of view. .. GENERATED FROM PYTHON SOURCE LINES 90-101 .. code-block:: Python filtered = flares[mask] print(filtered) filtered.plot_timeseries() plt.title(f"Peak counts — {len(filtered)} M/X-class limb flares") plt.tight_layout() filtered.plot_locations(observer="earth") plt.tight_layout() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_002.png :alt: Peak counts — 185 M/X-class limb flares :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_002.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_003.png :alt: Flare locations (n=185) — earth :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none FlareList Start: 2024-09-01 07:56:24 End: 2024-11-25 17:22:01 Center:2024-10-14 00:39:13 Duration:85.39278921296297 days or 2049.4269411111113 hours or 122965.61646666667 minutes or 7377936.988 seconds 185 flares .. GENERATED FROM PYTHON SOURCE LINES 102-105 Masking is non-destructive: ``flares`` is the full catalogue, so we can apply a completely independent filter to the same object — here, strong flares within ±30° of disk centre as seen from Earth. .. GENERATED FROM PYTHON SOURCE LINES 105-117 .. code-block:: Python near_disk = np.isfinite(lon) & (np.abs(lon) < 30) disk_flares = flares[is_strong & near_disk] print(f"Selected {len(disk_flares)} M/X-class on-disk flares of {len(flares)} total.") disk_flares.plot_timeseries() plt.title(f"Peak counts — {len(disk_flares)} M/X-class on-disk flares") plt.tight_layout() disk_flares.plot_locations(observer="earth") plt.tight_layout() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_004.png :alt: Peak counts — 77 M/X-class on-disk flares :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_004.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_005.png :alt: Flare locations (n=77) — earth :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none Selected 77 M/X-class on-disk flares of 7025 total. .. GENERATED FROM PYTHON SOURCE LINES 118-128 Plotting a catalogue that spans many weeks onto a single Earth-view Sun disc is misleading: solar rotation moves features ~13°/day, so a persistent active region smears into a horizontal streak across the disc and individual flares are no longer comparable in position. A rotation-fixed view solves this. ``observer="carrington"`` plots heliographic *Carrington* longitude (0–360°) vs latitude — the Carrington prime meridian rotates with the Sun, so an active region keeps the same longitude across many days. Each flare's own Solar Orbiter position is used as the HGC observer, matching how STIX actually saw the event. .. GENERATED FROM PYTHON SOURCE LINES 128-133 .. code-block:: Python flares.plot_locations(observer="carrington") plt.title(f"Carrington view — {len(flares)} flares (Sep–Nov 2024)") plt.tight_layout() plt.show() .. image-sg:: /generated/gallery/images/sphx_glr_flarelist_demo_006.png :alt: Carrington view — 7025 flares (Sep–Nov 2024) :srcset: /generated/gallery/images/sphx_glr_flarelist_demo_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (3 minutes 40.258 seconds) .. _sphx_glr_download_generated_gallery_flarelist_demo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: flarelist_demo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: flarelist_demo.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: flarelist_demo.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_