autolens.ArrayIrregular#

class ArrayIrregular[source]#

Bases: Structure

A collection of values which are structured as follows:

[value0, value1, value3]

The values object does not store the values as a list of floats, but instead a 1D NumPy array of shape [total_values]. This array can be mapped to the list of floats structure above. They are stored as a NumPy array so the values can be used efficiently for calculations.

The values input to this function can have any of the following forms:

[value0, value1]

In all cases, they will be converted to a list of floats followed by a 1D NumPy array.

Print methods are overridden so a user always “sees” the values as the list structure.

In contrast to a Array2D structure, ArrayIrregular do not lie on a uniform grid or correspond to values that originate from a uniform grid. Therefore, when handling irregular data-sets ArrayIrregular should be used.

Parameters

values ([float] or equivalent) – A collection of values.

Methods

all

Returns True if all elements evaluate to True.

any

Returns True if any of the elements of a evaluate to True.

argmax

Return indices of the maximum values along the given axis.

argmin

Return indices of the minimum values along the given axis.

argpartition

Returns the indices that would partition this array.

argsort

Returns the indices that would sort this array.

astype

Copy of the array, cast to a specified type.

byteswap

Swap the bytes of the array elements

choose

Use an index array to construct a new array from a set of choices.

clip

Return an array whose values are limited to [min, max].

compress

Return selected slices of this array along given axis.

conj

Complex-conjugate all elements.

conjugate

Return the complex conjugate, element-wise.

copy

Return a copy of the array.

cumprod

Return the cumulative product of the elements along the given axis.

cumsum

Return the cumulative sum of the elements along the given axis.

diagonal

Return specified diagonals.

dot

dump

Dump a pickle of the array to the specified file.

dumps

Returns the pickle of the array as a string.

fill

Fill the array with a scalar value.

flatten

Return a copy of the array collapsed into one dimension.

flip_hdu_for_ds9

from_file

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

getfield

Returns a field of the given array as a certain type.

grid_from

Create a Grid2DIrregular object from a 2D ndarray array of values of shape [total_values, 2].

item

Copy an element of an array to a standard Python scalar and return it.

itemset

Insert scalar into an array (scalar is cast to array's dtype, if possible)

max

Return the maximum along a given axis.

mean

Returns the average of the array elements along given axis.

min

Return the minimum along a given axis.

newbyteorder

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_fits

Output the grid to a .fits file.

output_to_json

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

partition

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

Return the product of the array elements over the given axis

ptp

Peak to peak (maximum - minimum) value along a given axis.

put

Set a.flat[n] = values[n] for all n in indices.

ravel

Return a flattened array.

repeat

Repeat elements of an array.

reshape

Returns an array containing the same data with a new shape.

resize

Change shape and size of array in-place.

round

Return a with each element rounded to the given number of decimals.

searchsorted

Find indices where elements of v should be inserted in a to maintain order.

setfield

Put a value into a specified place in a field defined by a data-type.

setflags

Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.

sort

Sort an array in-place.

squeeze

Remove axes of length one from a.

std

Returns the standard deviation of the array elements along given axis.

structure_2d_from

rtype

Structure

structure_2d_list_from

rtype

List[Structure]

sum

Return the sum of the array elements over the given axis.

swapaxes

Return a view of the array with axis1 and axis2 interchanged.

take

Return an array formed from the elements of a at the given indices.

tobytes

Construct Python bytes containing the raw data bytes in the array.

tofile

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

A compatibility alias for tobytes, with exactly the same behavior.

trace

Return the sum along diagonals of the array.

transpose

Returns a view of the array with axes transposed.

trimmed_after_convolution_from

rtype

Structure

values_from

Create a ArrayIrregular object from a 1D ndarray of values of shape [total_values].

var

Returns the variance of the array elements, along given axis.

view

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.

derive_grid

rtype

DeriveGrid2D

derive_indexes

rtype

DeriveIndexes2D

derive_mask

rtype

DeriveMask2D

dtype

Data-type of the array's elements.

flags

Information about the memory layout of the array.

flat

A 1-D iterator over the array.

geometry

hdu_for_output

imag

The imaginary part of the array.

in_list

Return the values in a list.

itemsize

Length of one array element in bytes.

native

Returns the data structure in its native format which contains all unmaksed values to the native dimensions.

nbytes

Total bytes consumed by the elements of the array.

ndim

Number of array dimensions.

origin

rtype

Tuple[int, ...]

pixel_area

pixel_scale

rtype

float

pixel_scale_header

rtype

Dict

pixel_scales

rtype

Tuple[float, ...]

real

The real part of the array.

shape

Tuple of array dimensions.

shape_native

rtype

Tuple[int, ...]

shape_slim

rtype

int

size

Number of elements in the array.

slim

The ArrayIrregular in their slim representation, a 1D ndarray of shape [total_values].

strides

Tuple of bytes to step in each dimension when traversing an array.

sub_shape_native

rtype

Tuple[int, ...]

sub_shape_slim

rtype

int

sub_size

rtype

int

total_area

total_pixels

rtype

int

unmasked_grid

rtype

Union[Grid1D, Grid2D]

property slim: ArrayIrregular#

The ArrayIrregular in their slim representation, a 1D ndarray of shape [total_values].

Return type

ArrayIrregular

property in_list: List#

Return the values in a list.

Return type

List

values_from(array_slim)[source]#

Create a ArrayIrregular object from a 1D ndarray of values of shape [total_values].

The returned values have an identical structure to this ArrayIrregular instance.

Parameters

array_slim (ndarray) – The 1D ndarray with (hape [total_values] whose values are mapped to a ArrayIrregular object.

Return type

ArrayIrregular

grid_from(grid_slim)[source]#

Create a Grid2DIrregular object from a 2D ndarray array of values of shape [total_values, 2].

The returned grid are structured following this ArrayIrregular instance.

Parameters

grid_slim (ndarray) – The 2d array (shape [total_coordinates, 2]) of (y,x) coordinates that are mapped to a Grid2DIrregular object.

Return type

Grid2DIrregular

classmethod from_file(file_path)[source]#

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

Parameters

file_path (Union[Path, str]) – The path to the coordinates .dat file containing the coordinates (e.g. ‘/path/to/coordinates.dat’)

Return type

ArrayIrregular

output_to_json(file_path, overwrite=False)[source]#

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

Parameters
  • file_path (Union[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.