SaveLoad module and saving file structure¶
The saving file for ErwinJr2 is a json file discribing the structure of QC layers and optical waveguide.
The save and load functions is independently functioning as the SaveLoad module.
This file defines functions to save and load JSON files from ErwinJr
- ErwinJr2.SaveLoad.EJSaveJSON(fhandle, qclayers=None, optstratum=None)¶
Save QCLayers and OptStratum as a json file
- Parameters
fhandle (file handle) – File handle of a json file to save to.
qclayers (QCLayers.QCLayers) – The QCLayers class to be saved.
optstratum (OptStrata.OptStratum) – The OptStratum class to be saved
- ErwinJr2.SaveLoad.loadBoth(fhandle)¶
Load QCLayers and OptStrata from a json file
- Parameters
fhandle (file handle) – file handle of a json file to read in
- Return type
- Returns
qclayers (QCLayers.QCLayers) – The QCLayers class described in the json file
strata (OptStrata.OptStrata or None) – The Optical Strata class described in the json file. For older version this is None
Examples
>>> import SaveLoad >>> with open("path/to/file.json") as f: >>> qcl, stratum = SaveLoad.loadBoth(f)
- ErwinJr2.SaveLoad.optLoad(fhandle)¶
Load OptStrata from a json file
- Parameters
fhandle (file handle) – file handle of a json file to read in
- Return type
- Returns
strata (OptStrata.OptStrata) – The OptStrata class described in the json file
Examples
>>> import SaveLoad >>> with open("path/to/file.json") as f: >>> strata = SaveLoad.optLoad(f)
- ErwinJr2.SaveLoad.qclLoad(fhandle)¶
Load QCLayers from a json file
- Parameters
fhandle (file handle) – file handle of a json file to read in
- Return type
- Returns
qclayers (QCLayers.QCLayers) – The QCLayers class described in the json file
Examples
>>> import SaveLoad >>> with open("path/to/file.json") as f: >>> qcl = SaveLoad.qclLoad(f)
Here is a sample json file
{
"FileType": "ErwinJr2 Data File",
"Version": "210330",
"Description": "dx.doi.org/10.1038/nphoton.2009.262",
"QCLayers": {
"Wavelength": 4.7,
"Substrate": "InP",
"EField": 102.0,
"x resolution": 1.0,
"E resolution": 0.5,
"No of states": 20,
"Solver": "ODE",
"Temperature": 300.0,
"Repeats": 4,
"MaterialDefs": {
"Compostion": ["InGaAs", "AlInAs"],
"Mole Fraction": [0.66, 0.31]
},
"Material": [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
"Width": [23.0, 28.0, 26.0, 22.0, 21.0, 18.0, 18.0, 15.0, 13.0, 12.0, 10.0, 42.0, 12.0, 39.0, 14.0, 33.0],
"Doping": [0.0, 0.0, 1.5, 1.5, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"Active Region": [false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true],
"IFR": false
},
"Waveguide": {
"wavelength": 4.7,
"materials": ["Air", "Au", "SiNx", "InxGa1-xAs", "InxGa1-xAs", "Al1-xInxAs", "Al1-xInxAs", "InxGa1-xAs", "Active Core", "InxGa1-xAs", "InP"],
"moleFracs": [0.0, 0.0, 0.35, 0.53, 0.53, 0.52, 0.52, 0.53, 0.53, 0.53, 0.0],
"dopings": [0.0, 0.0, 0.0, 1200.0, 90.0, 2.0, 3.0, 0.5, 0.5, 0.5, 0.0],
"width": [1.0, 0.45, 0.4, 0.01, 0.5, 0.5, 0.6, 0.2, 1.384, 0.2, 2.0],
"mobilities": [null, null, null, null, null, null, null, null, null, null, null],
"custom": {"Active Core": {"index": "(3.286+0j)", "period": [346.0, 40], "gain": 53.4}}
}
}