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

ls.get_default_spectral2_object()
ls.get_default_smarts_object()

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

solcore.light_source.light_source.REGISTERED_CONVERTERS = {'photon_flux_per_ev': <function photon_flux_per_ev>, 'photon_flux_per_hz': <function photon_flux_per_hz>, 'photon_flux_per_joule': <function photon_flux_per_joule>, 'photon_flux_per_m': <function photon_flux_per_m>, 'photon_flux_per_nm': <function photon_flux_per_nm>, 'power_density_per_ev': <function power_density_per_ev>, 'power_density_per_hz': <function power_density_per_hz>, 'power_density_per_joule': <function power_density_per_joule>, 'power_density_per_m': <function power_density_per_m>, 'power_density_per_nm': <function power_density_per_nm>}

Registered spectrum conversion functions.

solcore.light_source.light_source.reference_spectra()[source]

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, output_units='power_density_per_nm', concentration=1, **kwargs)[source]

Common interface to access all types of light sources supported by Solcore.

It includes standard solar spectra (AM0, AM1.5g, and AM1.5d), blackbody radiation, laser light or spectra created from atmospheric data using SPECTRAL2 or SMARTS. Additionally, it can also use experimentally measured spectra.

type_of_source = ['laser', 'black body', 'standard', 'SMARTS', 'SPECTRAL2', 'custom']
spectrum(x=None, output_units=None, concentration=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.

Parameters: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. :param output_units: Units of the output spectrum :param concentration: Concentration of the light source :param 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. :return: Array with the spectrum in the requested units

solcore.light_source.light_source.register_conversion_function(fun: Callable)[source]

Registers a view method that will trigger an event.

solcore.light_source.light_source.power_density_per_nm(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in power density per nanometer.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the wavelengths (in nm)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.photon_flux_per_nm(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in photon flux per nanometer.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the wavelengths (in nm)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.power_density_per_m(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in power density per meter.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the wavelengths (in m)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.photon_flux_per_m(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in photon flux per meter.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the wavelengths (in m)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.power_density_per_ev(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in power density per eV.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the energies (in eV)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.photon_flux_per_ev(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in photon flux per eV.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the energies (in eV)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.power_density_per_joule(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in power density per Joule.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the energies (in J)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.photon_flux_per_joule(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in photon flux per Joule.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the energies (in J)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.power_density_per_hz(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in power density per hertz.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the frequencies (in hz)
Returns:

The spectrum in the chosen units.

solcore.light_source.light_source.photon_flux_per_hz(spectrum: Callable[[numpy.ndarray], numpy.ndarray], x: numpy.ndarray)[source]

Function that returns the spectrum in photon flux per hertz.

The input spectrum is assumed to be in power density per nanometer.

Parameters:
  • spectrum – The spectrum to interpolate.
  • x – Array with the frequencies (in hz)
Returns:

The spectrum in the chosen units.

exception solcore.light_source.smarts.SmartsSolverError[source]
solcore.light_source.smarts.skipper(fname)[source]
solcore.light_source.smarts.calculate_spectrum_smarts(smarts_file_contents=None, filename='smarts295', target_directory=None)[source]
Parameters:
  • smarts_file_contents
  • filename
  • target_directory
Returns:

solcore.light_source.smarts.build_smarts_file(**kwargs)[source]
solcore.light_source.smarts.get_default_smarts_object()[source]
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:
solcore.light_source.spectral2.equation_of_time(day_angle)[source]
solcore.light_source.spectral2.loadUtilitySpectra()[source]
solcore.light_source.spectral2.get_default_spectral2_object()[source]

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:

http://rredc.nrel.gov/solar/models/spectral/SPCTRAL2/

Parameters:
  • stateObject
  • suppress_nan
Returns: