.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/solar_spectrum.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_auto_examples_solar_spectrum.py: Solar Spectrum ============== Plot the true Solar spectrum vs a black body approximation. .. GENERATED FROM PYTHON SOURCE LINES 7-19 .. code-block:: Python import kete import numpy as np import matplotlib.pyplot as plt # Sample wavelengths from 200nm to 5um at 1000 points wavelengths = np.linspace(200, 5000, 1000) # In units of au dist_from_sun = 1.0 .. GENERATED FROM PYTHON SOURCE LINES 20-24 Reference Solar Spectrum ------------------------ This is the 2000 ASTM Standard Extraterrestrial Spectrum Reference E-490-00: https://www.nrel.gov/grid/solar-resource/spectra-astm-e490.html .. GENERATED FROM PYTHON SOURCE LINES 24-28 .. code-block:: Python solar_flux = [kete.flux.solar_flux(dist_from_sun, w) for w in wavelengths] .. GENERATED FROM PYTHON SOURCE LINES 29-32 Black Body ---------- Compute black body for the sun from base principles. .. GENERATED FROM PYTHON SOURCE LINES 32-52 .. code-block:: Python sun_r_au = kete.constants.SUN_RADIUS_M / kete.constants.AU_M # black body radiation is Janskys / steradian, it needs to be integrated over the # steradian. black_body_flux = np.array( [ kete.flux.black_body_flux( temp=kete.constants.SUN_TEMP, wavelength=w, ) for w in wavelengths ] ) # Black body approximation of the solar flux at the radius of where the object is, # this treats the sun as a flat disk facing the object. This is an approximation # which breaks down when the object gets within a few solar radii. sun_black_body_flux = np.pi * black_body_flux * (sun_r_au / dist_from_sun) ** 2 .. GENERATED FROM PYTHON SOURCE LINES 53-55 Plot ---- .. GENERATED FROM PYTHON SOURCE LINES 55-61 .. code-block:: Python plt.title("Solar Spectrum vs Black Body") plt.plot(wavelengths, solar_flux, label="Solar Flux") plt.plot(wavelengths, sun_black_body_flux, label="Black Body") plt.ylabel("Flux (Jy)") plt.xlabel("Wavelength (nm)") plt.legend() .. image-sg:: /auto_examples/images/sphx_glr_solar_spectrum_001.png :alt: Solar Spectrum vs Black Body :srcset: /auto_examples/images/sphx_glr_solar_spectrum_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.108 seconds) .. _sphx_glr_download_auto_examples_solar_spectrum.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: solar_spectrum.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: solar_spectrum.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: solar_spectrum.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_