Possible lambda-cutoff bug in simple IFU mode

Aperta
#957 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
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by tracing how CubeSourceField wavelength planes pass through the simple_ifu optical train and into opt.image_planes[0].data; the report's five-plane reproduction shows the first output plane has about half the flux of the others. Run the supplied script and compare the summed flux per plane. Done when all planes conserve the same flux for this spectrally flat input.

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

Descrizione

What happened?

While testing flux conservation across different source geometries, a weird inconsistency was discovered in the simple_ifu mode of the basic instrument (using that for testing simplicity), MVE below. Could not check if this also occurs in e.g. METIS lms_cube mode because not enough memory.

What appears to happen is that the first wavelength slice of the input cube gets cut in half.

Code to reproduce
import numpy as np
import astropy.units as u
from astropy.io import fits
from astropy.wcs import WCS

import scopesim as sim
from scopesim import Source
from scopesim.source.source_fields import CubeSourceField

nx = ny = 16
nlam = 5
scale = 0.2            # arcsec / pixel
waves = np.linspace(1.9, 2.3, nlam)   # um, well inside simple_ifu's 1.7-2.5

flux = np.ones(nlam)                  # spectrally flat -> planes should be equal
w = np.zeros((ny, nx))
w[5:11, 5:11] = 1.0                   # uniform spatial block
data = (w[None, :, :] * flux[:, None, None]) / scale**2   # PHOTLAM/arcsec2

wcs = WCS(naxis=3)
wcs.wcs.ctype = "RA---TAN", "DEC--TAN", "WAVE"
wcs.wcs.cunit = "arcsec", "arcsec", "um"
wcs.wcs.crpix = (nx + 1) / 2, (ny + 1) / 2, 1.0
wcs.wcs.crval = 0.0, 0.0, waves[0]
wcs.wcs.cdelt = scale, scale, waves[1] - waves[0]
hdr = wcs.to_header()
hdr["NAXIS1"], hdr["NAXIS2"], hdr["NAXIS3"] = nx, ny, nlam
# Explicit FITS spelling of PHOTLAM/arcsec2
hdr["BUNIT"] = "ph Angstrom-1 s-1 cm-2 arcsec-2"

src = Source(field=CubeSourceField(field=fits.ImageHDU(header=hdr, data=data)))

# Simple OpticalTrain without atmosphere or PSF
opt = sim.load_example_optical_train(set_modes=["simple_ifu"])
opt["psf"].include = False
opt["atmospheric_radiometry"].include = False
opt.observe(src, update=True)

cube_out = opt.image_planes[0].data
per_plane = cube_out.sum(axis=(1, 2))

print(f"output cube shape : {cube_out.shape}")
print(f"flux per plane    : {per_plane.round(-2)}")
print(f"plane / last plane: {per_plane / per_plane[-1]}")
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.