Skip to content

Commit

Permalink
Prepping for RTD
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Dec 3, 2018
1 parent ac87784 commit 96e69ec
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 46 deletions.
1 change: 1 addition & 0 deletions .rtd-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ dependencies:
- matplotlib
- numpy
- sphinx-astropy
- h5py
# - pip:
# - dependency_from_pip
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
# List runtime dependencies for the package that are available as conda
# packages here.
- CONDA_DEPENDENCIES=''
- CONDA_DEPENDENCIES_DOC='sphinx-astropy'
- CONDA_DEPENDENCIES_DOC='sphinx-astropy h5py'

# List other runtime dependencies for the package that are available as
# pip packages here.
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ include arcesetc/tests/coveragerc
recursive-include arcesetc *.pyx *.c *.pxd
recursive-include docs *
recursive-include licenses *
recursive-include cextern *
recursive-include scripts *

prune build
prune docs/_build
Expand Down
2 changes: 1 addition & 1 deletion arcesetc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class UnsupportedPythonError(Exception):

if not _ASTROPY_SETUP_:
# For egg_info test builds to pass, put package imports here.
from .utils import *
from .plots import *
from .utils import *
7 changes: 0 additions & 7 deletions arcesetc/extern/__init__.py

This file was deleted.

29 changes: 14 additions & 15 deletions arcesetc/plots.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import matplotlib.pyplot as plt
import numpy as np
import astropy.units as u
from .utils import (closest_target, archive, scale_flux,
get_closest_order, matrix_row_to_spectrum,
sn_to_exp_time)

from .utils import (_closest_target, available_sptypes, archive,
_get_closest_order, _matrix_row_to_spectrum, _scale_flux,
_sn_to_exp_time)

__all__ = ['plot_order_counts', 'plot_order_sn', 'available_sptypes']
__all__ = ['plot_order_counts', 'plot_order_sn']


@u.quantity_input(exp_time=u.s, wavelength=u.Angstrom)
Expand Down Expand Up @@ -49,21 +48,21 @@ def plot_order_counts(sptype, wavelength, V, exp_time=None,
Exposure time input, or computed to achieve S/N ratio
``signal_to_noise`` at wavelength ``wavelength``
"""
target, closest_spectral_type = _closest_target(sptype)
target, closest_spectral_type = closest_target(sptype)

matrix = archive[target][:]

closest_order = _get_closest_order(matrix, wavelength)
wave, flux = _matrix_row_to_spectrum(matrix, closest_order)
flux *= _scale_flux(archive[target], V)
closest_order = get_closest_order(matrix, wavelength)
wave, flux = matrix_row_to_spectrum(matrix, closest_order)
flux *= scale_flux(archive[target], V)

fig, ax = plt.subplots()

if exp_time is not None and signal_to_noise is None:
flux *= exp_time.to(u.s).value

elif exp_time is None and signal_to_noise is not None:
exp_time = _sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
exp_time = sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
flux *= exp_time.value
else:
raise ValueError("Supply either the `exp_time` or the "
Expand Down Expand Up @@ -120,20 +119,20 @@ def plot_order_sn(sptype, wavelength, V, exp_time=None, signal_to_noise=None,
Exposure time input, or computed to achieve S/N ratio
``signal_to_noise`` at wavelength ``wavelength``
"""
target, closest_spectral_type = _closest_target(sptype)
target, closest_spectral_type = closest_target(sptype)

matrix = archive[target][:]

closest_order = _get_closest_order(matrix, wavelength)
wave, flux = _matrix_row_to_spectrum(matrix, closest_order)
flux *= _scale_flux(archive[target], V)
closest_order = get_closest_order(matrix, wavelength)
wave, flux = matrix_row_to_spectrum(matrix, closest_order)
flux *= scale_flux(archive[target], V)

fig, ax = plt.subplots()

if exp_time is not None:
flux *= exp_time.to(u.s).value
elif exp_time is None and signal_to_noise is not None:
exp_time = _sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
exp_time = sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
flux *= exp_time.value
else:
raise ValueError("Supply either the `exp_time` or the "
Expand Down
25 changes: 12 additions & 13 deletions arcesetc/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np
from json import load
import os
Expand All @@ -18,7 +17,7 @@
temps = np.array([sptype_to_temp[key] for key in spectral_types])


def _closest_sptype(sptype):
def closest_sptype(sptype):
"""
Return closest spectral type in the archive.
Expand All @@ -35,7 +34,7 @@ def _closest_sptype(sptype):
return spectral_types[np.argmin(np.abs(sptype_to_temp[sptype] - temps))]


def _closest_target(sptype):
def closest_target(sptype):
"""
Return target with the closest spectral type in the archive.
Expand All @@ -51,7 +50,7 @@ def _closest_target(sptype):
closest_spectral_type : str
Closest spectral type available in the archive
"""
closest_spectral_type = _closest_sptype(sptype)
closest_spectral_type = closest_sptype(sptype)
return sptypes[closest_spectral_type], closest_spectral_type


Expand All @@ -67,7 +66,7 @@ def available_sptypes():
return sorted(spectral_types)


def _get_closest_order(matrix, wavelength):
def get_closest_order(matrix, wavelength):
"""
Return the spectral order index closest to wavelength ``wavelength``.
Expand All @@ -86,7 +85,7 @@ def _get_closest_order(matrix, wavelength):
return np.argmin(np.abs(matrix[:, 0] - wavelength.to(u.Angstrom).value))


def _matrix_row_to_spectrum(matrix, closest_order):
def matrix_row_to_spectrum(matrix, closest_order):
"""
Given a ``matrix`` from the archive and a spectral order index
``closest_order``, return the spectrum (wavelength and flux).
Expand All @@ -113,7 +112,7 @@ def _matrix_row_to_spectrum(matrix, closest_order):
return wave, flux


def _scale_flux(dataset, V):
def scale_flux(dataset, V):
"""
Parameters
----------
Expand All @@ -127,7 +126,7 @@ def _scale_flux(dataset, V):
return magnitude_scaling


def _sn_to_exp_time(wave, flux, wavelength, signal_to_noise):
def sn_to_exp_time(wave, flux, wavelength, signal_to_noise):
"""
Calculate the required exposure time to achieve signal-to-noise ratio
``signal_to_noise`` given the count rates ``flux`` as a function of
Expand Down Expand Up @@ -182,13 +181,13 @@ def signal_to_noise_to_exp_time(sptype, wavelength, V, signal_to_noise):
Exposure time input, or computed to achieve S/N ratio
``signal_to_noise`` at wavelength ``wavelength``
"""
target, closest_spectral_type = _closest_target(sptype)
target, closest_spectral_type = closest_target(sptype)

matrix = archive[target][:]

closest_order = _get_closest_order(matrix, wavelength)
wave, flux = _matrix_row_to_spectrum(matrix, closest_order)
flux *= _scale_flux(archive[target], V)
closest_order = get_closest_order(matrix, wavelength)
wave, flux = matrix_row_to_spectrum(matrix, closest_order)
flux *= scale_flux(archive[target], V)

exp_time = _sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
exp_time = sn_to_exp_time(wave, flux, wavelength, signal_to_noise)
return exp_time
4 changes: 0 additions & 4 deletions arcesetc/utils/__init__.py

This file was deleted.

Empty file removed arcesetc/utils/tests/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ description = Exposure time calculator for APO/ARCES
long_description = Calculate S/N and exposure times for stellar spectroscopy with the ARC Echelle Spectrograph (ARCES) on the 3.5 m Telescope at Apache Point Observatory
author = Brett Morris & Trevor Dorn-Wallenstein
author_email = brettmorris21@gmail.com
license = Other
url = https://github.com/bmorris3/ARCES-ETC
license = MIT
url = https://github.com/bmorris3/arcesetc
edit_on_github = False
github_project = bmorris3/ARCES-ETC
github_project = bmorris3/arcesetc
# install_requires should be formatted as a comma-separated list, e.g.:
# install_requires = astropy, scipy, matplotlib
install_requires = astropy
Expand Down

0 comments on commit 96e69ec

Please sign in to comment.