SpectrumFile#
- class ansys.speos.core.input_files.spectrum_file.SpectrumFile(wavelengths=_DEFAULT_WAVELENGTHS, values=_DEFAULT_VALUES, description=_DEFAULT_DESCRIPTION, *, percent=True)#
Bases:
ansys.speos.core.input_files._base.SpeosTextFileFormatSpeos
*.spectrumfile, holding a sampled spectral distribution.The file is the text (
v1) flavor of the format: a header line, a description, the number of samples, then onewavelengthline per sample. Files are read and written locally, no Speos server is needed.value - Parameters:
- wavelengths
Sequence[float],optional Wavelengths of the samples, in nm. By default, 11 wavelengths from 360 nm to 830 nm in 47 nm steps.
- values
Sequence[float],optional Relative spectral values of the samples, in percent (0 to 100). By default, the values of the default 5200 K blackbody spectrum, normalized to 100 at its sampled maximum.
- description
str,optional Free text written on the second line of the file. By default,
"Blackbody at 5200.0 K".- percentbool,
optional Whether values are percentages limited to 0 to 100. By default,
True. Set it toFalsefor spectra in other units, such as the absorption and excitance spectra of a fluorescent dye in mm-1, whose values only need to be finite.
- wavelengths
- Parameters:
Notes
Called without arguments, the constructor creates the default 5200 K blackbody spectrum. Pass
wavelengthsandvaluestogether to describe another spectrum.SpectrumFile.percentis a validation setting: it is not written to the file, and a loaded*.spectrumfile has it set toTrue.Construction and setters validate numeric data before storing it. List getters return copies; assign an edited list back to change the model. Empty columns permit staged construction, while
SpectrumFile.validate()andsave()require complete matching columns. To resize a populated spectrum, clearSpectrumFile.values, replaceSpectrumFile.wavelengths, then assign the new values.Examples
>>> from ansys.speos.core.input_files.spectrum_file import SpectrumFile >>> SpectrumFile(wavelengths=[400.0, 700.0], values=[100.0, 50.0]).save("led.spectrum")
Overview#
Build a spectrum file from a sampled spectrum feature. |
Check the spectrum against the constraints of the |
Whether values are percentages limited to 0 to 100. |
|
Wavelengths in nm, returned as a copy. |
|
Spectral values, returned as a copy. |
|
Single-line description. |
Usual file extension of the format. |
|
First line of the file. Empty when the format has no header line. |
|
Version-agnostic start of |
Import detail#
from ansys.speos.core.input_files.spectrum_file import SpectrumFile
Property detail#
- property SpectrumFile.percent: bool#
Whether values are percentages limited to 0 to 100.
- Parameters:
- valuebool
Trueto limit values to 0 to 100,Falseto only require finite values.
- Returns:
- bool
Trueif values are percentages.
- Raises:
ValueErrorIf set to
Truewhile a stored value is outside 0 to 100.
- property SpectrumFile.values: List[float]#
Spectral values, returned as a copy.
- Parameters:
- values
Sequence[float] New spectral values of the samples. In percent (0 to 100) when
SpectrumFile.percentisTrue, otherwise any finite values.
- values
- Returns:
List[float]Spectral values.
Attribute detail#
- SpectrumFile.EXTENSION = '.spectrum'#
Usual file extension of the format.
- SpectrumFile.HEADER = 'OPTIS - Spectrum file v1'#
First line of the file. Empty when the format has no header line.
- SpectrumFile.HEADER_PREFIX = 'OPTIS - Spectrum'#
Version-agnostic start of
HEADER, used to validate a file being read.
Method detail#
- SpectrumFile.validate()#
Check the spectrum against the constraints of the
*.spectrumformat.- Raises:
ValueErrorIf the sample lists are empty, do not have the same length, hold more than 32767 samples, or if
SpectrumFile.percentisTrueand a value is outside the 0 to 100 percent range.
- classmethod SpectrumFile.from_sampled(spectrum, description='')#
Build a spectrum file from a sampled spectrum feature.
The feature is a
ansys.speos.core.spectrum.Spectrumobject.- Parameters:
- spectrum
ansys.speos.core.spectrum.Spectrum Spectrum feature configured with
Spectrum.set_sampled().- description
str,optional Free text written on the second line of the file. By default,
"", which uses the name of the spectrum feature.
- spectrum
- Returns:
ansys.speos.core.input_files.spectrum_file.SpectrumFileSpectrum file model.
- Raises:
ValueErrorIf
spectrumis not of sampled type.