Advanced

Data Import and Export

Material files, spectra, and result export

This chapter covers the four data-exchange tasks that matter in daily use: importing refractive-index files, importing incident-spectrum files, exporting results, and using the Data page to inspect the current model state. The focus is format, validation, and failure isolation.

Scope of this chapter

FunctionProblem it solvesMain entry point
Refractive-index importLoad measured or tabulated material data into the structure modelStructure page in File mode
Refractive-index databaseSelect materials from the built-in refractiveindex.info catalogDatabase button in File mode on the Structure page
Refractive-index interpolationControl how RI data are interpolated between data pointsInterpolation dropdown in File mode on the Structure page
Incident-spectrum importLoad a custom source spectrum into optics settingsOptics page with Incident Spectrum = File
Result exportExport calculation, sweep, or cleaned source dataResult pages and related action menus
Data pageInspect the current model as JSON-like structured dataSidebar Data

The Data page displays the internal data structure of the current model configuration and calculation results in JSON format.

Refractive-index files: format and import rules

The current parser accepts .nk and .txt. The file is read as a sequence of comment lines and data rows.

RuleCurrent implementation
Comment linesStart with #; imported into description
SeparatorsSpaces, tabs, or commas
Supported column counts2, 3, or 5
2-column formatwavelength n, with k automatically filled as 0
3-column formatwavelength n k
5-column formatwavelength n k nExt kExt, treated as birefringent data
Wavelength orderData are sorted into ascending wavelength order after parsing

The file does not need to be pre-sorted. The parser reorders all arrays together and preserves row alignment.

Hard validation rules for refractive-index files

CheckCurrent requirementCommon failure cause
Data presencewavelength / n / k must contain at least one valid rowComments only, no numeric rows
Numeric validityAll values must be finite; no NaN / InfinityText, invalid symbols, malformed columns
WavelengthMust be > 0 and strictly increasingDuplicated or descending wavelengths
nMust be > 0Placeholder zeros or invalid data cleanup
kMust be >= 0Negative extinction values
Birefringent extensionIf the file is recognized as birefringent, valid nExt / kExt must also existMissing or invalid extended columns

Refractive-index file format

# ITO measured data
# source: ellipsometry fit
400 1.95 0.12
500 1.90 0.10
600 1.87 0.09

For a birefringent file:

# Birefringent sample
400 1.70 0.00 1.75 0.00
500 1.69 0.00 1.74 0.00
600 1.68 0.00 1.73 0.00

Refractive-index database as a data source

In addition to local file upload, the File mode on the Structure page provides a Database button that opens the built-in refractiveindex.info material catalog. Database materials are stored in the same data structure as uploaded files, but they retain a database link that enables version tracking and updates.

For database material management, see Structure Configuration - Refractive-Index Database and Structure Configuration - RI Status Check.

Refractive-index interpolation methods

When a layer or surrounding medium loads refractive-index data via File mode, the software must interpolate between data points to obtain index values at arbitrary wavelengths. The Interpolation dropdown provides three methods:

MethodCharacteristicsRecommended use
LinearStraight-line segments between adjacent points; fastest but not smoothVery dense data points, or rough estimates only
PCHIPPiecewise Cubic Hermite Interpolating Polynomial; preserves monotonicity, no overshootRecommended default for most material data
Cubic SplineCubic spline with C2 continuity; smoothest curveSparse data where smooth behavior is expected; may overshoot at sharp features
Before running, the software checks for layers and surrounding media that still use Linear interpolation and recommends switching to PCHIP. For production calculations, PCHIP is the recommended default.

Wavelength coverage check

Before running a calculation, the software automatically verifies that the refractive-index data wavelength range of every File-mode layer and surrounding medium fully covers the wavelength sampling range configured in the Optics page. If any layer fails this check, the run is blocked.

The error message format is: {layer name}: Refractive Index (RI) data range {dataFrom}–{dataTo} nm does not cover Wavelength Sampling {reqFrom}–{reqTo} nm.

Corrective actions:

  1. Replace the refractive-index material with one that has a wider wavelength range.
  2. Or reduce the wavelength sampling range in the Optics page so that it falls within the existing data's valid interval.

Incident-spectrum files: format and import rules

The current parser accepts .txt and .pl. Unlike refractive-index files, incident-spectrum files must contain exactly two columns.

RuleCurrent implementation
Comment linesStart with #; imported into description
SeparatorsSpaces, tabs, or commas
Column countMust be exactly 2
Data formatwavelength intensity

Hard validation rules for incident-spectrum files

CheckCurrent requirementCommon failure cause
Data presenceAt least one valid numeric row is requiredComments only or empty file
Column countEach row must contain exactly 2 columnsExtra unit or note columns
Numeric validityAll values must be finiteText or malformed numeric values
WavelengthMust be > 0 and strictly increasingDescending or repeated wavelengths
IntensityMust be non-negativeNegative intensity or invalid normalization

Incident-spectrum file format

# Custom LED spectrum
400 0.12
450 0.45
500 0.92
550 1.00
600 0.61

If Visible Color will also be enabled later, make sure this spectrum is consistent with the active wavelength sampling range, or the color calculation will be blocked by the wavelength-range rules.

Export: result data and round-trip source data

The app currently supports two export categories.

TypeCurrent capabilityTypical use
Result exportResult pages export CSV; sweep exports expand by parameter combinationPost-processing, fitting, reporting
Source-data exportRefractive-index and incident-spectrum data can be exported as CSV / TXTRound-trip editing with external tools

Important behaviors of source-data export:

  1. Refractive-index and incident-spectrum exports are validated again before download.
  2. description is written back as # comment lines so the exported file remains compatible with the import parser.
  3. Birefringent refractive-index exports preserve nExt / kExt.
  4. TXT export uses a plain-text layout that can be imported again directly.

Result CSV interpretation:

  • Regular calculation results export as Wavelength_nm, Value;
  • Sweep CSV exports parameter columns first, then wavelength columns;
  • Sweep CSV is meant for batch comparison, not as a simple single-curve file.

The Data page: inspect the active model directly

The Data page is not a result page. It exposes the current frontend model state as structured data.

PanelCurrent contentBest use case
StructureCurrent structure arrayVerify layer order, names, and pre-expansion stack content
OpticsCurrent optics objectVerify wavelength mode, detectors, and spectrum toggles
SweepCurrent sweep listVerify paths, ranges, and steps
OptimizerObjectives, variables, and algorithm settingsVerify optimization configuration before running

Each panel supports expand/collapse. Use it in these situations:

  1. after importing a file, confirm the data actually landed in the intended field;
  2. when sweep or optimizer reports a path issue, verify the exact path names in the structured data;
  3. before saving or documenting an example case, confirm that the model state matches the intended setup.

Troubleshooting order

When import succeeds but the result still looks wrong, use this order:

  1. check that the source file has a strictly increasing wavelength column and consistent units;
  2. use the Data page to verify array lengths and key fields after import;
  3. return to Structure or Optics and confirm the imported data are actually enabled in the active model.

The check order is: format -> binding -> modeling.

Copyright © 2026 Dreapex