Frame and axes

A Frame holds the coordinate axes of a Datafield. It describes binning and coordinates; the values belong to the field.

Create axes and a frame

import bornagain as ba

x_axis = ba.EquiDivision("x (nm)", 3, 0, 3)
y_axis = ba.EquiDivision("y (nm)", 2, 0, 2)
frame = ba.Frame(x_axis, y_axis)

Use ba.Frame(x_axis) for one dimension. Axis constructors return a Scale:

Constructor Coordinates
ba.EquiDivision(label, n, start, end) n bins between outer bounds.
ba.EquiScan(label, n, start, end) n points, endpoints included.
ba.ListScan(label, points) Explicit scan points in increasing order.
ba.GenericScale(label, limits) Flat list of lower/upper bin-edge pairs.

For example, EquiDivision("x", 3, 0, 3) has centers 0.5, 1.5, 2.5, whereas EquiScan("x", 3, 0, 3) has points 0, 1.5, 3. A label describes the coordinates; it does not convert the supplied numbers to another unit.

Axes of a Datafield

frame = datafield.frame()
x_axis = datafield.xAxis()
print(x_axis.size(), x_axis.min(), x_axis.max())

Keep the field alive while using its frame or axes. For an independent frame, use ba.Frame(datafield.frame()). To transform a field together with its axes, see Axis coordinates and transformations.

All operations

Frame

Operation Result
rank() Number of axes.
size() Total number of bins, the product of the axis sizes.
axis(k) Axis k, numbered from zero.
xAxis() First axis.
yAxis() Second axis, for a 2D frame.
allIndices(i) Bin index on each axis for flat index i.
projectedIndex(i, k) Bin index on axis k for flat index i.
projectedCoord(i, k) Bin center on axis k for flat index i.
hasSameSizes(other) Whether the rank and axis sizes agree.
frame == other Whether the axes are equal.
flat() Copy with single-bin axes removed.
plottableFrame() Copy with axes in display units, such as degrees.

Axis

Operation Result
size() Number of bins.
binCenter(i) Center of bin i.
binCenters() Centers of all bins.
min() Lower outer bound.
max() Upper outer bound.
bounds() Both outer bounds, as (min, max).
span() Distance between the outer bounds.
axisLabel() Coordinate label, including its unit.
rangeComprises(value) Whether min() <= value < max().