WallGo.fields
Classes for Fields and FieldPoint objects that hold information about the background fields.
Classes
|
FieldPoint is a subclass of numpy's ndarray, representing a point in a field with certain constraints. |
|
Simple class for holding collections of background fields in a common format. |
- class FieldPoint(arr)[source]
FieldPoint is a subclass of numpy’s ndarray, representing a point in a field with certain constraints.
- Parameters:
arr (ndarray)
- Return type:
- getField(i)[source]
Retrieve the field value at the specified index.
- Parameters:
i (int) – The index of the field to retrieve.
- Returns:
fieldValue – The value of the field at the specified index.
- Return type:
float
- numFields()[source]
Calculate the number of background fields.
This method returns the number of background fields contained within the object.
- Returns:
nFields – The number of background fields.
- Return type:
int
- class Fields(*fieldSpacePoints)[source]
Simple class for holding collections of background fields in a common format.
If the theory has N background fields, then a field-space point is defined by a list of length
N. This array describes a collection of field-space points, so that the shape is(numPoints, numFields). Each row represents one field-space point. This is always a 2D array, even if we just have one field-space point.- Parameters:
fieldSpacePoints (Tuple[FieldPoint])
- Return type:
- static castFromNumpy(arr)[source]
Cast a NumPy array to a Fields object.
- Parameters:
arr (np.ndarray) – The input NumPy array. It can be either 1D or 2D.
- Returns:
fields – A Fields object created from the input NumPy array.
- Return type:
- Raises:
AssertionError : – If the input array has more than 2 dimensions.
- getField(i)[source]
Get field at index
i. I.e. if the theory has \(N\) background fields \(f_j\) with \(j\in 0, 1, \dots, N-1\), this will give all values of the field \(f_{i}\) as a 1D array.- Parameters:
i (int)
- Return type:
ndarray
- getFieldPoint(i)[source]
Get a field space point. It would be a 1D array, but we cast to a FieldPoint object for consistency. NB: no validation so will error if the index is out of bounds
- Parameters:
i (int)
- Return type:
- getFieldPreserveShape(i)[source]
Retrieve a field while preserving the original shape of the Fields object.
This method returns an array of the same shape as the original Fields object, but with all elements set to zero except for those corresponding to the specified field index.
- Parameters:
i (int) – The index of the field to retrieve.
- Returns:
arr – An array of the same shape as the original Fields object, with only the values of the specified field index preserved.
- Return type:
np.ndarray
- resizeFields(newNumPoints, newNumFields)[source]
Returns a resized array (uses np.resize internally)
- Parameters:
newNumPoints (int)
newNumFields (int)
- Return type:
- setField(i, fieldArray)[source]
Set new values to the field at the specified index.
- Parameters:
i (int) – The index at which to set the new field values.
fieldArray (np.ndarray) – The array containing the new field values.
- Returns:
fields (Fields) – The updated Fields object with the new values set at
the specified index.
- Return type:
- takeSlice(idxStart, idxEnd, axis)[source]
Extracts a slice from the array along the specified axis.
- Parameters:
idxStart (int) – The starting index of the slice (inclusive).
idxEnd (int) – The ending index of the slice (inclusive).
axis (int) – The axis along which to take the slice.
- Returns:
arr – A sliced portion of the array as a numpy ndarray.
- Return type:
np.ndarray
Notes
The method does not perform range checking on the indices.
The output is cast to a Fields object.