picongpu.pypicongpu.species.operation.densityprofile.densityprofile
This file is part of the PIConGPU. Copyright 2021-2023 PIConGPU contributors Authors: Hannes Troepgen, Brian Edward Marre License: GPLv3+
Module Contents
Classes
(abstract) parent class of all density profiles |
- class picongpu.pypicongpu.species.operation.densityprofile.densityprofile.DensityProfile
Bases:
picongpu.pypicongpu.rendering.RenderedObject
(abstract) parent class of all density profiles
A density profile describes the density in space.
- abstract check() None
check self, overwritten by child class
Perform checks if own parameters are valid. On error raise, if everything is okay pass silently.
- get_generic_profile_rendering_context() dict
retrieve a context valid for “any profile”
Problem: Every profile has its respective schema, and it is difficult in JSON (particularly in a mustache-compatible way) to get the type of the schema.
Solution: The normal rendering of profiles get_rendering_context() provides only their parameters, i.e. there is no meta information on types etc.
If a generic profile is requested one can use the schema for “DensityProfile” (this class), for which this method returns the correct content, which includes metainformation and the data on the schema itself.
E.g.:
{ "type": { "uniform": true, "gaussian": false, ... }, "data": DATA }
where DATA is the serialization as returned by get_rendering_context().
There are two context serialization methods for density profiles:
get_rendering_context()
provided by RenderedObject parent class, serialization (“context building”) performed by _get_serialized()
_get_serialized() implemented in every profile
checks against schema of respective profile
returned context is a representation of exactly this profile
(left empty == not implemented in parent ProfileDensity)
get_generic_profile_rendering_context()
implemented in parent densityprofile
returned representation is generic for any profile (i.e. contains meta information which type is actually used)
passes information from get_rendering_context() through
returned representation is designed for easy use with templating engine mustache
- get_rendering_context() dict
get rendering context representation of this object
delegates work to _get_serialized and invokes checks performed by check_context_for_type(). :raise ValidationError: on schema violiation :raise RuntimeError: on schema not found :return: self as rendering context
- static check_context_for_type(type_to_check: type, context: dict) None
check if the given context is valid for the given type
Raises on error, passes silently if okay.
- Raises:
ValidationError – on schema violiation
RuntimeError – on schema not found