cutana_loader
anomaly_match.prediction.cutana_loader
¶
On-demand cutout creation via Cutana for streaming sources.
Used by the prediction UI to create cutouts for the image detail view and preview gallery when the original cutout was created in-memory during prediction and no file exists on disk.
BatchCutoutResult(cutouts=dict(), partial=False)
dataclass
¶
Cutouts loaded by :func:load_batch_cutouts, plus the bail-out flag.
Attributes:
| Name | Type | Description |
|---|---|---|
cutouts |
dict[str, ndarray]
|
Map from |
partial |
bool
|
|
load_single_cutout(cfg, source_id)
¶
Create a single normalised cutout for a streaming source using Cutana.
Locates source_id in the catalogues under cfg.prediction_search_dir
(via the #506 catalogue index when available) and runs Cutana to produce a
display-ready cutout under the config's normalisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DotMap
|
Full prediction config with normalisation settings. |
required |
source_id
|
str
|
The source identifier stored in the prediction DB. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC uint8 numpy array, or |
Source code in anomaly_match/prediction/cutana_loader.py
load_single_native_cutout(cfg, source_id)
¶
Extract one cutout at its native pixel size for the detail view.
Returns a normalisation-independent per-band float cutout the detail view
re-normalises in-process (so retuning normalisation never re-reads the
catalogue/tile). Cutana is run with do_only_cutout_extraction so it
skips the resize to a fixed target resolution — the cutout comes back at its
true native pixel size (e.g. 14x14 for a small Euclid source), letting the
user inspect real pixels rather than an interpolated resample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DotMap
|
Full prediction config (locates the catalogues / index DB). |
required |
source_id
|
str
|
The source identifier stored in the prediction DB. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC float32 array (one channel per FITS band) at native resolution, or |
ndarray | None
|
|
Source code in anomaly_match/prediction/cutana_loader.py
load_sample_cutouts(cfg, search_dir, n_samples=9)
¶
Create a few sample cutouts from the catalogue for preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DotMap
|
Full prediction config with normalisation settings. |
required |
search_dir
|
str
|
Path to the directory containing catalogue files. |
required |
n_samples
|
int
|
Maximum number of sample cutouts to create. |
9
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, ndarray]]
|
List of |
list[tuple[str, ndarray]]
|
than n_samples if some cutouts fail to load. |
Source code in anomaly_match/prediction/cutana_loader.py
load_batch_cutouts(cfg, source_ids, *, search_dir=None, stale_check=None)
¶
Create cutouts for multiple sources by scanning catalogues in parallel.
Dispatches one worker per catalogue file across a thread pool
(:func:_scan_one_catalogue). Each worker reads its catalogue,
filters to the requested ids, and builds cutouts for the matching
rows in a single batch orchestrator call. The parent thread merges
results as workers complete and cancels queued workers once every
requested id has resolved, so fast catalogues that hold the wanted
ids return before a slow read finishes. Far more efficient than
calling load_single_cutout per source, and the parallel scan
keeps one slow parquet read from freezing the whole walk (#444).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DotMap
|
Full prediction config with normalisation settings. |
required |
source_ids
|
list[str]
|
List of source identifiers from the prediction DB. |
required |
search_dir
|
str | None
|
Directory containing catalogue files. Falls back to
|
None
|
stale_check
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
BatchCutoutResult
|
class: |
BatchCutoutResult
|
|
BatchCutoutResult
|
completion over every catalogue — either |
BatchCutoutResult
|
and the remaining workers were cancelled, or one or more |
BatchCutoutResult
|
catalogue reads raised. In both cases the cutouts dict may be |
BatchCutoutResult
|
missing entries, so consumers that require complete results must |
BatchCutoutResult
|
inspect this flag rather than treat the dict as authoritative. |
Source code in anomaly_match/prediction/cutana_loader.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |