Sources exactly on a chunk border are extracted by every adjacent chunk

Aperta
#1,061 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, data

Direzione di ricerca

Start in optics/fov.py at extract_from (around line 166) and extract_area_from_table (around lines 282–285), where chunk bounds are derived from the WCS footprint and applied to sources. Run the provided reproduction with chunking enabled and compare its corner, edge, and interior flux ratios. Done means each source is extracted by exactly one chunk and all three ratios are 1.000.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

optics
What happened?

Reported by Claude

FieldOfView.extract_area_from_table selects table sources with half-open bounds (>= min, < max), which should give each source to exactly one chunk. But the bounds come from the WCS footprint (get_corners → calc_footprint), and the pixel-to-world conversion leaves adjacent chunks overlapping by about 3e-13 arcsec. A source exactly on a border therefore passes the selection of every adjacent chunk: it is counted twice on a chunk edge and four times on a corner. This is not rare in practice. For example, a single star at the field centre with 2 × 2 chunks sits on the corner.

Expected: every source in exactly one chunk (ratio 1.000 in all three cases).

Where: optics/fov.py, extract_from (line 166, minmax from the footprint) and extract_area_from_table (lines 282–285). Possible fixes: take the bounds from the FOV volume definition (exact values) instead of the WCS footprint, or round them before the comparison.

Code to reproduce
import astropy.units as u
from synphot import SourceSpectrum, ConstFlux1D
import scopesim as sim
from scopesim.tests.mocks.load_basic_instrument import load_example_optical_train

def image_plane_flux(x, y, chunked):
    props = {"!DET.width": 320, "!DET.height": 320}
    if chunked:  # force 2 x 2 chunks of 160 x 160 pixels
        props.update({"!SIM.computing.chunk_size": 160,
                      "!SIM.computing.max_segment_size": 160 * 160})
    opt = load_example_optical_train(set_modes=["imaging"], properties=props)
    opt["atmospheric_radiometry"].include = False   # no sky
    opt["psf"].include = False                      # no PSF: nothing can leak
    src = sim.Source(x=[x], y=[y], ref=[0], weight=[1],
                     spectra=[SourceSpectrum(ConstFlux1D, amplitude=1 * u.mJy)])
    opt.observe(src)
    return opt.image_planes[0].hdu.data.sum()

# chunk borders run through x = 0 and y = 0
for x, y, where in [(0, 0, "corner"), (0, 5, "edge"), (0.37, 0.41, "inside")]:
    ratio = image_plane_flux(x, y, True) / image_plane_flux(x, y, False)
    print(f"star on chunk {where:6s} ({x}, {y}): chunked / unchunked flux = {ratio:.3f}")


# Output:
# star on chunk corner (0, 0): chunked / unchunked flux = 4.000
# star on chunk edge   (0, 5): chunked / unchunked flux = 2.000
# star on chunk inside (0.37, 0.41): chunked / unchunked flux = 1.000
Exception traceback

ScopeSim bug_report()

IRDB installation

Cloned and linked IRDB repository

Use case

Other

Lingua principale
Python
Stelle
42
Fork
30
Merge medio
2g 22h
PR unite (30g)
7

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AstarVienna/ScopeSim

Tutte le issue di AstarVienna/ScopeSim

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.