Skip to content

Commit 0a081b8

Browse files
Jammy2211Copilot
andauthored
Update autoarray/geometry/geometry_2d.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent df52fa4 commit 0a081b8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

autoarray/geometry/geometry_2d.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,29 @@ def pixel_coordinates_wcs_2d_from(
194194
self, scaled_coordinates_2d: Tuple[float, float]
195195
) -> Tuple[float, float]:
196196
"""
197-
Convert a 2D (y,x) scaled coordinate to a 2D (y,x) pixel coordinate, which are returned as floats such that they
198-
include the decimal offset from each pixel's top-left corner relative to the input scaled coordinate.
197+
Convert a 2D (y,x) scaled coordinate to a 2D (y,x) WCS/FITS-style pixel coordinate.
199198
200-
The conversion is performed according to the 2D geometry on a uniform grid, where the pixel coordinate origin
201-
is at the top left corner, such that the pixel [0,0] corresponds to the highest (most positive) y scaled
202-
coordinate and lowest (most negative) x scaled coordinate on the gird.
199+
The returned pixel coordinates follow the standard WCS convention:
203200
204-
The scaled coordinate is defined by an origin and coordinates are shifted to this origin before computing their
205-
1D grid pixel coordinate values.
201+
- Coordinates are 1-based rather than 0-based, so that the centre of the top-left pixel is at (y, x) = (1.0, 1.0).
202+
- Coordinates refer to pixel centres, not pixel corners.
203+
- Values are continuous floats, so the fractional part encodes the sub-pixel offset from the pixel centre.
204+
205+
This differs from integer pixel-index conversions (e.g. ``pixel_coordinates_2d_from``), which return 0-based
206+
indices associated with pixel corners/top-left positions.
207+
208+
The mapping from scaled coordinates to WCS pixel coordinates is defined by this geometry's ``origin``: scaled
209+
coordinates are first shifted by the specified origin(s) before being converted using the pixel scale and
210+
array shape. Changing ``origin`` therefore translates the returned WCS pixel coordinates by a constant offset.
206211
207212
Parameters
208213
----------
209214
scaled_coordinates_2d
210-
The 2D (y,x) coordinates in scaled units which are converted to pixel coordinates.
215+
The 2D (y,x) coordinates in scaled units to be converted to WCS-style pixel coordinates.
211216
212217
Returns
213218
-------
214-
A 2D (y,x) pixel-value coordinate.
219+
A 2D (y,x) WCS pixel coordinate, expressed as 1-based, pixel-centre, floating-point values.
215220
"""
216221
return geometry_util.pixel_coordinates_wcs_2d_from(
217222
scaled_coordinates_2d=scaled_coordinates_2d,

0 commit comments

Comments
 (0)