Light Sources

The Solcore module light_source is designed to deal easily with different light sources. It has direct support for:

  • Gaussian emission, typical of lasers and light emitting diodes.
  • Black-body radiation, characteristic of halogen lamps defined by a temperature, but also used very often to simulate the spectrum of the Sun, very close to a black body source at 5800 K.
  • Standard solar spectra: the extraterrestial spectrum AM0 and the two terrestial ones, AM1.5D and AM1.5G as defined by the ASTM G173 - 03(2008) standard.
  • Irradiance models, using location, time and atmospheric parameters to calculate a synthetic solar spectrum. Solcore includes two models: SPECTRAL2, fully implemented in Python, and an interface to SMARTS binaries (which need to be installed separately), which greatly simplifies its use in batch mode.
  • User-defined irradiances, provided externally from a database or any other source, allowing for maximum flexibility.

The syntax in all cases is simple and intuitive considering the type of source that needs to be created. In the case of the irradiance models, which often have a large number of inputs, Solcore defines a set of default values, so only those that are different need to be provided. These default values can be obtained by:

import solcore.light_source as ls


Once created, specific parameters of the light sources can be easily modified without the need for creating the source from scratch. That is particularly useful for the irradiance models, where we might be interested in getting the spectrum as a function of a certain parameter (e.g. the hour of the day, or the humidity) without changing the others. For example, smarts.spectrum(HOUR=11) and smarts.spectrum(HOUR=17) will provide the spectrum of the SMART light source (assuming it has already been created) calculated at 11h and at 17h, respectively; all additional parameters have the default values. This method has been used to model experimental solar irradiances measured by different spectroradiometers based on the local atmospheric conditions.

A final, very convenient feature of the LightSource class is the ability to request the spectrum in a range of different units. The default is power density per nanometer, but other common units are power density per eV or photon flux per nanometer, among others. While these unit conversions are straightforward, it is often an initial source of errors due to missing constants or incompatible magnitudes.

The light_source module has been described in the context of the solar spectrum, but it can be applied broadly where there is spectral data involved, such as the fitting of photoluminescence, electroluminescence or Raman spectra.

Description of functions and modules


Function providing the standard reference spectra: AM0, AM1.5g and AM1.5d.

Returns:A 2D array with 4 columns representing the wavelength, AM0, AM1.5g and AM1.5d standard spectra.
class solcore.light_source.light_source.LightSource(source_type, x=None, **kwargs)[source]

This is a common interface to access all types of light sources supported by Solcore: standard solar spectra (AM0, AM1.5g, and AM1.5d), blackbody radiation, laser light or spectra created from atmospheric data using SPECTRAL2 or SMARTS. Aditionally, it can also use experimentally measured spectra.

type_of_source = ['laser', 'black body', 'standard', 'SMARTS', 'SPECTRAL2', 'custom']
output_units = ['power_density_per_eV', 'power_density_per_nm', 'power_density_per_J', 'power_density_per_m', 'power_density_per_hz', 'photon_flux_per_eV', 'photon_flux_per_nm', 'photon_flux_per_J', 'photon_flux_per_hz', 'photon_flux_per_m']
spectrum(x=None, **kwargs)[source]

Returns the spectrum of the light in the requested units. Internally, the spectrum is always managed in power density per nanometers, but the output can be provided in other compatible units, such as power density per Hertz or photon flux per eV.

  • x – (Default=None) If “x” is provided, it must be an array with the spectral range in which to calculate the spectrum. Depending on the “units” defined when creating the light source, this array must be in nm, m, eV, J or hz.
  • kwargs – Options to update the light source. It can be “units”, “concentration” or any of the options specific to the chosen type of light source.

Array with the spectrum in the requested units

solcore.light_source.smarts.calculate_spectrum_smarts(smarts_file_contents=None, filename='smarts295', target_directory=None)[source]
  • smarts_file_contents
  • filename
  • target_directory

Provides a dictionary with most of the parameters (values of the CARDS) needed by SMARTS to calculate
a solar spectrum. It can be used as a template to customize for user defined conditions.

Returns a default state object for use with calculate_spectrum. Parameters returned are for: - Coventry (52.39°N,-1.56°E) - for 12:30 pm on the 30th of June 2011 (that’s in the future!) (not any more..) - rural atmospheric conditions - 30% humidity - 1.42mm precipitated water - 1030 hPa atmospheric pressure - 0.34mm of Ozone - turbidity of 15%.

solcore.light_source.spectral2.calculate_spectrum_spectral2(stateObject=None, suppress_nan=True, power_density_in_nm=False)[source]

Calculates a solar spectrum using the SPECTRAL2 irradiance model developed by the NRL:

  • stateObject
  • suppress_nan