traceshifts fail if half of b-camera CCD is masked
- Dominant language
- Python
- Stars
- 42
- Forks
- 26
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 15
Description
On 20231202 through 20231205, b5 amps A and C (left half of CCD) were bad. We tried to recover the other half by using a PSF from a previous night, but `desi_compute_trace_shifts` fails:
```
cd $CFS/desi/users/desi/debug/traceshifts
desi_compute_trace_shifts --degxx 2 --degxy 0 --degyx 2 --degyy 0 --sky \
--image preproc-b5-00207663.fits.gz \
--psf psfnight-b5-20231126.fits \
--outpsf $SCRATCH/psf-b5-00207663.fits
...
INFO:trace_shifts.py:242:fit_trace_shifts: polynomial fit of measured offsets with degx=(0,0) degy=(0,0)
WARNING:trace_shifts.py:269:fit_trace_shifts: polynomial fit failed with degx=(0,0) degy=(0,0)
ERROR:trace_shifts.py:271:fit_trace_shifts: polynomial degrees are already 0. we can't fit the offsets
Traceback (most recent call last):
File "/global/common/software/desi/perlmutter/desiconda/20230111-2.1.0/code/desispec/main/py/desispec/scripts/trace_shifts.py", line 245, in fit_trace_shifts
dy_coeff,dy_coeff_covariance,dy_errorfloor,dy_mod,dy_mask=polynomial_fit(z=dy,ez=ey,xx=x_for_dy,yy=y_for_dy,degx=degyx,degy=degyy)
File "/global/common/software/desi/perlmutter/desiconda/20230111-2.1.0/code/desispec/main/py/desispec/trace_shifts.py", line 1166, in polynomial_fit
coeff=cholesky_solve(A,B)
File "/global/common/software/desi/perlmutter/desiconda/20230111-2.1.0/code/desispec/main/py/desispec/linalg.py", line 27, in cholesky_solve
UorL,lower = scipy.linalg.cho_factor(A, lower=lower, overwrite_a=overwrite)
File "/global/common/software/desi/perlmutter/desiconda/20230111-2.1.0/conda/lib/python3.10/site-packages/scipy/linalg/_decomp_cholesky.py", line 152, in cho_factor
c, lower = _cholesky(a, lower=lower, overwrite_a=overwrite_a, clean=False,
File "/global/common/software/desi/perlmutter/desiconda/20230111-2.1.0/conda/lib/python3.10/site-packages/scipy/linalg/_decomp_cholesky.py", line 37, in _cholesky
raise LinAlgError("%d-th leading minor of the array is not positive "
numpy.linalg.LinAlgError: 1-th leading minor of the array is not positive definite
```
Ideally it would solve for the shifts for the fibers covering the masked regions, and apply an average shift (or no shift?) to the masked fibers, so that we could then proceed with extractions using shifted PSFs for the ~250 good fibers.
I'm not sure why we haven't encountered this problem before, since we do have support for masking individual amps.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the supplied desi_compute_trace_shifts command and its input files, if accessible. Read fit_trace_shifts in py/desispec/scripts/trace_shifts.py, polynomial_fit in py/desispec/trace_shifts.py, and cholesky_solve in py/desispec/linalg.py. Clarify the desired treatment of masked fibers; done means the half-masked b5 case produces shifted PSFs usable for extracting the roughly 250 good fibers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100