.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/stix.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_stix.py: ====================================== Solar Orbiter/STIX Visibility Imaging ====================================== Imports .. GENERATED FROM PYTHON SOURCE LINES 9-21 .. code-block:: Python import pickle import matplotlib.pyplot as plt import numpy as np import astropy.units as apu from xrayvision.clean import vis_clean from xrayvision.imaging import vis_psf_map, vis_to_map from xrayvision.mem import mem, resistant_mean .. GENERATED FROM PYTHON SOURCE LINES 22-26 Create images from STIX visibility data. The STIX data has already been prepared and stored in python pickle format the variables can be simply restored. .. GENERATED FROM PYTHON SOURCE LINES 26-34 .. code-block:: Python with open("./stix_vis.pkl", "rb") as file: stix_data = pickle.load(file) time_range = stix_data["time_range"] energy_range = stix_data["energy_range"] stix_vis = stix_data["stix_visibilities"] .. GENERATED FROM PYTHON SOURCE LINES 35-36 Lets have a look at the point spread function (PSF) or dirty beam .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: Python psf_map = vis_psf_map(stix_vis, shape=(129, 129) * apu.pixel, pixel_size=2 * apu.arcsec / apu.pix, scheme="uniform") psf_map.plot() .. image-sg:: /generated/gallery/images/sphx_glr_stix_001.png :alt: 2026-07-15 16:06:03 :srcset: /generated/gallery/images/sphx_glr_stix_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase] /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:1015: SunpyMetadataWarning: Missing metadata for observation time, setting observation time to current time. Set the 'DATE-OBS' FITS keyword to prevent this warning. warn_metadata("Missing metadata for observation time, " /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:671: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer. For frame 'heliographic_stonyhurst' the following metadata is missing: dsun_obs,hglt_obs,hgln_obs For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs obs_coord = self.observer_coordinate .. GENERATED FROM PYTHON SOURCE LINES 41-42 Back projection .. GENERATED FROM PYTHON SOURCE LINES 42-46 .. code-block:: Python backproj_map = vis_to_map(stix_vis, shape=(129, 129) * apu.pixel, pixel_size=2 * apu.arcsec / apu.pix, scheme="uniform") backproj_map.plot() .. image-sg:: /generated/gallery/images/sphx_glr_stix_002.png :alt: 2026-07-15 16:06:04 :srcset: /generated/gallery/images/sphx_glr_stix_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase] /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:1015: SunpyMetadataWarning: Missing metadata for observation time, setting observation time to current time. Set the 'DATE-OBS' FITS keyword to prevent this warning. warn_metadata("Missing metadata for observation time, " /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:671: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer. For frame 'heliographic_stonyhurst' the following metadata is missing: dsun_obs,hglt_obs,hgln_obs For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs obs_coord = self.observer_coordinate .. GENERATED FROM PYTHON SOURCE LINES 47-48 Clean .. GENERATED FROM PYTHON SOURCE LINES 48-58 .. code-block:: Python clean_map, model_map, resid_map = vis_clean( stix_vis, shape=[129, 129] * apu.pixel, pixel_size=[2, 2] * apu.arcsec / apu.pix, clean_beam_width=20 * apu.arcsec, niter=100, ) clean_map.plot() .. image-sg:: /generated/gallery/images/sphx_glr_stix_003.png :alt: 2026-07-15 16:06:06 :srcset: /generated/gallery/images/sphx_glr_stix_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase] /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:1015: SunpyMetadataWarning: Missing metadata for observation time, setting observation time to current time. Set the 'DATE-OBS' FITS keyword to prevent this warning. warn_metadata("Missing metadata for observation time, " /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:671: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer. For frame 'heliographic_stonyhurst' the following metadata is missing: dsun_obs,hglt_obs,hgln_obs For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs obs_coord = self.observer_coordinate .. GENERATED FROM PYTHON SOURCE LINES 59-60 MEM .. GENERATED FROM PYTHON SOURCE LINES 60-70 .. code-block:: Python # Compute percent_lambda snr_value, _ = resistant_mean((np.abs(stix_vis.visibilities) / stix_vis.amplitude_uncertainty).flatten(), 3) percent_lambda = 2 / (snr_value**2 + 90) * apu.percent mem_map = mem( stix_vis, shape=[129, 129] * apu.pixel, pixel_size=[2, 2] * apu.arcsec / apu.pix, percent_lambda=percent_lambda ) mem_map.plot() .. image-sg:: /generated/gallery/images/sphx_glr_stix_004.png :alt: 2026-07-15 16:06:26 :srcset: /generated/gallery/images/sphx_glr_stix_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase] /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:1015: SunpyMetadataWarning: Missing metadata for observation time, setting observation time to current time. Set the 'DATE-OBS' FITS keyword to prevent this warning. warn_metadata("Missing metadata for observation time, " /home/docs/checkouts/readthedocs.org/user_builds/xrayvision/conda/v0.3.0/lib/python3.12/site-packages/sunpy/map/mapbase.py:671: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer. For frame 'heliographic_stonyhurst' the following metadata is missing: dsun_obs,hglt_obs,hgln_obs For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs obs_coord = self.observer_coordinate .. GENERATED FROM PYTHON SOURCE LINES 71-72 Comparison .. GENERATED FROM PYTHON SOURCE LINES 72-87 .. code-block:: Python fig = plt.figure(figsize=(10, 10)) fig.add_subplot(221, projection=psf_map) fig.add_subplot(222, projection=backproj_map) fig.add_subplot(223, projection=clean_map) fig.add_subplot(224, projection=mem_map) axs = fig.get_axes() psf_map.plot(axes=axs[0]) axs[0].set_title("PSF") backproj_map.plot(axes=axs[1]) axs[1].set_title("Back Projection") clean_map.plot(axes=axs[2]) axs[2].set_title("Clean") mem_map.plot(axes=axs[3]) axs[3].set_title("MEM") plt.show() .. image-sg:: /generated/gallery/images/sphx_glr_stix_005.png :alt: PSF, Back Projection, Clean, MEM :srcset: /generated/gallery/images/sphx_glr_stix_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 22.889 seconds) .. _sphx_glr_download_generated_gallery_stix.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: stix.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: stix.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: stix.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_