astroplan icon indicating copy to clipboard operation
astroplan copied to clipboard

Adding an exptime calculator, Telescope class, and sky model

Open tcjansen opened this issue 5 years ago • 11 comments

All of the additions I've made in this PR are motivated by adding an exposure time calculator to astroplan. To do so, the user supplies their own spectrum (or spectral model) of their target (in the following example as waveset_of_target and flux_of_target), the desired signal to noise ratio (SNR) the user wants to reach, an astroplan observer object, and a new astroplan telescope object to a function called exptime_from_ccd_snr:

>>> from astroplan import exptime_from_ccd_snr
>>> snr = 100
>>> exptime_from_ccd_snr(snr, waveset_of_target, flux_of_target, observer, telescope)

To compute the exposure time needed to obtain the given SNR, astroplan needs to know some telescope specifications such as the gain, aperture area, and bandpass. The new astroplan.telescope.Telescope object handles those parameters. astroplan then convolves the bandpass, spectrum, and any other optional effects (such as ccd response) with the help of synphot, which astroplan also uses to get the count rate of the mock observation.

I have also added the option for the user to input a custom sky model to the Observer object (i.e. a model of the atmospheric transmission at the location of the observer). With the new skycalc module, the user can alternatively obtain a sky model generated from an arsenal of optional sky parameters via the SKYCALC sky calculator.

See here for a tutorial!

Much of the content of this PR has been reviewed in this PR to synphot, where we had originally thought these functions might go before deciding that astroplan would be more a more appropriate place!

I haven't integrated the tests yet since I wanted to get this PR in ASAP, but they are coming soon (after which some minor changes may be made if I discover any buggy behavior)!

Update: this PR closes #29

tcjansen avatar Aug 20 '19 14:08 tcjansen

Test failures are symptoms of a broken CI on master itself. I am trying to see if I can fix it up at #421 but I can't promise anything.

UPDATE: Yup, I fixed it, but it needs to be merged first before you can reap the benefit here via a rebase.

pllim avatar Aug 20 '19 17:08 pllim

Thanks for looking it over @pllim! Sorry it was unusually sloppy, I forgot to run pycodestyle before pushing 😱 (I used to have my sublimelinter running but it has mysteriously stopped showing me errors...)

tcjansen avatar Aug 21 '19 21:08 tcjansen

@tcjansen , tests are fixed for master, please rebase. Thanks!

pllim avatar Aug 26 '19 15:08 pllim

Hey @tcjansen – any chance you'll be able to address the comments above sometime? If not, no problem just let us know so someone else gets to it. Thanks again!

bmorris3 avatar Oct 29 '19 13:10 bmorris3

Ohh my gosh thanks for the reminder, @bmorris3! For some reason I had it in my head that I was waiting for comments... Will get to it soon!

tcjansen avatar Oct 30 '19 14:10 tcjansen

Added some more comments – please also rebase when you get a chance.

bmorris3 avatar Nov 06 '19 15:11 bmorris3

In order to get your new tests to pass which rely on synphot, you'll need to do a few more small changes:

  • add a line like the others here for synphot
  • add synphot to the tests_require line here
  • add synphot to the testing matrix dependencies here

bmorris3 avatar Nov 06 '19 15:11 bmorris3

  • add synphot to the testing matrix dependencies here

So I tried adding synphot to this line but I'm getting a conflict error... what's the correct way of going about this?

tcjansen avatar Nov 13 '19 01:11 tcjansen

You'll need to rebase and then force-push your changes. I recommend you make a backup branch of your work by typing git branch backup before you rebase, just in case.

bmorris3 avatar Nov 13 '19 08:11 bmorris3

Ah okay, I misunderstood "rebase" to mean "squash". Now that the conflicts are fixed, travis is still angry... I tried a few different approaches to adding synphot to '.travis.yml' but no luck.. but I'm admittedly fumbling around in the dark since I'm not familiar with travis 😅

tcjansen avatar Nov 13 '19 22:11 tcjansen

Sorry to leave you hanging so long @tcjansen!

  • One test is failing because astroquery is not in pip requirements for tests. You might be able to fix this by adding astroquery to this line

  • Another test is failing due to formatting of the file. To reproduce this test locally, install flake8 with pip install flake8 type the following in the astroplan repo flake8 astroplan --count --max-line-length=100. It will return to you the formatting tweaks that you need to make. Adjust the code and rerun flake8 until it returns 0.

  • this one is a bit mysterious to me, but maybe we'll tackle it after we get the first two solved.

bmorris3 avatar Dec 06 '19 08:12 bmorris3