Coordinate2D

class sofia_redux.scan.coordinate_systems.coordinate_2d.Coordinate2D(coordinates=None, unit=None, copy=True)[source]

Bases: Coordinate

The Coordinate2D is a specialized extension of the Coordinate class for 2-dimensional (x, y) data.

Initialize a coordinate.

The Coordinate class is a generic container to store and operate on a set of coordinates.

Parameters:
coordinateslist or tuple or array-like or units.Quantity, optional

The coordinates used to populate the object during initialization.

unitstr or units.Unit or units.Quantity, optional

The units of the internal coordinates.

copybool, optional

If True, populate these coordinates with a copy of coordinates rather than the actual coordinates.

Attributes Summary

default_dimensions

length

Return the distance of the coordinate from (0, 0).

max

Return the (x, y) maximum values.

min

Return the (x, y) minimum values.

ndim

Return the number of dimensions in the coordinate.

singular

Return if the coordinates are scalar in nature (not an array).

span

Return the range of x and y values.

x

Return the x coordinate.

y

Return the y coordinate.

Methods Summary

add(coordinates)

Add other coordinates to these.

add_x(x)

Add x to coordinates.

add_y(y)

Add y to coordinates.

angle([center])

Return the angle between the x and y coordinates w.r.t a center.

copy()

Return a copy of the Coordinate2D.

copy_coordinates(coordinates)

Copy the coordinates from another system to this system.

edit_header(header, key_stem[, alt])

Edit a FITS header with the coordinate information.

empty_copy()

Return an unpopulated instance of the coordinates.

get_indices(indices)

Return selected data for given indices.

invert()

Scale the x and y coordinates by -1.

invert_x()

Scale the x-coordinates by -1.

invert_y()

Scale the y-coordinates by -1.

parse_header(header, key_stem[, alt, default])

Parse a header and return a Coordinate2D for the desired stem.

plot(*args, **kwargs)

Plot the coordinates.

rotate(angle)

Rotate the coordinates by a given angle.

rotate_offsets(offsets, angle)

Rotate zero-centered offsets in-place by an angle.

scale(factor)

Scale the coordinates by a factor.

scale_x(factor)

Scale the x coordinates by a factor.

scale_y(factor)

Scale the y coordinates by a factor.

set(coordinates[, copy])

Set the (x, y) coordinates.

set_singular([empty])

Create a single coordinate.

set_x(coordinates[, copy])

Set the x coordinates.

set_y(coordinates[, copy])

Set the y coordinates.

subtract(coordinates)

Subtract other coordinates from these.

subtract_x(x)

Subtract x from coordinates.

subtract_y(y)

Subtract y from coordinates.

Attributes Documentation

default_dimensions = 2
length

Return the distance of the coordinate from (0, 0).

Returns:
distancefloat or numpy.ndarray or astropy.units.Quantity
max

Return the (x, y) maximum values.

Returns:
Coordinate2D
min

Return the (x, y) minimum values.

Returns:
Coordinate2D
ndim

Return the number of dimensions in the coordinate.

Returns:
dimensionsint
singular

Return if the coordinates are scalar in nature (not an array).

Returns:
bool
span

Return the range of x and y values.

Returns:
Coordinate2D
x

Return the x coordinate.

Returns:
float or numpy.ndarray (float)
y

Return the y coordinate.

Returns:
float or numpy.ndarray (float)

Methods Documentation

add(coordinates)[source]

Add other coordinates to these.

Parameters:
coordinatesCoordinate2D
Returns:
None
add_x(x)[source]

Add x to coordinates.

Parameters:
xfloat or numpy.ndarray

The value(s) to add.

Returns:
None
add_y(y)[source]

Add y to coordinates.

Parameters:
yfloat or numpy.ndarray

The value(s) to add.

Returns:
None
angle(center=None)[source]

Return the angle between the x and y coordinates w.r.t a center.

Parameters:
centerCoordinate2D, optional

The center about which to find an origin.

