loadtable.py¶
-
jcmwave.
loadtable
(file_name, format='named')¶ Loads data from .jcm file stored in JCM table format.
Parameters: - file_name (filepath) – path to a .jcm table file
- format (str) – output format of the loaded table (see below).
Returns: The output depends on the optional format specification
format==’named’
The output is a python dictionary with entries
’title’
title of the table
’header’
nested dictionary containing meta-information.
’<Data1>’, … ‘<DataN>’
fields containing the table’s data. <Data1>, …, <DataN> are the column names as found in the .jcm file. A column is not necessarily a (n_row x 1) vector. For example, the xyz-components of n_rows wave vectors are stored as a (n_row x 3) numpy-matrix. Numbered data of the same type are stored in dictionaries with integer keys (see the example of a Fourier table below).
format==’list’
returns data as a list ordered as above
table[0]: titletable[1]: headertable[2 : N+1]: {<Data1>, …, <DataN>}format==’matrix’
drops title and header entry, returns complete table data as a (n_row x ?) numpy-matrix.
format==’legacy’
same as named, but data is not converted to numpy arrays and remains as column vectors
Examples:
Load table containing computed eigenvalues of a resonance mode or propagating mode problem:
>>> ev = jcmwave.loadtable('project_results/eigenvalues.jcm')
In case of a propagating mode problem, the dictionary ev will contain the following fields (in given order)
‘title’: title of the table‘effective_refractive_index’: computed propagating modes‘precision’: estimated accuracy of the computed modesLoad Fourier coefficient table as produced by post-process FourierTransform for a electromagnetic field scattering problem:
>>> ft = jcmwave.loadtable('project_results/fourier_transform.jcm')
When the electric field components were computed, ft is a dictionary with the following fields (in given order):
- ‘title’:
title of the table
- ‘header’:
header containing meta-information, i.e. incoming field specifcation, permittivities of the lower and upper half space, reciprocal grid vectors for periodic problem, etc.
- ‘K’:
k-vectors of the sampling in k-space (n_row x 3) matrix
- ‘N1’, ‘N2’:
defractions order with respect to first and second reciprocal grid vectors as given in the header (only present for periodic problems)
- ‘ElectricFieldStrength’:
electric field vectors of the Fourier modes. This is dictionary with integer keys, where ft.ElectricFieldStrength[iF] refers to the (iF+1)-th computed electric field.
Load Fourier coefficients in matrix form:
>>> ft = loadtable('project_results/fourier_transform.jcm', format='matrix')
This yields a (n_row x ?) numpy-matrix containing the data as in 2.:
>>> ft = [ft.N1; ft.N2; ft.ElectricFieldStrength[0]; ... ft.ElectricFieldStrength[nF-1]]
where
nF
is the number of computed electric fields.