-
Notifications
You must be signed in to change notification settings - Fork 9
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
Efficient simulation of multiple sources in a single exposure #53
Conversation
I have implemented a simple benchmark in a new cmd-line script
I get the following timing results for the loop (i.e., not including the simulator start up time):
In other words, this is surprisingly fast, with a total time for 5K targets of ~70ms! |
Those timing results were completely wrong because the code was still using the fiberloss tables, instead of galsim. The updated numbers look a lot more plausible:
The total time for 5K targets is now ~230s (3:50 minutes). This is without any caching of things that do not change (atmospheric PSF and anti-aliased fiber aperture, for example), so the next steps are to:
|
The profile is instructive:
It looks like we are spending more time in |
Hardcode the following values:
and repeat the profile:
This confirms that the astropy slowdown is mostly coming from those two calls. |
…lossCalculator class
Instructions for profiling a console-script entry point within ipython:
To examine the profile results saved in
|
After the latest commits, the profile is:
so we are still dominated by astropy units. |
Checklist for closing this PR:
|
…ng the astropy template files
I think I have fixed the last travis problems and I am ready to merge now. I decided to push the new "batch simulate" method into a separate PR since there is already a lot to review here. I am assigning @sbailey, but anyone else is welcome to jump in. |
Updated readthedocs for this PR are at http://specsim.readthedocs.io/en/multiplesources/, including:
|
Did you want to finish the unchecked punchlist item of "Update I don't see how to combine the fiberloss calculations with a spectral simulation here, even for a single target. Could you add a section to the Users Guide with the actual python code to simulate a spectrum of flux vs. wavelength for a r=2 arcsec disk galaxy at x=100,y=50 on the DESI focal plane, and an example of how to override/replace the default fiberloss calculation with a different fiberloss vs. wavelength? i.e. this code looks fine to merge, though I don't yet know how to use it to accomplish the original goal of this branch / PR. I'm not sure if that is because this PR lays the groundwork but the final integration is still to be done, or whether I'm just not reading the right part of the documentation/code, or whether that connection isn't documented yet. |
You didn't miss anything. I decided to do the final connection in a new PR since it will probably break the public API and there are a lot of changes here already. To simulate a single fiber with this code, you just need to change |
If using method=galsim, how does the user specify where on the focal plane the object is? For consideration: is it necessary to change the public specsim API to support multiple fibers simultaneously? Are there big performance benefits from reusing calculations? We could just wrap the existing single spectrum API in a multi-spectrum API on the desisim side. I think updating the specsim API could be useful, but I don't think it has to happen that way. Documentation comment doesn't have to be a blocking factor for this PR, but it still applies: specsim provides great details on what it does, but lacks the big picture example of how to put the pieces together to do a simulation (unless using the command line quickspecsim). You may be so familiar with it that it is obvious to you, but I have to poke under the hood in quickspecsim or quickgen to figure that out. |
I am merging now and will update the docs as part of the next PR after consultation with Stephen. The scipy docs web server has been down for ~2 days now, so this may cause travis failures (since the docs build uses intersphinx). |
This PR is to address #6 and, in particular, to look at the feasibility of calculating fiberloss fractions for a whole focal plane on the fly.