Closed moustakas closed 5 months ago
I reproduced these on the same file/targetid using PCA galaxy templates and PCA/NMF QSO templates, but are we sure this is a bug with NMF mixing? The STAR Chi^2 scan is the same regardless of Galaxy/QSO template type:
And in both cases @moustakas presents above the reported minimum for the STAR_K template is -0.0014 and in both cases the star zscan is identical, with the same chi^2 value. So changing the template types doesn't change the STAR zscan (as expected) but did (accidentally) illuminate a potential problem with the minimum in the stellar template being off from what the zscan would indicate.
Chasing the rabbit hole a bit further I ran with only the STAR-K template, and it reported two minima in the zscan, the aforementinoed -0.0014 and the expected one at 0.002 with the expected ZWARN that it is at the edge of the zscan range (1056 = 1024 + 32, bits 5 and 10 i.e. Z_FITLIMIT and BAD_MINFIT).
int64 float64 float64 int64 float64 ... str4 str1 int64 int64 float64
----------------- ---------------------- ---------------------- ----- ------------------ ... -------- ------- ------ ----- ---------
39627688712865504 -0.0014753342400076923 1.1470858022826353e-05 0 64323.94825649643 ... STAR K 5 0 0.0
39627688712865504 0.0020000000000000104 1.4543807701833745e-05 1056 62445.457767245876 ... STAR K 5 1 0.0
I think the more concerning bug(?) here is that there's clearly better minima in the STAR scan that are neither of the two redshifts reported (around 0.00075) but for some reason the scan is focusing on the one at -0.0014. I am not proficient enough in running redrock to chase this further, I tried to force redrock to scan more minima with --nminima 50
but it didn't change the above results.
Short summary: Based on the reported chi^2 values, NMF is just missing this galaxy. Unlikely that this is a bug in the NMF/PCA mix, although there seems to be entirely separate issues with the stellar template zscan that I have no intuition on.
Two issues:
Comparing the PCA and NMF galaxy chi2 vs. z scans (upper plot), both have a local minimum near z~0.16, but the NMF chi2 is considerably worse. Looking at the data and reconstructed templates (lower plot), both PCA and NMF are struggling to model a galaxy that red, but PCA appears to have more flexibility to absorb the continuum and thus gets a much better chi2, allowing that local minimum to win.
See code at $CFS/desi/users/sjbailey/debug/redrock276/plotfits.py; it's a bit too long to paste here.
This is consistent with what @dylanagreen has been seeing with QSO NMF templates: the broad chi2 vs. z shape is set by how well the templates can fit the continuum, and the depth of local minima is set by how well they can model the lines. With a similar number of templates for NMF vs. PCA, NMF has less broadband flexibility and thus is failing to model the overall color as well.
Conclusion:
Thanks to both @sbailey and @dylanagreen.
@sbailey regarding your plot which shows the data and both the PCA and NMF model spectra, both those fits are complete crap. I agree it's quite dusty, but that's not a particularly "hard" spectrum to model. E.g., here's the FastSpecFit model fit-- https://fastspecfit.desi.lbl.gov/target/sv1-dark-17691-39627688712865504
So what this tells me is that there are too few NMF (and possibly PCA) components... This is helpful...
In the end this wasn't a bug in mixing NMF and PCA and the action times from debugging this are spawned off to other tickets (#277 zmin neighbor exclusion for stars; #279 and #280 improved templates). Closing.
@sbailey I think this is a bug but I'm not certain and I haven't dug into the code to assess what might be going amiss:
First, run redrock run with the nominal templates and then with a template set which includes NMF galaxy templates (but otherwise includes the same star and QSO templates):
Looking at the fitting results, we see that the nominal (PCA) templates like the
GALAXY
atz=0.16364
(which is the right answer). Meanwhile, the templates which include the NMF galaxy templates yield aSTAR
spectype atz=-0.0014
with the correctGALAXY
redshift as the fourth minimum!However, the NMF fitting results don't match the redshift scan!
So something is amiss. Any thoughts?
Tagging @dylanagreen as well since he's messing around with NMF fitting, too.