Coverage for python/lsst/meas/extensions/trailedSources/NaivePlugin.py: 84%
238 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-14 09:57 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-14 09:57 +0000
1#
2# This file is part of meas_extensions_trailedSources.
3#
4# Developed for the LSST Data Management System.
5# This product includes software developed by the LSST Project
6# (http://www.lsst.org).
7# See the COPYRIGHT file at the top-level directory of this distribution
8# for details of code ownership.
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
24import logging
25import numpy as np
26import scipy.optimize as sciOpt
27from scipy.special import erf
28from math import sqrt
30from lsst.geom import Point2D, Point2I, arcseconds
31from lsst.meas.base.pluginRegistry import register
32from lsst.meas.base import SingleFramePlugin, SingleFramePluginConfig
33from lsst.meas.base import FlagHandler, FlagDefinitionList
34import lsst.pex.config
36from ._trailedSources import VeresModel
37from .utils import getMeasurementCutout
39__all__ = ("SingleFrameNaiveTrailConfig", "SingleFrameNaiveTrailPlugin")
42class SingleFrameNaiveTrailConfig(SingleFramePluginConfig):
43 """Config class for SingleFrameNaiveTrailPlugin.
44 """
45 maxFlux = lsst.pex.config.Field(
46 dtype=float,
47 default=1e10,
48 doc="Maximum calculated model flux before falling back on aperture flux."
49 )
52@register("ext_trailedSources_Naive")
53class SingleFrameNaiveTrailPlugin(SingleFramePlugin):
54 """Naive trailed source measurement plugin
56 Measures the length, angle from +x-axis, and end points of an extended
57 source using the second moments.
59 Parameters
60 ----------
61 config: `SingleFrameNaiveTrailConfig`
62 Plugin configuration.
63 name: `str`
64 Plugin name.
65 schema: `lsst.afw.table.Schema`
66 Schema for the output catalog.
67 metadata: `lsst.daf.base.PropertySet`
68 Metadata to be attached to output catalog.
70 Notes
71 -----
72 This measurement plugin aims to utilize the already measured adaptive
73 second moments to naively estimate the length and angle, and thus
74 end-points, of a fast-moving, trailed source. The length is solved for via
75 finding the root of the difference between the numerical (stack computed)
76 and the analytic adaptive second moments. The angle, theta, from the x-axis
77 is also computed via adaptive moments: theta = arctan(2*Ixy/(Ixx - Iyy))/2.
78 The end points of the trail are then given by (xc +/- (length/2)*cos(theta)
79 and yc +/- (length/2)*sin(theta)), with xc and yc being the centroid
80 coordinates.
82 See also
83 --------
84 lsst.meas.base.SingleFramePlugin
85 """
87 ConfigClass = SingleFrameNaiveTrailConfig
89 @classmethod
90 def getExecutionOrder(cls):
91 # Needs centroids, shape, and flux measurements.
92 # VeresPlugin is run after, which requires image data.
93 return cls.APCORR_ORDER + 0.1
95 def __init__(self, config, name, schema, metadata, logName=None):
96 if logName is None: 96 ↛ 98line 96 didn't jump to line 98 because the condition on line 96 was always true
97 logName = __name__
98 super().__init__(config, name, schema, metadata, logName=logName)
100 # Measurement Keys
101 self.keyRa = schema.addField(name + "_ra", type="D", doc="Trail centroid right ascension.")
102 self.keyDec = schema.addField(name + "_dec", type="D", doc="Trail centroid declination.")
103 self.keyRaErr = schema.addField(name + "_raErr", type="D",
104 doc="Trail centroid right ascension error.", units="arcsec")
105 self.keyDecErr = schema.addField(name + "_decErr", type="D",
106 doc="Trail centroid declination error.", units="arcsec")
107 self.keyX0 = schema.addField(name + "_x0", type="D", doc="Trail head X coordinate.", units="pixel")
108 self.keyY0 = schema.addField(name + "_y0", type="D", doc="Trail head Y coordinate.", units="pixel")
109 self.keyX1 = schema.addField(name + "_x1", type="D", doc="Trail tail X coordinate.", units="pixel")
110 self.keyY1 = schema.addField(name + "_y1", type="D", doc="Trail tail Y coordinate.", units="pixel")
111 self.keyFlux = schema.addField(name + "_flux", type="D", doc="Trailed source flux.", units="count")
112 self.keyLength = schema.addField(name + "_length", type="D", doc="Trail length.", units="pixel")
113 self.keyAngle = schema.addField(name + "_angle", type="D", doc="Angle measured from +x-axis.")
115 # Measurement Error Keys
116 self.keyX0Err = schema.addField(name + "_x0Err", type="D",
117 doc="Trail head X coordinate error.", units="pixel")
118 self.keyY0Err = schema.addField(name + "_y0Err", type="D",
119 doc="Trail head Y coordinate error.", units="pixel")
120 self.keyX1Err = schema.addField(name + "_x1Err", type="D",
121 doc="Trail tail X coordinate error.", units="pixel")
122 self.keyY1Err = schema.addField(name + "_y1Err", type="D",
123 doc="Trail tail Y coordinate error.", units="pixel")
124 self.keyFluxErr = schema.addField(name + "_fluxErr", type="D",
125 doc="Trail flux error.", units="count")
126 self.keyLengthErr = schema.addField(name + "_lengthErr", type="D",
127 doc="Trail length error.", units="pixel")
128 self.keyAngleErr = schema.addField(name + "_angleErr", type="D", doc="Trail angle error.")
129 self.keyAlgorithm = schema.addField(name + "_algorithmKey", type="I",
130 doc="Algorithm key indicating which algorithm is "
131 "used to measure trailed source.")
133 flagDefs = FlagDefinitionList()
134 self.FAILURE = flagDefs.addFailureFlag("No trailed-source measured")
135 self.NO_FLUX = flagDefs.add("flag_noFlux", "No suitable prior flux measurement")
136 self.NO_CONVERGE = flagDefs.add("flag_noConverge", "The root finder did not converge")
137 self.NO_SIGMA = flagDefs.add("flag_noSigma", "No PSF width (sigma)")
138 self.EDGE = flagDefs.add("flag_edge", "Trail contains edge pixels")
139 self.OFFIMAGE = flagDefs.add("flag_off_image", "Trail extends off image")
140 self.NAN = flagDefs.add("flag_nan", "One or more trail coordinates are missing")
141 self.SUSPECT_LONG_TRAIL = flagDefs.add("flag_suspect_long_trail",
142 "Trail length is greater than three times the psf radius")
143 self.SHAPE = flagDefs.add("flag_shape", "Shape flag is set, trail length not calculated")
144 self.SAFE_CENTROID = flagDefs.add("flag_centroid",
145 "Centroid flag is set, trail length not calculated")
146 self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
148 self.log = logging.getLogger(self.logName)
150 def measure(self, measRecord, exposure):
151 """Run the Naive trailed source measurement algorithm.
153 Parameters
154 ----------
155 measRecord : `lsst.afw.table.SourceRecord`
156 Record describing the object being measured.
157 exposure : `lsst.afw.image.Exposure`
158 Pixel data to be measured.
160 See also
161 --------
162 lsst.meas.base.SingleFramePlugin.measure
163 """
164 self.flagHandler.setValue(measRecord, self.FAILURE.number, False)
165 use_sdss_shape = True
166 if measRecord['base_SdssShape_flag']:
167 if measRecord.getShapeFlag(): 167 ↛ 174line 167 didn't jump to line 174 because the condition on line 167 was always true
168 self.log.debug("HSM shape flag is also set for measRecord: %s. Trail measurement "
169 "will not be made. All trail values will be set to nan.", measRecord.getId())
170 self.flagHandler.setValue(measRecord, self.FAILURE.number, True)
171 self.flagHandler.setValue(measRecord, self.SHAPE.number, True)
172 return
173 else:
174 use_sdss_shape = False
175 measRecord.set(self.keyAlgorithm, 2)
176 self.log.debug(
177 "SDSS Shape flag is set for measRecord: %s. Falling back"
178 "to HSMshape. No error measurements will be made.", measRecord.getId())
179 xc = measRecord["slot_Shape_x"]
180 yc = measRecord["slot_Shape_y"]
181 Ixx, Iyy, Ixy = measRecord.getShape().getParameterVector()
183 else:
184 measRecord.set(self.keyAlgorithm, 1)
185 xc = measRecord["base_SdssShape_x"]
186 yc = measRecord["base_SdssShape_y"]
187 Ixx = measRecord["base_SdssShape_xx"]
188 Iyy = measRecord["base_SdssShape_yy"]
189 Ixy = measRecord["base_SdssShape_xy"]
191 if not np.isfinite(xc) or not np.isfinite(yc): 191 ↛ 192line 191 didn't jump to line 192 because the condition on line 191 was never true
192 self.flagHandler.setValue(measRecord, self.SAFE_CENTROID.number, True)
193 self.flagHandler.setValue(measRecord, self.FAILURE.number, True)
194 return
195 ra, dec = self.computeRaDec(exposure, xc, yc)
197 # Transform the second-moments to semi-major and minor axes
198 xmy = Ixx - Iyy
199 xpy = Ixx + Iyy
200 xmy2 = xmy*xmy
201 xy2 = Ixy*Ixy
202 a2 = 0.5 * (xpy + sqrt(xmy2 + 4.0*xy2))
203 b2 = 0.5 * (xpy - sqrt(xmy2 + 4.0*xy2))
205 # Measure the trail length
206 length, gradLength, results = self.findLength(a2, b2)
207 if not results.converged: 207 ↛ 208line 207 didn't jump to line 208 because the condition on line 207 was never true
208 self.log.info("Results not converged: %s", results.flag)
209 self.flagHandler.setValue(measRecord, self.NO_CONVERGE.number, True)
210 self.flagHandler.setValue(measRecord, self.FAILURE.number, True)
211 return
213 # Compute the angle of the trail from the x-axis
214 theta = 0.5 * np.arctan2(2.0 * Ixy, xmy)
216 # Get end-points of the trail (there is a degeneracy here)
217 radius = length/2.0 # Trail 'radius'
218 dydtheta = radius*np.cos(theta)
219 dxdtheta = radius*np.sin(theta)
220 x0 = xc - dydtheta
221 y0 = yc - dxdtheta
222 x1 = xc + dydtheta
223 y1 = yc + dxdtheta
225 self.check_trail(measRecord, exposure, x0, y0, x1, y1, length)
227 # Get a cutout of the object from the exposure
228 cutout = getMeasurementCutout(measRecord, exposure)
230 # Compute flux assuming fixed parameters for VeresModel
231 params = np.array([xc, yc, 1.0, length, theta]) # Flux = 1.0
232 model = VeresModel(cutout)
233 flux, gradFlux = model.computeFluxWithGradient(params)
235 # Fall back to aperture flux
236 flux_is_fallback = False
237 if (not np.isfinite(flux)) | (np.abs(flux) > self.config.maxFlux): 237 ↛ 238line 237 didn't jump to line 238 because the condition on line 237 was never true
238 if np.isfinite(measRecord.getApInstFlux()):
239 flux = measRecord.getApInstFlux()
240 flux_is_fallback = True
241 else:
242 self.flagHandler.setValue(measRecord, self.NO_FLUX.number, True)
243 self.flagHandler.setValue(measRecord, self.FAILURE.number, True)
244 return
246 # Errors can only be calculated when using SDSS shape. Otherwise,
247 # the errors are set to nan.
248 if use_sdss_shape: 248 ↛ 311line 248 didn't jump to line 311 because the condition on line 248 was always true
249 # Propogate errors from second moments and centroid.
250 # Retrieved error is the standard of deviation, not
251 # covariance and must be squared.
252 IxxErr2 = measRecord["base_SdssShape_xxErr"]**2
253 IyyErr2 = measRecord["base_SdssShape_yyErr"]**2
254 IxyErr2 = measRecord["base_SdssShape_xyErr"]**2
256 # Centroid Errors
257 xcErr2 = measRecord["base_SdssCentroid_xErr"]**2
258 ycErr2 = measRecord["base_SdssCentroid_yErr"]**2
260 # Error in RA and Dec
261 wcs = exposure.getWcs()
262 jacobian = wcs.linearizePixelToSky(Point2D(xc, yc), arcseconds).getLinear().getMatrix()
263 raErr = sqrt(jacobian[0, 0]**2 * xcErr2 + jacobian[0, 1]**2 * ycErr2)
264 decErr = sqrt(jacobian[1, 0]**2 * xcErr2 + jacobian[1, 1]**2 * ycErr2)
266 # Error in length
267 desc = sqrt(xmy2 + 4.0*xy2) # Descriminant^1/2 of EV equation
268 da2dIxx = 0.5*(1.0 + (xmy/desc))
269 da2dIyy = 0.5*(1.0 - (xmy/desc))
270 da2dIxy = 2.0*Ixy / desc
271 a2Err2 = IxxErr2*da2dIxx*da2dIxx + IyyErr2*da2dIyy*da2dIyy + IxyErr2*da2dIxy*da2dIxy
272 b2Err2 = IxxErr2*da2dIyy*da2dIyy + IyyErr2*da2dIxx*da2dIxx + IxyErr2*da2dIxy*da2dIxy
273 dLda2, dLdb2 = gradLength
274 lengthErr = np.sqrt(dLda2*dLda2*a2Err2 + dLdb2*dLdb2*b2Err2)
276 # Error in theta
277 dThetadIxx = -Ixy / (xmy2 + 4.0*xy2) # dThetadIxx = -dThetadIyy
278 dThetadIxy = xmy / (xmy2 + 4.0*xy2)
279 thetaErr = sqrt(dThetadIxx*dThetadIxx*(IxxErr2 + IyyErr2) + dThetadIxy*dThetadIxy*IxyErr2)
281 # Error in flux
282 if not flux_is_fallback: 282 ↛ 287line 282 didn't jump to line 287 because the condition on line 282 was always true
283 dFdxc, dFdyc, _, dFdL, dFdTheta = gradFlux
284 fluxErr = sqrt(dFdL*dFdL*lengthErr*lengthErr + dFdTheta*dFdTheta*thetaErr*thetaErr
285 + dFdxc*dFdxc*xcErr2 + dFdyc*dFdyc*ycErr2)
286 else:
287 fluxErr = np.nan
289 # Errors in end-points
290 dxdradius = np.cos(theta)
291 dydradius = np.sin(theta)
292 radiusErr2 = lengthErr*lengthErr/4.0
293 # Variance
294 xErr2 = sqrt(xcErr2 + radiusErr2*dxdradius*dxdradius + thetaErr*thetaErr*dxdtheta*dxdtheta)
295 yErr2 = sqrt(ycErr2 + radiusErr2*dydradius*dydradius + thetaErr*thetaErr*dydtheta*dydtheta)
296 x0Err = xErr2 # Same for x1, standard of deviation
297 y0Err = yErr2 # Same for y1, standard of deviation
299 # Set error values
300 measRecord.set(self.keyRaErr, raErr)
301 measRecord.set(self.keyDecErr, decErr)
302 measRecord.set(self.keyX0Err, x0Err)
303 measRecord.set(self.keyY0Err, y0Err)
304 measRecord.set(self.keyX1Err, x0Err)
305 measRecord.set(self.keyY1Err, y0Err)
306 measRecord.set(self.keyFluxErr, fluxErr)
307 measRecord.set(self.keyLengthErr, lengthErr)
308 measRecord.set(self.keyAngleErr, thetaErr)
310 # Set values
311 measRecord.set(self.keyRa, ra)
312 measRecord.set(self.keyDec, dec)
313 measRecord.set(self.keyX0, x0)
314 measRecord.set(self.keyY0, y0)
315 measRecord.set(self.keyX1, x1)
316 measRecord.set(self.keyY1, y1)
317 measRecord.set(self.keyFlux, flux)
318 measRecord.set(self.keyLength, length)
319 measRecord.set(self.keyAngle, theta)
321 def check_trail(self, measRecord, exposure, x0, y0, x1, y1, length):
322 """ Set flags for edge pixels, off chip, and nan trail coordinates and
323 flag if trail length is three times larger than psf.
325 Check if the coordinates of the beginning and ending of the trail fall
326 inside the exposures bounding box. If not, set the off_chip flag.
327 If the beginning or ending falls within a pixel marked as edge, set the
328 edge flag. If any of the coordinates happens to fall on a nan, then
329 set the nan flag.
330 Additionally, check if the trail is three times larger than the psf. If
331 so, set the suspect trail flag.
333 Parameters
334 ----------
335 measRecord: `lsst.afw.MeasurementRecord`
336 Record describing the object being measured.
337 exposure: `lsst.afw.Exposure`
338 Pixel data to be measured.
340 x0: `float`
341 x coordinate of the beginning of the trail.
342 y0: `float`
343 y coordinate of the beginning of the trail.
344 x1: `float`
345 x coordinate of the end of the trail.
346 y1: `float`
347 y coordinate of the end of the trail.
348 """
349 x_coords = [x0, x1]
350 y_coords = [y0, y1]
352 # Check if one of the end points of the trail sources is nan. If so,
353 # set the trailed source nan flag.
354 if np.isnan(x_coords).any() or np.isnan(y_coords).any():
355 self.flagHandler.setValue(measRecord, self.NAN.number, True)
356 x_coords = [x for x in x_coords if not np.isnan(x)]
357 y_coords = [y for y in y_coords if not np.isnan(y)]
359 # Check if the non-nan coordinates are within the bounding box
360 if not (all(exposure.getBBox().beginX <= x <= exposure.getBBox().endX for x in x_coords)
361 and all(exposure.getBBox().beginY <= y <= exposure.getBBox().endY for y in y_coords)):
362 self.flagHandler.setValue(measRecord, self.EDGE.number, True)
363 self.flagHandler.setValue(measRecord, self.OFFIMAGE.number, True)
364 else:
365 # Check if edge is set for any of the pixel pairs. Do not
366 # check any that have a nan.
367 for (x_val, y_val) in zip(x_coords, y_coords):
368 if x_val is not np.nan and y_val is not np.nan: 368 ↛ 367line 368 didn't jump to line 367 because the condition on line 368 was always true
369 if exposure.mask[Point2I(int(x_val), 369 ↛ 371line 369 didn't jump to line 371 because the condition on line 369 was never true
370 int(y_val))] & exposure.mask.getPlaneBitMask('EDGE') != 0:
371 self.flagHandler.setValue(measRecord, self.EDGE.number, True)
372 # Check whether trail extends off the edge of the exposure. Allows nans
373 # as their location
374 elif not (all(exposure.getBBox().beginX <= x <= exposure.getBBox().endX for x in x_coords)
375 and all(exposure.getBBox().beginY <= y <= exposure.getBBox().endY for y in y_coords)):
376 self.flagHandler.setValue(measRecord, self.EDGE.number, True)
377 self.flagHandler.setValue(measRecord, self.OFFIMAGE.number, True)
378 else:
379 # Check whether the beginning or end point of the trail has the
380 # edge flag set. The end points are not whole pixel values, so
381 # the pixel value must be rounded.
382 if exposure.mask[Point2I(int(x0), int(y0))] and exposure.mask[Point2I(int(x1), int(y1))]: 382 ↛ 388line 382 didn't jump to line 388 because the condition on line 382 was always true
383 if ((exposure.mask[Point2I(int(x0), int(y0))] & exposure.mask.getPlaneBitMask('EDGE') != 0)
384 or (exposure.mask[Point2I(int(x1), int(y1))]
385 & exposure.mask.getPlaneBitMask('EDGE') != 0)):
386 self.flagHandler.setValue(measRecord, self.EDGE.number, True)
388 psfShape = exposure.psf.computeShape(exposure.getBBox().getCenter())
389 psfRadius = psfShape.getDeterminantRadius()
391 if length > psfRadius*3.0:
392 self.flagHandler.setValue(measRecord, self.SUSPECT_LONG_TRAIL.number, True)
394 def fail(self, measRecord, error=None):
395 """Record failure
397 See also
398 --------
399 lsst.meas.base.SingleFramePlugin.fail
400 """
401 if error is None:
402 self.flagHandler.handleFailure(measRecord)
403 else:
404 self.flagHandler.handleFailure(measRecord, error.cpp)
406 @staticmethod
407 def _computeSecondMomentDiff(z, c):
408 """Compute difference of the numerical and analytic second moments.
410 Parameters
411 ----------
412 z : `float`
413 Proportional to the length of the trail. (see notes)
414 c : `float`
415 Constant (see notes)
417 Returns
418 -------
419 diff : `float`
420 Difference in numerical and analytic second moments.
422 Notes
423 -----
424 This is a simplified expression for the difference between the stack
425 computed adaptive second-moment and the analytic solution. The variable
426 z is proportional to the length such that length=2*z*sqrt(2*(Ixx+Iyy)),
427 and c is a constant (c = 4*Ixx/((Ixx+Iyy)*sqrt(pi))). Both have been
428 defined to avoid unnecessary floating-point operations in the root
429 finder.
430 """
432 diff = erf(z) - c*z*np.exp(-z*z)
433 return diff
435 @classmethod
436 def findLength(cls, Ixx, Iyy):
437 """Find the length of a trail, given adaptive second-moments.
439 Uses a root finder to compute the length of a trail corresponding to
440 the adaptive second-moments computed by previous measurements
441 (ie. SdssShape).
443 Parameters
444 ----------
445 Ixx : `float`
446 Adaptive second-moment along x-axis.
447 Iyy : `float`
448 Adaptive second-moment along y-axis.
450 Returns
451 -------
452 length : `float`
453 Length of the trail.
454 results : `scipy.optimize.RootResults`
455 Contains messages about convergence from the root finder.
456 """
458 xpy = Ixx + Iyy
459 c = 4.0*Ixx/(xpy*np.sqrt(np.pi))
461 # Given a 'c' in (c_min, c_max], the root is contained in (0,1].
462 # c_min is given by the case: Ixx == Iyy, ie. a point source.
463 # c_max is given by the limit Ixx >> Iyy.
464 # Empirically, 0.001 is a suitable lower bound, assuming Ixx > Iyy.
465 z, results = sciOpt.brentq(lambda z: cls._computeSecondMomentDiff(z, c),
466 0.001, 1.0, full_output=True)
468 length = 2.0*z*np.sqrt(2.0*xpy)
469 gradLength = cls._gradFindLength(Ixx, Iyy, z, c)
470 return length, gradLength, results
472 @staticmethod
473 def _gradFindLength(Ixx, Iyy, z, c):
474 """Compute the gradient of the findLength function.
475 """
476 spi = np.sqrt(np.pi)
477 xpy = Ixx+Iyy
478 xpy2 = xpy*xpy
479 enz2 = np.exp(-z*z)
480 sxpy = np.sqrt(xpy)
482 fac = 4.0 / (spi*xpy2)
483 dcdIxx = Iyy*fac
484 dcdIyy = -Ixx*fac
486 # Derivatives of the _computeMomentsDiff function
487 dfdc = z*enz2
488 dzdf = spi / (enz2*(spi*c*(2.0*z*z - 1.0) + 2.0)) # inverse of dfdz
490 dLdz = 2.0*np.sqrt(2.0)*sxpy
491 pLpIxx = np.sqrt(2.0)*z / sxpy # Same as pLpIyy
493 dLdc = dLdz*dzdf*dfdc
494 dLdIxx = dLdc*dcdIxx + pLpIxx
495 dLdIyy = dLdc*dcdIyy + pLpIxx
496 return dLdIxx, dLdIyy
498 @staticmethod
499 def computeLength(Ixx, Iyy):
500 """Compute the length of a trail, given unweighted second-moments.
501 """
502 denom = np.sqrt(Ixx - 2.0*Iyy)
504 length = np.sqrt(6.0)*denom
506 dLdIxx = np.sqrt(1.5) / denom
507 dLdIyy = -np.sqrt(6.0) / denom
508 return length, (dLdIxx, dLdIyy)
510 @staticmethod
511 def computeRaDec(exposure, x, y):
512 """Convert pixel coordinates to RA and Dec.
514 Parameters
515 ----------
516 exposure : `lsst.afw.image.ExposureF`
517 Exposure object containing the WCS.
518 x : `float`
519 x coordinate of the trail centroid
520 y : `float`
521 y coodinate of the trail centroid
523 Returns
524 -------
525 ra : `float`
526 Right ascension.
527 dec : `float`
528 Declination.
529 """
531 wcs = exposure.getWcs()
532 center = wcs.pixelToSky(Point2D(x, y))
533 ra = center.getRa().asDegrees()
534 dec = center.getDec().asDegrees()
535 return ra, dec