Chunked FOVs lose flux at chunk borders when PSF-convolved

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

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Start by tracing the chunking and PSF convolution paths that use scipy.signal.convolve(..., mode="same"); the issue does not name their files, so locate them from !SIM.computing.chunk_size and !SIM.computing.max_segment_size. Run the supplied reproduction with chunking enabled and disabled, then check that sources near chunk borders retain the same total flux and seams disappear.

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

Descrizione

optics
What happened?

Reported by Claude

When a large field is split into spatial chunks (!SIM.computing.chunk_size, !SIM.computing.max_segment_size), every chunk is convolved with the PSF on its own, with scipy.signal.convolve(..., mode="same"). Flux that should spread across a chunk border is cut off on both sides instead of being added to the neighboring chunk. Sources near borders lose flux, and extended sources show seams along the chunk borders. With default settings this only affects large fields, but those are exactly the ones that get chunked.

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: star flux only
    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()

# a star close to (but not on) the corner shared by the four chunks
for x, y in [(0.37, 0.41), (12, 13)]:
    f1 = image_plane_flux(x, y, chunked=False)
    f4 = image_plane_flux(x, y, chunked=True)
    print(f"star at ({x}, {y}) arcsec: chunked / unchunked flux = {f4 / f1:.3f}")


# Output:
# star at (0.37, 0.41) arcsec: chunked / unchunked flux = 0.465
# star at (12, 13) arcsec: 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.