LED Illuminants
Direct LED emission, as opposed to Phosphor-Converted LED emission, can be described using Gaussian-based spectral irradiance distributions. Red LEDs typically use an AlInGaP semiconductor material, which has a red emission, and blue and green LEDs typically use an InGaN semiconductor. White light can be generated by a combination of at least three red, green, blue, and amber LEDs, or by using a blue or violet emitting LED chip, in combination with a phosphor mixture, which converts part of the emission to yellowish-green light. There is no phosphor-converted white LED model in this library, due to the complex spectral interactions of the phosphor materials.
Direct emission of InGaN and AlInGaP LEDs are implemented in this library is modeled in the LedArray illuminant class.
The spectral model used is described by Y. Ohno in Spectral design considerations for white LED color rendering,
in which the spectral distribution Si of an individual LED emitter is given by:
S(λ)=g(λ)+2g5(λ)3.
The irradiance of an individual LED is given by: ∫∞−∞S(λ)dλ=aλw,
LED Array Illuminant
In a LedArray, each LED in the array is described by an irradiance parameter Ee (in units of watts per square
meter), a center wavelength λc (in units of meters), and its full width at half maximum value
λ2 (also in units of meters).
The illuminant requires at least a single LED, with its parameters supplied in the constructor.
In this example we start with a single LED, with an irradiant power of 4 W/m2, a center wavelength of 450 nm (450E-9 m), and a width of 25 nm (25E-9 m):
    import init, {
        Domain,
        fetchCIE1931,
        integrate,
        LedArray,
        Observer,
    } from "https://www.gerardharbers.com/cie.js";
    await init();
    const ledArray = new LedArray(4.0, 450E-9, 30E-9);
And we can add more LEDs, with center wavelengths of 550 and 650 nm, and spectral widths of 40 and 20 nm, respectively, by using the add_led method:
    ledArray.addLed(6.0, 550E-9, 40E-9);
    ledArray.addLed(3.0, 650E-9, 20E-9);
Using its illuminate method, we get a spectral irradiance distribution over a wavelength range from 380 to 780 nm,
with a step size of 1 nm, and confirm that the total irradiance is the sum of the LED’s irradiances, we can integrate
the spectral distribution, and confirm that the total irradiant power is the sum of the individual irradiant LED powers,
being 13 W/m2:
    const domain = new Domain(380E-9, 780E-9, 401);
    const sid = ledArray.illuminate(domain);
    const totalIrradiance = integrate(sid,domain.step());
    console.log(`Expect 13W/m², got ${totalIrradiance.toFixed(2)}`);
    // Output: "Expect 13W/m², got 13.00"
To change the total target irradiance from an LED array, you can set its irradiance value. Here we set it to a value of 10W/m2, and confirm it worked, by integrating all the values of the spectral irradiance distribution:
    ledArray.irradiance = 10.0;
    const newIrradiance = integrate(ledArray.illuminate(domain), domain.step());
    console.log(`Expect 10W/m², got ${newIrradiance.toFixed(2)}`);
    // Output: Expect 10W/m², got 10.00
Total irradiance is different from illuminance.
You cannot directly set the target illuminance in the LedArray class,
but you can use its scale function after calculating its illuminance after defining an observer using this illuminant.
Here we set it to 10W/m2, and confirm it worked, by integrating all the values of the spectral irradiance distribution:
    ledArray.irradiance = 10.0;
    const newIrradiance = integrate(ledArray.illuminate(domain), domain.step());
    console.log(`Expect 10W/m², got ${newIrradiance.toFixed(2)}`);
    // Output: Expect 10W/m², got 10.00
Target White Point
The LEDArrayIlluminant class requires the exact irradiance values to construct or add LEDs.
If you don’t know the exact component irradiance values to target a particular white point, you can use the
LEDArrayIlluminantFactory function, which requires a color-matching function to use, a target illuminant,
and a flat array of center and wavelength pairs, without a power specification: