Example #1
0
def single_rayleigh_scattering_spd_plot(
        CO2_concentration=STANDARD_CO2_CONCENTRATION,
        temperature=STANDARD_AIR_TEMPERATURE,
        pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
        latitude=DEFAULT_LATITUDE,
        altitude=DEFAULT_ALTITUDE,
        cmfs='CIE 1931 2 Degree Standard Observer',
        **kwargs):
    """
    Plots a single *Rayleigh* scattering spectral power distribution.

    Parameters
    ----------
    CO2_concentration : numeric, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric, optional
        Latitude of the site in degrees.
    altitude : numeric, optional
        Altitude of the site in meters.
    cmfs : unicode, optional
        Standard observer colour matching functions.

    Other Parameters
    ----------------
    \**kwargs : dict, optional
        {:func:`boundaries`, :func:`canvas`, :func:`decorate`,
        :func:`display`},
        Please refer to the documentation of the previously listed definitions.
    out_of_gamut_clipping : bool, optional
        {:func:`single_spd_plot`},
        Whether to clip out of gamut colours otherwise, the colours will be
        offset by the absolute minimal colour leading to a rendering on
        gray background, less saturated and smoother. [1]_

    Returns
    -------
    Figure
        Current figure or None.

    Examples
    --------
    >>> single_rayleigh_scattering_spd_plot()  # doctest: +SKIP
    """

    title = 'Rayleigh Scattering'

    cmfs = get_cmfs(cmfs)

    settings = {'title': title, 'y_label': 'Optical Depth'}
    settings.update(kwargs)

    spd = rayleigh_scattering_spd(cmfs.shape, CO2_concentration, temperature,
                                  pressure, latitude, altitude)

    return single_spd_plot(spd, **settings)
Example #2
0
    def test_rayleigh_scattering_spd(self):
        """
        Tests :func:`colour.phenomenons.rayleigh.rayleigh_scattering_spd`
        definition.
        """

        np.testing.assert_almost_equal(rayleigh_scattering_spd().values,
                                       RAYLEIGH_SCATTERING_SPD_DATA,
                                       decimal=7)
Example #3
0
def single_rayleigh_scattering_spd_plot(
        CO2_concentration=STANDARD_CO2_CONCENTRATION,
        temperature=STANDARD_AIR_TEMPERATURE,
        pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
        latitude=DEFAULT_LATITUDE,
        altitude=DEFAULT_ALTITUDE,
        cmfs='CIE 1931 2 Degree Standard Observer',
        **kwargs):
    """
    Plots a single rayleigh scattering spectral power distribution.

    Parameters
    ----------
    CO2_concentration : numeric, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric, optional
        Latitude of the site in degrees.
    altitude : numeric, optional
        Altitude of the site in meters.
    cmfs : unicode, optional
        Standard observer colour matching functions.
    \**kwargs : dict, optional
        Keywords arguments.

    Returns
    -------
    bool
        Definition success.

    Examples
    --------
    >>> single_rayleigh_scattering_spd_plot()  # doctest: +SKIP
    True
    """

    title = 'Rayleigh Scattering'

    cmfs = get_cmfs(cmfs)

    settings = {
        'title': title,
        'y_label': 'Optical Depth'}
    settings.update(kwargs)

    spd = rayleigh_scattering_spd(cmfs.shape,
                                  CO2_concentration,
                                  temperature,
                                  pressure,
                                  latitude,
                                  altitude)

    return single_spd_plot(spd, **settings)
Example #4
0
    def test_rayleigh_scattering_spd(self):
        """
        Tests :func:`colour.phenomenons.rayleigh.rayleigh_scattering_spd`
        definition.
        """

        np.testing.assert_almost_equal(
            rayleigh_scattering_spd().values,
            RAYLEIGH_SCATTERING_SPD_DATA,
            decimal=7)
Example #5
0
def single_rayleigh_scattering_spd_plot(
        CO2_concentration=STANDARD_CO2_CONCENTRATION,
        temperature=STANDARD_AIR_TEMPERATURE,
        pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
        latitude=DEFAULT_LATITUDE,
        altitude=DEFAULT_ALTITUDE,
        cmfs='CIE 1931 2 Degree Standard Observer',
        **kwargs):
    """
    Plots a single rayleigh scattering spectral power distribution.

    Parameters
    ----------
    CO2_concentration : numeric, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric, optional
        Latitude of the site in degrees.
    altitude : numeric, optional
        Altitude of the site in meters.
    cmfs : unicode, optional
        Standard observer colour matching functions.
    \**kwargs : dict, optional
        Keywords arguments.

    Returns
    -------
    Figure
        Current figure or None.

    Examples
    --------
    >>> single_rayleigh_scattering_spd_plot()  # doctest: +SKIP
    """

    title = 'Rayleigh Scattering'

    cmfs = get_cmfs(cmfs)

    settings = {
        'title': title,
        'y_label': 'Optical Depth'}
    settings.update(kwargs)

    spd = rayleigh_scattering_spd(cmfs.shape,
                                  CO2_concentration,
                                  temperature,
                                  pressure,
                                  latitude,
                                  altitude)

    return single_spd_plot(spd, **settings)
Example #6
0
def the_blue_sky_plot(cmfs='CIE 1931 2 Degree Standard Observer', **kwargs):
    """
    Plots the blue sky.

    Parameters
    ----------
    cmfs : unicode, optional
        Standard observer colour matching functions.
    \**kwargs : dict, optional
        Keywords arguments.

    Returns
    -------
    bool
        Definition success.

    Examples
    --------
    >>> the_blue_sky_plot()  # doctest: +SKIP
    True
    """

    canvas(**kwargs)

    cmfs, name = get_cmfs(cmfs), cmfs

    ASTM_G_173_spd = ASTM_G_173_ETR.clone()
    rayleigh_spd = rayleigh_scattering_spd()
    ASTM_G_173_spd.align(rayleigh_spd.shape)

    spd = rayleigh_spd * ASTM_G_173_spd

    matplotlib.pyplot.subplots_adjust(hspace=0.4)

    matplotlib.pyplot.figure(1)
    matplotlib.pyplot.subplot(211)

    settings = {
        'title': 'The Blue Sky - Synthetic Spectral Power Distribution',
        'y_label': u'W / m-2 / nm-1',
        'standalone': False
    }
    settings.update(kwargs)

    single_spd_plot(spd, name, **settings)

    matplotlib.pyplot.subplot(212)

    settings = {
        'title':
        'The Blue Sky - Colour',
        'x_label': ('The sky is blue because molecules in the atmosphere '
                    'scatter shorter wavelengths more than longer ones.\n'
                    'The synthetic spectral power distribution is computed as '
                    'follows: '
                    '(ASTM G-173 ETR * Standard Air Rayleigh Scattering).'),
        'y_label':
        '',
        'aspect':
        None,
        'standalone':
        False
    }

    blue_sky_color = XYZ_to_sRGB(spectral_to_XYZ(spd))
    single_colour_plot(ColourParameter('', normalise(blue_sky_color)),
                       **settings)

    settings = {'standalone': True}
    settings.update(kwargs)

    boundaries(**settings)
    decorate(**settings)

    return display(**settings)
Example #7
0
def the_blue_sky_plot(
        cmfs='CIE 1931 2 Degree Standard Observer',
        **kwargs):
    """
    Plots the blue sky.

    Parameters
    ----------
    cmfs : unicode, optional
        Standard observer colour matching functions.
    \*\*kwargs : \*\*
        Keywords arguments.

    Returns
    -------
    bool
        Definition success.

    Examples
    --------
    >>> the_blue_sky_plot()  # doctest: +SKIP
    True
    """

    canvas(**kwargs)

    cmfs, name = get_cmfs(cmfs), cmfs

    ASTM_G_173_spd = ASTM_G_173_ETR.clone()
    rayleigh_spd = rayleigh_scattering_spd()
    ASTM_G_173_spd.align(rayleigh_spd.shape)

    spd = rayleigh_spd * ASTM_G_173_spd

    matplotlib.pyplot.subplots_adjust(hspace=0.4)

    matplotlib.pyplot.figure(1)
    matplotlib.pyplot.subplot(211)

    settings = {
        'title': 'The Blue Sky - Synthetic Spectral Power Distribution',
        'y_label': u'W / m-2 / nm-1',
        'standalone': False}
    settings.update(kwargs)

    single_spd_plot(spd, name, **settings)

    matplotlib.pyplot.subplot(212)

    settings = {
        'title': 'The Blue Sky - Colour',
        'x_label': ('The sky is blue because molecules in the atmosphere '
                    'scatter shorter wavelengths more than longer ones.\n'
                    'The synthetic spectral power distribution is computed as '
                    'follows: '
                    '(ASTM G-173 ETR * Standard Air Rayleigh Scattering).'),
        'y_label': '',
        'aspect': None,
        'standalone': False}

    blue_sky_color = XYZ_to_sRGB(spectral_to_XYZ(spd))
    single_colour_plot(colour_parameter('', normalise(blue_sky_color)),
                       **settings)

    settings = {'standalone': True}
    settings.update(kwargs)

    boundaries(**settings)
    decorate(**settings)
    return display(**settings)
