QPMS
Electromagnetic multiple scattering library and toolkit.
Public Member Functions | Data Fields | Static Public Attributes
qpms.argproc.ArgParser Class Reference

Public Member Functions

def __init__ (self, features=[])
 
def add_feature (self, feat)
 
def add_argument (self, *args, **kwargs)
 
def add_argument_group (self, *args, **kwargs)
 
def parse_args (self, process_data=True, *args, **kwargs)
 
def __getattr__ (self, name)
 
def get_particles (self)
 

Data Fields

 ap
 
 features_enabled
 
 call_at_parse_list
 
 parsed
 
 args
 
 background_epsmu
 
 background_emg
 
 foreground_emg
 
 tmgen
 
 bspec
 
 omega
 
 omegas
 
 omega_max
 
 omega_min
 
 omega_singles
 
 omega_ranges
 
 omega_descr
 
 allomegas
 
 direct_basis
 
 reciprocal_basis1
 
 reciprocal_basis2pi
 
 tmspecs
 
 tmgens
 
 bspecs
 
 positions
 

Static Public Attributes

dictionary atomic_arguments
 
dictionary feature_sets_available
 

Detailed Description

 Common argument parsing engine for QPMS python CLI scripts. 

Member Function Documentation

◆ add_argument()

def qpms.argproc.ArgParser.add_argument (   self,
args,
**  kwargs 
)
Add a custom argument directly to the standard library ArgParser object

◆ add_argument_group()

def qpms.argproc.ArgParser.add_argument_group (   self,
args,
**  kwargs 
)
Add a custom argument group directly to the standard library ArgParser object

◆ get_particles()

def qpms.argproc.ArgParser.get_particles (   self)
Creates a list of Particle instances that can be directly used in ScatteringSystem.create().

Assumes that self._process_multi_particle() has been already called.

Field Documentation

◆ atomic_arguments

dictionary qpms.argproc.ArgParser.atomic_arguments
static
Initial value:
= {
'rectlattice2d_periods': lambda ap: ap.add_argument("-p", "--period", type=float, nargs='+', required=True, help='square/rectangular lattice periods', metavar=('px','[py]')),
'rectlattice2d_counts': lambda ap: ap.add_argument("--size", type=int, nargs=2, required=True, help='rectangular array size (particle column, row count)', metavar=('NCOLS', 'NROWS')),
'single_frequency_eV': lambda ap: ap.add_argument("-f", "--eV", type=float, required=True, help='radiation angular frequency in eV'),
'multiple_frequency_eV_optional': lambda ap: ap.add_argument("-f", "--eV", type=float, nargs='*', help='radiation angular frequency in eV (additional)'),
'seq_frequency_eV': lambda ap: ap.add_argument("-F", "--eV-seq", type=float, nargs=3, required=True, help='uniform radiation angular frequency sequence in eV', metavar=('FIRST', 'INCREMENT', 'LAST')),
'real_frequencies_eV_ng': lambda ap: ap.add_argument("-f", "--eV", type=float_range, nargs=1, action='append', required=True, help='Angular frequency (or angular frequency range) in eV'), # nargs='+', action='extend' would be better, but action='extend' requires python>=3.8
'single_material': lambda ap: ap.add_argument("-m", "--material", help='particle material (Au, Ag, ... for Lorentz-Drude or number for constant refractive index)', type=material_spec, required=True),
'single_radius': lambda ap: ap.add_argument("-r", "--radius", type=float, required=True, help='particle radius (sphere or cylinder)'),
'single_height': lambda ap: ap.add_argument("-H", "--height", type=float, help='cylindrical particle height; if not provided, particle is assumed to be spherical'),
'single_kvec2': lambda ap: ap.add_argument("-k", '--kx-lim', nargs=2, type=sfloat, required=True, help='k vector', metavar=('KX_MIN', 'KX_MAX')),
'kpi': lambda ap: ap.add_argument("--kpi", action='store_true', help="Indicates that the k vector is given in natural units instead of SI, i.e. the arguments given by -k shall be automatically multiplied by pi / period (given by -p argument)"),
'bg_real_refractive_index': lambda ap: ap.add_argument("-n", "--refractive-index", type=float, default=1., help='background medium strictly real refractive index'),
'bg_analytical': lambda ap: ap.add_argument("-B", "--background", type=material_spec, default=1., help="Background medium specification (constant real or complex refractive index, or supported material label)"),
'single_lMax': lambda ap: ap.add_argument("-L", "--lMax", type=int, required=True, default=3, help='multipole degree cutoff'),
'single_lMax_extend': lambda ap: ap.add_argument("--lMax-extend", type=int, required=False, default=6, help='multipole degree cutoff for T-matrix calculation (cylindrical particles only'),
'outfile': lambda ap: ap.add_argument("-o", "--output", type=str, required=False, help='output path (if not provided, will be generated automatically)'), # TODO consider type=argparse.FileType('w')
'plot_out': lambda ap: ap.add_argument("-O", "--plot-out", type=str, required=False, help="path to plot output (optional)"),
'plot_do': lambda ap: ap.add_argument("-P", "--plot", action='store_true', help="if -p not given, plot to a default path"),
'lattice2d_basis': lambda ap: ap.add_argument("-b", "--basis-vector", nargs='+', action=AppendTupleAction, help="basis vector in xy-cartesian coordinates (two required)", required=True, type=sfloat, dest='basis_vectors', metavar=('X', 'Y')),
'planewave_pol_angles': __add_planewave_argparse_group,
'multi_particle': __add_manyparticle_argparse_group,
}

