.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/multi-instrument.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_multi-instrument.py: Modeling Intensities from Multiple Instruments ============================================== This example shows how to compute the synthetic intensities from three different observatories: AIA, XRT, and EUVI. It also demonstrates how to define a custom instrument class. .. GENERATED FROM PYTHON SOURCE LINES 11-33 .. code-block:: Python import astropy.units as u import matplotlib.pyplot as plt import numpy as np from astropy.coordinates import SkyCoord from astropy.visualization import quantity_support from sunpy.coordinates import ( get_earth, get_horizons_coord, HeliographicStonyhurst, Helioprojective, ) import synthesizAR from synthesizAR.instruments.hinode import InstrumentHinodeXRT from synthesizAR.instruments.sdo import InstrumentSDOAIA from synthesizAR.interfaces import MartensInterface from synthesizAR.models import semi_circular_arcade # sphinx_gallery_thumbnail_number = -1 .. GENERATED FROM PYTHON SOURCE LINES 34-36 First, we'll set up the geometry for the active region that we are modeling. We'll use a simple arcade of semi-circular loops all with a length of 150 Mm. .. GENERATED FROM PYTHON SOURCE LINES 36-41 .. code-block:: Python obstime = '2021-10-28T15:00:00' loc = SkyCoord(HeliographicStonyhurst(lon=0*u.deg,lat=-30*u.deg, radius=1*u.R_sun, obstime=obstime)) arcade = semi_circular_arcade(150*u.Mm, 10*u.deg, 50, loc, gamma=90*u.deg, n_points=5000) skeleton = synthesizAR.Skeleton([synthesizAR.Strand(f'{i}', c) for i,c in enumerate(arcade)]) .. GENERATED FROM PYTHON SOURCE LINES 42-47 We'll select a few different observer locations for SDO and STERO-A and use `sunpy.coordinates.get_horizons_coord` to get these locations from the `JPL Horizons service `_. We'll approximate the location of *Hinode* as Earth since its location is not available through JPL Horizons. .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python sdo = get_horizons_coord('SDO', time=obstime) stereo_a = get_horizons_coord('STEREO-A', time=obstime) hinode = get_earth(time=obstime) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Obtained JPL HORIZONS location for Solar Dynamics Observatory (spacecraft) (-136395) [sunpy.coordinates.ephemeris] INFO: Obtained JPL HORIZONS location for STEREO-A (spacecraft) (-234) [sunpy.coordinates.ephemeris] .. GENERATED FROM PYTHON SOURCE LINES 52-54 We can quickly peek at what the structure of our active region looks like from the viewpoints of SDO and STEREO-A. .. GENERATED FROM PYTHON SOURCE LINES 54-57 .. code-block:: Python skeleton.peek(observer=sdo, axes_limits=[(-500,500)*u.arcsec, (-1000,0)*u.arcsec]) skeleton.peek(observer=stereo_a, axes_limits=[(0,1000)*u.arcsec, (-1000,0)*u.arcsec]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_001.png :alt: multi instrument :srcset: /generated/gallery/images/sphx_glr_multi-instrument_001.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_002.png :alt: multi instrument :srcset: /generated/gallery/images/sphx_glr_multi-instrument_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 58-61 Next, we want to calculate some sort of thermodynamic model for each one of these strands. We'll use the `~synthesizAR.models.MartensScalingLaws` model with the heating rate chosen from a uniform distribution. .. GENERATED FROM PYTHON SOURCE LINES 61-71 .. code-block:: Python class MartensRandom(MartensInterface): def get_heating_constant(self, loop): h_a = 1e-5 * u.Unit('erg cm-3 s-1') h_b = 100*h_a return h_a + np.random.random_sample()*(h_b - h_a) martens = MartensRandom(None) skeleton.load_loop_simulations(martens) .. GENERATED FROM PYTHON SOURCE LINES 72-73 We can visualize the electron temperature and density profiles for each loop. .. GENERATED FROM PYTHON SOURCE LINES 73-83 .. code-block:: Python with quantity_support(): plt.figure(figsize=(11, 5)) ax1 = plt.subplot(121) for l in skeleton.strands: plt.plot(l.field_aligned_coordinate_center.to('Mm'), l.electron_temperature[0].to('MK'), color='k') plt.subplot(122) for l in skeleton.strands: plt.plot(l.field_aligned_coordinate_center.to('Mm'), l.density[0], color='k') plt.yscale('log') .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_003.png :alt: multi instrument :srcset: /generated/gallery/images/sphx_glr_multi-instrument_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 84-89 Let's compute the emission that would be observed from these loops with this particular model for the temperature and density. First, we'll compute the emission as observed in all channels of AIA. We'll select a field of view by specifying the center of the field of view as well as the width and height. .. GENERATED FROM PYTHON SOURCE LINES 89-96 .. code-block:: Python center = SkyCoord(Tx=0*u.arcsec, Ty=-550*u.arcsec, frame=Helioprojective(observer=sdo, obstime=sdo.obstime)) fov_width = (250,250)*u.arcsec aia = InstrumentSDOAIA([0]*u.s, sdo, fov_center=center, fov_width=fov_width) aia_images = aia.observe(skeleton) for k in aia_images: aia_images[k][0].peek() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_004.png :alt: AIA $94 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_004.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_005.png :alt: AIA $131 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_005.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_006.png :alt: AIA $171 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_006.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_007.png :alt: AIA $193 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_007.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_008.png :alt: AIA $211 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_008.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_009.png :alt: AIA $335 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_009.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Apparent body location accounts for 495.70 seconds of light travel time [sunpy.coordinates.ephemeris] .. GENERATED FROM PYTHON SOURCE LINES 97-99 We can carry out this same procedure for *Hinode* XRT for the same field of view. We'll look just at the Be-thin and Al-poly channels. .. GENERATED FROM PYTHON SOURCE LINES 99-105 .. code-block:: Python xrt = InstrumentHinodeXRT([0]*u.s, hinode, ['Be-thin', 'Al-poly'], fov_center=center, fov_width=fov_width) xrt_images = xrt.observe(skeleton) for k in xrt_images: xrt_images[k][0].peek() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_010.png :alt: XRT Be thin-Open 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_010.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_011.png :alt: XRT Al poly-Open 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_011.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Apparent body location accounts for 495.76 seconds of light travel time [sunpy.coordinates.ephemeris] .. GENERATED FROM PYTHON SOURCE LINES 106-112 Lastly, we want to compute the emission as observed by EUVI on STEREO-A. Currently, `synthesizAR.instruments` does not contain an EUVI instrument class. However, we can easily define our own as follows. Note that here, for simplicity, we are using the 171 Å temperature response function for AIA as a proxy for the temperature response of the 171 Å channel on EUVI. .. GENERATED FROM PYTHON SOURCE LINES 112-138 .. code-block:: Python class InstrumentSTEREOEUVI(InstrumentSDOAIA): name = 'STEREO_EUVI' def __init__(self, *args, **kwargs): super().__init__( *args, plate_scale=u.Quantity([1.58777404, 1.58777404], 'arcsec / pixel'), cadence=1*u.h, **kwargs, ) @property def observatory(self): return 'STEREO A' @property def telescope(self): return 'STEREO' @property def detector(self): return 'EUVI' def get_instrument_name(self, *args): return 'SECCHI' .. GENERATED FROM PYTHON SOURCE LINES 139-142 We can then use our custom instrument class in the exact same way as our predefined classes to model the emission from EUVI. Note that we'll only do this for the 171 Å channel. .. GENERATED FROM PYTHON SOURCE LINES 142-145 .. code-block:: Python euvi = InstrumentSTEREOEUVI([0]*u.s, stereo_a, fov_center=center, fov_width=fov_width) euvi_images = euvi.observe(skeleton, channels=euvi.channels[2:3]) euvi_images['171'][0].peek() .. image-sg:: /generated/gallery/images/sphx_glr_multi-instrument_012.png :alt: EUVI-A $171 \; \mathrm{\mathring{A}}$ 2021-10-28 15:00:00 :srcset: /generated/gallery/images/sphx_glr_multi-instrument_012.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO: Apparent body location accounts for 478.19 seconds of light travel time [sunpy.coordinates.ephemeris] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 14.865 seconds) .. _sphx_glr_download_generated_gallery_multi-instrument.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: multi-instrument.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: multi-instrument.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: multi-instrument.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_