zones#
Here we implement the generic Zone class, as well as a series of
ZoneCollection classes that are used to combine several zones
Note
the actual implementation of zones are in other modules
- class atomsmltr.environment.zones.generic.ANDCollection(*args, **kwargs)[source]#
Bases:
ZoneCollection- property type#
a description of the object type
- Type:
str
- class atomsmltr.environment.zones.generic.ORCollection(*args, **kwargs)[source]#
Bases:
ZoneCollection- property type#
a description of the object type
- Type:
str
- class atomsmltr.environment.zones.generic.SuperZone(zones: list = [], logic: str = 'AND', action: str = 'stop', tag: str = None, in_tag: str = None, out_tag: str = None)[source]#
Bases:
ZoneCollectionSuperZone is a zone collection for position/speed vectors
- Parameters:
zones (list, optional) – list of zones to add at object creation, by default []
logic (str, optional) – the logic of zone combination. Can be “OR”, “AND”, “XOR”, by default “AND”
action (str, optional) – the action to trigger implemented actions = [“stop”, “ignore”], default is “stop”
tag (str, optional) – the tag of the zone, by default None
in_tag (str, optional) – tag for an object inside the zone, by default None
out_tag (str, optional) – tag for an object inside the zone, by default None
- get_value(vector: ndarray, nocheck: bool = False) ndarray[source]#
Evaluates whether ‘vector’ is in the zone
- Parameters:
vector (array of shape (6,) or (n1, n2, ..., 6)) – cartesian coordinates of the vectors in the lab frame
nocheck (bool, optional) – if set to True, function will not check that the shape of position matches requirements, by default False
- Returns:
value – whether the vector is ‘in the zone’
- Return type:
array of shape (1,) or (n1, n2, …, 1)
Notes
This is a
SuperZoneobject, so it acts on position-speed vectors of dimensions 6 !vectorshould be an array of shape (6,) or (n1, n2, .., 6), where last axis contains the coordinates (position & speed) to evaluate.In all cases, the last dimension contains cordinates (x, y, z, vx, vy, vz),
if the
invertedproperty is set to true,get_valuewill return True outside the zone
- property logic#
the logic for the SuperZone combination (“OR”, “XOR”, “AND”)
- Type:
str
- property target#
not used in this case
- property type#
a description of the object type
- Type:
str
- class atomsmltr.environment.zones.generic.XORCollection(*args, **kwargs)[source]#
Bases:
ZoneCollection- property type#
a description of the object type
- Type:
str
- class atomsmltr.environment.zones.generic.Zone(target: str = 'position', action: str = 'stop', tag: str = None, in_tag: str = None, out_tag: str = None)[source]#
Bases:
EnvObjectA generic Zone object
- Parameters:
target (str, optional) – the target for the zone, can be “position” or “speed”, by default “position”
action (str, optional) – the action associated to the zone. implemented actions = [“stop”, “ignore”], default is “stop”
tag (str, optional) – the zone tag
in_tag (str, optional) – tag for an object inside the zone, by default None
out_tag (str, optional) – tag for an object inside the zone, by default None
- property action#
the action associated with the zone. implemented actions = [“stop”, “ignore”].
- Type:
str
- get_value(vector: ndarray, nocheck: bool = False) ndarray[source]#
Evaluates whether ‘vector’ is in the zone
- Parameters:
vector (array of shape (3,) or (n1, n2, ..., 3)) – cartesian coordinates of the vectors in the lab frame
nocheck (bool, optional) – if set to True, function will not check that the shape of position matches requirements, by default False
- Returns:
value – wheter the vector is ‘in the zone’
- Return type:
array of shape (1,) or (n1, n2, …, 1)
Notes
vectorshould be an array of shape (…,3), where last axis contains the coordinates to evaluate.if the
invertedproperty is set to true,get_valuewill return True outside the zone
- property in_tag: str#
tag for a object inside the zone
- Type:
str
- property inverted#
if inverted, the zone logic is inverted
- Type:
bool
- property out_tag: str#
tag for a object outside the zone
- Type:
str
- property target#
the target for the zone. Can be “position” or “speed”
- Type:
str
- property vector#
True it the object value is vectorial, False if scalar
- Type:
bool
- class atomsmltr.environment.zones.generic.ZoneCollection(*args, **kwargs)[source]#
Bases:
Zone- add_zone(zone: Zone)[source]#
adds a zone to the current collection
- Parameters:
zone (Zone) – the zone to add
- property type#
a description of the object type
- Type:
str
- property zones: list#
a list of the zones included in the collection
- Type:
list