solprop.recipe.metadata#
Machine-readable metadata of every keyword a recipe can set (SEP 41, S9).
One Parameter per keyword of a route’s Simulation.from_* constructor, of
its prop_* function and of the execution settings: its forms (a keyword often takes
several, as pressure takes a number, a gradient or a profile), their units and
ranges, whether it needs the "none" spelling, the unit a front end shows it in,
whether the resolved recipe writes it back, the rule that resolves a None default,
and where it is documented. The function’s signature stays the single source of the
default: parameters() reads it, and a test holds the table and the signature to
the same names.
A front end’s tooltips and field validation come from this table; its labels and wording are its own.
Module Attributes
What a form of a keyword holds. |
|
Where a front end shows a keyword. |
|
Whether a newcomer sees a keyword, or only an expert. |
|
Keywords whose elements carry different units (SEP 41 section 4). |
|
The default |
|
The routes whose |
|
Keywords of an object route's constructor that a recipe writes under |
|
Given the values a recipe sets, return what a |
|
The keywords that are per metre of y on a slab mode set ( |
Functions
|
Return the metadata of a route's build keywords, with their defaults. |
|
Return whether a recipe's pulse energy and peak power are per metre of y. |
|
Return the constructor whose keywords a route's |
Classes
|
One form a keyword's value may take. |
|
Everything a front end needs to show and check one keyword. |
|
The value a |
- solprop.recipe.metadata.ElementUnits#
Keywords whose elements carry different units (SEP 41 section 4).
phasesis[rad, s, s^2, ...];betasiss^n/mfor ordern; the(z, p)form ofpressureis two rows, positions in metres and pressures in bar.alias of
Literal[‘phases’, ‘betas’, ‘z_pressure’]
- class solprop.recipe.metadata.Form(kind, unit=None, elements=None, minimum=None, maximum=None, exclusive=False, choices=(), types=(), length=None, recipe=True)[source]#
Bases:
objectOne form a keyword’s value may take.
- Attributes:
- kindstr
A
FormKind.- unitstr or None
The keyword’s own unit, in which a bare number is read: SI, except that pressures are in bar (
docs/dev/conventions.md).Nonefor a number with no unit, and for the non-numeric kinds.- elements{‘phases’, ‘betas’} or None
For an array whose elements carry different units, which rule gives them.
- minimum, maximumfloat or None
The allowed range, inclusive unless exclusive says otherwise.
- exclusivebool
Whether the range’s ends are excluded.
- choicestuple of str
The allowed values of a
"choice".- typestuple of str
The registered types an
"object"may name.- lengthint or None
The number of elements of a
"pair"or fixed-length array.- recipebool
Whether a recipe can hold this form;
Falsefor a callable or an object type that is not registered, which only the Python export carries.
Examples
>>> from solprop.recipe.metadata import Form >>> Form("number", unit="m", minimum=0.0, exclusive=True).recipe True
- solprop.recipe.metadata.FormKind#
What a form of a keyword holds.
"number"a real number or quantity string;"integer"an integer (a decimal string for one beyond 64 bits);"boolean";"choice"one of fixed strings;"string"free text, such as a gas name;"pair"two numbers;"array"a one-dimensional list of numbers or a data file;"mapping"a table keyed by name;"object"a registered type, written as a table with atypekey;"callable"a Python function, which no recipe holds (the Python export is the way out).alias of
Literal[‘number’, ‘integer’, ‘boolean’, ‘choice’, ‘string’, ‘pair’, ‘array’, ‘mapping’, ‘object’, ‘callable’]
- solprop.recipe.metadata.Group#
Where a front end shows a keyword.
alias of
Literal[‘geometry’, ‘medium’, ‘nonlinear’, ‘input’, ‘grid’, ‘numerics’, ‘output’]
- solprop.recipe.metadata.Level#
Whether a newcomer sees a keyword, or only an expert.
alias of
Literal[‘basic’, ‘advanced’]
- solprop.recipe.metadata.OBJECT_ROUTES: Final = ('radial', 'free', 'planar')#
The routes whose
[build]keywords are objects: grids, medium, beam and settings.Their
Simulation.from_*takes the time grid, the transverse grid, the medium, the responses and the beam positionally, and the stepping in asettingsobject; a recipe writes each as a table under its keyword’s name.
- solprop.recipe.metadata.PER_WIDTH_KEYWORDS: Final = ('energy', 'peak_power')#
The keywords that are per metre of y on a slab mode set (
per_unit_width()).
- class solprop.recipe.metadata.Parameter(name, forms, group, level, summary, anchor, display=None, none=False, resolvable=False, resolver=None, default=REQUIRED)[source]#
Bases:
objectEverything a front end needs to show and check one keyword.
- Attributes:
- namestr
The keyword.
- formstuple of Form
The forms its value may take;
Noneis a form wherever the default isNoneor none is set.- groupstr
A
Group.- levelstr
A
Level.- summarystr
One line.
- anchorstr
The manual section, as a path under
docs/with an optional#anchor.- displaystr or None
The unit a front end shows and a canonical recipe writes, in ASCII (
"um","fs");Nonefor no unit.- nonebool
Whether the keyword’s default is not
Noneyet it acceptsNone, so a recipe spellsNoneas the string"none"(SEP 41 section 5.1).- resolvablebool
Whether the resolved recipe writes the value that was used (SEP 41 section 5.2): only where writing it back gives the same record.
- resolvercallable or None
For a
Nonedefault resolved by a rule, the function that says what it resolves to (Resolver).- defaultobject
The function’s default, filled in by
parameters()from the signature;REQUIREDfor a keyword the caller must give.
Examples
>>> from solprop.recipe import metadata >>> table = metadata.parameters("capillary") >>> table["pressure"].display, table["pressure"].forms[0].unit ('bar', 'bar')
- solprop.recipe.metadata.REQUIRED: Final = REQUIRED#
The default
parameters()records for a keyword the caller must give.
- class solprop.recipe.metadata.Resolution(value, rule)[source]#
Bases:
objectThe value a
Nonedefault will take, and the rule that chose it.- Attributes:
- valueobject
The value the build will use.
- rulestr
The rule, in a sentence a front end can show.
Examples
>>> from solprop.recipe.metadata import Resolution >>> Resolution(1e-6, "the capillary's default").value 1e-06
- solprop.recipe.metadata.Resolver#
Given the values a recipe sets, return what a
Nonedefault resolves to.alias of
Callable[[Mapping[str,object]],Resolution]
- solprop.recipe.metadata.SETTINGS_KEYWORDS: Final = ('absorber', 'absorber_scheme')#
Keywords of an object route’s constructor that a recipe writes under
settings.prop_radial,prop_freeandprop_planarapply them to their settings; a recipe holds thefrom_*form, so they are keywords of itssettingstable (SEP 41 section 5.1), and the route’s table does not list them.
- solprop.recipe.metadata.parameters(route)[source]#
Return the metadata of a route’s build keywords, with their defaults.
- Parameters:
- routestr
A route of
solprop.recipe.core.ROUTES,"execution"for the[execution]table’s keys, or a registered type’s name (solprop.recipe.registry.REGISTRY) for the keywords of its table.
- Returns:
- collections.abc.Mapping
Parameterby keyword, in the constructor’s order, each with the default its signature declares (REQUIREDwhere it has none). An object route’s table leaves outSETTINGS_KEYWORDS, which a recipe writes undersettings; a type’s leaves out what it receives as its build context and the keywords a recipe may not give (omitted).
Examples
>>> from solprop.recipe.metadata import parameters >>> table = parameters("gnlse") >>> table["rtol"].default is None, table["rtol"].resolver({}).value (True, 1e-07) >>> parameters("execution")["fields"].default 'all' >>> pulse = parameters("GaussianPulse") >>> pulse["fwhm"].display, pulse["m"].default ('fs', 1)
- solprop.recipe.metadata.per_unit_width(route, values)[source]#
Return whether a recipe’s pulse energy and peak power are per metre of y.
A slab mode set is uniform in y, a plane wave in the free direction, so on the waveguide route with slab modes the
PER_WIDTH_KEYWORDSare read in J/m and W/m though written, as everywhere, in J and W: the value is the same number, and a front end shows the unit per metre.- Parameters:
- routestr
The route.
- valuescollections.abc.Mapping
The recipe’s
[build]values, as it gives them (modesas tables).
- Returns:
- bool
Whether the route is the waveguide’s and its mode set a slab set.
Examples
>>> from solprop.recipe.metadata import per_unit_width >>> per_unit_width("waveguide", {"modes": {"type": "ModeCollection.slab"}}) True >>> per_unit_width("waveguide", {"modes": [{"type": "RectMode"}]}) False
- solprop.recipe.metadata.surface(route)[source]#
Return the constructor whose keywords a route’s
[build]table holds.- Parameters:
- routestr
The route, one of
solprop.recipe.core.ROUTES.
- Returns:
- callable
The route’s
Simulation.from_*:from_gnlse,from_capillary,from_waveguide,from_radial,from_freeorfrom_planar.
- Raises:
- DriverError
If the route has no recipe yet.
Examples
>>> from solprop.recipe.metadata import surface >>> surface("gnlse").__name__ 'from_gnlse'