Returns:
units.Quantity
copy()[source]

Return a copy of the Coordinate2D.

Returns:
Coordinate2D
copy_coordinates(coordinates)[source]

Copy the coordinates from another system to this system.

Parameters:
coordinatesCoordinate2D
Returns:
None
edit_header(header, key_stem, alt='')[source]

Edit a FITS header with the coordinate information.

Parameters:
headerfits.Header
key_stemstr

The name of the coordinate in the FITS header. The name of the x coordinate in the header will be {key_stem}1, and y will be {key_stem}2.

altstr, optional

The alternate FITS header system.

Returns:
None
empty_copy()[source]

Return an unpopulated instance of the coordinates.

Returns:
Coordinate2D
get_indices(indices)[source]

Return selected data for given indices.

Parameters:
indicesslice or list or int or numpy.ndarray (int)

The indices to extract.

Returns:
Coordinate2D
invert()[source]

Scale the x and y coordinates by -1.

Returns:
None
invert_x()[source]

Scale the x-coordinates by -1.

Returns:
None
invert_y()[source]

Scale the y-coordinates by -1.

Returns:
None
parse_header(header, key_stem, alt='', default=None)[source]

Parse a header and return a Coordinate2D for the desired stem.

Parameters:
headerfits.Header
key_stemstr
altstr, optional
defaultCoordinate2D or numpy.ndarray, optional
Returns:
None
plot(*args, **kwargs)[source]

Plot the coordinates.

Parameters:
argsvalues

Optional positional parameters to pass into pyplot.plot.

kwargsdict, optional

Optional keyword arguments.

Returns:
None
rotate(angle)[source]

Rotate the coordinates by a given angle.

Internal coordinates are rotated anti-clockwise about zero.

Parameters:
angleunits.Quantity
Returns:
None
classmethod rotate_offsets(offsets, angle)[source]

Rotate zero-centered offsets in-place by an angle.

Offsets are rotated anti-clockwise.

Parameters:
offsetsCoordinate2D or numpy.ndarray or units.Quantity or None

The (x, y) offset coordinates to rotate.

angleastropy.units.Quantity or float

The angle by which to rotate the offsets. If a float value is provided, it should be in radians.

Returns:
None
scale(factor)[source]

Scale the coordinates by a factor.

Parameters:
factorint or float or Coordinate2D
Returns:
None
scale_x(factor)[source]

Scale the x coordinates by a factor.

Parameters:
factorfloat or units.Quantity

The factor by which to scale the x-coordinates.

Returns:
None
scale_y(factor)[source]

Scale the y coordinates by a factor.

Parameters:
factorfloat

The factor by which to scale the y-coordinates.

Returns:
None
set(coordinates, copy=True)[source]

Set the (x, y) coordinates.

Parameters:
coordinatesnumpy.ndarray or list
copybool, optional

If True, copy the coordinates. Otherwise do a reference.

Returns:
None
set_singular(empty=False)[source]

Create a single coordinate.

Parameters:
emptybool, optional

If True, create an empty coordinate array. Otherwise, create a zeroed array.

Returns:
None
set_x(coordinates, copy=True)[source]

Set the x coordinates.

Parameters:
coordinatesfloat or numpy.ndarray
copybool, optional

If True, copy the coordinates. Otherwise do a reference.

Returns:
None
set_y(coordinates, copy=True)[source]

Set the y coordinates.

Parameters:
coordinatesnumpy.ndarray
copybool, optional

If True, copy the coordinates. Otherwise do a reference.

Returns:
None
subtract(coordinates)[source]

Subtract other coordinates from these.

Parameters:
coordinatesCoordinate2D
Returns:
None
subtract_x(x)[source]

Subtract x from coordinates.

Parameters:
xfloat or numpy.ndarray

The value(s) to subtract.

Returns:
None
subtract_y(y)[source]

Subtract y from coordinates.

Parameters:
yfloat or numpy.ndarray or astropy.units.Quantity

The value(s) to subtract.

Returns:
None