diff --git a/.travis.yml b/.travis.yml index 9c9b51e..62d60eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,7 @@ install: - conda info -a - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION - - conda install -c conda-forge numpy scipy matplotlib nose future scikit-learn - - conda install -c conda-forge codecov - - conda install -c conda-forge scikit-optimize + - conda install -c conda-forge numpy scipy matplotlib nose future scikit-learn codecov scikit-optimize - source activate test-environment - conda install coverage diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8cdef95 --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +from setuptools import setup, find_packages + +setup( + name="siggi", + version="0.1.0", + author="Bryce Kalmbach", + author_email="brycek@uw.edu", + url="https://github.com/jbkalmbach/siggi", + packages=find_packages(), + description="Spectral Information Gain Optimization", + long_description=open("README.md").read(), + package_data={"": ["README.md", "LICENSE"], + "siggi": ["data/*", + "data/lsst_baseline_throughputs/*"]}, + include_package_data=True, + classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python", + ], +) diff --git a/siggi/calcIG.py b/siggi/calcIG.py index 80d50f4..6248d62 100644 --- a/siggi/calcIG.py +++ b/siggi/calcIG.py @@ -63,7 +63,7 @@ def __init__(self, filter_dict, sed_list, sed_probs, sed_mags=22.0, def calc_colors(self, return_all=False): """ - Calculate the colors and errors in color measurement + Calculate the colors and errors in color measurement of the SEDs in the given filters. """ diff --git a/data/Inst.10E10.1Z.spec.gz b/siggi/data/Inst.10E10.1Z.spec.gz similarity index 100% rename from data/Inst.10E10.1Z.spec.gz rename to siggi/data/Inst.10E10.1Z.spec.gz diff --git a/data/Inst.64E08.1Z.spec.gz b/siggi/data/Inst.64E08.1Z.spec.gz similarity index 100% rename from data/Inst.64E08.1Z.spec.gz rename to siggi/data/Inst.64E08.1Z.spec.gz diff --git a/data/lsst_baseline_throughputs/LSSTfilters.png b/siggi/data/lsst_baseline_throughputs/LSSTfilters.png similarity index 100% rename from data/lsst_baseline_throughputs/LSSTfilters.png rename to siggi/data/lsst_baseline_throughputs/LSSTfilters.png diff --git a/data/lsst_baseline_throughputs/README.md b/siggi/data/lsst_baseline_throughputs/README.md similarity index 100% rename from data/lsst_baseline_throughputs/README.md rename to siggi/data/lsst_baseline_throughputs/README.md diff --git a/data/lsst_baseline_throughputs/atmos_10.dat b/siggi/data/lsst_baseline_throughputs/atmos_10.dat similarity index 100% rename from data/lsst_baseline_throughputs/atmos_10.dat rename to siggi/data/lsst_baseline_throughputs/atmos_10.dat diff --git a/data/lsst_baseline_throughputs/atmos_std.dat b/siggi/data/lsst_baseline_throughputs/atmos_std.dat similarity index 100% rename from data/lsst_baseline_throughputs/atmos_std.dat rename to siggi/data/lsst_baseline_throughputs/atmos_std.dat diff --git a/data/lsst_baseline_throughputs/darksky.dat b/siggi/data/lsst_baseline_throughputs/darksky.dat similarity index 100% rename from data/lsst_baseline_throughputs/darksky.dat rename to siggi/data/lsst_baseline_throughputs/darksky.dat diff --git a/data/lsst_baseline_throughputs/detector.dat b/siggi/data/lsst_baseline_throughputs/detector.dat similarity index 100% rename from data/lsst_baseline_throughputs/detector.dat rename to siggi/data/lsst_baseline_throughputs/detector.dat diff --git a/data/lsst_baseline_throughputs/filter_g.dat b/siggi/data/lsst_baseline_throughputs/filter_g.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_g.dat rename to siggi/data/lsst_baseline_throughputs/filter_g.dat diff --git a/data/lsst_baseline_throughputs/filter_i.dat b/siggi/data/lsst_baseline_throughputs/filter_i.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_i.dat rename to siggi/data/lsst_baseline_throughputs/filter_i.dat diff --git a/data/lsst_baseline_throughputs/filter_r.dat b/siggi/data/lsst_baseline_throughputs/filter_r.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_r.dat rename to siggi/data/lsst_baseline_throughputs/filter_r.dat diff --git a/data/lsst_baseline_throughputs/filter_u.dat b/siggi/data/lsst_baseline_throughputs/filter_u.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_u.dat rename to siggi/data/lsst_baseline_throughputs/filter_u.dat diff --git a/data/lsst_baseline_throughputs/filter_y.dat b/siggi/data/lsst_baseline_throughputs/filter_y.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_y.dat rename to siggi/data/lsst_baseline_throughputs/filter_y.dat diff --git a/data/lsst_baseline_throughputs/filter_z.dat b/siggi/data/lsst_baseline_throughputs/filter_z.dat similarity index 100% rename from data/lsst_baseline_throughputs/filter_z.dat rename to siggi/data/lsst_baseline_throughputs/filter_z.dat diff --git a/data/lsst_baseline_throughputs/hardware_g.dat b/siggi/data/lsst_baseline_throughputs/hardware_g.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_g.dat rename to siggi/data/lsst_baseline_throughputs/hardware_g.dat diff --git a/data/lsst_baseline_throughputs/hardware_i.dat b/siggi/data/lsst_baseline_throughputs/hardware_i.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_i.dat rename to siggi/data/lsst_baseline_throughputs/hardware_i.dat diff --git a/data/lsst_baseline_throughputs/hardware_r.dat b/siggi/data/lsst_baseline_throughputs/hardware_r.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_r.dat rename to siggi/data/lsst_baseline_throughputs/hardware_r.dat diff --git a/data/lsst_baseline_throughputs/hardware_u.dat b/siggi/data/lsst_baseline_throughputs/hardware_u.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_u.dat rename to siggi/data/lsst_baseline_throughputs/hardware_u.dat diff --git a/data/lsst_baseline_throughputs/hardware_y.dat b/siggi/data/lsst_baseline_throughputs/hardware_y.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_y.dat rename to siggi/data/lsst_baseline_throughputs/hardware_y.dat diff --git a/data/lsst_baseline_throughputs/hardware_z.dat b/siggi/data/lsst_baseline_throughputs/hardware_z.dat similarity index 100% rename from data/lsst_baseline_throughputs/hardware_z.dat rename to siggi/data/lsst_baseline_throughputs/hardware_z.dat diff --git a/data/lsst_baseline_throughputs/lens1.dat b/siggi/data/lsst_baseline_throughputs/lens1.dat similarity index 100% rename from data/lsst_baseline_throughputs/lens1.dat rename to siggi/data/lsst_baseline_throughputs/lens1.dat diff --git a/data/lsst_baseline_throughputs/lens2.dat b/siggi/data/lsst_baseline_throughputs/lens2.dat similarity index 100% rename from data/lsst_baseline_throughputs/lens2.dat rename to siggi/data/lsst_baseline_throughputs/lens2.dat diff --git a/data/lsst_baseline_throughputs/lens3.dat b/siggi/data/lsst_baseline_throughputs/lens3.dat similarity index 100% rename from data/lsst_baseline_throughputs/lens3.dat rename to siggi/data/lsst_baseline_throughputs/lens3.dat diff --git a/data/lsst_baseline_throughputs/m1.dat b/siggi/data/lsst_baseline_throughputs/m1.dat similarity index 100% rename from data/lsst_baseline_throughputs/m1.dat rename to siggi/data/lsst_baseline_throughputs/m1.dat diff --git a/data/lsst_baseline_throughputs/m2.dat b/siggi/data/lsst_baseline_throughputs/m2.dat similarity index 100% rename from data/lsst_baseline_throughputs/m2.dat rename to siggi/data/lsst_baseline_throughputs/m2.dat diff --git a/data/lsst_baseline_throughputs/m3.dat b/siggi/data/lsst_baseline_throughputs/m3.dat similarity index 100% rename from data/lsst_baseline_throughputs/m3.dat rename to siggi/data/lsst_baseline_throughputs/m3.dat diff --git a/data/lsst_baseline_throughputs/total_g.dat b/siggi/data/lsst_baseline_throughputs/total_g.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_g.dat rename to siggi/data/lsst_baseline_throughputs/total_g.dat diff --git a/data/lsst_baseline_throughputs/total_i.dat b/siggi/data/lsst_baseline_throughputs/total_i.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_i.dat rename to siggi/data/lsst_baseline_throughputs/total_i.dat diff --git a/data/lsst_baseline_throughputs/total_r.dat b/siggi/data/lsst_baseline_throughputs/total_r.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_r.dat rename to siggi/data/lsst_baseline_throughputs/total_r.dat diff --git a/data/lsst_baseline_throughputs/total_u.dat b/siggi/data/lsst_baseline_throughputs/total_u.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_u.dat rename to siggi/data/lsst_baseline_throughputs/total_u.dat diff --git a/data/lsst_baseline_throughputs/total_y.dat b/siggi/data/lsst_baseline_throughputs/total_y.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_y.dat rename to siggi/data/lsst_baseline_throughputs/total_y.dat diff --git a/data/lsst_baseline_throughputs/total_z.dat b/siggi/data/lsst_baseline_throughputs/total_z.dat similarity index 100% rename from data/lsst_baseline_throughputs/total_z.dat rename to siggi/data/lsst_baseline_throughputs/total_z.dat diff --git a/siggi/lsst_utils/BandpassDict.py b/siggi/lsst_utils/BandpassDict.py index e3fd79e..59a74b3 100644 --- a/siggi/lsst_utils/BandpassDict.py +++ b/siggi/lsst_utils/BandpassDict.py @@ -158,13 +158,17 @@ def loadBandpassesFromFiles(cls, @classmethod def addSystemBandpass(cls, filter_dict, - bandpassDir=os.path.join(os.path.dirname(__file__), - '../../data/lsst_baseline_throughputs'), + bandpassDir=None, components=['detector.dat', 'm1.dat', 'm2.dat', 'm3.dat', 'lens1.dat', 'lens2.dat', 'lens3.dat'], atmosFile='atmos_std.dat'): + if bandpassDir is None: + bandpassDir = os.path.join(os.path.dirname(__file__), + '..', 'data', + 'lsst_baseline_throughputs') + comp_list = [os.path.join(bandpassDir, comp) for comp in components] comp_atmos_list = comp_list + [os.path.join(bandpassDir, atmosFile)] diff --git a/siggi/siggi.py b/siggi/siggi.py index 7a3730e..2e3b93f 100644 --- a/siggi/siggi.py +++ b/siggi/siggi.py @@ -72,7 +72,7 @@ def __init__(self, spec_list, spec_weights, z_prior, self.z_probs.append(z_prior(z_val)*weight) bp_dict_folder = os.path.join(os.path.dirname(__file__), - '../data', + 'data', 'lsst_baseline_throughputs') bp_dict = BandpassDict.loadTotalBandpassesFromFiles( bandpassDir=bp_dict_folder) diff --git a/siggi/spectra.py b/siggi/spectra.py index f312d3d..02a55bd 100644 --- a/siggi/spectra.py +++ b/siggi/spectra.py @@ -19,7 +19,7 @@ def get_red_spectrum(self): sed_obj = Sed() sed_obj.readSED_flambda(os.path.join(os.path.dirname(__file__), - '../data/Inst.10E10.1Z.spec.gz')) + 'data/Inst.10E10.1Z.spec.gz')) return sed_obj @@ -27,7 +27,7 @@ def get_blue_spectrum(self): sed_obj = Sed() sed_obj.readSED_flambda(os.path.join(os.path.dirname(__file__), - '../data/Inst.64E08.1Z.spec.gz')) + 'data/Inst.64E08.1Z.spec.gz')) return sed_obj @@ -35,7 +35,7 @@ def get_dark_sky_spectrum(self): sed_obj = Sed() sky_sed = os.path.join(os.path.dirname(__file__), - '../data/lsst_baseline_throughputs', + 'data/lsst_baseline_throughputs', 'darksky.dat') sed_obj.readSED_flambda(sky_sed) diff --git a/tests/test_calcIG.py b/tests/test_calcIG.py index d8ca076..12c5f45 100644 --- a/tests/test_calcIG.py +++ b/tests/test_calcIG.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') import unittest import numpy as np from siggi import filters, spectra, calcIG diff --git a/tests/test_filters.py b/tests/test_filters.py index c6580d2..b2783e5 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') import unittest import numpy as np from siggi import filters diff --git a/tests/test_mathUtils.py b/tests/test_mathUtils.py index 6393ad5..9bb9a97 100644 --- a/tests/test_mathUtils.py +++ b/tests/test_mathUtils.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') import unittest import numpy as np from scipy.spatial.distance import cdist diff --git a/tests/test_siggi.py b/tests/test_siggi.py index 12db4e8..0cc3a65 100644 --- a/tests/test_siggi.py +++ b/tests/test_siggi.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') import os import unittest import pickle @@ -21,7 +19,7 @@ def setUpClass(cls): cls.frozen_dict = BandpassDict.loadTotalBandpassesFromFiles( bandpassNames=['u', 'g'], bandpassDir=os.path.join(os.path.dirname(__file__), - '../data', + '../siggi/data', 'lsst_baseline_throughputs')) return @@ -51,7 +49,7 @@ def prior_z(z, z0=0.5): system_wavelen_max=1200., n_opt_points=14, optimizer_verbosity=10, - procs=4, + procs=4, acq_func_kwargs_dict={'kappa': 3}, frozen_filt_dict=self.frozen_dict, frozen_filt_eff_wavelen=[365, 477], @@ -65,7 +63,7 @@ def prior_z(z, z0=0.5): system_wavelen_max=1200., n_opt_points=14, optimizer_verbosity=10, - procs=4, + procs=4, acq_func_kwargs_dict={'kappa': 3}, frozen_filt_dict=self.frozen_dict, frozen_filt_eff_wavelen=[365, 477], @@ -85,7 +83,7 @@ def prior_z(z, z0=0.5): system_wavelen_max=1200., n_opt_points=10, optimizer_verbosity=10, - procs=4, + procs=4, acq_func_kwargs_dict={'kappa': 3}, frozen_filt_dict=self.frozen_dict, frozen_filt_eff_wavelen=[365, 477], @@ -104,14 +102,14 @@ def prior_z(z, z0=0.5): system_wavelen_max=1200., n_opt_points=4, optimizer_verbosity=10, - procs=4, + procs=4, acq_func_kwargs_dict={'kappa': 3}, frozen_filt_dict=self.frozen_dict, frozen_filt_eff_wavelen=[365, 477], starting_points=None, load_optimizer=test_opt, rand_state=23) - + np.testing.assert_array_equal(t_1.Xi, t_4.Xi) np.testing.assert_array_equal(t_1.yi, t_4.yi) @@ -119,6 +117,8 @@ def prior_z(z, z0=0.5): def tearDownClass(cls): os.remove('test.pkl') + os.remove('Xi.out') + os.remove('yi.out') return diff --git a/tests/test_siggiBase.py b/tests/test_siggiBase.py index 5c04fd9..745445e 100644 --- a/tests/test_siggiBase.py +++ b/tests/test_siggiBase.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') import os import unittest from siggi import _siggiBase, filters, spectra, calcIG @@ -20,7 +18,7 @@ def setUpClass(cls): cls.frozen_dict = BandpassDict.loadTotalBandpassesFromFiles( bandpassNames=['u', 'g'], bandpassDir=os.path.join(os.path.dirname(__file__), - '../data', + '../siggi/data', 'lsst_baseline_throughputs')) return