Skip to content

Commit

Permalink
Merge e486830 into 197abbc
Browse files Browse the repository at this point in the history
  • Loading branch information
profxj committed Jan 14, 2019
2 parents 197abbc + e486830 commit f3b28bf
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 11 deletions.
2 changes: 1 addition & 1 deletion astropy_helpers
Submodule astropy_helpers updated 90 files
+21 −0 .coveragerc
+24 −53 .travis.yml
+18 −267 CHANGES.rst
+1 −1 MANIFEST.in
+2 −21 README.rst
+84 −83 ah_bootstrap.py
+22 −15 appveyor.yml
+0 −17 astropy_helpers/__init__.py
+0 −81 astropy_helpers/commands/_dummy.py
+0 −307 astropy_helpers/commands/_test_compat.py
+107 −400 astropy_helpers/commands/build_ext.py
+37 −82 astropy_helpers/commands/build_sphinx.py
+0 −1 astropy_helpers/commands/setup_package.py
+0 −35 astropy_helpers/commands/test.py
+38 −0 astropy_helpers/compat/_subprocess_py2/__init__.py
+19 −0 astropy_helpers/compat/subprocess.py
+0 −51 astropy_helpers/conftest.py
+1 −1 astropy_helpers/distutils_helpers.py
+0 −11 astropy_helpers/extern/__init__.py
+0 −1 astropy_helpers/extern/automodapi/__init__.py
+0 −138 astropy_helpers/extern/automodapi/autodoc_enhancements.py
+0 −214 astropy_helpers/extern/automodapi/utils.py
+0 −8 astropy_helpers/extern/numpydoc/__init__.py
+0 −425 astropy_helpers/extern/numpydoc/docscrape_sphinx.py
+0 −325 astropy_helpers/extern/numpydoc/numpydoc.py
+0 −16 astropy_helpers/extern/numpydoc/templates/numpydoc_docstring.rst
+0 −4 astropy_helpers/extern/setup_package.py
+5 −10 astropy_helpers/git_helpers.py
+0 −107 astropy_helpers/openmp_helpers.py
+194 −92 astropy_helpers/setup_helpers.py
+1 −3 astropy_helpers/sphinx/__init__.py
+34 −46 astropy_helpers/sphinx/conf.py
+1 −0 astropy_helpers/sphinx/ext/__init__.py
+113 −0 astropy_helpers/sphinx/ext/astropyautosummary.py
+98 −0 astropy_helpers/sphinx/ext/autodoc_enhancements.py
+35 −97 astropy_helpers/sphinx/ext/automodapi.py
+93 −173 astropy_helpers/sphinx/ext/automodsumm.py
+0 −4 astropy_helpers/sphinx/ext/changelog_links.py
+169 −0 astropy_helpers/sphinx/ext/comment_eater.py
+865 −0 astropy_helpers/sphinx/ext/compiler_unparse.py
+76 −169 astropy_helpers/sphinx/ext/docscrape.py
+274 −0 astropy_helpers/sphinx/ext/docscrape_sphinx.py
+1 −19 astropy_helpers/sphinx/ext/doctest.py
+4 −7 astropy_helpers/sphinx/ext/edit_on_github.py
+187 −0 astropy_helpers/sphinx/ext/numpydoc.py
+167 −0 astropy_helpers/sphinx/ext/phantom_import.py
+7 −22 astropy_helpers/sphinx/ext/smart_resolver.py
+0 −0 astropy_helpers/sphinx/ext/templates/autosummary_core/base.rst
+0 −0 astropy_helpers/sphinx/ext/templates/autosummary_core/class.rst
+0 −0 astropy_helpers/sphinx/ext/templates/autosummary_core/module.rst
+70 −0 astropy_helpers/sphinx/ext/tests/__init__.py
+56 −0 astropy_helpers/sphinx/ext/tests/test_autodoc_enhancements.py
+343 −0 astropy_helpers/sphinx/ext/tests/test_automodapi.py
+114 −0 astropy_helpers/sphinx/ext/tests/test_automodsumm.py
+762 −0 astropy_helpers/sphinx/ext/tests/test_docscrape.py
+34 −0 astropy_helpers/sphinx/ext/tests/test_utils.py
+0 −4 astropy_helpers/sphinx/ext/tocdepthfix.py
+142 −0 astropy_helpers/sphinx/ext/traitsdoc.py
+65 −0 astropy_helpers/sphinx/ext/utils.py
+220 −0 astropy_helpers/sphinx/ext/viewcode.py
+ astropy_helpers/sphinx/local/python2_local_links.inv
+0 −25 astropy_helpers/sphinx/local/python2_local_links.txt
+ astropy_helpers/sphinx/local/python3_local_links.inv
+0 −38 astropy_helpers/sphinx/local/python3_local_links.txt
+ astropy_helpers/sphinx/local/python3links.inv
+20 −0 astropy_helpers/sphinx/local/python3links.txt
+1 −1 astropy_helpers/sphinx/setup_package.py
+1 −5 astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css
+8 −14 astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js
+244 −7 astropy_helpers/test_helpers.py
+40 −54 astropy_helpers/tests/__init__.py
+0 −32 astropy_helpers/tests/coveragerc
+93 −117 astropy_helpers/tests/test_ah_bootstrap.py
+36 −58 astropy_helpers/tests/test_git_helpers.py
+0 −38 astropy_helpers/tests/test_openmp_helpers.py
+86 −373 astropy_helpers/tests/test_setup_helpers.py
+0 −24 astropy_helpers/tests/test_utils.py
+25 −226 astropy_helpers/utils.py
+6 −17 astropy_helpers/version_helpers.py
+71 −0 continuous-integration/appveyor/install-miniconda.ps1
+47 −0 continuous-integration/appveyor/windows_sdk.cmd
+7 −0 continuous-integration/travis/install_conda_linux.sh
+7 −0 continuous-integration/travis/install_conda_osx.sh
+4 −0 continuous-integration/travis/install_graphviz_linux.sh
+4 −0 continuous-integration/travis/install_graphviz_osx.sh
+382 −0 ez_setup.py
+0 −28 licenses/LICENSE_ASTROSCRAPPY.rst
+1 −1 setup.cfg
+7 −6 setup.py
+19 −0 tox.ini
2 changes: 1 addition & 1 deletion docs/guis.rst
Expand Up @@ -32,7 +32,7 @@ This enables interactive fitting of the unabsorbed continuum for a
spectrum. A series of 'knot' positions are estimated, and these are
then joined with a spline to produce a continuum. Spline points can be
interactively added, deleted or moved to improve the continuum. See
the notebook for an example.
the notebook for an example or use the lt_continuumfit script directly.

