NewStyleField

class hcipy.field.NewStyleField(data, grid=None)[source]

Bases: FieldBase

The value of some physical quantity for each point in some coordinate system.

Parameters:
dataarray or Field

An array of values or tensors for each point in the Grid.

gridGrid or None

The corresponding Grid on which these values are set. The default (None) indicates that there is no grid associated with this Field.

Attributes:
dataarray

An array of values or tensors for each point in the Grid.

gridGrid or None

The corresponding Grid on which these values are set. When this is None, this indicates that there is no grid associated with this Field.

Attributes Summary

T

Tranpose of the array.

data

device

The hardware device the array data resides on.

dtype

The data type of the array elements.

grid

imag

The imaginary part of the field.

mT

The transpose of a matrix or stack of matrices.

ndim

The number of axes in the array.

real

The real part of the field.

shape

The dimensions of the array.

size

The number of elements in the array.

trace

transpose

Methods Summary

all(*[, axis, keepdims])

any(*[, axis, keepdims])

argmax(*[, axis, keepdims])

argmin(*[, axis, keepdims])

argsort(*[, axis, stable])

astype(dtype, /, *[, copy, device])

clip([min, max])

conj()

conjugate()

copy()

Create a copy of the field.

cumprod(*[, axis, dtype, include_initial])

cumsum(*[, axis, dtype, include_initial])

cumulative_prod(*[, axis, dtype, ...])

cumulative_sum(*[, axis, dtype, include_initial])

dot(b)

flatten()

Return a flattened field.

from_dict(val)

Create a Field from a dict.

max(*[, axis, keepdims])

mean(*[, axis, keepdims])

min(*[, axis, keepdims])

nonzero()

prod(*[, axis, dtype, keepdims])

ravel()

Return a flattened field.

repeat(repeats, /, *[, axis])

Repeat elements of a field.

reshape(shape, *[, copy])

round()

sort(*[, axis, stable])

squeeze(*[, axis])

std(*[, axis, correction, keepdims])

sum(*[, axis, dtype, keepdims])

to_device(device, /, *[, stream])

Copy the Field from the device on which it currently resides to the specified device.

to_dict()

Convert the Field to a dict.

var(*[, axis, correction, keepdims])

Attributes Documentation

T

Tranpose of the array.

data
device

The hardware device the array data resides on.

dtype

The data type of the array elements.

grid
imag

The imaginary part of the field.

mT

The transpose of a matrix or stack of matrices.

ndim

The number of axes in the array.

real

The real part of the field.

shape

The dimensions of the array.

size

The number of elements in the array.

trace = None
transpose = None

Methods Documentation

all(*, axis=None, keepdims=False)
any(*, axis=None, keepdims=False)
argmax(*, axis=None, keepdims=False)
argmin(*, axis=None, keepdims=False)
argsort(*, axis=-1, stable=True)
astype(dtype, /, *, copy=True, device=None)
clip(min=None, max=None)
conj()
conjugate()
copy()[source]

Create a copy of the field.

Returns:
Field

The copied field.

cumprod(*, axis=None, dtype=None, include_initial=False)
cumsum(*, axis=None, dtype=None, include_initial=False)
cumulative_prod(*, axis=None, dtype=None, include_initial=False)
cumulative_sum(*, axis=None, dtype=None, include_initial=False)
dot(b)[source]
flatten()[source]

Return a flattened field.

A copy is made only when needed.

Returns:
Field

A contiguous 1-D field with the same datatype.

classmethod from_dict(val)[source]

Create a Field from a dict.

Parameters:
valdict

A dictionary generated from Field.to_dict().

Returns:
Field

The created field.

max(*, axis=None, keepdims=False)
mean(*, axis=None, keepdims=False)
min(*, axis=None, keepdims=False)
nonzero()
prod(*, axis=None, dtype=None, keepdims=False)
ravel()[source]

Return a flattened field.

A copy is made only when needed.

Returns:
Field

A contiguous 1-D field with the same datatype.

repeat(repeats, /, *, axis=None)[source]

Repeat elements of a field.

Parameters:
repeatsint or array of ints

The number of repetitions for each element.

axisint, optional

The axis (dimension) along which to repeat elements. If this is None (default), the field is is flattened first after which elements are repeated. The flattened field is returned.

Returns:
Field

The output field containing repeated elements.

reshape(shape, *, copy=None)
round()
sort(*, axis=-1, stable=True)
squeeze(*, axis=None)
std(*, axis=None, correction=0.0, keepdims=False)
sum(*, axis=None, dtype=None, keepdims=False)
to_device(device, /, *, stream=None)[source]

Copy the Field from the device on which it currently resides to the specified device.

Parameters:
devicedevice

A device object.

streamstream or None

The stream to use. For CUDA and ROCm, a Python integer representing a pointer to a stream, on devices that support streams. stream is provided by the consumer to the producer to instruct the producer to ensure that operations can safely be performed on the array (e.g., by inserting a dependency between streams via “wait for event”). The pointer must be an integer larger than or equal to -1 (see below for allowed values on each platform). If stream is -1, the value may be used by the consumer to signal “producer must not perform any synchronization”. The ownership of the stream stays with the consumer. On CPU and other device types without streams, only None is accepted.

Returns:
Field

An array with the same data and data type as self and located on the specified device.

to_dict()[source]

Convert the Field to a dict.

Returns:
dict

The created dict.

var(*, axis=None, correction=0.0, keepdims=False)