-
Notifications
You must be signed in to change notification settings - Fork 22
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
refactored newexp #238
refactored newexp #238
Conversation
Shoot. I completely forgot about random state seed propagation for this. Once we have the 2% inputs ready to use I'll test this with those anyway, but we should decide if reproducibility is a blocking factor or not for merging this (I'm inclined to think that it should be, but that may slow the sprint...) |
add notebook comparing various interpolation methods
heads up: I'm going to rebase this newexp branch to get the changes in #246 to get back in sync with API changes from desitarget/master and resolve merge conflicts with desisim/master. Usually rebasing after making a branch public is a Bad Idea, but I'm under the impression that I'm the only one developing on this branch. |
The rebase was a massive mess, so I'm going to abandon this PR and delete the branch from github and re-push and start a new PR. |
Disclaimer: this is a rather unsatisfying refactor since so much more could be done and it just doesn't "feel" right yet, but in the spirit of the 2% sprint I'm going to stop shuffling deck chairs and provide something that works for now.
Please review this but let's hold off on merging until we've confirmed that it properly handles the full 2% mock spectra input (I debugged it on a much earlier run). Tests pass on my laptop but I see I still have some Travis cleanup to do...
This refactors
newexp-desi
(now justnewexp
) to accept inputs from a mock target catalog, mock truth spectra, fiber assignment, and observing conditions from surveysim instead of making up a random exposure on the fly. It also switches to usingspecsim
for the sky/lunar model and fiberloss calculations, also laying the groundwork for optionally using galsim for detailed per-object fiberloss calculations.A random dark/bright/etc. exposure can still be generated from a python API (old
desisim.obs.new_exposure
code) but not via a command-line script anymore.newarc
andnewflat
are split out as separate scripts since they take different parameters than a new science exposure (e.g. no observing conditions or fiber assignment inputs...)This also provides a
simulate_spectra
convenience function that wraps specsim to provide a translation from obsconditions and fibermap tables into how to construct and run a specsim Simulator. At its simplest this is justsim = simulate_spectra(wave, flux)
, but it optionally can take surveysim inputs for specifying observing conditions or a target/fiberassign/fibermap table to specify target locations and targeting bits to derive fiber input losses.simspec format was simplified (?) to use binary tables with columns e.g. WAVELENGTH, FLUX, SKYFLUX instead of one image HDU per variable. If this mucks up BGS or other work that may have been writing simspec formats on their own, I could consider expanding
desisim.io.read_simspec
to support both formats.Examples:
Generate new arc and flat exposures to be written to
$DESI_SPECTRO_SIM/$PIXPROD/{night}/*-{expid}.fits
:Write output to a different location:
Generate a new science exposure using fiberassignment, surveysim, and mock spectra inputs:
This
obsnum
row fromtwopct.ecsv
to get the exposure dateobs (and thus the YEARMMDD night) and observing conditions. That file does not have exposure IDs so that is separately assigned here (--expid 4
)mocktargets/{abc}/truth-{brickname}.fits
The simspec+fiberassign outputs from these can be fed into either quickgen or pixsim, e.g.
Future work that this PR does not try to address:
py/desisim/newexp.py
became a bit of a dumping ground for new functions to try to keep them together and not break existing code. After we've sorted out what we really want, pieces could move elsewhere, e.g. reading mocks -> desitarget.desisim.obs.new_exposure
(previous code) generates a random exposure on-the-fly whiledesisim.newexp.newexp
(new code) takes fibermap, mock, and observing conditions as input and generates an matching exposure. These are confusingly similarly names and could be consolidated.