Skip to content

npxpy.nodes.misc.DoseCompensation

Bases: Node

A class to represent dose compensation with various attributes and methods for managing dose settings.

Attributes:

Name Type Description
edge_location List[Union[float, int]]

Location of the edge [x, y, z] in micrometers.

edge_orientation Union[float, int]

Orientation of the edge in degrees.

domain_size List[Union[float, int]]

Size of the domain [width, height, depth] in micrometers.

gain_limit Union[float, int]

Gain limit for the dose compensation.

Source code in npxpy/nodes/misc.py
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
class DoseCompensation(Node):
    """
    A class to represent dose compensation with various attributes and methods
    for managing dose settings.

    Attributes:
        edge_location (List[Union[float, int]]): Location of the edge [x, y, z] in micrometers.
        edge_orientation (Union[float, int]): Orientation of the edge in degrees.
        domain_size (List[Union[float, int]]): Size of the domain [width, height, depth] in micrometers.
        gain_limit (Union[float, int]): Gain limit for the dose compensation.
    """

    def __init__(
        self,
        name: str = "Dose compensation 1",
        edge_location: List[Union[float, int]] = [0.0, 0.0, 0.0],
        edge_orientation: Union[float, int] = 0.0,
        domain_size: List[Union[float, int]] = [200.0, 100.0, 100.0],
        gain_limit: Union[float, int] = 2.0,
    ):
        """
        Initialize the dose compensation with the specified parameters.

        Parameters:
            name (str): Name of the dose compensation.
            edge_location (List[Union[float, int]]): Location of the edge [x, y, z] in micrometers.
            edge_orientation (Union[float, int]): Orientation of the edge in degrees.
            domain_size (List[Union[float, int]]): Size of the domain [width, height, depth] in micrometers.
            gain_limit (Union[float, int]): Gain limit, must be >= 1.
        """
        super().__init__(node_type="dose_compensation", name=name)
        self.edge_location = edge_location
        self.edge_orientation = edge_orientation
        self.domain_size = domain_size
        self.gain_limit = gain_limit

    @property
    def edge_location(self):
        """Get the location of the edge."""
        return self._edge_location

    @edge_location.setter
    def edge_location(self, value: List[Union[float, int]]):
        """
        Set the location of the edge.

        Parameters:
            value (List[Union[float, int]]): The edge location [x, y, z].

        Raises:
            TypeError: If edge_location is not a list of three numbers.
        """
        if len(value) != 3 or not all(
            isinstance(val, (float, int)) for val in value
        ):
            raise TypeError("edge_location must be a list of three numbers.")
        self._edge_location = value

    @property
    def edge_orientation(self):
        """Get the edge orientation."""
        return self._edge_orientation

    @edge_orientation.setter
    def edge_orientation(self, value: Union[float, int]):
        """
        Set the edge orientation.

        Parameters:
            value (Union[float, int]): The edge orientation in degrees.

        Raises:
            TypeError: If the value is not a number.
        """
        if not isinstance(value, (float, int)):
            raise TypeError("edge_orientation must be a float or an int.")
        self._edge_orientation = value

    @property
    def domain_size(self):
        """Get the size of the domain."""
        return self._domain_size

    @domain_size.setter
    def domain_size(self, value: List[Union[float, int]]):
        """
        Set the domain size.

        Parameters:
            value (List[Union[float, int]]): The domain size [width, height, depth].

        Raises:
            TypeError: If domain_size is not a list of three numbers.
            ValueError: If any element in domain_size is <= 0.
        """
        if len(value) != 3 or not all(
            isinstance(val, (float, int)) for val in value
        ):
            raise TypeError("domain_size must be a list of three numbers.")
        if any(size <= 0 for size in value):
            raise ValueError(
                "All elements in domain_size must be greater than 0."
            )
        self._domain_size = value

    @property
    def gain_limit(self):
        """Get the gain limit."""
        return self._gain_limit

    @gain_limit.setter
    def gain_limit(self, value: Union[float, int]):
        """
        Set the gain limit.

        Parameters:
            value (Union[float, int]): The gain limit.

        Raises:
            ValueError: If the gain limit is less than 1.
        """
        if value < 1:
            raise ValueError("gain_limit must be greater than or equal to 1.")
        self._gain_limit = value

    def to_dict(self) -> Dict[str, Any]:
        """
        Convert the DoseCompensation object into a dictionary.

        Returns:
            Dict[str, Any]: Dictionary representation of the object.
        """
        node_dict = super().to_dict()  # Get the basic dict from Node
        node_dict.update(
            {
                "position_local_cos": self.edge_location,
                "z_rotation_local_cos": self.edge_orientation,
                "size": self.domain_size,
                "gain_limit": self.gain_limit,
            }
        )
        return node_dict

domain_size property writable

Get the size of the domain.

edge_location property writable

Get the location of the edge.

edge_orientation property writable

Get the edge orientation.

gain_limit property writable

Get the gain limit.

__init__(name='Dose compensation 1', edge_location=[0.0, 0.0, 0.0], edge_orientation=0.0, domain_size=[200.0, 100.0, 100.0], gain_limit=2.0)

Initialize the dose compensation with the specified parameters.

Parameters:

Name Type Description Default
name str

Name of the dose compensation.

'Dose compensation 1'
edge_location List[Union[float, int]]

Location of the edge [x, y, z] in micrometers.

[0.0, 0.0, 0.0]
edge_orientation Union[float, int]

Orientation of the edge in degrees.

0.0
domain_size List[Union[float, int]]

Size of the domain [width, height, depth] in micrometers.

[200.0, 100.0, 100.0]
gain_limit Union[float, int]

Gain limit, must be >= 1.

2.0
Source code in npxpy/nodes/misc.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def __init__(
    self,
    name: str = "Dose compensation 1",
    edge_location: List[Union[float, int]] = [0.0, 0.0, 0.0],
    edge_orientation: Union[float, int] = 0.0,
    domain_size: List[Union[float, int]] = [200.0, 100.0, 100.0],
    gain_limit: Union[float, int] = 2.0,
):
    """
    Initialize the dose compensation with the specified parameters.

    Parameters:
        name (str): Name of the dose compensation.
        edge_location (List[Union[float, int]]): Location of the edge [x, y, z] in micrometers.
        edge_orientation (Union[float, int]): Orientation of the edge in degrees.
        domain_size (List[Union[float, int]]): Size of the domain [width, height, depth] in micrometers.
        gain_limit (Union[float, int]): Gain limit, must be >= 1.
    """
    super().__init__(node_type="dose_compensation", name=name)
    self.edge_location = edge_location
    self.edge_orientation = edge_orientation
    self.domain_size = domain_size
    self.gain_limit = gain_limit

to_dict()

Convert the DoseCompensation object into a dictionary.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: Dictionary representation of the object.

Source code in npxpy/nodes/misc.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def to_dict(self) -> Dict[str, Any]:
    """
    Convert the DoseCompensation object into a dictionary.

    Returns:
        Dict[str, Any]: Dictionary representation of the object.
    """
    node_dict = super().to_dict()  # Get the basic dict from Node
    node_dict.update(
        {
            "position_local_cos": self.edge_location,
            "z_rotation_local_cos": self.edge_orientation,
            "size": self.domain_size,
            "gain_limit": self.gain_limit,
        }
    )
    return node_dict