Skip to content

Coordinates¤

Spec

dLux.coordinates.Spec ¤

Bases: Base

Abstract base class for coordinate/sampling specifications.

UML

UML

Source code in dLux/coordinates.py
 7
 8
 9
10
11
12
13
14
15
class Spec(zdx.Base):
    """
    Abstract base class for coordinate/sampling specifications.

    ??? abstract "UML"
        ![UML](../../assets/uml/Spec.png)
    """

    pass
PadSpec

dLux.coordinates.PadSpec ¤

Bases: Spec

Coordinate specification defined via integer padding and cropping factors relative to an input grid size.

UML

UML

Attributes:

Name Type Description
pad int

Factor by which to increase the grid size. The padded grid will have n * pad pixels along each axis.

crop int

Factor by which to reduce the grid size after processing. The cropped grid will have n_out // crop pixels along each axis.

c float

Centre coordinate of the grid, in metres.

Source code in dLux/coordinates.py
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
class PadSpec(Spec):
    """
    Coordinate specification defined via integer padding and cropping factors
    relative to an input grid size.

    ??? abstract "UML"
        ![UML](../../assets/uml/PadSpec.png)

    Attributes
    ----------
    pad : int
        Factor by which to increase the grid size. The padded grid will have
        ``n * pad`` pixels along each axis.
    crop : int
        Factor by which to reduce the grid size after processing. The cropped
        grid will have ``n_out // crop`` pixels along each axis.
    c : float
        Centre coordinate of the grid, in metres.
    """

    pad: int
    crop: int
    c: float

    def __init__(self, pad=1, crop=1, c=0.0):
        """
        Parameters
        ----------
        pad : int = 1
            Grid size increase factor.
        crop : int = 1
            Grid size reduction factor applied after processing.
        c : float = 0.0
            Centre coordinate of the grid, in metres.
        """
        self.pad = int(pad)
        self.crop = int(crop)
        self.c = c

__init__(pad=1, crop=1, c=0.0) ¤

Parameters:

Name Type Description Default
pad int = 1

Grid size increase factor.

1
crop int = 1

Grid size reduction factor applied after processing.

1
c float = 0.0

Centre coordinate of the grid, in metres.

0.0
Source code in dLux/coordinates.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(self, pad=1, crop=1, c=0.0):
    """
    Parameters
    ----------
    pad : int = 1
        Grid size increase factor.
    crop : int = 1
        Grid size reduction factor applied after processing.
    c : float = 0.0
        Centre coordinate of the grid, in metres.
    """
    self.pad = int(pad)
    self.crop = int(crop)
    self.c = c
CoordSpec

dLux.coordinates.CoordSpec ¤

Bases: Spec

Coordinate specification defined explicitly by number of pixels, pixel scale, and centre offset.

UML

UML

Attributes:

Name Type Description
n int

Number of pixels along each axis.

d float

Pixel scale (spacing between adjacent pixels), in metres.

c float

Centre coordinate of the grid, in metres.

Source code in dLux/coordinates.py
 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
class CoordSpec(Spec):
    """
    Coordinate specification defined explicitly by number of pixels, pixel
    scale, and centre offset.

    ??? abstract "UML"
        ![UML](../../assets/uml/CoordSpec.png)

    Attributes
    ----------
    n : int
        Number of pixels along each axis.
    d : float
        Pixel scale (spacing between adjacent pixels), in metres.
    c : float
        Centre coordinate of the grid, in metres.
    """

    n: int
    d: float
    c: float

    def __init__(self, n=None, d=None, c=0.0):
        """
        Parameters
        ----------
        n : int = None
            Number of pixels along each axis.
        d : float = None
            Pixel scale in metres.
        c : float = 0.0
            Centre coordinate of the grid, in metres.
        """
        self.n = n
        self.d = d
        self.c = c

    @property
    def xs(self):
        """
        1D array of pixel centre coordinates along one axis.

        Returns
        -------
        xs : Array
            Coordinates of pixel centres, in metres, centred on `c`.
        """
        if self.d is None:
            raise ValueError("d must be specified to calculate coordinates.")
        return self.c + (np.arange(self.n) - (self.n - 1) / 2) * self.d

    @property
    def fov(self):
        """
        Total field of view of the grid.

        Returns
        -------
        fov : float
            Field of view in metres, equal to ``n * d``.
        """
        if self.d is None:
            raise ValueError("d must be specified to calculate FOV.")
        return self.n * self.d

    @property
    def extent(self):
        """
        Coordinate range (min, max) of the grid edges.

        Returns
        -------
        extent : tuple[float, float]
            ``(lower_edge, upper_edge)`` coordinates in metres.
        """
        if self.d is None:
            raise ValueError("d must be specified to calculate extent.")
        return self.c - (self.n / 2) * self.d, self.c + (self.n / 2) * self.d

extent property ¤

Coordinate range (min, max) of the grid edges.

Returns:

Name Type Description
extent tuple[float, float]

(lower_edge, upper_edge) coordinates in metres.

fov property ¤

Total field of view of the grid.

Returns:

Name Type Description
fov float

Field of view in metres, equal to n * d.

xs property ¤

1D array of pixel centre coordinates along one axis.

Returns:

Name Type Description
xs Array

Coordinates of pixel centres, in metres, centred on c.

__init__(n=None, d=None, c=0.0) ¤

Parameters:

Name Type Description Default
n int = None

Number of pixels along each axis.

None
d float = None

Pixel scale in metres.

None
c float = 0.0

Centre coordinate of the grid, in metres.

0.0
Source code in dLux/coordinates.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def __init__(self, n=None, d=None, c=0.0):
    """
    Parameters
    ----------
    n : int = None
        Number of pixels along each axis.
    d : float = None
        Pixel scale in metres.
    c : float = 0.0
        Centre coordinate of the grid, in metres.
    """
    self.n = n
    self.d = d
    self.c = c