Skip to content
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

Implement a model of twilight sky brightness #84

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5d9d828
Add twilight config to desi.yaml
dkirkby Nov 23, 2017
50c5d79
Stub out new atmosphere.Twilight class
dkirkby Nov 23, 2017
98ec415
Implement twilight model ctor
dkirkby Nov 23, 2017
7b98c4b
Implement Twilight model getter/setters
dkirkby Nov 23, 2017
cbc85e3
Implement twilight model in standalone func with unit tests
dkirkby Nov 23, 2017
c232502
Allow travis test failures with astropy dev
dkirkby Nov 23, 2017
4cd8b50
Add twilight polar plot
dkirkby Nov 23, 2017
7a03996
Fix sphinx error
dkirkby Nov 23, 2017
23e72b4
Flesh out docstring
dkirkby Nov 25, 2017
54c8968
Implement optional dark subtraction from twilight model
dkirkby Nov 25, 2017
a5166c2
Scale solar spectrum for twilight prediction
dkirkby Nov 25, 2017
ee81881
Incorporate Twilight into Atmosphere
dkirkby Nov 25, 2017
77a7151
Remove obsolete sky_conditions logic
dkirkby Nov 25, 2017
e7f4f44
Update user docs to include twilight examples
dkirkby Nov 26, 2017
f4b1828
Use updated (x,y) parameterization from Sergey
dkirkby Nov 26, 2017
e748b42
Implement autoranging for twilight plot
dkirkby Nov 26, 2017
b371e5c
Use r-band fit instead of i-band for twilight model
dkirkby Nov 26, 2017
6c020fe
Add extinction to twilight model
dkirkby Nov 27, 2017
5c93325
Update documentation plots
dkirkby Nov 27, 2017
c1e3c66
Add new plot to help explain twilight model
dkirkby Nov 27, 2017
14d401f
Fix some doc typos
dkirkby Nov 27, 2017
a8877e7
Update default subtract_dark value for r-band (increases twilight norm)
dkirkby Nov 27, 2017
636ddf4
Add units to twilight r-band mag
dkirkby Dec 1, 2017
8003dd9
Add units to calculated twilight r-mag
dkirkby Dec 1, 2017
d702098
Scale dark sky emission with airmass
dkirkby Dec 1, 2017
51647d4
Fix typo
dkirkby Dec 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ matrix:
- os: linux
env: SETUP_CMD='build_docs -w'

# Now try Astropy dev and LTS vesions with the latest 3.x and 2.7.
# Try astropy dev version.
- os: linux
env: ASTROPY_VERSION=development
EVENT_TYPE='pull_request push cron'

# Now try Astropy LTS vesions with the latest 3.x and 2.7.
- os: linux
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=lts
- os: linux
Expand Down Expand Up @@ -110,6 +112,13 @@ matrix:
env: MAIN_CMD='pycodestyle packagename --count' SETUP_CMD=''

allow_failures:
# Try astropy dev version. This current causes some doctests
# to fail because they produce the following unexpected output:
# Downloading http://maia.usno.navy.mil/ser7/finals2000A.all [Done]
# from `simulator = specsim.simulator.Simulator('test')``
- os: linux
env: ASTROPY_VERSION=development
EVENT_TYPE='pull_request push cron'
# Do a PEP8 test with pycodestyle
# (allow to fail unless your code completely compliant)
- os: linux
Expand Down
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
0.12 (unreleased)
-----------------

- No changes yet.
- Scale the dark sky spectrum with airmass.
- Implement Twilight sky brightness model and integrate with Atmosphere model.
- Remove obsolete sky_conditions parameter and only read tabulated dark sky.

0.11 (2017-10-10)
0.11 (2017-11-10)
-----------------

- Implement fast fiberloss calculator that interpolates GalSim results (#78).
Expand Down
Binary file modified docs/_static/desi_atmosphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/desi_moon_atmosphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/desi_moon_twilight_atmosphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/desi_twilight_polar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/twilight_spectrum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 46 additions & 15 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ multi-HDU FITS file::
In this case the HDU and columns are identified by their names in the FITS file.

Finally, some tabulated data uses different files to represent different options.
For example, sky surface brightness tables under different conditions are
For example, fiberloss tables for different source types are
specified by replacing the ``path`` node with a ``paths`` node as follows::

paths:
dark: dark-sky.csv
grey: grey-sky.csv
bright: bright-sky.csv
# Each path corresponds to a different source type.
qso: throughput/fiberloss-qso.dat
elg: throughput/fiberloss-elg.dat
lrg: throughput/fiberloss-lrg.dat

For additional examples of specifying tabular data, refer to the configurations
included with this package and described below.
Expand Down Expand Up @@ -182,37 +183,67 @@ The following plot summarizes the default DESI atmosphere used for simulations,
and was created using::

config = specsim.config.load_config('desi')
specsim.atmosphere.initialize(config).plot()
atm = specsim.atmosphere.initialize(config)
atm.plot()

.. image:: _static/desi_atmosphere.png
:alt: DESI default atmosphere configuration

The default atmosphere has the moon below the horizon. To simulate grey or
bright conditions, add scattered moon light by :doc:`modifying the relevant
parameters in the configuration </api>`, or else by changing attributes of the
initialized atmosphere model. For example::
The default atmosphere has the moon below the horizon. To add scattered
moonlight, :doc:`adjust the relevant parameters in the configuration </api>`,
or change attributes of the initialized atmosphere model. For example::

atm = specsim.atmosphere.initialize(config)
atm.airmass = 1.3
atm.moon.moon_zenith = 60 * u.deg
atm.moon.separation_angle = 50 * u.deg
atm.moon.moon_phase = 0.25
atm.plot()

.. image:: _static/desi_bright_atmosphere.png
:alt: DESI bright atmosphere configuration
.. image:: _static/desi_moon_atmosphere.png
:alt: DESI moon configuration

To add an additional twilight component::

atm.twilight.sun_altitude = -13 * u.deg
atm.twilight.sun_relative_azimuth = 30 * u.deg
atm.plot()

.. image:: _static/desi_moon_twilight_atmosphere.png
:alt: DESI moon plus twilight configuration

Note how total sky emission has increased significantly and is dominated by
scattered moon at the blue end. To explore the dependence of the scattered
moon brightness on the observed field, use
:func:`specsim.atmosphere.plot_lunar_brightness`. For example::
scattered moon at the blue end and twilight sun at the red end. To explore
the dependence of scattering on the observing conditions, use the
:func:`plot_lunar_brightness <specsim.atmosphere.plot_lunar_brightness>` and
:func:`plot_twlight_brightness <specsim.atmosphere.plot_twilight_brightness>`
functions. For example::

specsim.atmosphere.plot_lunar_brightness(
moon_zenith=60*u.deg, moon_azimuth=90*u.deg, moon_phase=0.25)

.. image:: _static/desi_scattered_moon.png
:alt: DESI scattered moon brightness

and::

specsim.atmosphere.plot_twilight_brightness(
sun_altitude=-13*u.deg, sun_azimuth=90*u.deg)

.. image:: _static/desi_twilight_polar.png
:alt: DESI twlight brightness

For an explanatory plot of the twilight spectrum, use::

atm.twilight.plot_spectrum()

.. image:: _static/twilight_spectrum.png
:alt: DESI twilight spectrum

Note how the twilight spectrum is significantly reddened relative to the
solar spectrum above the atmosphere (yellow) since it passes through a
large airmass (X~40) before scattering in the atmosphere above the observing
line of sight.

Instrument
^^^^^^^^^^

Expand Down
6 changes: 3 additions & 3 deletions docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ independent of its SED.
Atmosphere Model
----------------

The atmosphere adds its own emission spectrum :math:`b(\lambda)` to that of the
source and then both are attenuated by their passage through the atmosphere by
the extinction factor:
The atmosphere adds its own emission spectrum :math:`b(\lambda) X` to that of
the source and then both are attenuated by their passage through the atmosphere
by the extinction factor:

.. math::

Expand Down
10 changes: 2 additions & 8 deletions docs/nb/config/desi-blur-offset-scale-stochastic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wavelength_grid:
# The atmosphere configuration is interpreted and validated by the
# specsim.atmosphere module.
atmosphere:
# Sky emission surface brightness.
# Dark sky emission surface brightness.
sky:
table:
# The .dat extension is not automatically recognized as ascii.
Expand All @@ -42,13 +42,7 @@ atmosphere:
index: 1
# Note the factor of 1e-17 in the units!
unit: 1e-17 erg / (Angstrom arcsec2 cm2 s)
paths:
# Each path defines a possible condition.
dark: spectra/spec-sky.dat
grey: spectra/spec-sky-grey.dat
bright: spectra/spec-sky-bright.dat
# Specify the current condition.
condition: dark
path: spectra/spec-sky.dat
# Atmospheric seeing (only used when instrument.fiberloss.method = galsim)
seeing:
# The seeing is assumed to scale with wavelength as
Expand Down
10 changes: 2 additions & 8 deletions docs/nb/config/desi-blur-offset-scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wavelength_grid:
# The atmosphere configuration is interpreted and validated by the
# specsim.atmosphere module.
atmosphere:
# Sky emission surface brightness.
# Dark sky emission surface brightness.
sky:
table:
# The .dat extension is not automatically recognized as ascii.
Expand All @@ -42,13 +42,7 @@ atmosphere:
index: 1
# Note the factor of 1e-17 in the units!
unit: 1e-17 erg / (Angstrom arcsec2 cm2 s)
paths:
# Each path defines a possible condition.
dark: spectra/spec-sky.dat
grey: spectra/spec-sky-grey.dat
bright: spectra/spec-sky-bright.dat
# Specify the current condition.
condition: dark
path: spectra/spec-sky.dat
# Atmospheric seeing (only used when instrument.fiberloss.method = galsim)
seeing:
# The seeing is assumed to scale with wavelength as
Expand Down
10 changes: 2 additions & 8 deletions docs/nb/config/desi-blur-offset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wavelength_grid:
# The atmosphere configuration is interpreted and validated by the
# specsim.atmosphere module.
atmosphere:
# Sky emission surface brightness.
# Dark sky emission surface brightness.
sky:
table:
# The .dat extension is not automatically recognized as ascii.
Expand All @@ -42,13 +42,7 @@ atmosphere:
index: 1
# Note the factor of 1e-17 in the units!
unit: 1e-17 erg / (Angstrom arcsec2 cm2 s)
paths:
# Each path defines a possible condition.
dark: spectra/spec-sky.dat
grey: spectra/spec-sky-grey.dat
bright: spectra/spec-sky-bright.dat
# Specify the current condition.
condition: dark
path: spectra/spec-sky.dat
# Atmospheric seeing (only used when instrument.fiberloss.method = galsim)
seeing:
# The seeing is assumed to scale with wavelength as
Expand Down
10 changes: 2 additions & 8 deletions docs/nb/config/desi-blur.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wavelength_grid:
# The atmosphere configuration is interpreted and validated by the
# specsim.atmosphere module.
atmosphere:
# Sky emission surface brightness.
# Dark sky emission surface brightness.
sky:
table:
# The .dat extension is not automatically recognized as ascii.
Expand All @@ -42,13 +42,7 @@ atmosphere:
index: 1
# Note the factor of 1e-17 in the units!
unit: 1e-17 erg / (Angstrom arcsec2 cm2 s)
paths:
# Each path defines a possible condition.
dark: spectra/spec-sky.dat
grey: spectra/spec-sky-grey.dat
bright: spectra/spec-sky-bright.dat
# Specify the current condition.
condition: dark
path: spectra/spec-sky.dat
# Atmospheric seeing (only used when instrument.fiberloss.method = galsim)
seeing:
# The seeing is assumed to scale with wavelength as
Expand Down
Loading