Astrometry (pyobs.images.processors.astrometry)

Astrometry

class Astrometry(on_error: str = 'raise', **kwargs: Any)

Base class for astrometry processors

AstrometryDotNet

class AstrometryDotNet(url: str, source_count: int = 50, radius: float = 3.0, timeout: int = 10, exceptions: bool | None = None, on_error: str = 'raise', **kwargs: Any)

Perform astrometric solving using an astrometry.net-compatible service.

This processor submits sources extracted from a pyobs.images.Image to an astrometry.net service, obtains a WCS solution, and writes it back to the image’s FITS header. The solver endpoint is configured via url and the request content is built by the internal _DotNetRequestBuilder helper.

Parameters:
  • url (str) – Base URL of the astrometry.net service endpoint.

  • source_count (int) – Number of detected sources to include in the request payload. The source selection strategy is defined by _DotNetRequestBuilder. Default: 50.

  • radius (float) – Search radius constraint passed to the request builder. Units and semantics are defined by _DotNetRequestBuilder (commonly degrees for astrometry.net). Default: 3.0.

  • timeout (int) – Timeout in seconds for the network call to the astrometry web service. Default: 10.

  • exceptions (bool) – Deprecated, use on_error instead. exceptions=False is equivalent to on_error="error"; exceptions=True (the default) is equivalent to on_error="raise".

  • on_error (str) – How the pipeline should handle a failed solve: "raise" (default, abort the pipeline), "error" (mark WCSERR=1 in the header, log a warning, and pass the image through – see handle_error), "info", or "ignore". Only takes effect when this processor runs as a step in a PipelineMixin pipeline; a direct call always raises on failure.

  • kwargs – Additional keyword arguments forwarded to pyobs.images.processors.astrometry.Astrometry.

Behavior

  • Constructs a request from the input image using the internal _DotNetRequestBuilder(source_count, radius).

  • Logs request metadata via the internal _RequestLogger.

  • Sends the request to the configured service with request.send(url, timeout).

  • On success, receives solver output and writes the resulting WCS into a copy of the input image using the internal _ResponseImageWriter.

  • Logs the outcome, including WCS information, and returns the result image.

  • On failure, raises the underlying ImageError. When run as a pipeline step with on_error="error", the pipeline calls handle_error, which sets WCSERR=1 in the FITS header, logs a warning, and returns the original image unchanged.

Input/Output

Configuration (YAML)

Minimal local solver:

class: pyobs.images.processors.astrometry.AstrometryDotNet
url: "http://localhost:8080/api"

Handle failures without aborting the pipeline:

class: pyobs.images.processors.astrometry.AstrometryDotNet
url: "http://localhost:8080/api"
on_error: error

Notes

  • The _DotNetRequestBuilder determines how sources are extracted and how the request is formed (including any unit conventions for radius). Consult its documentation for details.

  • WCSERR is used as a failure marker in the FITS header when handle_error runs.

property exceptions: bool

Deprecated, use on_error instead.

handle_error(image: Image, error: ImageError) → Image[source]

Handle an ImageError raised by this step, when on_error == “error”.

Override this to customize error handling (e.g. tag the image with a FITS header). The default implementation re-raises the error.

Parameters:
  • image – The image that caused the error.

  • error – The ImageError that was raised.

Returns:

The image to pass to the next pipeline step.