-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rrdesi option to output best-fit models #283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this work to generate the models given all the MPI data wrangling complexity. Big picture looks good, though I'll keep testing and reviewing for optimizations and I put some comments inline. Docstrings would be the most helpful since that is information in your head; the other requests I can update myself if needed (float32 vs. float64, writing via a tempfile).
refactor template/archetype model eval
There are a few merge conflicts to get this branch back in sync with other changes from main. I'm going to try to resolve them, but will want to do some more testing with fresh eyes before merging so heads up -- this branch might become temporarily broken. |
I reran with and without archetypes, and with multiprocessing and MPI, and verified that the output models look good when plotting on top of the data, while also being different between archetypes vs. PCA templates as expected. Looks good. |
This pull request is for #270
The PR also adds support for redshift scan for coadded spectra (already coadded across the cameras) in the archetype mode. I also added support to get
bands
fromtarget
objects. It's very useful in case we want to match wavehashes with band names and save the data using band keywords, particularly in model files.Sanity checks:
Archetype mode (main branch):
srun -n 64 -c 2 rrdesi_mpi -i /global/cfs/cdirs/desi/spectro/redux/iron/tiles/cumulative/80605/20210205/coadd-6-80605-thru20210205.fits -o main_test.fits -d main_test.h5 --archetypes /global/homes/a/abhijeet/software/desisoft/new-archetypes/rrarchetype-galaxy.fits
on this branch:
srun -n 64 -c 2 rrdesi_mpi -i /global/cfs/cdirs/desi/spectro/redux/iron/tiles/cumulative/80605/20210205/coadd-6-80605-thru20210205.fits -o branch_test.fits -d branch_test.h5 --archetypes /global/homes/a/abhijeet/software/desisoft/new-archetypes/rrarchetype-galaxy.fits
comparison
Along with this, we can now run
rrdesi --model
for both coadded and uncoadded spectrarrdesi --model option
I have added
rrdesi --model
option in the current redrock. If run with this option, the code now also returns the best-fit models for each target in the input coadd file and stores them in a separate file. The data format is similar to the coadd file (meaning if the coadd file hasB, R, Z_FLUX,
then the model file also has theB, R, Z_MODEL
and corresponding wavelengths. It also saves the redrock file's fits header in the model file, which includes information suchTARGETID, Z, ZWARN, SPECTYPE,... and COEFFTYPE
(which stores if the model is based onPCA, NMF, or ARCHETYPE
). The resolution matrix is applied while estimating the best-fit model.If coadded (across cameras) spectrum is provided (including resolution matrix) then also code should work.
The code adds another ~1s in no archetype mode and ~4s in archetype mode (I am sure can be optimized) to estimate/save the final models.
Test runs (uncoadded spectra):
Without archetypes:
srun -n 64 -c 2 rrdesi_mpi -i /global/cfs/cdirs/desi/spectro/redux/iron/tiles/cumulative/80605/20210205/coadd-6-80605-thru20210205.fits -o test.fits -d test.h5 --model test_model.fits
With archetypes:
srun -n 64 -c 2 rrdesi_mpi -i /global/cfs/cdirs/desi/spectro/redux/iron/tiles/cumulative/80605/20210205/coadd-6-80605-thru20210205.fits -o test.fits -d test.h5 --model test_model.fits --archetypes $ARCHETYPES
The headers of model file look like :
for coadded (across cameras) headers of the model file look like:
Example run and model spectra: