autolens.Grid2DIrregular

class autolens.Grid2DIrregular(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

all([axis, out, keepdims]) Returns True if all elements evaluate to True.
any([axis, out, keepdims]) Returns True if any of the elements of a evaluate to True.
argmax([axis, out]) Return indices of the maximum values along the given axis.
argmin([axis, out]) Return indices of the minimum values along the given axis of a.
argpartition(kth[, axis, kind, order]) Returns the indices that would partition this array.
argsort([axis, kind, order]) Returns the indices that would sort this array.
astype(dtype[, order, casting, subok, copy]) Copy of the array, cast to a specified type.
byteswap([inplace]) Swap the bytes of the array elements
choose(choices[, out, mode]) Use an index array to construct a new array from a set of choices.
clip([min, max, out]) Return an array whose values are limited to [min, max].
compress(condition[, axis, out]) Return selected slices of this array along given axis.
conj() Complex-conjugate all elements.
conjugate() Return the complex conjugate, element-wise.
copy([order]) Return a copy of the array.
cumprod([axis, dtype, out]) Return the cumulative product of the elements along the given axis.
cumsum([axis, dtype, out]) Return the cumulative sum of the elements along the given axis.
diagonal([offset, axis1, axis2]) Return specified diagonals.
distances_to_coordinate(coordinate, …) Returns the distance of every (y,x) coordinate in this Coordinate instance from an input coordinate.
dot(b[, out]) Dot product of two arrays.
dump(file) Dump a pickle of the array to the specified file.
dumps() Returns the pickle of the array as a string.
fill(value) Fill the array with a scalar value.
flatten([order]) Return a copy of the array collapsed into one dimension.
from_json(file_path) Create a Grid2DIrregular object from a file which stores the coordinates as a list of list of tuples.
from_pixels_and_mask(pixels, List[T]], mask) Create Grid2DIrregular from a list of coordinates in pixel units and a mask which allows these coordinates to be converted to scaled units.
from_yx_1d(y, x) Create Grid2DIrregular from a list of y and x values.
getfield(dtype[, offset]) Returns a field of the given array as a certain type.
grid_from(grid_slim) Create a Grid2DIrregular object from a 2D NumPy array of values of shape [total_coordinates, 2].
grid_of_closest_from(grid_pair) From an input grid, find the closest coordinates of this instance of the Grid2DIrregular to each coordinate on the input grid and return each closest coordinate as a new Grid2DIrregular.
grid_via_deflection_grid_from(deflection_grid) Returns a new Grid2DIrregular from this grid coordinates, where the (y,x) coordinates of this grid have a
item(*args) Copy an element of an array to a standard Python scalar and return it.
itemset(*args) Insert scalar into an array (scalar is cast to array’s dtype, if possible)
load(file_path, filename)
max([axis, out, keepdims, initial, where]) Return the maximum along a given axis.
mean([axis, dtype, out, keepdims]) Returns the average of the array elements along given axis.
min([axis, out, keepdims, initial, where]) Return the minimum along a given axis.
newbyteorder([new_order]) Return the array with the same data viewed with a different byte order.
nonzero() Return the indices of the elements that are non-zero.
output_to_json(file_path, overwrite) Output this instance of the Grid2DIrregular object to a list of list of tuples.
partition(kth[, axis, kind, order]) Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array.
prod([axis, dtype, out, keepdims, initial, …]) Return the product of the array elements over the given axis
ptp([axis, out, keepdims]) Peak to peak (maximum - minimum) value along a given axis.
put(indices, values[, mode]) Set a.flat[n] = values[n] for all n in indices.
ravel([order]) Return a flattened array.
repeat(repeats[, axis]) Repeat elements of an array.
reshape(shape[, order]) Returns an array containing the same data with a new shape.
resize(new_shape[, refcheck]) Change shape and size of array in-place.
round([decimals, out]) Return a with each element rounded to the given number of decimals.
save(file_path, filename) Save the tracer by serializing it with pickle.
searchsorted(v[, side, sorter]) Find indices where elements of v should be inserted in a to maintain order.
setfield(val, dtype[, offset]) Put a value into a specified place in a field defined by a data-type.
setflags([write, align, uic]) Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY), respectively.
sort([axis, kind, order]) Sort an array in-place.
squared_distances_to_coordinate(coordinate, …) Returns the squared distance of every (y,x) coordinate in this Coordinate instance from an input
squeeze([axis]) Remove single-dimensional entries from the shape of a.
std([axis, dtype, out, ddof, keepdims]) Returns the standard deviation of the array elements along given axis.
structure_2d_from(result, List[T]]) Convert a result from a non autoarray structure to an aa.ValuesIrregular or aa.Grid2DIrregular structure, where the conversion depends on type(result) as follows:
structure_2d_list_from(result_list) Convert a result from a list of non autoarray structures to a list of aa.ValuesIrregular or aa.Grid2DIrregular structures, where the conversion depends on type(result) as follows:
sum([axis, dtype, out, keepdims, initial, where]) Return the sum of the array elements over the given axis.
swapaxes(axis1, axis2) Return a view of the array with axis1 and axis2 interchanged.
take(indices[, axis, out, mode]) Return an array formed from the elements of a at the given indices.
tobytes([order]) Construct Python bytes containing the raw data bytes in the array.
tofile(fid[, sep, format]) Write array to a file as text or binary (default).
tolist() Return the array as an a.ndim-levels deep nested list of Python scalars.
tostring([order]) A compatibility alias for tobytes, with exactly the same behavior.
trace([offset, axis1, axis2, dtype, out]) Return the sum along diagonals of the array.
transpose(*axes) Returns a view of the array with axes transposed.
values_from(array_slim) Create a ValuesIrregular object from a 1D NumPy array of values of shape [total_coordinates].
values_via_value_from(value)
var([axis, dtype, out, ddof, keepdims]) Returns the variance of the array elements, along given axis.
view([dtype][, type]) New view of array with the same data.

