Input/Output API
Data Export
CSV Exporter
- class prismo.io.exporters.csv_exporter.CSVExporter(output_dir=None)[source]
CSV data exporter.
Exports field data, spectra, and S-parameters to CSV format. Suitable for small to medium datasets that can be easily opened in spreadsheet applications.
- export_fields(filename, fields, coordinates, metadata=None)[source]
Export field data to CSV.
Creates a CSV file with columns: x, y, z, Ex, Ey, Ez, Hx, Hy, Hz, |E|, |H|
- Parameters:
- Returns:
Path to exported CSV file.
- Return type:
Path
- export_spectrum(filename, frequencies, spectrum, metadata=None)[source]
Export spectrum data to CSV.
Creates a CSV file with columns: frequency, spectrum, (optional phase).
- export_sparameters(filename, frequencies, sparameters, metadata=None)[source]
Export S-parameters to CSV.
Creates a CSV file with columns for each S-parameter (magnitude and phase).
Parquet Exporter
- class prismo.io.exporters.parquet_exporter.ParquetExporter(output_dir=None, compression='snappy')[source]
Parquet data exporter using Polars.
Exports field data, spectra, and S-parameters to Apache Parquet format. Parquet provides efficient columnar storage with compression, making it ideal for large datasets.
- Parameters:
output_dir (Path, optional) – Output directory for exported files.
compression (str, optional) – Compression algorithm (‘snappy’, ‘gzip’, ‘lz4’, ‘zstd’). Default=’snappy’.
- __init__(output_dir=None, compression='snappy')[source]
Initialize exporter.
- Parameters:
output_dir (Path, optional) – Output directory for exported files. If None, uses current directory.
- export_fields(filename, fields, coordinates, metadata=None)[source]
Export field data to Parquet format.
Creates a Parquet file with efficient columnar storage.
- Parameters:
- Returns:
Path to exported Parquet file.
- Return type:
Path
- export_spectrum(filename, frequencies, spectrum, metadata=None)[source]
Export spectrum data to Parquet.
- export_sparameters(filename, frequencies, sparameters, metadata=None)[source]
Export S-parameters to Parquet.
- static read_parquet(filepath)[source]
Read a Parquet file.
- Parameters:
filepath (Path) – Path to Parquet file.
- Returns:
Polars DataFrame with the data.
- Return type:
pl.DataFrame
- static read_with_filter(filepath, filter_expr=None, columns=None)[source]
Read Parquet file with lazy evaluation and filtering.
- Parameters:
filepath (Path) – Path to Parquet file.
filter_expr (polars expression, optional) – Filter expression to apply.
columns (list, optional) – Specific columns to read.
- Returns:
Filtered DataFrame.
- Return type:
pl.DataFrame
Lumerical Import
FSP Parser
- class prismo.io.lumerical.fsp_parser.FSPParser(fsp_file)[source]
Parser for Lumerical .fsp files.
Lumerical FDTD Solutions saves projects as .fsp files, which are compressed archives containing XML and binary data. This parser extracts the relevant information for conversion to Prismo.
- Parameters:
fsp_file (Path) – Path to .fsp file.
- class prismo.io.lumerical.fsp_parser.FSPProject(filename, geometries=<factory>, sources=<factory>, monitors=<factory>, simulation_region=<factory>, materials=<factory>, metadata=<factory>)[source]
Complete FSP project data.
- filename
Original .fsp filename.
- Type:
Path
- geometries
Geometry objects.
- Type:
List[FSPGeometry]
- sources
Source definitions.
- Type:
List[FSPSource]
- monitors
Monitor definitions.
- Type:
List[FSPMonitor]
- __init__(filename, geometries=<factory>, sources=<factory>, monitors=<factory>, simulation_region=<factory>, materials=<factory>, metadata=<factory>)
Material Database
- class prismo.io.lumerical.material_db.LumericalMaterialDB(db_path)[source]
Parser for Lumerical material database files.
Lumerical stores material data in various formats including: - Text files with (n, k) data - XML files with dispersion model parameters - MDF (Material Data Format) files
- Parameters:
db_path (Path) – Path to Lumerical material database directory or file.
- load_material(material_name)[source]
Load a material from the database.
- Parameters:
material_name (str) – Name of material to load.
- Returns:
Material object if found.
- Return type:
DispersiveMaterial or None
- prismo.io.lumerical.material_db.import_lumerical_material(file_path, material_name=None)[source]
Import a single material from a Lumerical file.
- Parameters:
file_path (Path) – Path to material data file.
material_name (str, optional) – Material name to use. If None, uses filename.
- Returns:
Imported material.
- Return type:
DispersiveMaterial or None
Examples
>>> mat = import_lumerical_material('path/to/Silicon.txt') >>> prismo.add_material('Silicon_imported', mat)