autocti.Array1D#
- class autocti.Array1D(values: Union[ndarray, List], mask: Mask1D, header: Optional[Header] = None, store_native: bool = False, *args, **kwargs)[source]#
Bases:
StructureMethods
allReturns True if all elements evaluate to True.
anyReturns True if any of the elements of a evaluate to True.
argmaxReturn indices of the maximum values along the given axis.
argminReturn indices of the minimum values along the given axis.
argpartitionReturns the indices that would partition this array.
argsortReturns the indices that would sort this array.
astypeCopy of the array, cast to a specified type.
byteswapSwap the bytes of the array elements
chooseUse an index array to construct a new array from a set of choices.
clipReturn an array whose values are limited to
[min, max].compressReturn selected slices of this array along given axis.
conjComplex-conjugate all elements.
conjugateReturn the complex conjugate, element-wise.
copyReturn a copy of the array.
cumprodReturn the cumulative product of the elements along the given axis.
cumsumReturn the cumulative sum of the elements along the given axis.
diagonalReturn specified diagonals.
dotdumpDump a pickle of the array to the specified file.
dumpsReturns the pickle of the array as a string.
fillFill the array with a scalar value.
flattenReturn a copy of the array collapsed into one dimension.
Create an Array1D (see Array1D.__new__) by loading the array values from a .fits file.
Create an Array1D (see Array1D.__new__) where all values are filled with an input fill value, analogous to the method np.full().
getfieldReturns a field of the given array as a certain type.
itemCopy an element of an array to a standard Python scalar and return it.
itemsetInsert scalar into an array (scalar is cast to array's dtype, if possible)
maxReturn the maximum along a given axis.
meanReturns the average of the array elements along given axis.
minReturn the minimum along a given axis.
newbyteorderReturn the array with the same data viewed with a different byte order.
Create a Array1D (see Array1D.__new__) by inputting the array values in 1D
nonzeroReturn the indices of the elements that are non-zero.
Create an Array1D (see Array1D.__new__) where all values are filled with ones, analogous to the method np.ones().
Output the array to a .fits file.
partitionRearranges 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.
prodReturn the product of the array elements over the given axis
ptpPeak to peak (maximum - minimum) value along a given axis.
putSet
a.flat[n] = values[n]for all n in indices.ravelReturn a flattened array.
repeatRepeat elements of an array.
reshapeReturns an array containing the same data with a new shape.
resizeChange shape and size of array in-place.
roundReturn a with each element rounded to the given number of decimals.
searchsortedFind indices where elements of v should be inserted in a to maintain order.
setfieldPut a value into a specified place in a field defined by a data-type.
setflagsSet array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.
sortSort an array in-place.
squeezeRemove axes of length one from a.
stdReturns the standard deviation of the array elements along given axis.
structure_2d_fromstructure_2d_list_fromsumReturn the sum of the array elements over the given axis.
swapaxesReturn a view of the array with axis1 and axis2 interchanged.
takeReturn an array formed from the elements of a at the given indices.
tobytesConstruct Python bytes containing the raw data bytes in the array.
tofileWrite array to a file as text or binary (default).
tolistReturn the array as an
a.ndim-levels deep nested list of Python scalars.tostringA compatibility alias for tobytes, with exactly the same behavior.
traceReturn the sum along diagonals of the array.
transposeReturns a view of the array with axes transposed.
trimmed_after_convolution_fromvarReturns the variance of the array elements, along given axis.
viewNew view of array with the same data.
Create an Array1D (see Array1D.__new__) where all values are filled with zeros, analogous to the method np.zeros().
Attributes
TThe transposed array.
baseBase object if memory is from some other object.
ctypesAn object to simplify the interaction of the array with the ctypes module.
dataPython buffer object pointing to the start of the array's data.
derive_gridderive_indexesderive_maskdtypeData-type of the array's elements.
flagsInformation about the memory layout of the array.
flatA 1-D iterator over the array.
geometrygrid_radialimagThe imaginary part of the array.
itemsizeLength of one array element in bytes.
Return an Array1D where the data is stored in its native representation, which is an ndarray of shape [total_pixels * sub_size].
nbytesTotal bytes consumed by the elements of the array.
ndimNumber of array dimensions.
originpixel_areapixel_scalepixel_scalesreadout_offsetsrealThe real part of the array.
shapeTuple of array dimensions.
shape_nativeshape_slimsizeNumber of elements in the array.
Return an Array1D where the data is stored its slim representation, which is an ndarray of shape [total_unmasked_pixels * sub_size].
stridesTuple of bytes to step in each dimension when traversing an array.
sub_shape_nativesub_shape_slimsub_sizetotal_areatotal_pixelsunmasked_grid- classmethod no_mask(values: Union[ndarray, Tuple[float], List[float]], pixel_scales: Union[Tuple[float], Tuple[float, float], float], sub_size: int = 1, origin: Tuple[float] = (0.0,), header: Optional[Header] = None) Array1D[source]#
Create a Array1D (see Array1D.__new__) by inputting the array values in 1D
- Parameters:
values – The values of the array input as an ndarray of shape [total_unmasked_pixels*sub_size] or a list.
pixel_scales – The scaled units to pixel units conversion factor of the array data coordinates (e.g. the x-axis).
sub_size – The size of each unmasked pixels sub-grid.
origin – The origin of the 1D array’s mask.
Examples
import autoarray as aa # Make Array1D from input np.ndarray. array_1d = aa.Array1D.no_mask(values=np.array([1.0, 2.0, 3.0, 4.0]), pixel_scales=1.0) # Make Array2D from input list. array_1d = aa.Array1D.no_mask(values=[1.0, 2.0, 3.0, 4.0], pixel_scales=1.0) # Print array's slim (masked 1D data representation) and # native (masked 1D data representation) print(array_1d.slim) print(array_1d.native)
- classmethod full(fill_value: float, shape_native: Union[int, Tuple[int]], pixel_scales: Union[Tuple[float], Tuple[float, float], float], sub_size: int = 1, origin: Tuple[float] = (0.0,), header: Optional[Header] = None) Array1D[source]#
Create an Array1D (see Array1D.__new__) where all values are filled with an input fill value, analogous to the method np.full().
From 1D input the method cannot determine the 1D shape of the array and its mask, thus the shape_native must be input into this method. The mask is setup as a unmasked Mask1D of size shape_native.
- Parameters:
fill_value – The value all array elements are filled with.
shape_native (Tuple[int]) – The 1D shape of the mask the array is paired with.
pixel_scales – The (y,x) scaled units to pixel units conversion factors of every pixel. If this is input as a float, it is converted to a (float,) structure.
sub_size – The size (sub_size) of each unmasked pixels sub-array.
origin ((float,)) – The (x) scaled units origin of the mask’s coordinate system.
- classmethod zeros(shape_native: Union[int, Tuple[int]], pixel_scales: Union[Tuple[float], Tuple[float, float], float], sub_size: int = 1, origin: Tuple[float] = (0.0,), header: Optional[Header] = None) Array1D[source]#
Create an Array1D (see Array1D.__new__) where all values are filled with zeros, analogous to the method np.zeros().
From 1D input the method cannot determine the 1D shape of the array and its mask, thus the shape_native must be input into this method. The mask is setup as a unmasked Mask1D of size shape_native.
- Parameters:
shape_native (Tuple[int]) – The 1D shape of the mask the array is paired with.
pixel_scales – The (y,x) scaled units to pixel units conversion factors of every pixel. If this is input as a float, it is converted to a (float,) structure.
sub_size – The size (sub_size) of each unmasked pixels sub-array.
origin ((float,)) – The (x) scaled units origin of the mask’s coordinate system.
- classmethod ones(shape_native: Union[int, Tuple[int]], pixel_scales: Union[Tuple[float], Tuple[float, float], float], sub_size: int = 1, origin: Tuple[float] = (0.0,), header: Optional[Header] = None) Array1D[source]#
Create an Array1D (see Array1D.__new__) where all values are filled with ones, analogous to the method np.ones().
From 1D input the method cannot determine the 1D shape of the array and its mask, thus the shape_native must be input into this method. The mask is setup as a unmasked Mask1D of size shape_native.
- Parameters:
shape_native (Tuple[int]) – The 1D shape of the mask the array is paired with.
pixel_scales – The (y,x) scaled units to pixel units conversion factors of every pixel. If this is input as a float, it is converted to a (float,) structure.
sub_size – The size (sub_size) of each unmasked pixels sub-array.
origin ((float,)) – The (x) scaled units origin of the mask’s coordinate system.
- classmethod from_fits(file_path: str, pixel_scales: Union[Tuple[float], Tuple[float, float], float], hdu: int = 0, sub_size: int = 1, origin: Tuple[float] = (0.0, 0.0)) Array1D[source]#
Create an Array1D (see Array1D.__new__) by loading the array values from a .fits file.
- Parameters:
file_path – The path the file is loaded from, including the filename and the .fits extension, e.g. ‘/path/to/filename.fits’
hdu – The Header-Data Unit of the .fits file the array data is loaded from.
pixel_scales – The (x,) scaled units to pixel units conversion factors of every pixel. If this is input as a float, it is converted to a (float,) structure.
sub_size – The sub-size of each unmasked pixels sub-array.
origin – The (x,) scaled units origin of the coordinate system.
- property slim: Array1D#
Return an Array1D where the data is stored its slim representation, which is an ndarray of shape [total_unmasked_pixels * sub_size].
If it is already stored in its slim representation it is returned as it is. If not, it is mapped from native to slim and returned as a new Array1D.
- property native: Array1D#
Return an Array1D where the data is stored in its native representation, which is an ndarray of shape [total_pixels * sub_size].
If it is already stored in its native representation it is return as it is. If not, it is mapped from slim to native and returned as a new Array1D.
- output_to_fits(file_path: str, overwrite: bool = False)[source]#
Output the array to a .fits file.
- Parameters:
file_path – The output path of the file, including the filename and the .fits extension e.g. ‘/path/to/filename.fits’
overwrite – If a file already exists at the path, if overwrite=True it is overwritten else an error is raised.