@@ -409,8 +409,8 @@ def sd_gaussian_normal(
409
409
>>> sd = sd_gaussian_normal(555, 25)
410
410
>>> sd.shape
411
411
SpectralShape(360.0, 780.0, 1.0)
412
- >>> sd[555] # doctest: +ELLIPSIS
413
- 1...
412
+ >>> sd[555] # doctest: +SKIP
413
+ 1.0
414
414
>>> sd[530] # doctest: +ELLIPSIS
415
415
0.6065306...
416
416
"""
@@ -465,16 +465,17 @@ def sd_gaussian_fwhm(
465
465
>>> sd = sd_gaussian_fwhm(555, 25)
466
466
>>> sd.shape
467
467
SpectralShape(360.0, 780.0, 1.0)
468
- >>> sd[555] # doctest: +ELLIPSIS
469
- 1...
470
- >>> sd[530] # doctest: +ELLIPSIS
471
- 0.3678794...
468
+ >>> sd[555] # doctest: +SKIP
469
+ 1.0
470
+ >>> sd[530]
471
+ 0.0625
472
472
"""
473
473
474
474
settings = {"name" : f"{ peak_wavelength } nm - { fwhm } FWHM - Gaussian" }
475
475
settings .update (kwargs )
476
476
477
- values = np .exp (- (((shape .wavelengths - peak_wavelength ) / fwhm ) ** 2 ))
477
+ mu , sigma = peak_wavelength , fwhm / (2 * np .sqrt (2 * np .log (2 )))
478
+ values = np .exp (- ((shape .wavelengths - mu ) ** 2 ) / (2 * sigma ** 2 ))
478
479
479
480
return SpectralDistribution (values , shape .wavelengths , ** settings )
480
481
@@ -505,7 +506,7 @@ def sd_gaussian(
505
506
peak at.
506
507
sigma_fwhm
507
508
Standard deviation :math:`sigma` of the gaussian spectral distribution
508
- or Full width at half maximum, i.e. width of the gaussian spectral
509
+ or full width at half maximum, i.e. width of the gaussian spectral
509
510
distribution measured between those points on the *y* axis which are
510
511
half the maximum amplitude.
511
512
shape
@@ -535,17 +536,17 @@ def sd_gaussian(
535
536
>>> sd = sd_gaussian(555, 25)
536
537
>>> sd.shape
537
538
SpectralShape(360.0, 780.0, 1.0)
538
- >>> sd[555] # doctest: +ELLIPSIS
539
- 1...
539
+ >>> sd[555] # doctest: +SKIP
540
+ 1.0
540
541
>>> sd[530] # doctest: +ELLIPSIS
541
542
0.6065306...
542
543
>>> sd = sd_gaussian(555, 25, method="FWHM")
543
544
>>> sd.shape
544
545
SpectralShape(360.0, 780.0, 1.0)
545
- >>> sd[555] # doctest: +ELLIPSIS
546
- 1...
547
- >>> sd[530] # doctest: +ELLIPSIS
548
- 0.3678794...
546
+ >>> sd[555] # doctest: +SKIP
547
+ 1.0
548
+ >>> sd[530]
549
+ 0.0625
549
550
"""
550
551
551
552
method = validate_method (method , tuple (SD_GAUSSIAN_METHODS ))
@@ -557,31 +558,29 @@ def sd_gaussian(
557
558
558
559
def sd_single_led_Ohno2005 (
559
560
peak_wavelength : float ,
560
- fwhm : float ,
561
+ half_spectral_width : float ,
561
562
shape : SpectralShape = SPECTRAL_SHAPE_DEFAULT ,
562
563
** kwargs : Any ,
563
564
) -> SpectralDistribution :
564
565
"""
565
566
Return a single *LED* spectral distribution of given spectral shape at
566
- given peak wavelength and full width at half maximum according to
567
- *Ohno (2005)* method.
567
+ given peak wavelength and half spectral width :math:` \\ Delta \\ lambda_{0.5}`
568
+ according to *Ohno (2005)* method.
568
569
569
570
Parameters
570
571
----------
571
572
peak_wavelength
572
573
Wavelength the single *LED* spectral distribution will peak at.
573
- fwhm
574
- Full width at half maximum, i.e. width of the underlying gaussian
575
- spectral distribution measured between those points on the *y* axis
576
- which are half the maximum amplitude.
574
+ half_spectral_width
575
+ Half spectral width :math:`\\ Delta\\ lambda_{0.5}`.
577
576
shape
578
577
Spectral shape used to create the spectral distribution.
579
578
580
579
Other Parameters
581
580
----------------
582
581
kwargs
583
- {:func :`colour.colorimetry.sd_gaussian_fwhm `},
584
- See the documentation of the previously listed definition .
582
+ {:class :`colour.SpectralDistribution `},
583
+ See the documentation of the previously listed class .
585
584
586
585
Returns
587
586
-------
@@ -606,14 +605,18 @@ def sd_single_led_Ohno2005(
606
605
1...
607
606
"""
608
607
609
- settings = {"name" : f"{ peak_wavelength } nm - { fwhm } FWHM LED - Ohno (2005)" }
608
+ settings = {
609
+ "name" : f"{ peak_wavelength } nm - { half_spectral_width } "
610
+ f"Half Spectral Width LED - Ohno (2005)"
611
+ }
610
612
settings .update (kwargs )
611
613
612
- sd = sd_gaussian_fwhm (peak_wavelength , fwhm , shape , ** kwargs )
613
-
614
- sd .values = (sd .values + 2 * sd .values ** 5 ) / 3
614
+ values = np .exp (
615
+ - (((shape .wavelengths - peak_wavelength ) / half_spectral_width ) ** 2 )
616
+ )
617
+ values = (values + 2 * values ** 5 ) / 3
615
618
616
- return sd
619
+ return SpectralDistribution ( values , shape . wavelengths , ** settings )
617
620
618
621
619
622
SD_SINGLE_LED_METHODS : CanonicalMapping = CanonicalMapping (
@@ -628,24 +631,18 @@ def sd_single_led_Ohno2005(
628
631
629
632
def sd_single_led (
630
633
peak_wavelength : float ,
631
- fwhm : float ,
632
634
shape : SpectralShape = SPECTRAL_SHAPE_DEFAULT ,
633
635
method : Literal ["Ohno 2005" ] | str = "Ohno 2005" ,
634
636
** kwargs : Any ,
635
637
) -> SpectralDistribution :
636
638
"""
637
639
Return a single *LED* spectral distribution of given spectral shape at
638
- given peak wavelength and full width at half maximum according to given
639
- method.
640
+ given peak wavelength according to given method.
640
641
641
642
Parameters
642
643
----------
643
644
peak_wavelength
644
645
Wavelength the single *LED* spectral distribution will peak at.
645
- fwhm
646
- Full width at half maximum, i.e. width of the underlying gaussian
647
- spectral distribution measured between those points on the *y*
648
- axis which are half the maximum amplitude.
649
646
shape
650
647
Spectral shape used to create the spectral distribution.
651
648
method
@@ -673,31 +670,30 @@ def sd_single_led(
673
670
674
671
Examples
675
672
--------
676
- >>> sd = sd_single_led(555, 25)
673
+ >>> sd = sd_single_led(555, half_spectral_width= 25)
677
674
>>> sd.shape
678
675
SpectralShape(360.0, 780.0, 1.0)
679
676
>>> sd[555] # doctest: +ELLIPSIS
680
677
1...
681
678
"""
682
679
683
680
method = validate_method (method , tuple (SD_SINGLE_LED_METHODS ))
681
+ kwargs ["shape" ] = shape
684
682
685
- return SD_SINGLE_LED_METHODS [method ](
686
- peak_wavelength , fwhm , shape , ** kwargs
687
- )
683
+ return SD_SINGLE_LED_METHODS [method ](peak_wavelength , ** kwargs )
688
684
689
685
690
686
def sd_multi_leds_Ohno2005 (
691
687
peak_wavelengths : ArrayLike ,
692
- fwhm : ArrayLike ,
688
+ half_spectral_widths : ArrayLike ,
693
689
peak_power_ratios : ArrayLike | None = None ,
694
690
shape : SpectralShape = SPECTRAL_SHAPE_DEFAULT ,
695
691
** kwargs : Any ,
696
692
) -> SpectralDistribution :
697
693
"""
698
694
Return a multi *LED* spectral distribution of given spectral shape at
699
- given peak wavelengths and full widths at half maximum according to
700
- *Ohno (2005)* method.
695
+ given peak wavelengths, half spectral widths :math:` \\ Delta \\ lambda_{0.5}`
696
+ and peak power ratios according to *Ohno (2005)* method.
701
697
702
698
The multi *LED* spectral distribution is generated using many single *LED*
703
699
spectral distributions generated with :func:`colour.sd_single_led_Ohno2005`
@@ -708,10 +704,8 @@ def sd_multi_leds_Ohno2005(
708
704
peak_wavelengths
709
705
Wavelengths the multi *LED* spectral distribution will peak at, i.e.
710
706
the peaks for each generated single *LED* spectral distributions.
711
- fwhm
712
- Full widths at half maximum, i.e. widths of the underlying gaussian
713
- spectral distributions measured between those points on the *y* axis
714
- which are half the maximum amplitude.
707
+ half_spectral_widths
708
+ Half spectral widths :math:`\\ Delta\\ lambda_{0.5}`.
715
709
peak_power_ratios
716
710
Peak power ratios for each generated single *LED* spectral
717
711
distributions.
@@ -752,7 +746,9 @@ def sd_multi_leds_Ohno2005(
752
746
"""
753
747
754
748
peak_wavelengths = as_float_array (peak_wavelengths )
755
- fwhm = np .resize (fwhm , peak_wavelengths .shape )
749
+ half_spectral_widths = np .resize (
750
+ half_spectral_widths , peak_wavelengths .shape
751
+ )
756
752
if peak_power_ratios is None :
757
753
peak_power_ratios = ones (peak_wavelengths .shape )
758
754
else :
@@ -762,11 +758,13 @@ def sd_multi_leds_Ohno2005(
762
758
763
759
sd = sd_zeros (shape )
764
760
765
- for peak_wavelength , fwhm_s , peak_power_ratio in zip (
766
- peak_wavelengths , fwhm , peak_power_ratios
761
+ for peak_wavelength , half_spectral_width , peak_power_ratio in zip (
762
+ peak_wavelengths , half_spectral_widths , peak_power_ratios
767
763
):
768
764
sd += (
769
- sd_single_led_Ohno2005 (peak_wavelength , fwhm_s , ** kwargs )
765
+ sd_single_led_Ohno2005 (
766
+ peak_wavelength , half_spectral_width , ** kwargs
767
+ )
770
768
* peak_power_ratio
771
769
)
772
770
@@ -777,7 +775,7 @@ def _format_array(a: NDArrayFloat) -> str:
777
775
778
776
sd .name = (
779
777
f"{ _format_array (peak_wavelengths )} nm - "
780
- f"{ _format_array (fwhm )} FWHM - "
778
+ f"{ _format_array (half_spectral_widths )} FWHM - "
781
779
f"{ _format_array (peak_power_ratios )} Peak Power Ratios - "
782
780
f"LED - Ohno (2005)"
783
781
)
@@ -797,29 +795,19 @@ def _format_array(a: NDArrayFloat) -> str:
797
795
798
796
def sd_multi_leds (
799
797
peak_wavelengths : ArrayLike ,
800
- fwhm : ArrayLike ,
801
- peak_power_ratios : ArrayLike | None = None ,
802
798
shape : SpectralShape = SPECTRAL_SHAPE_DEFAULT ,
803
799
method : Literal ["Ohno 2005" ] | str = "Ohno 2005" ,
804
800
** kwargs : Any ,
805
801
) -> SpectralDistribution :
806
802
"""
807
803
Return a multi *LED* spectral distribution of given spectral shape at
808
- given peak wavelengths and full widths at half maximum according to given
809
- method.
804
+ given peak wavelengths.
810
805
811
806
Parameters
812
807
----------
813
808
peak_wavelengths
814
809
Wavelengths the multi *LED* spectral distribution will peak at, i.e.
815
810
the peaks for each generated single *LED* spectral distributions.
816
- fwhm
817
- Full widths at half maximum, i.e. widths of the underlying gaussian
818
- spectral distributions measured between those points on the *y* axis
819
- which are half the maximum amplitude.
820
- peak_power_ratios
821
- Peak power ratios for each generated single *LED* spectral
822
- distributions.
823
811
shape
824
812
Spectral shape used to create the spectral distribution.
825
813
method
@@ -849,8 +837,8 @@ def sd_multi_leds(
849
837
--------
850
838
>>> sd = sd_multi_leds(
851
839
... np.array([457, 530, 615]),
852
- ... np.array([20, 30, 20]),
853
- ... np.array([0.731, 1.000, 1.660]),
840
+ ... half_spectral_widths= np.array([20, 30, 20]),
841
+ ... peak_power_ratios= np.array([0.731, 1.000, 1.660]),
854
842
... )
855
843
>>> sd.shape
856
844
SpectralShape(360.0, 780.0, 1.0)
@@ -859,7 +847,6 @@ def sd_multi_leds(
859
847
"""
860
848
861
849
method = validate_method (method , tuple (SD_MULTI_LEDS_METHODS ))
850
+ kwargs ["shape" ] = shape
862
851
863
- return SD_MULTI_LEDS_METHODS [method ](
864
- peak_wavelengths , fwhm , peak_power_ratios , shape , ** kwargs
865
- )
852
+ return SD_MULTI_LEDS_METHODS [method ](peak_wavelengths , ** kwargs )
0 commit comments