Attributes

T The transposed array.
base Base object if memory is from some other object.
ctypes An object to simplify the interaction of the array with the ctypes module.
data Python buffer object pointing to the start of the array’s data.
dtype Data-type of the array’s elements.
extent The extent of the coordinates returned as a NumPy array [x_min, x_max, y_min, y_max].
flags Information about the memory layout of the array.
flat A 1-D iterator over the array.
furthest_distances_to_other_coordinates For every (y,x) coordinate on the Grid2DIrregular returns the furthest radial distance of each coordinate to any other coordinate on the grid.
imag The imaginary part of the array.
in_list Return the coordinates in a list.
itemsize Length of one array element in bytes.
nbytes Total bytes consumed by the elements of the array.
ndim Number of array dimensions.
real The real part of the array.
scaled_maxima The maximum values of the coordinates returned as a tuple (y_max, x_max).
scaled_minima The minimum values of the coordinates returned as a tuple (y_max, x_max).
shape Tuple of array dimensions.
shape_native_scaled The two dimensional shape of the coordinates spain in scaled units, computed by taking the minimum and maximum values of the coordinates.
size Number of elements in the array.
slim
strides Tuple of bytes to step in each dimension when traversing an array.
shape_native_scaled

The two dimensional shape of the coordinates spain in scaled units, computed by taking the minimum and maximum values of the coordinates.

scaled_maxima

The maximum values of the coordinates returned as a tuple (y_max, x_max).

scaled_minima

The minimum values of the coordinates returned as a tuple (y_max, x_max).

extent

The extent of the coordinates returned as a NumPy array [x_min, x_max, y_min, y_max].

This follows the format of the extent input parameter in the matplotlib method imshow (and other methods) and is used for visualization in the plot module.

classmethod from_yx_1d(y: numpy.ndarray, x: numpy.ndarray) → autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular

Create Grid2DIrregular from a list of y and x values.

classmethod from_pixels_and_mask(pixels: Union[numpy.ndarray, List[T]], mask: autoarray.mask.mask_2d.Mask2D) → autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular

Create Grid2DIrregular from a list of coordinates in pixel units and a mask which allows these coordinates to be converted to scaled units.

in_list

Return the coordinates in a list.

values_from(array_slim: numpy.ndarray) → autoarray.structures.arrays.values.ValuesIrregular

Create a ValuesIrregular object from a 1D NumPy array of values of shape [total_coordinates]. The ValuesIrregular are structured following this Grid2DIrregular instance.

grid_from(grid_slim: numpy.ndarray) → Union[autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular, autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregularTransformed]

Create a Grid2DIrregular object from a 2D NumPy array of values of shape [total_coordinates, 2]. The Grid2DIrregular are structured following this Grid2DIrregular instance.

