QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
tmatrix_hdf5.h File Reference

Reading T-matrices from the community HDF5 format (.tmat.h5). More...

#include "qpms_types.h"
#include "tmatrices.h"
Include dependency graph for tmatrix_hdf5.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qpms_tmatrix_hdf5_t
 A T-matrix sweep loaded from a community-format .tmat.h5 file. More...
 
struct  qpms_tmatrix_hdf5_write_params_t
 Parameters of the community-format .tmat.h5 writer. More...
 

Macros

#define QPMS_TMATRIX_HDF5_NORM
 VSWF normalisation convention of the T-matrix community data format.
 

Typedefs

typedef struct qpms_tmatrix_hdf5_t qpms_tmatrix_hdf5_t
 A T-matrix sweep loaded from a community-format .tmat.h5 file.
 
typedef struct qpms_tmatrix_hdf5_write_params_t qpms_tmatrix_hdf5_write_params_t
 Parameters of the community-format .tmat.h5 writer.
 

Functions

qpms_tmatrix_hdf5_t * qpms_tmatrix_hdf5_read (const char *path, char *errbuf, size_t errlen)
 Reads a T-matrix sweep from a community-format .tmat.h5 file.
 
void qpms_tmatrix_hdf5_free (qpms_tmatrix_hdf5_t *h)
 Frees a T-matrix sweep.
 
qpms_tmatrix_interpolator_t * qpms_tmatrix_hdf5_interpolator (const qpms_tmatrix_hdf5_t *h)
 Creates a frequency interpolator over the loaded sweep.
 
qpms_errno_t qpms_tmatrix_hdf5_write (const char *path, const qpms_tmatrix_hdf5_write_params_t *params, char *errbuf, size_t errlen)
 Writes a T-matrix sweep into a community-format .tmat.h5 file.
 

Detailed Description

Reading T-matrices from the community HDF5 format (.tmat.h5).

Implements the reader side of the T-matrix data format described in "T-matrix representation of optical scattering response: Suggestion for a data format" (github.com/tfp-photonics/tmatrix_data_format, storage_format_version "v1"). The file layout is:

/                        attributes: name, description, keywords,
                         storage_format_version ("v1")
/tmatrix                 dataset (a, b_s, b_i), complex
/modes/l, /modes/m       datasets (b_s), integer
/modes/polarization      dataset (b_s), strings ("electric"/"magnetic")
/frequency               one of /frequency, /angular_frequency,
                         /vacuum_wavelength, /vacuum_wavenumber,
                         /angular_vacuum_wavenumber (length a),
                         with a string attribute "unit"
/embedding               group with relative_permittivity (+relative_permeability)
                         or refractive_index (+relative_impedance) datasets

Limitations of the current implementation:

The mode normalisation convention of the format corresponds to QPMS_TMATRIX_HDF5_NORM; the loaded basis spec uses it directly.

Macro Definition Documentation

◆ QPMS_TMATRIX_HDF5_NORM

#define QPMS_TMATRIX_HDF5_NORM
Value:
qpms_normalisation_t
Vector spherical wavefuction normalisation and phase convention codes.
Definition qpms_types.h:109
@ QPMS_NORMALISATION_CSPHASE
Flag indicating usage of Condon-Shortley phase.
Definition qpms_types.h:129
@ QPMS_NORMALISATION_NORM_SPHARM
The VSWFs shall be normalised as in .
Definition qpms_types.h:148

VSWF normalisation convention of the T-matrix community data format.

The format defines the modes with spherical harmonics including the Condon-Shortley phase and the vector spherical wave functions X_lm = L Y_lm / sqrt(l(l+1)), M = z_l X, N = (grad/k) x M (Jackson-style, as used by treams; see the format description, appendix "Mode normalization").

Typedef Documentation

◆ qpms_tmatrix_hdf5_write_params_t

Parameters of the community-format .tmat.h5 writer.

The file is written with storage_format_version "v1"; the sweep is stored as /angular_frequency with the unit "rad/s"; the embedding as /embedding/relative_permittivity and /embedding/relative_permeability. All the strings may be NULL except software and method. The modes of bspec must form a complete +/-m parity basis (as checked by the reader).

Function Documentation

◆ qpms_tmatrix_hdf5_interpolator()

qpms_tmatrix_interpolator_t * qpms_tmatrix_hdf5_interpolator ( const qpms_tmatrix_hdf5_t *  h)

Creates a frequency interpolator over the loaded sweep.

The returned interpolator borrows the basis spec from h and copies the table data into its splines, so it may outlive the raw data array but not h->bspec. Use with qpms_tmatrix_generator_interpolator(). The interpolation variable is the angular frequency in rad/s, matching the convention of the other T-matrix generators.

◆ qpms_tmatrix_hdf5_read()

qpms_tmatrix_hdf5_t * qpms_tmatrix_hdf5_read ( const char *  path,
char *  errbuf,
size_t  errlen 
)

Reads a T-matrix sweep from a community-format .tmat.h5 file.

Parameters
pathPath to the HDF5 file.
errbufBuffer for a human readable error message (may be NULL).
errlenSize of errbuf.
Returns
A newly allocated sweep, or NULL on error (with errbuf filled in).

◆ qpms_tmatrix_hdf5_write()

qpms_errno_t qpms_tmatrix_hdf5_write ( const char *  path,
const qpms_tmatrix_hdf5_write_params_t *  params,
char *  errbuf,
size_t  errlen 
)

Writes a T-matrix sweep into a community-format .tmat.h5 file.

The file is truncated if it exists.

Parameters
pathOutput path.
paramsThe data to write; software and method must be set.
errbufBuffer for a human readable error message (may be NULL).
errlenSize of errbuf.
Returns
QPMS_SUCCESS or an error code (with errbuf filled in).