Positions

class galsim.Position[source]

A class for representing 2D positions on the plane.

Position is a base class for two slightly different kinds of positions: PositionD describes positions with floating point values in x and y. PositionI described positions with integer values in x and y.

In the C++ layer, these are templates, but of course no such thing exists in Python, so the trailing D or I indicate the type.

Initialization:

For the float-valued position class, example initializations include:

>>> pos = galsim.PositionD(x=0.5, y=-0.5)
>>> pos = galsim.PositionD(0.5, -0.5)
>>> pos = galsim.PositionD( (0.5, -0.5) )

And for the integer-valued position class, example initializations include:

>>> pos = galsim.PositionI(x=45, y=13)
>>> pos = galsim.PositionI(45, 13)
>>> pos = galsim.PositionD( (45, 15) )
Attributes:
  • x – The x component of the position

  • y – The y component of the position

Arithmetic:

Most arithmetic that makes sense for a position is allowed:

>>> pos1 + pos2
>>> pos1 - pos2
>>> pos * x
>>> pos / x
>>> -pos
>>> pos1 += pos2
>>> pos1 -= pos2
>>> pos *= x
>>> pos -= x

Note though that the types generally need to match. For example, you cannot multiply a PositionI by a float add a PositionD to a PositionI in place.

Position instances can be sheared by a galsim.Shear:

>>> pos = galsim.PositionD(x=0.5, y=-0.5)
>>> shear = galsim.Shear(g1=0.1, g2=-0.1)
>>> sheared_pos = pos.shear(shear)

Note that this operation will always return a PositionD even if an integer position is being sheared.

shear(shear)[source]

Shear the position.

See the doc string of galsim.Shear.getMatrix for more details.

Parameters:

shear – a galsim.Shear instance

Returns:

a galsim.PositionD instance.

class galsim.PositionI(*args, **kwargs)[source]

Bases: Position

A Position that takes only integer values.

Typically used for coordinate positions on an image.

See the Position doc string for more details.

class galsim.PositionD(*args, **kwargs)[source]

Bases: Position

A Position that takes floating point values.

See the Position doc string for more details.

round()[source]

Return the rounded-off PositionI version of this position.