◆ feature_sets_available

dictionary qpms.argproc.ArgParser.feature_sets_available
static
Initial value:
= { # name : (description, dependencies, atoms not in other dependencies, methods called after parsing, "virtual" features provided)
'const_real_background': ("Background medium with constant real refractive index", (), ('bg_real_refractive_index',), ('_eval_const_background_epsmu',), ('background', 'background_analytical')),
'background' : ("Most general background medium specification currently supported", ('background_analytical',), (), (), ()),
'background_analytical' : ("Background medium model holomorphic for 'reasonably large' complex frequency areas", (), ('bg_analytical',), ('_eval_analytical_background_epsmugen',), ('background',)),
'single_particle': ("Single particle definition (shape [currently spherical or cylindrical]) and materials, incl. background)", ('background',), ('single_material', 'single_radius', 'single_height', 'single_lMax_extend'), ('_eval_single_tmgen',), ()),
'multi_particle': ("One or more particle definition (shape [curently spherical or cylindrical]), materials, and positions)", ('background',), ('multi_particle',), ('_process_multi_particle',), ()),
'single_lMax': ("Single particle lMax definition", (), ('single_lMax',), (), ()),
'single_omega': ("Single angular frequency", (), ('single_frequency_eV',), ('_eval_single_omega',), ()),
'omega_seq': ("Equidistant real frequency range with possibility of adding individual frequencies", (), ('seq_frequency_eV', 'multiple_frequency_eV_optional',), ('_eval_omega_seq',), ()),
'omega_seq_real_ng': ("Equidistant real frequency ranges or individual frequencies (new syntax)", (), ('real_frequencies_eV_ng',), ('_eval_omega_seq_real_ng',), ()),
'lattice2d': ("Specification of a generic 2d lattice (spanned by the x,y axes)", (), ('lattice2d_basis',), ('_eval_lattice2d',), ()),
'rectlattice2d': ("Specification of a rectangular 2d lattice; conflicts with lattice2d", (), ('rectlattice2d_periods',), ('_eval_rectlattice2d',), ()),
'rectlattice2d_finite': ("Specification of a rectangular 2d lattice; conflicts with lattice2d", ('rectlattice2d',), ('rectlattice2d_counts',), (), ()),
'planewave': ("Specification of a normalised plane wave (typically used for scattering) with a full polarisation state", (), ('planewave_pol_angles',), ("_process_planewave_angles",), ()),
}

The documentation for this class was generated from the following file: