Array Operations
Contains a series of functions for performing paraxial operations on arrays.
pad_to
Paraxially zero-pads the input array to the shape (npixels, npixels). Due to the paraxial requirement, the input array must be square and even arrays can only be padded to even shapes, and odd shaped arrays can only be padded to odd shapes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
Array
|
The input array to pad. |
required |
npixels
|
int
|
The size to pad to the array to. |
required |
Returns:
Name | Type | Description |
---|---|---|
array |
Array
|
The padded array. |
Source code in src/dLux/utils/array_ops.py
14 15 16 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 |
|
crop_to
Paraxially crops the input array to the shape (npixels, npixels). Due to the paraxial requirement, the input array must be square and even arrays can only be cropped to even shapes, and odd shaped arrays can only be cropped to odd shapes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
Array
|
The input array to crop. |
required |
npixels
|
int
|
The size to crop the array to. |
required |
Returns:
Name | Type | Description |
---|---|---|
array |
Array
|
The cropped array. |
Source code in src/dLux/utils/array_ops.py
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 |
|
resize
Resizes the input array to the shape (npixels, npixels), using either a pad or crop depending on the input array size. Due to the paraxial requirement, the input array must be square and even arrays can only be resized to even shapes, and odd shaped arrays can only be resized to odd shapes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
Array
|
The input array to resize. |
required |
npixels
|
int
|
The size to output the array. |
required |
Returns:
Name | Type | Description |
---|---|---|
array |
Array
|
The resized array. |
Source code in src/dLux/utils/array_ops.py
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 |
|
downsample
Downsamples the input array by a factor of n, either by taking the mean or sum of the array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
Array
|
The input array to downsample. |
required |
n
|
int
|
The factor by which to downsample the array. |
required |
mean
|
bool = True
|
Whether to downsample by taking the mean or sum of the array. |
True
|
Returns:
Name | Type | Description |
---|---|---|
array |
Array
|
The downsampled array. |
Source code in src/dLux/utils/array_ops.py
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 |
|