from colour.phenomenons import rayleigh_scattering_spd
from colour.plotting import *  # noqa
from colour.utilities.verbose import message_box

message_box('Optical Phenomenons Plots')

message_box(('Plotting a single "Rayleigh Scattering" spectral power '
             'distribution.'))
single_rayleigh_scattering_spd_plot()

print('\n')

message_box(('Comparing multiple "Rayleigh Scattering" spectral power '
             'distributions with different CO_2 concentrations.'))
name_template = 'Rayleigh Scattering - CO2: {0} ppm'
rayleigh_spds = []
for ppm in (0, 50, 300):
    rayleigh_spd = rayleigh_scattering_spd(CO2_concentration=ppm)
    rayleigh_spd.name = name_template.format(ppm)
    rayleigh_spds.append(rayleigh_spd)
multi_spd_plot(rayleigh_spds,
               title=('Rayleigh Optical Depth - '
                      'Comparing "C02" Concentration Influence'),
               y_label='Optical Depth',
               legend_location='upper right')

print('\n')

message_box('Plotting "The blue Sky".')
the_blue_sky_plot()
Example #9
0
"""

import colour
from colour.phenomenons import (rayleigh_optical_depth,
                                rayleigh_scattering_spd,
                                scattering_cross_section)
from colour.utilities.verbose import message_box

message_box('Rayleigh Optical Depth Computations')

wavelength = 555 * 10e-8
message_box(('Computing the scattering cross section per molecule at given '
             'wavelength in cm:\n'
             '\n\tWavelength: {0} cm'.format(wavelength)))
print(scattering_cross_section(wavelength))

print('\n')

message_box(('Computing the "Rayleigh Optical depth" as function of '
             'wavelength in cm:\n'
             '\n\tWavelength: {0} cm'.format(wavelength)))
print(rayleigh_optical_depth(wavelength))

print('\n')

message_box(('Creating a "Rayleigh" spectral power distribution with default '
             'spectral shape:\n'
             '\n\t{0}'.format(colour.DEFAULT_SPECTRAL_SHAPE)))
spd = rayleigh_scattering_spd()
print(spd[555])
from colour.utilities.verbose import message_box

message_box('Optical Phenomenons Plots')

colour_plotting_defaults()

message_box(('Plotting a single "Rayleigh" scattering spectral power '
             'distribution.'))
single_rayleigh_scattering_spd_plot()

print('\n')

message_box(('Comparing multiple "Rayleigh" scattering spectral power '
             'distributions with different CO_2 concentrations.'))
name_template = 'Rayleigh Scattering - CO2: {0} ppm'
rayleigh_spds = []
for ppm in (0, 50, 300):
    rayleigh_spd = rayleigh_scattering_spd(CO2_concentration=ppm)
    rayleigh_spd.name = name_template.format(ppm)
    rayleigh_spds.append(rayleigh_spd)
multi_spd_plot(rayleigh_spds,
               title=('Rayleigh Optical Depth - '
                      'Comparing "C02" Concentration Influence'),
               y_label='Optical Depth',
               legend_location='upper right')

print('\n')

message_box('Plotting "The Blue Sky".')
the_blue_sky_plot()
Example #11
0
import colour
from colour.phenomenons import (
    rayleigh_optical_depth,
    rayleigh_scattering_spd,
    scattering_cross_section)
from colour.utilities.verbose import message_box

message_box('Rayleigh Optical Depth Computations')

wavelength = 555 * 10e-8
message_box(('Computing the scattering cross section per molecule at given '
             'wavelength in cm:\n'
             '\n\tWavelength: {0} cm'.format(wavelength)))
print(scattering_cross_section(wavelength))

print('\n')

message_box(('Computing the "Rayleigh Optical depth" as function of '
             'wavelength in cm:\n'
             '\n\tWavelength: {0} cm'.format(wavelength)))
print(rayleigh_optical_depth(wavelength))

print('\n')

message_box(('Creating a "Rayleigh" spectral power distribution with default '
             'spectral shape:\n'
             '\n\t{0}'.format(colour.DEFAULT_SPECTRAL_SHAPE)))
spd = rayleigh_scattering_spd()
print(spd[555])