arange#

ctis.arange(start, stop, axis, step=1)[source]#

Return evenly-spaced values over a range, centered within it.

This is the centered counterpart of named_arrays.arange(), which starts exactly at start and leaves the remainder of the range as a gap on the right. ctis.arange() fits as many samples spaced by step as possible into [start, stop] and centers them, splitting the leftover evenly between the two ends. This is convenient for building a coordinate grid with a fixed pitch that is centered on a field of view rather than biased toward one edge.

Unlike named_arrays.arange(), this is built on named_arrays.linspace(), so it works correctly when the arguments are astropy.units.Quantity instances.

If start, stop, and step are instances of named_arrays.AbstractVectorArray, each component is centered independently along its own axis (given by the matching component of axis), producing an outer-product grid.

Parameters:
Return type:

AbstractArray

Examples

named_arrays.arange() starts at start, leaving the remainder of the range as a gap on the right.

import named_arrays as na
import ctis

na.arange(0, 10, axis="x", step=3)
ScalarArray(
    ndarray=[0, 3, 6, 9],
    axes=('x',),
)

ctis.arange() uses the same samples and step, but splits that remainder evenly between the two ends of the range.

ctis.arange(0, 10, axis="x", step=3)
ScalarArray(
    ndarray=[0.5, 3.5, 6.5, 9.5],
    axes=('x',),
)

Vector arguments produce a centered grid, with each component sampled independently along its own axis.

import astropy.units as u

ctis.arange(
    start=na.Cartesian2dVectorArray(-10, -8) * u.arcsec,
    stop=na.Cartesian2dVectorArray(10, 8) * u.arcsec,
    axis=na.Cartesian2dVectorArray("x", "y"),
    step=na.Cartesian2dVectorArray(6, 5) * u.arcsec,
)
Cartesian2dVectorArray(
    x=ScalarArray(
        ndarray=[-9., -3.,  3.,  9.] arcsec,
        axes=('x',),
    ),
    y=ScalarArray(
        ndarray=[-7.5, -2.5,  2.5,  7.5] arcsec,
        axes=('y',),
    ),
)