Skip to content

Commit

Permalink
Merge pull request #58 from hover2pi/bytes
Browse files Browse the repository at this point in the history
Bytes
  • Loading branch information
hover2pi committed Dec 19, 2020
2 parents 2e7763a + f1b5aee commit ffe5dc9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 15 deletions.
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- python>=3.6.8
- bokeh>=1.4.0
- astroquery>=0.4.1
- scipy>=1.2.1
- scipy>=1.4.1
- pandas>=0.23.4
- pip>=20.3.3
- selenium>=2.49.2
Expand All @@ -19,5 +19,4 @@ dependencies:
- pip:
- svo-filters==0.2.19
- dustmaps==1.0.4
- astroquery==0.4.1
- numpydoc==0.8.0
17 changes: 8 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
numpy==1.18.1
astropy==4.0
bokeh==2.2.3
astroquery==0.4.1
scipy==1.4.1
numpy>=1.18.1
astropy>=4.0
bokeh>=2.2.3
astroquery>=0.4.1
scipy>=1.4.1
pandas==0.23.4
svo_filters==0.2.19
dustmaps==1.0
selenium==2.49.2

pytest==6.1.2
dustmaps>=1.0.4
selenium>=2.49.2
pytest>=6.2.1
pytest-runner==4.2
pip==20.2.3
bumpversion==0.5.3
Expand Down
4 changes: 2 additions & 2 deletions sedkit/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def query_vizier(catalog, target=None, sky_coords=None, cols=None, wildcards=['e

# Pull out the photometry
for name, viz in zip(names, cols):
fetch = [viz]+[wc.replace('*', viz) for wc in wildcards]
fetch = [viz] + [wc.replace('*', viz) for wc in wildcards]
if all([i in rec.columns for i in fetch]):
data = [round(val, places) if u.isnumber(val) else val for val in rec[fetch]]
results.append([name]+data+[ref])
results.append([name] + data + [ref])
else:
print("{}: Could not find all those columns".format(fetch))

Expand Down
29 changes: 29 additions & 0 deletions sedkit/tests/test_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""A suite of tests for the query.py module"""

import astropy.units as q
from astropy.coordinates import SkyCoord

from .. import query


def test_query_vizier():
"""Test for equivalent function"""
# 2MASS catalog
catalog = 'II/246/out'
cols = ['Jmag', 'Hmag', 'Kmag']
names = ['2MASS.J', '2MASS.H', '2MASS.Ks']
cat = '2MASS'

# Query target
results = query.query_vizier(catalog, target='Vega', cols=cols, wildcards=['e_*'], names=names, search_radius=20 * q.arcsec, idx=0, places=3, cat_name=cat, verbose=True)
assert len(results) > 0

# Query coords
sky_coords = SkyCoord(ra=1.23, dec=2.34, unit=(q.degree, q.degree), frame='icrs')
results = query.query_vizier(catalog, sky_coords=sky_coords, cols=cols, wildcards=['e_*'], names=None, search_radius=20 * q.arcmin, idx=0, places=3, cat_name=cat, verbose=True)
assert len(results) > 0

# No results
results = query.query_vizier(catalog, sky_coords=sky_coords, cols=cols, wildcards=['e_*'], names=None, search_radius=0.1 * q.arcsec, idx=0, places=3, cat_name=cat, verbose=True)
assert len(results) == 0

15 changes: 14 additions & 1 deletion sedkit/tests/test_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import astropy.units as q
from astropy.modeling.blackbody import blackbody_lambda
from astropy.coordinates import SkyCoord

from .. import sed
from .. import spectrum as sp
Expand All @@ -27,7 +28,7 @@ def setUp(self):
SPEC2 = [WAVE2, FLUX2, FLUX2/100.]
self.spec2 = sp.Spectrum(*SPEC2)

self.sed = sed.SED(verbose=True)
self.sed = sed.SED(verbose=True, foo=123)

def test_add_photometry(self):
"""Test that photometry is added properly"""
Expand Down Expand Up @@ -96,6 +97,12 @@ def test_attributes(self):
s.ra = 1.2345*q.deg
self.assertRaises(TypeError, setattr, s, 'ra', 1.2345)

# Sky coords
s.sky_coords = 1.2345*q.deg, 1.2345*q.deg
s.sky_coords = '1.2345', '1.2345'
self.assertRaises(TypeError, setattr, s, 'sky_coords', 'foo')
self.assertRaises(TypeError, setattr, s, 'sky_coords', None)

# Distance
s.distance = None
s.distance = 1.2*q.pc, 0.1*q.pc
Expand Down Expand Up @@ -212,6 +219,12 @@ def test_find_methods(self):

self.assertNotEqual(len(s.photometry), 0)

def test_run_methods(self):
"""Test that the method_list argument works"""
s = sed.SED('trappist-1', method_list=['find_2MASS'])

self.assertNotEqual(len(s.photometry), 0)

def test_fit_spectrum(self):
"""Test that the SED can be fit by a model grid"""
# Grab the SPL
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='sedkit',
version='1.0.7',
version='1.0.8',
description='Spectral energy distribution construction and analysis tools',
url='https://github.com/hover2pi/sedkit',
author='Joe Filippazzo',
Expand Down

0 comments on commit ffe5dc9

Please sign in to comment.