Lumerical's software supports the use of the JSON file format to save and transfer data between products. The JSON is a popular file format with customers using Lumerical's Python API. JSON files can be saved and loaded with the following commands: jsonload, jsonsave, jsonread, jsonwrite, jsonloads, jsonsaves, jsonreads, jsonwrites. See an example of loading data from JSON in the MQW Edge Emitting Laser application example.
Lumerical JSON file format specifications
The following section defines Lumerical's JSON file format. Data that will be loaded into Lumerical's software must conform to these specifications. The JSON file format is defined by the lumjson.py module located at:
Windows: C:\Program Files\Lumerical\$(PRODUCT)\api\python
Linux: /opt/lumerical/$(PRODUCT)/api/python
macOS: /Applications/Lumerical/$(PRODUCT)/$(PRODUCT).app/Contents/API/Python
Lumerical JSON file notation
Object Specifier Fields |
Values |
Description |
---|---|---|
_type |
matrix/string/struct/cell |
This field is required. |
_size |
dimensions of data |
This field is optional and it only applies to matrix type. The format is [page, row, column]. |
_data |
array of values |
|
_complex |
true/false |
This field only applies to numbers, the default value is false. |
Note: Additional fields will be ignored |
Following are some examples of the JSON format of type "cell" and "matrix".
Example: Cell
The "jsonsave" and "jsonsaves" commands save Lumerical cell into JSON object, e.g., the command
a = {10, 20, 30};
b1 = jsonsaves(a);
generates the following JSON object b1:
'''{
_type: "cell"
_data: [10, 20, 30]
}'''
The "jsonwrite" and "jsonwrites" commands save Lumerical cell into JSON list, e.g., the command
a = {10, 20, 30};
b2 = jsonwrites(a);
generates the following JSON list b2:
'''{
"a" : [ 10, 20, 30 ]
}'''
Example: Matrix
Number
'''{
_type: "matrix"
_data: [42]
}'''
Complex numbers
'''{
_type: "matrix"
_complex = true
_data: [2, 4]
}'''
Matrix
Option 1: specify the size and data is a single array. This option offers direct mapping to Lumerical matrix. The "_size" matches dimlist and "_data" is in real/imaginary pairs if "_complex" is true.
'''{
_type: "matrix"
_size: [2, 3]
_complex = true
_data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
}'''
and the data is:
[1+2i, 5+6i, 9+10i
3+4i, 7+8i, 11+12i]
Option 2: ommit "_size" and data filed is nested arrays. Data format matches numpy.text().
'''{
_type: "matrix"
_data: [[1, 2, 3], [4, 5, 6]]
}'''
and the data is:
[1, 2, 3
4, 5, 6]