desihub / gpu_specter

Scratch work for porting spectroperfectionism extractions to GPUs
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

cpu - get_xyrange differs from specter #33

Open dmargala opened 4 years ago

dmargala commented 4 years ago

Follow up from #31

Here is a simple test comparing xyrange between gpu_specter and specter:

import pkg_resources
import numpy as np

from gpu_specter.extract.cpu import get_xyrange, get_spots
from gpu_specter.io import read_psf

import specter.psf

psffile = pkg_resources.resource_filename(
    'gpu_specter', 'test/data/psf-r0-00051060.fits')

# gpu_specter
psfdata = read_psf(psffile)
wavelengths = np.arange(6000.0, 6050.0, 1.0)
spots, corners = get_spots(0, 25, wavelengths, psfdata)

ispec, nspec, iwave, nwave = (0, 5, 0, 25)

xyrange = get_xyrange(
    ispec=ispec, nspec=nspec, iwave=iwave, nwave=nwave,
    spots=spots, corners=corners
)

# specter
psf = specter.psf.load_psf(psffile)

specter_xyrange = psf.xyrange(
    spec_range=(ispec, ispec+nspec), 
    wavelengths=(wavelengths[iwave], wavelengths[iwave+nwave])
)

assert xyrange == specter_xyrange, f'{xyrange} != {specter_xyrange}'

Currently this test fails:

AssertionError: (113, 159, 794, 851) != (113, 159, 793, 853)

The following plot compares a set patch pixels that are passed to ex2d_patch. The solid red lined rectangle and white dashed lined rectangle outline the pixels considered by spex and specter respectively. The patch sizes are slightly narrower in the y-direction by a couple of pixels on each end.

image

The following plot compares xyrange used to determine the projection matrix in spex. It seems to reasonably respond to adjustments to wavepad. It's a bit harder for me to figure out the xyrange used in specter for this part so I don't have a comparison for that right now.

image