def test_sd_rayleigh_scattering(self): """ Tests :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering` definition. """ np.testing.assert_almost_equal(sd_rayleigh_scattering().values, RAYLEIGH_SCATTERING_SD_DATA, decimal=7)
def test_sd_rayleigh_scattering(self): """ Tests :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering` definition. """ np.testing.assert_almost_equal( sd_rayleigh_scattering().values, RAYLEIGH_SCATTERING_SD_DATA, decimal=7)
plot_the_blue_sky) from colour.utilities import message_box message_box('Optical Phenomenons Plots') colour_style() message_box(('Plotting a single "Rayleigh" scattering spectral ' 'distribution.')) plot_single_sd_rayleigh_scattering() print('\n') message_box(('Comparing multiple "Rayleigh" scattering spectral ' 'distributions with different CO_2 concentrations.')) name_template = 'Rayleigh Scattering - CO2: {0} ppm' rayleigh_sds = [] for ppm in (0, 50, 300): rayleigh_sd = sd_rayleigh_scattering(CO2_concentration=ppm) rayleigh_sd.name = name_template.format(ppm) rayleigh_sds.append(rayleigh_sd) plot_multi_sds(rayleigh_sds, title=('Rayleigh Optical Depth - ' 'Comparing "C02" Concentration Influence'), y_label='Optical Depth') print('\n') message_box('Plotting "The Blue Sky".') plot_the_blue_sky()
def plot_single_sd_rayleigh_scattering( 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 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:`colour.plotting.artist`, :func:`colour.plotting.plot_single_sd`, :func:`colour.plotting.render`}, Please refer to the documentation of the previously listed definitions. out_of_gamut_clipping : bool, optional {:func:`colour.plotting.plot_single_sd`}, 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. Returns ------- tuple Current figure and axes. Examples -------- >>> plot_single_sd_rayleigh_scattering() # doctest: +SKIP .. image:: ../_static/Plotting_Plot_Single_SD_Rayleigh_Scattering.png :align: center :alt: plot_single_sd_rayleigh_scattering """ title = 'Rayleigh Scattering' cmfs = first_item(filter_cmfs(cmfs).values()) settings = {'title': title, 'y_label': 'Optical Depth'} settings.update(kwargs) sd = sd_rayleigh_scattering(cmfs.shape, CO2_concentration, temperature, pressure, latitude, altitude) return plot_single_sd(sd, **settings)
def plot_the_blue_sky(cmfs='CIE 1931 2 Degree Standard Observer', **kwargs): """ Plots the blue sky. Parameters ---------- cmfs : unicode, optional Standard observer colour matching functions. Other Parameters ---------------- \\**kwargs : dict, optional {:func:`colour.plotting.artist`, :func:`colour.plotting.plot_single_sd`, :func:`colour.plotting.plot_multi_colour_swatches`, :func:`colour.plotting.render`}, Please refer to the documentation of the previously listed definitions. Returns ------- tuple Current figure and axes. Examples -------- >>> plot_the_blue_sky() # doctest: +SKIP .. image:: ../_static/Plotting_Plot_The_Blue_Sky.png :align: center :alt: plot_the_blue_sky """ figure = plt.figure() figure.subplots_adjust(hspace=COLOUR_STYLE_CONSTANTS.geometry.short / 2) cmfs = first_item(filter_cmfs(cmfs).values()) ASTM_G_173_sd = ASTM_G_173_ETR.copy() rayleigh_sd = sd_rayleigh_scattering() ASTM_G_173_sd.align(rayleigh_sd.shape) sd = rayleigh_sd * ASTM_G_173_sd axes = figure.add_subplot(211) settings = { 'axes': axes, 'title': 'The Blue Sky - Synthetic Spectral Distribution', 'y_label': u'W / m-2 / nm-1', } settings.update(kwargs) settings['standalone'] = False plot_single_sd(sd, cmfs, **settings) axes = figure.add_subplot(212) x_label = ('The sky is blue because molecules in the atmosphere ' 'scatter shorter wavelengths more than longer ones.\n' 'The synthetic spectral distribution is computed as ' 'follows: ' '(ASTM G-173 ETR * Standard Air Rayleigh Scattering).') settings = { 'axes': axes, 'aspect': None, 'title': 'The Blue Sky - Colour', 'x_label': x_label, 'y_label': '', 'x_ticker': False, 'y_ticker': False, } settings.update(kwargs) settings['standalone'] = False blue_sky_color = XYZ_to_plotting_colourspace(sd_to_XYZ(sd)) figure, axes = plot_single_colour_swatch( ColourSwatch('', normalise_maximum(blue_sky_color)), **settings) settings = {'axes': axes, 'standalone': True} settings.update(kwargs) return render(**settings)
def plot_single_sd_rayleigh_scattering( CO2_concentration: FloatingOrArrayLike = CONSTANT_STANDARD_CO2_CONCENTRATION, temperature: FloatingOrArrayLike = CONSTANT_STANDARD_AIR_TEMPERATURE, pressure: FloatingOrArrayLike = CONSTANT_AVERAGE_PRESSURE_MEAN_SEA_LEVEL, latitude: FloatingOrArrayLike = CONSTANT_DEFAULT_LATITUDE, altitude: FloatingOrArrayLike = CONSTANT_DEFAULT_ALTITUDE, cmfs: Union[MultiSpectralDistributions, str, Sequence[Union[ MultiSpectralDistributions, str]], ] = "CIE 1931 2 Degree Standard Observer", **kwargs: Any, ) -> Tuple[plt.Figure, plt.Axes]: """ Plot a single *Rayleigh* scattering spectral distribution. Parameters ---------- CO2_concentration :math:`CO_2` concentration in parts per million (ppm). temperature Air temperature :math:`T[K]` in kelvin degrees. pressure Surface pressure :math:`P` of the measurement site. latitude Latitude of the site in degrees. altitude Altitude of the site in meters. cmfs Standard observer colour matching functions used for computing the spectrum domain and colours. ``cmfs`` can be of any type or form supported by the :func:`colour.plotting.filter_cmfs` definition. Other Parameters ---------------- kwargs {:func:`colour.plotting.artist`, :func:`colour.plotting.plot_single_sd`, :func:`colour.plotting.render`}, See the documentation of the previously listed definitions. Returns ------- :class:`tuple` Current figure and axes. Examples -------- >>> plot_single_sd_rayleigh_scattering() # doctest: +ELLIPSIS (<Figure size ... with 1 Axes>, <...AxesSubplot...>) .. image:: ../_static/Plotting_Plot_Single_SD_Rayleigh_Scattering.png :align: center :alt: plot_single_sd_rayleigh_scattering """ title = "Rayleigh Scattering" cmfs = cast(MultiSpectralDistributions, first_item(filter_cmfs(cmfs).values())) settings: Dict[str, Any] = {"title": title, "y_label": "Optical Depth"} settings.update(kwargs) sd = sd_rayleigh_scattering( cmfs.shape, CO2_concentration, temperature, pressure, latitude, altitude, ) return plot_single_sd(sd, **settings)
def plot_the_blue_sky( cmfs: Union[MultiSpectralDistributions, str, Sequence[Union[ MultiSpectralDistributions, str]], ] = "CIE 1931 2 Degree Standard Observer", **kwargs: Any, ) -> Tuple[plt.Figure, plt.Axes]: """ Plot the blue sky. Parameters ---------- cmfs Standard observer colour matching functions used for computing the spectrum domain and colours. ``cmfs`` can be of any type or form supported by the :func:`colour.plotting.filter_cmfs` definition. Other Parameters ---------------- kwargs {:func:`colour.plotting.artist`, :func:`colour.plotting.plot_single_sd`, :func:`colour.plotting.plot_multi_colour_swatches`, :func:`colour.plotting.render`}, See the documentation of the previously listed definitions. Returns ------- :class:`tuple` Current figure and axes. Examples -------- >>> plot_the_blue_sky() # doctest: +ELLIPSIS (<Figure size ... with 2 Axes>, <...AxesSubplot...>) .. image:: ../_static/Plotting_Plot_The_Blue_Sky.png :align: center :alt: plot_the_blue_sky """ figure = plt.figure() figure.subplots_adjust(hspace=CONSTANTS_COLOUR_STYLE.geometry.short / 2) cmfs = cast(MultiSpectralDistributions, first_item(filter_cmfs(cmfs).values())) ASTMG173_sd = cast(SpectralDistribution, SD_ASTMG173_ETR.copy()) rayleigh_sd = sd_rayleigh_scattering() ASTMG173_sd.align(rayleigh_sd.shape) sd = rayleigh_sd * ASTMG173_sd axes = figure.add_subplot(211) settings: Dict[str, Any] = { "axes": axes, "title": "The Blue Sky - Synthetic Spectral Distribution", "y_label": "W / m-2 / nm-1", } settings.update(kwargs) settings["standalone"] = False plot_single_sd(sd, cmfs, **settings) axes = figure.add_subplot(212) x_label = ("The sky is blue because molecules in the atmosphere " "scatter shorter wavelengths more than longer ones.\n" "The synthetic spectral distribution is computed as " "follows: " "(ASTM G-173 ETR * Standard Air Rayleigh Scattering).") settings = { "axes": axes, "aspect": None, "title": "The Blue Sky - Colour", "x_label": x_label, "y_label": "", "x_ticker": False, "y_ticker": False, } settings.update(kwargs) settings["standalone"] = False blue_sky_color = XYZ_to_plotting_colourspace( sd_to_XYZ(cast(SpectralDistribution, sd))) figure, axes = plot_single_colour_swatch( ColourSwatch(normalise_maximum(blue_sky_color)), **settings) settings = {"axes": axes, "standalone": True} settings.update(kwargs) return render(**settings)