torchsky.quality¶
Stability: core. Names on this page follow the deprecation policy in contributing.
Torch-native quality, inverse-variance, and confidence contracts.
Guides: coadds
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.quality unless the group text says otherwise.
Top-level namespace¶
Torch-native quality, inverse-variance, and confidence contracts.
DEFAULT_ZERO_WEIGHT_BITS
module-attribute
¶
DEFAULT_ZERO_WEIGHT_BITS = (
BAD_PIXEL
| SATURATED
| COSMIC_RAY
| STREAK
| INVALID_VARIANCE
)
INVERSE_VARIANCE_SEMANTICS
module-attribute
¶
INVERSE_VARIANCE_SEMANTICS = 'inverse_variance_per_pixel'
QualityBit ¶
Bases: IntFlag
Named quality conditions stored as set bits in an integer mask.
WeightProduct
dataclass
¶
WeightProduct(
quality_mask: Tensor,
inverse_variance: Tensor,
weight: Tensor,
confidence: Tensor,
metadata: Mapping[str, Any],
)
Classical quality products with reserved producer metadata.
build_weight_product ¶
build_weight_product(
inverse_variance: Tensor,
quality_mask: Tensor | None = None,
*,
exclude_detected: bool = False,
confidence_percentile: float = 99.0,
producer: Mapping[str, Any] | None = None,
) -> WeightProduct
Sanitize inverse variance and combine it with named quality bits.
Invalid variance is represented by zero inverse variance and zero weight,
and is recorded as INVALID_VARIANCE. producer reserves a stable
artifact field for future learned mask/weight generators without changing
downstream consumers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inverse_variance
|
Tensor
|
Per-pixel inverse variance; nonpositive or nonfinite values are invalid. |
required |
quality_mask
|
Tensor | None
|
Optional integer bit mask with the same shape. |
None
|
exclude_detected
|
bool
|
Give detected-source pixels zero weight when true. |
False
|
confidence_percentile
|
float
|
Positive-weight percentile mapped to confidence one. |
99.0
|
producer
|
Mapping[str, Any] | None
|
Optional provenance mapping stored in the result metadata. |
None
|
Returns:
| Type | Description |
|---|---|
WeightProduct
|
Sanitized mask, inverse variance, weight, confidence, and metadata. |
Examples:
>>> import torch
>>> from torchsky.quality import build_weight_product
>>> build_weight_product(torch.tensor([1.0])).weight.tolist()
[1.0]
quality_bit_names ¶
quality_bit_names(
value: int | QualityBit,
) -> frozenset[str]
Decode a bitset into stable public names.
quality_bits_from_names ¶
quality_bits_from_names(
names: Mapping[str, Any]
| list[str]
| tuple[str, ...]
| set[str],
) -> QualityBit
Encode stable public quality names into a bitset.