Skip to content

Commit

Permalink
Merge pull request #25 from jbkalmbach/issue/12/create_notebook_for_p…
Browse files Browse the repository at this point in the history
…aper

Issue/12/create notebook for paper
  • Loading branch information
jbkalmbach authored Oct 30, 2017
2 parents cad78fa + 8e5fff8 commit b79e431
Show file tree
Hide file tree
Showing 12 changed files with 2,872 additions and 211 deletions.
14 changes: 9 additions & 5 deletions esp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from .esp import *
from .pca import *
from .plot_utils import *
from .spec_utils import *
from .gp_utils import *
__all__ = ["estimateBase", "NearestNeighborEstimate",
"gaussianProcessEstimate"]

from .esp import estimateBase, nearestNeighborEstimate, gaussianProcessEstimate
from .pca import pcaSED
from .plot_utils import plotUtils
from .spec_utils import specUtils
from .lsst_utils import Bandpass, BandpassDict, Sed, PhysicalParameters
from .gp_utils import optimize
3 changes: 3 additions & 0 deletions esp/esp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from .gp_utils import optimize
from sklearn.neighbors import KNeighborsRegressor as knr

__all__ = ["estimateBase", "NearestNeighborEstimate",
"gaussianProcessEstimate"]


class estimateBase(object):

Expand Down
2 changes: 2 additions & 0 deletions esp/gp_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import scipy.optimize as op

__all__ = ["optimize"]


def optimize(gp_obj, x, y, **kwargs):

Expand Down
10 changes: 6 additions & 4 deletions esp/lsst_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .Bandpass import *
from .BandpassDict import *
from .PhysicalParameters import *
from .Sed import *
__all__ = ["Bandpass", "BandpassDict", "PhysicalParameters", "Sed"]

from .Bandpass import Bandpass
from .BandpassDict import BandpassDict
from .PhysicalParameters import PhysicalParameters
from .Sed import Sed
8 changes: 7 additions & 1 deletion esp/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import numpy as np
from .spec_utils import specUtils
from sklearn.decomposition import PCA as sklPCA
from .lsst_utils.Sed import Sed
from .lsst_utils import Sed

__all__ = ["pcaSED"]


class pcaSED(specUtils):
Expand Down Expand Up @@ -150,6 +152,10 @@ def reconstruct_spectra(self, num_comps):
np.dot(self.coeffs[:, :num_comps],
self.eigenspectra[:num_comps])

for spec_num in range(len(reconstructed_specs)):
neg_idx = np.where(reconstructed_specs[spec_num] < 0.)[0]
reconstructed_specs[spec_num][neg_idx] = 0.

return reconstructed_specs

def calc_colors(self, bandpass_dict, num_comps):
Expand Down
2 changes: 2 additions & 0 deletions esp/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import matplotlib.pyplot as plt
plt.style.use('ggplot')

__all__ = ["plotUtils"]


class plotUtils(object):
"""
Expand Down
6 changes: 4 additions & 2 deletions esp/spec_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import os
import math
import numpy as np
from .lsst_utils.Sed import Sed
from .lsst_utils import Sed

__all__ = ["specUtils"]


class specUtils(object):
Expand All @@ -28,7 +30,7 @@ def load_spectra(self, directory):
for root, dirs, files in os.walk(directory):
file_total = len(files)
file_on = 1
for name in files:
for name in sorted(files):
if file_on % 100 == 0:
print(str("File On " + str(file_on) + " out of " +
str(file_total)))
Expand Down
321 changes: 132 additions & 189 deletions examples/esp_example.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit b79e431

Please sign in to comment.