Loads StarPopulation from .h5 file

        Correct properties should be restored to object, and object
        will be original type that was saved.  Complement to
        :func:`StarPopulation.save_hdf`.

        Example usage::

            >>> from vespa.stars import Raghavan_BinaryPopulation, StarPopulation
            >>> pop = Raghavan_BinaryPopulation(1., n=1000)
            >>> pop.save_hdf('test.h5')
            >>> pop2 = StarPopulation.load_hdf('test.h5')
            >>> pop == pop2
                True
            >>> pop3 = Ragahavan_BinaryPopulation.load_hdf('test.h5')
            >>> pop3 == pop2
                True


        :param filename:
            HDF file with saved :class:`StarPopulation`.

        :param path:
            Path within HDF file.

        :return:
            :class:`StarPopulation` or appropriate subclass; whatever
            was saved with :func:`StarPopulation.save_hdf`.

def load_hdf(cls, filename, path=''):
        """Loads StarPopulation from .h5 file

        Correct properties should be restored to object, and object
        will be original type that was saved.  Complement to
        :func:`StarPopulation.save_hdf`.

        Example usage::

            >>> from vespa.stars import Raghavan_BinaryPopulation, StarPopulation
            >>> pop = Raghavan_BinaryPopulation(1., n=1000)
            >>> pop.save_hdf('test.h5')
            >>> pop2 = StarPopulation.load_hdf('test.h5')
            >>> pop == pop2
                True
            >>> pop3 = Ragahavan_BinaryPopulation.load_hdf('test.h5')
            >>> pop3 == pop2
                True


        :param filename:
            HDF file with saved :class:`StarPopulation`.

        :param path:
            Path within HDF file.

        :return:
            :class:`StarPopulation` or appropriate subclass; whatever
            was saved with :func:`StarPopulation.save_hdf`.

        """
        stars = pd.read_hdf(filename,path+'/stars')
        constraint_df = pd.read_hdf(filename,path+'/constraints')

        with pd.HDFStore(filename) as store:
            has_orbpop = '{}/orbpop/df'.format(path) in store
            has_triple_orbpop = '{}/orbpop/long/df'.format(path) in store
            attrs = store.get_storer('{}/stars'.format(path)).attrs

            poptype = attrs.poptype
            new = poptype()

            #if poptype != type(self):
            #    raise TypeError('Saved population is {}.  Please instantiate proper class before loading.'.format(poptype))


            distribution_skip = attrs.distribution_skip
            selectfrac_skip = attrs.selectfrac_skip
            name = attrs.name

            for kw,val in attrs.properties.items():
                setattr(new, kw, val)

        #load orbpop if there
        orbpop = None
        if has_orbpop:
            orbpop = OrbitPopulation.load_hdf(filename, path=path+'/orbpop')
        elif has_triple_orbpop:
            orbpop = TripleOrbitPopulation.load_hdf(filename, path=path+'/orbpop')

        new.stars = stars
        new.orbpop = orbpop


        for n in constraint_df.columns:
            mask = np.array(constraint_df[n])
            c = Constraint(mask,name=n)
            sel_skip = n in selectfrac_skip
            dist_skip = n in distribution_skip
            new.apply_constraint(c,selectfrac_skip=sel_skip,
                                  distribution_skip=dist_skip)

        return new