Closed abhi0395 closed 2 months ago
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 https://github.com/desihub/redrock/issues/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: