lsst-sims / legacy_sims_maf

LSST Simulations package for the metrics analysis framework (MAF)
13 stars 19 forks source link

U/yoachim/satlimit #204

Closed yoachim closed 3 years ago

yoachim commented 3 years ago

Add a stacker that adds the saturation magnitude for each visit. Would be nice to grab the saturation limit, gain, filter zeropoints, etc automatically from somewhere else. There's something close in sims_photUtils that could be expanded. Might make more sense to put it in sims_utils along with Site.

Looks like some plotting fiddles snuck in too. Should be mostly harmless.

rhiannonlynne commented 3 years ago

Offline comments lead me to think that the parameters used for the saturation limit calculation are not correct, so before merging, this needs to be validated with @bxin 's work (need link to Bo's work).

bxin commented 3 years ago

Offline comments lead me to think that the parameters used for the saturation limit calculation are not correct, so before merging, this needs to be validated with @bxin 's work (need link to Bo's work).

https://github.com/bxin/scratchBook/blob/master/saturation_limit/saturation_limit.ipynb

rhiannonlynne commented 3 years ago

Looking at Bo's notebook, one difference is that he is using a full-well of 150,000 electrons. Still looking into a comparison. Also I realized: if the full-well is in electrons, then whatever we specify as gain shouldn't matter .. (the limit is not on the ADU side). So why did the calculated saturation limit change, when I changed the gain? (seems like gain should be irrelevant, so maybe the code is missing or adding a conversion somewhere?)

UPDATE - the zeropoints in the notebook referenced, were calculated using gain=1 so are zeropoints for a single electron (rather than adu count). This is why the gain is influencing the saturation limit. Bo's notebook calculates saturation limit in two ways: with and without the zeropoints, but always using gain=1. So we have two ways to approach this .. set gain=1 and use electrons all the way through (this is more straightforward and less confusing) or use the utilities in sims_photUtils to calculate from scratch things like counts .. I'm voting for gain=1. Also adjusting the full well depth. -- ok, after adjusting both of these we're still about 1 magnitude off from Bo's calculation for a dark sky, X=1, total seeing=0.70 situation. I believe there is something off in the calculation of the peak vs. total in the stacker.

rhiannonlynne commented 3 years ago

Ok - cleaned up a few more things regarding the actual on-sky time (there were some errors in how this was being accounted for) and zeropoints. In general, things seem much closer to Bo's estimates now. However, we're now about 0.5 mag brighter than Bo's calculations. Looking at Bo's notebook, it's not clear to me how he's accounting for the fact that the visit is 30s in two exposures, rather than 30s in 1 exposure. (the way the code looks, it seems like he's calculating the counts that could go between the sky and the full well limit in a single 30s exposure, rather than two separate 15 second exposures). Indeed, if I set the saturation stacker to use 1x30s visits instead of 2x15s visits, we end up within 0.1 mag of his estimates, which I think is probably pretty good given that he's using a more sophisticated model for the PSF which distributes flux slightly differently. (indeed, if I use the very helpful 'ratio' he printed out for the ratio between source and remainder of the PSF, we end up almost identical).

@bxin could you comment on the 1x30s vs. 2x15s issue? If you were calculating saturation limit for a single 1x30s visit (i.e. total flux over the whole 30s instead of flux in 15s..), then I think we are now consistent.

rhiannonlynne commented 3 years ago

Updated point source saturation limits (using 2x15s visits) image

bxin commented 3 years ago

@bxin could you comment on the 1x30s vs. 2x15s issue? If you were calculating saturation limit for a single 1x30s visit (i.e. total flux over the whole 30s instead of flux in 15s..), then I think we are now consistent.

yes the saturation limits I calculated were for 1x30s. I should have mentioned that. It is "unofficial", but is likely to be what we do. Also I did this calculation as a prequel to the StarLink analysis. We wanted to be conservative with the results.

rhiannonlynne commented 3 years ago

Ok, great! Looks like we are in agreement then.

Running jenkins, then will merge.

ivezic commented 3 years ago

It would be good to produce a little table with saturation magnitudes for a few fiducial cases in ugrizy, and also list all the assumptions that went in with it (e.g. the seeing, the full well, effective collecting area, exposure time). It is sufficient to have a single value of seeing and full well etc, (e.g. what is the r band saturation mag for 15 sec exposure and median seeing?) but we need to demonstrate that the code produces scaling of the saturation with these quantities as expected. I think Bo already produced such a table but I cannot find it.

bxin commented 3 years ago

@ivezic Perhaps you are thinking about the table in https://github.com/bxin/scratchBook/blob/master/saturation_limit/saturation_limit.ipynb cell#12? For example, the column labelled "SatLim50" gives saturation limits for 50% quartile atmosphere (0.6 arcsec), 30 sec exposure for each band. I can switch to 15s if you like.

ivezic commented 3 years ago

Yes, Bo, that's the table I vaguely remembered! Given that our baseline is still 2x15 sec, I would recommend to do calculations for 15 sec (until, and if, we change the baseline). Lynne, Peter, let's make sure your calculations are consistent with Bo's (including Cm, too!). We are using Bo's results when talking to various reviewers and Boards, and your results for cadence optimization - they better agree! (also, remember that for 50 sec u band, the saturation limit will be 1.3 mag brighter)

rhiannonlynne commented 3 years ago

For future reference:

A sample case to compare to Bo's work, plus examples of the values across the whole simulation is available here: https://github.com/lsst-pst/survey_strategy/blob/master/fbs_1.7/Saturation%20Limits.ipynb

Bo's comparison notebook is here: https://github.com/bxin/scratchBook/blob/master/saturation_limit/saturation_limit.ipynb

If we run a sample case at 0.72" seeing (50th percentile), Bo finds -

Screen Shot 2021-02-16 at 5 24 22 PM

(cell 17) for 1x30s visits

and if we calculate the equivalent, we find

Screen Shot 2021-02-16 at 5 10 12 PM

(for 1x30s visits)

These are using the same parameters for full well (150,000 electrons) and zeropoints for the telescope / syseng throughputs curves consistent with throughputs @ end of 2019.

Swapping to 2x15s visits (appropriate for most of our recent simulations), we find these values shift as expected:

Screen Shot 2021-02-16 at 5 15 28 PM
rhiannonlynne commented 3 years ago

Merged and deleting branch u/yoachim/satlimit