# Path: apogee/util/dens_kde.py
# class densKDE:
#     def __init__(self,data,kernel='biweight',w=None,
#                  scale=True,fit=False,h=1.,
#                  variable=False,variablenitt=2,variableexp=0.5):
#     def __call__(self,x,h=None,log=False,scale=True,sx2=None):
#     def _setup_variable(self,nitt,alpha):
#     def _prepare_x(self,x,scale):
#     def _scale_data(self,data,w):
#     def _setup_kernel(self,kernel):
# def kernel_biweight(x,y,log=False):
# def kernel_gauss(x,y,log=False):
# def preparexy(x,y):
# def preparex(x):


import numpy
import scipy.interpolate
import isodist, isodist.imf
from scipy import misc, special
    from galpy.util import bovy_plot
from apogee.util import dens_kde
            from apogee.samples.rc import loggteffcut
                                weights.append(dN[ii]*10**(logage-7.)*numpy.exp((10.**(logage-7.))/self._expsfh/100.)) #e.g., Binney (2010)
                                massweights.append(dmass[ii]*10**(logage-7.)*numpy.exp((10.**(logage-7.))/self._expsfh/100.)) #e.g., Binney (2010)
                            else:
                                weights.append(dN[ii]*10**(logage-7.))
                                massweights.append(dmass[ii]*10**(logage-7.))
                    else: 
                        continue #no use in continuing here   
        #Form array
        sample= numpy.array(sample)
        loggs= numpy.array(loggs)
        teffs= numpy.array(teffs)
        pmasses= numpy.array(pmasses)
        plages= numpy.array(plages)-9.
        pjks= numpy.array(pjks)
        weights= numpy.array(weights)
        massweights= numpy.array(massweights)
        #Cut out low weights
        if False:
            indx= (weights > 10.**-5.*numpy.sum(weights))
        else:
            indx= numpy.ones(len(weights),dtype='bool')
        self._sample= sample[indx,:]
        self._weights= weights[indx]
        self._massweights= massweights[indx]
        self._loggs= loggs[indx]
        self._teffs= teffs[indx]
        self._masses= pmasses[indx]
        self._lages= plages[indx]
        self._jks= pjks[indx]
        #Setup KDE

# Path: apogee/util/dens_kde.py
# class densKDE:
#     def __init__(self,data,kernel='biweight',w=None,
#                  scale=True,fit=False,h=1.,
#                  variable=False,variablenitt=2,variableexp=0.5):
#     def __call__(self,x,h=None,log=False,scale=True,sx2=None):
#     def _setup_variable(self,nitt,alpha):
#     def _prepare_x(self,x,scale):
#     def _scale_data(self,data,w):
#     def _setup_kernel(self,kernel):
# def kernel_biweight(x,y,log=False):
# def kernel_gauss(x,y,log=False):
# def preparexy(x,y):
# def preparex(x):


# Path: apogee/samples/isomodel.py
import numpy
import scipy.interpolate
import isodist, isodist.imf
from scipy import misc, special
    from galpy.util import bovy_plot
from apogee.util import dens_kde
            from apogee.samples.rc import loggteffcut

                                weights.append(dN[ii]*10**(logage-7.)*numpy.exp((10.**(logage-7.))/self._expsfh/100.)) #e.g., Binney (2010)
                                massweights.append(dmass[ii]*10**(logage-7.)*numpy.exp((10.**(logage-7.))/self._expsfh/100.)) #e.g., Binney (2010)
                            else:
                                weights.append(dN[ii]*10**(logage-7.))
                                massweights.append(dmass[ii]*10**(logage-7.))
                    else: 
                        continue #no use in continuing here   
        #Form array
        sample= numpy.array(sample)
        loggs= numpy.array(loggs)
        teffs= numpy.array(teffs)
        pmasses= numpy.array(pmasses)
        plages= numpy.array(plages)-9.
        pjks= numpy.array(pjks)
        weights= numpy.array(weights)
        massweights= numpy.array(massweights)
        #Cut out low weights
        if False:
            indx= (weights > 10.**-5.*numpy.sum(weights))
        else:
            indx= numpy.ones(len(weights),dtype='bool')
        self._sample= sample[indx,:]
        self._weights= weights[indx]
        self._massweights= massweights[indx]
        self._loggs= loggs[indx]
        self._teffs= teffs[indx]
        self._masses= pmasses[indx]
        self._lages= plages[indx]
        self._jks= pjks[indx]
        #Setup KDE

        self._kde= dens_kde.densKDE(self._sample,w=self._weights,