XSpecGUI
========
Expand Down
11 changes: 9 additions & 2 deletions docs/scripts.rst
Expand Up @@ -171,13 +171,16 @@ lt_continuumfit

Launch the GUI to continuum fit a spectrum.
If a redshift is supplied by zsys, then the
script assumes this is a QSO.::
script assumes this is a QSO. Enables spectra
to be read in via a `specdb <https://specdb.readthedocs.io/en/latest/>`__ file
which then requires specdb be installed.::

lt_continuumfit input_file output_filename --redshift 0.867

Here is the current usage message::

usage: lt_continuumfit [-h] [--redshift REDSHIFT] [--wchunk WCHUNK]
usage: lt_continuumfit [-h] [--redshift REDSHIFT] [--wchunk WCHUNK] [--native]
[--specdb SPECDB]
file outfil

GUI to fit a continuum to a spectrum
Expand All @@ -191,3 +194,7 @@ Here is the current usage message::
-h, --help show this help message and exit
--redshift REDSHIFT Redshift of the Source
--wchunk WCHUNK Width of a 'chunk' (Ang)
--native Do not mask input spectrum
--specdb SPECDB Input file is specdb. Input (ra,dec,group) in this
order without spaces

5 changes: 3 additions & 2 deletions linetools/analysis/continuum.py
Expand Up @@ -226,7 +226,7 @@ def unmask(masked, indices, wa, fl, er, minpix=3):
masked[ind1] = False


def estimate_continuum(s, knots, indices, masked, ax=None, maxiter=1000,
def estimate_continuum(s, knots, indices, masked, ax=None, maxiter=100,
nsig=1.5, debug=False):
""" Iterate to estimate the continuum.
"""
Expand Down Expand Up @@ -255,7 +255,8 @@ def estimate_continuum(s, knots, indices, masked, ax=None, maxiter=1000,
print('No further points masked, stopping')
break
if count > maxiter:
raise RuntimeError('Exceeded maximum iterations')
warnings.warn('Exceeded maximum iterations. Continue at your own risk..')
break

count +=1

Expand Down
76 changes: 76 additions & 0 deletions linetools/guis/specdbutils.py
@@ -0,0 +1,76 @@
""" Module for integrating specdb within linetools. Mainly widgets and scripts"""

try:
import specdb
except ImportError:
flg_specdb = False
else:
flg_specdb = True
from specdb.specdb import SpecDB

from astropy.coordinates import SkyCoord


def load_specb(specdb_file):
"""
Load a specdb_file
Parameters
----------
specdb_file: str
Full path to the specdb file
Returns
-------
spdb: SpecDB or None
Returns None if specdb cannot be imported
"""
# Required import?
if not flg_specdb:
return None
#
spdb = SpecDB(db_file=specdb_file)
return spdb


def load_xspec(spdb, ra, dec, group=None, **kwargs):
"""
Load an XSpectrum1D class from a SpecDB object
Parameters
----------
spdb: SpecDB
ra: float
RA coordinate (ICRS)
dec: float
DEC coordinate (ICRS)
group: str, optional
Data group to grab spectrum from
**kwargs
Passed to XSpectrum1D, e.g. masking
Returns
-------
spec: XSpectrum1D or None
Returns None if specdb cannot be imported
"""
# Required import?
if not flg_specdb:
return None

# Need a list of group(s)
if group is None:
group = []
else:
group = [group]

# Coord
scoord = SkyCoord(ra=ra, dec=dec, unit='deg')

spec, _ = spdb.spectra_from_coord(scoord, groups=group, **kwargs)

# Return
return spec
19 changes: 17 additions & 2 deletions linetools/scripts/lt_continuumfit.py
Expand Up @@ -19,20 +19,35 @@ def main(*args, **kwargs):
parser.add_argument("--redshift", type=float, help="Redshift of the Source")
parser.add_argument("--wchunk", type=float, help="Width of a 'chunk' (Ang)")
parser.add_argument("--native", default=True, action='store_true', help="Do not mask input spectrum")
parser.add_argument("--specdb", type=str, help="Input file is specdb. Input (ra,dec,group) in this order without spaces")
#parser.add_argument("-exten", type=int, help="FITS extension")

pargs = parser.parse_args()


from linetools.guis.xspecgui import XSpecGui
from linetools.guis import specdbutils
from linetools.spectra import io as lsio

# Read spectrum
if pargs.native:
masking = 'none'
else:
masking = 'edges'
xspec = lsio.readspec(pargs.file, masking=masking)

# Load from simple file
if pargs.specdb is None:
xspec = lsio.readspec(pargs.file, masking=masking)
else:
# Load specdb
spdb = specdbutils.load_specb(pargs.file)
if spdb is None:
print("You have not yet installed specdb!!")
print("Exiting..")
return
# Parse
ra,dec,group = pargs.specdb.split(',')
# Load
xspec = specdbutils.load_xspec(spdb, float(ra), float(dec), group=group, masking=masking)

kwrds = {}
if pargs.wchunk is not None:
Expand Down
3 changes: 1 addition & 2 deletions linetools/spectra/tests/test_xspec_attrib.py
Expand Up @@ -19,8 +19,7 @@ def data_path(filename):
return os.path.join(data_dir, filename)


@pytest.fixture
def dummy_spec(wave=None, npix=2000, s2n=10., seed=None):
def dummy_spec(wave=None, s2n=10., npix=2000, seed=None):
"""
Parameters
----------
Expand Down
1 change: 0 additions & 1 deletion linetools/spectra/xspectrum1d.py
Expand Up @@ -10,7 +10,6 @@

from astropy import units as u
from astropy.units import Quantity, UnitBase
from astropy import constants as const
from astropy.io import fits
#from astropy.nddata import StdDevUncertainty
from astropy.table import QTable, Column, Table
Expand Down

0 comments on commit f3b28bf

Please sign in to comment.