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
Flux calib and config edits #707
Conversation
Borrowing an idea from the QLF repo, I have added a "WIP" (work in progress) label to desispec and applied it to this PR. We can use this for pull requests that are in progress but shouldn't be merged yet. When the owner feels that it is ready s/he can remove the label indicating that it is ready for final review and merging. |
@sbailey very useful. Thank you. |
@felipelm This is a heads up about this PR which will provide a further ‘cframe’ output from QL. This note is included here, to connect to your discussion with @sbailey on #279 and sframe files. After the current PR, the final stage frame file will be a flux calibrated file, rather than sframe which is in uncalibrated (except for fiberflattening and pixel flattening) counts. |
@sbailey We currently use imaging magnitudes for the SNR fit. With the implementation of flux calibration in this branch, should we switch to fiber magnitudes? |
Thanks @rkehoe please also notify @felipeaoli to this kind of changes as well. |
@felipelm thank you. Will do. |
@Srheft The most recent commit calculates fiber magnitudes in the Integrate_Spec QA after flux calibration. Could you please test this? |
@rstaten absolutely! coming up shortly. Have the conflicts with the master resolved prior to pushing your last commit? we shall merge the master with the PR based on Felipe's comment |
@Srheft I will merge master soon with any conflicts fixed. For now, it should be ok to test with the QL algorithms in place. |
@Srheft QP algorithms are now in this branch. |
@rstaten @Srheft @rkehoe how close are you to being ready to merge this PR? If this can be done on Wednesday morning, we could merge this and make a new desispec tag prior to merging PR #717 that will break QL (and then proceed with another PR to fix QL again...) With the new healpy installation Travis tests are passing for this PR. |
@sbailey: thanks for resolving the build failure.
|
@Srheft I agree that we should use FIBERFLUX_* for SNR, but unless @sbailey and/or @rkehoe disagrees, I don't know that this should hold up a tag. Integrate_Spec was moved to the FluxCalibration PA so that calibrated flux is used to calculate fiber magnitudes. FluxCalibration does not directly affect the SNR QA at this point, but as you mention it doesn't hurt anything. I was initially using old calibration files that I generated a long time ago to start testing, but I found the redwood calibration files in nersc (/global/project/projectdirs/desi/datachallenge/redwood/spectro/redux/redwood/exposures/20200515) and have been using these files since. As far as I know, desi_compute_fluxcalibration is used to generate these files, but I will leave it to a more experienced person to comment more. They are stored in $QL_SPEC_REDUX/exposures/NIGHT/0000EXPID as this is where they are located in the io.meta.findfile function. It is my understanding that the information contained in the response file is needed to compute fiber magnitudes, so I'm not sure how we would go about these calculations without this file. Any suggestions on how to handle this are of course welcome. Perhaps this information should be stored in a more general area that is already required to run QL so that this error doesn't occur. |
@rkehoe this PR does not have much to hold up a tag for a review. Please take a look as I will be merging as soon as Stephen wants to create the tag today. Thanks. |
@Srheft Sure, looking now. One note to @sbailey, this PR will likely break QLF because the changes necessarily impact QA metrics. Normally, we would not merge until the desispec and qlf code branches were in sync. But this could happen afterwards if you prefer. I realize in reviewing the PR comments that we have not itemized what is in this PR. So this includes:
Examining the updates now... |
Regarding breaking QLF with this PR: ok this time; they can continue to use the previous tag for QLF development. Please itemize here all non-backwards compatible changes so they know what changed and what they need to do instead to get QLF working with this again. Over on desihub/qlf#265 they were requested to "could you use PR#707 and see if you still see the NaNs in XWSIGMA_AMP" but that doesn't seem practical without documenting for them what else would need to be changed to use this branch. We'll need to do more work on the flux calibration (I acknowledge that we haven't been responsive in providing these from offline). I'm confused by the calib vectors "stored in $QL_SPEC_REDUX/exposures/NIGHT/0000EXPID" since that directory doesn't even exist when QL first starts running. In general let's aim for smaller more focused PRs, with one PR = one feature = addressing one issue. |
@rkehoe tried running night
|
It appears that QL is expecting something to pre-stage calibration vectors into the output directories. As @Srheft noted, we should not do that. QL reference calibration vectors should:
|
@sbailey. Can you clarify ‘pre-stage’ calibration vectors? The intent has been for QL to take as input the official calibration vectors from the offline processing, which was assumed to be one per camera. However, we do not currently have a decided data model for those. I have guessed that these would be in the $DESI_CCD_CALIBRATION_DATA area, but I don’t believe they are there yet. I agree to your third point also. This PR was not necessarily meant for immediate merging, since I had hoped we could resolve this issue before submitting it. If we can establish a version of such inputs into $DESi_CCD_CALIBRATION_DATA, we can modify the code to that. Do you have a suggestion of where to hold them for now if this change will take some time? |
Also one point of clarification. The ‘Integ_spec’ QA, which yields fiber magnitudes, does need to follow a flux calibration step in order to account for the wavelength dependence of the spectral response. Right now, the zero points seem to be ill-defined, but the fiber magnitudes are linearly related to the imaging magnitudes. SNR may not need to follow the flux calibration, this is true. But this depends on what the preference to plot vs. Is. If it is fiber magnitude, then it will matter here as well. I had sent a question to @sbailey to see if there is a need to switch from imaging magnitude to fiber magnitude, and that choice can be finalized as soon as we hear back. |
I'll go ahead and merge this PR now, but a few comments:
After merging this I'll merge #717 with the new fibermap format (including the "FIBERFLUX_G/R/Z" values to use for the SNR vs. fibermag calculations). That will break quicklook (sorry!) due to the changed meaning of OBJTYPE (TGT, SKY, BAD instead of ELG, LRG, QSO, ...), so top priorities for QL should be:
|
Sure. I had noted the features for this PR in my comment yesterday at 11:05 AM CST, but give again here with some elaboration:
So the result of this PR was to output the final frame output as flux units rather than counts, and to provide the estimate of a 'spectral magnitude' from INTEG QA instead of the previous integrated counts estimate. So numerically the 'FIBERMAG' entries have changed units and are numerically changed. The next PR will made adjustments to this naming (to 'SPECMAG') and to the specific form of the fiber magnitude used in SNR. |
Just started this. Will add a list of accomplishments of this PR when it is completed.