grid_via_deflection_grid_from(deflection_grid: numpy.ndarray) → autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular
Returns a new Grid2DIrregular from this grid coordinates, where the (y,x) coordinates of this grid have a

grid of (y,x) values, termed the deflection grid, subtracted from them to determine the new grid of (y,x) values.

This is used by PyAutoLens to perform grid ray-tracing.

Parameters:
deflection_grid

The grid of (y,x) coordinates which is subtracted from this grid.

structure_2d_from(result: Union[numpy.ndarray, List[T]]) → Union[autoarray.structures.arrays.values.ValuesIrregular, autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular, autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregularTransformed, List[T]]

Convert a result from a non autoarray structure to an aa.ValuesIrregular or aa.Grid2DIrregular structure, where the conversion depends on type(result) as follows:

  • 1D np.ndarray -> aa.ValuesIrregular
  • 2D np.ndarray -> aa.Grid2DIrregular
  • [1D np.ndarray] -> [aa.ValuesIrregular]
  • [2D np.ndarray] -> [aa.Grid2DIrregular]

This function is used by the grid_2d_to_structure decorator to convert the output result of a function to an autoarray structure when a Grid2DIrregular instance is passed to the decorated function.

Parameters:or [np.ndarray] (result) – The input result (e.g. of a decorated function) that is converted to a PyAutoArray structure.
structure_2d_list_from(result_list: List[T]) → List[Union[autoarray.structures.arrays.values.ValuesIrregular, autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular, autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregularTransformed]]

Convert a result from a list of non autoarray structures to a list of aa.ValuesIrregular or aa.Grid2DIrregular structures, where the conversion depends on type(result) as follows:

  • [1D np.ndarray] -> [aa.ValuesIrregular]
  • [2D np.ndarray] -> [aa.Grid2DIrregular]

This function is used by the grid_like_list_to_structure_list decorator to convert the output result of a function to a list of autoarray structure when a Grid2DIrregular instance is passed to the decorated function.

Parameters:or [np.ndarray] (result_list) – The input result (e.g. of a decorated function) that is converted to a PyAutoArray structure.
squared_distances_to_coordinate(coordinate: Tuple[float, float] = (0.0, 0.0)) → autoarray.structures.arrays.values.ValuesIrregular
Returns the squared distance of every (y,x) coordinate in this Coordinate instance from an input
coordinate.
Parameters:
coordinate

The (y,x) coordinate from which the squared distance of every Coordinate is computed.

distances_to_coordinate(coordinate: Tuple[float, float] = (0.0, 0.0)) → autoarray.structures.arrays.values.ValuesIrregular

Returns the distance of every (y,x) coordinate in this Coordinate instance from an input coordinate.

Parameters:
coordinate

The (y,x) coordinate from which the distance of every Coordinate is computed.

furthest_distances_to_other_coordinates

For every (y,x) coordinate on the Grid2DIrregular returns the furthest radial distance of each coordinate to any other coordinate on the grid.

For example, for the following grid:

grid=[(0.0, 0.0), (0.0, 1.0), (0.0, 3.0)]

The returned further distances are:

[3.0, 2.0, 3.0]

Returns:The further distances of every coordinate to every other coordinate on the irregular grid.
Return type:ValuesIrregular
grid_of_closest_from(grid_pair: Grid2DIrregular) → autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular

From an input grid, find the closest coordinates of this instance of the Grid2DIrregular to each coordinate on the input grid and return each closest coordinate as a new Grid2DIrregular.

Parameters:grid_pair – The grid of coordinates the closest coordinate of each (y,x) location is paired with.
Returns:The grid of coordinates corresponding to the closest coordinate of each coordinate of this instance of the Grid2DIrregular to the input grid.
Return type:Grid2DIrregular
classmethod from_json(file_path: str) → autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular

Create a Grid2DIrregular object from a file which stores the coordinates as a list of list of tuples.

Parameters:file_path (str) – The path to the coordinates .dat file containing the coordinates (e.g. ‘/path/to/coordinates.dat’)
output_to_json(file_path: str, overwrite: bool = False)

Output this instance of the Grid2DIrregular object to a list of list of tuples.

Parameters:
  • file_path (str) – The path to the coordinates .dat file containing the coordinates (e.g. ‘/path/to/coordinates.dat’)
  • overwrite (bool) – If there is as exsiting file it will be overwritten if this is True.
save(file_path: str, filename: str)

Save the tracer by serializing it with pickle.