Skip to content

torchsky.map.operators.pixel_calibration

Experimental surface

These APIs are under active development. Names, defaults, and result objects may change between minor releases; pin a version if you depend on them in production.

Explicit diagonal calibration of an already integrated detector product.

Guides: likelihoods


This reference is generated from the package source. Names are grouped by the module that defines them; import every name from the public namespace torchsky.map.operators.pixel_calibration unless the group text says otherwise.

Top-level namespace

Explicit diagonal calibration of an already integrated detector product.

PixelCalibrationOp dataclass

PixelCalibrationOp(
    *,
    scale: Tensor,
    input_unit: str,
    output_unit: str,
    calibration_id: str,
    provenance_id: str,
    flat_convention: str,
    reference_convention: str,
    dependencies: EvidenceSnapshot | None = None,
)

A fixed positive detector-product transform D = diag(scale).

scale[P] multiplies native pixel values after detector integration. input_unit and output_unit declare its dimensional ratio; labels do not trigger conversions or infer pixel area, exposure time or QE. flat_convention identifies the declared response product (e.g. sky_flat, point_source or detector_counts). reference_convention explicitly identifies the illuminating spatial and spectral reference used to calibrate that product. Neither convention asserts simultaneous uniform-sky and point-source-flux invariants. In a spatially varying response, row and column sums can differ: a sky-flat correction can change the pixel sum of a point-source response.

Compose calibration.forward(response.forward(source_intensity)) with a source-quadrature operator. Source solid-angle and wavelength measures stay inside that operator; no pixel integral or normalization is repeated here. Signed mean vectors are allowed; a physical count/rate model must enforce its own support. This primitive has no additive offset.

The scale and metadata bindings are fixed. Ordinary in-place scale writes invalidate the captured EvidenceSnapshot. Supply dependencies with an explicit revision getter for hidden state, inference tensors or writes through NumPy/.data aliases. Calibration/provenance IDs are lineage, not freshness checks. Include covariance callback state in the same snapshot when using apply_covariance; callbacks are not inspected. Rebuild the transform after changing dependencies or conventions, and when a new autograd graph is required. No tensors are copied or detached.

Mean actions cost O(P) per vector. The matrix-free covariance action uses one caller covariance action plus two diagonal products; the explicit dense covariance transform costs O(P^2) per matrix. The covariance is conditional on this fixed calibration: uncertainty in the scale is not estimated or marginalized by this transform.

_snapshot class-attribute instance-attribute

_snapshot: EvidenceSnapshot = field(
    init=False, repr=False, compare=False
)

calibration_id instance-attribute

calibration_id: str

dependencies class-attribute instance-attribute

dependencies: EvidenceSnapshot | None = None

flat_convention instance-attribute

flat_convention: str

input_unit instance-attribute

input_unit: str

output_unit instance-attribute

output_unit: str

provenance_id instance-attribute

provenance_id: str

reference_convention instance-attribute

reference_convention: str

scale class-attribute instance-attribute

scale: Tensor = field(kw_only=False)

__post_init__

__post_init__() -> None

_compatible

_compatible(value: Tensor, name: str) -> None

_vector

_vector(value: Tensor, name: str) -> None

adjoint

adjoint(value: Tensor) -> Tensor

Apply the Euclidean transpose D.T = D to value[...,P].

This is not inverse calibration; positivity does not change the distinction between a transpose and multiplication by reciprocal scale.

apply_covariance

apply_covariance(
    value: Tensor,
    *,
    covariance_action: Callable[[Tensor], Tensor],
) -> Tensor

Apply the full output covariance D C D.T to value[...,P].

covariance_action must implement the input product's fixed linear covariance on the same vector shape/dtype/device, including any correlations. Its symmetry/PSD are the caller's contract. Scaling only its output or only diagonal variances would change this action.

forward

forward(value: Tensor) -> Tensor

Apply D to signed mean values value[...,P].

transform_covariance

transform_covariance(covariance: Tensor) -> Tensor

Transform a full matrix covariance[...,P,P] as D C D.T.

This optional dense operation preserves off-diagonal terms. The input is caller-declared covariance; it does not estimate/check its PSD or substitute a diagonal approximation.

validate_evidence

validate_evidence() -> None

Reject changed declared calibration/covariance dependencies.