Creates h5 file from dictionary containing the file structure.
        
        Filedict is a regular dictinary whose keys are hdf5 paths and whose
        values are dictinaries containing the metadata and datasets. Metadata
        is given as normal key-value -pairs and dataset arrays are given using
        'DATASET' key. Datasets must be numpy arrays.
                
        Method can also be used to append existing hdf5 file. If the file is
        opened in read only mode, method does nothing.

        Examples
        --------
        Create newfile.h5 and fill it with data and metadata

        >>> h5f = HiisiHDF('newfile.h5', 'w')
        >>> filedict = {'/':{'attr1':'A'},
                        '/dataset1/data1/data':{'DATASET':np.zeros(100), 'quantity':'emptyarray'}, 'B':'b'}
        >>> h5f.create_from_filedict(filedict)

def create_from_filedict(self, filedict):
        """
        Creates h5 file from dictionary containing the file structure.
        
        Filedict is a regular dictinary whose keys are hdf5 paths and whose
        values are dictinaries containing the metadata and datasets. Metadata
        is given as normal key-value -pairs and dataset arrays are given using
        'DATASET' key. Datasets must be numpy arrays.
                
        Method can also be used to append existing hdf5 file. If the file is
        opened in read only mode, method does nothing.

        Examples
        --------
        Create newfile.h5 and fill it with data and metadata

        >>> h5f = HiisiHDF('newfile.h5', 'w')
        >>> filedict = {'/':{'attr1':'A'},
                        '/dataset1/data1/data':{'DATASET':np.zeros(100), 'quantity':'emptyarray'}, 'B':'b'}
        >>> h5f.create_from_filedict(filedict)

        """
        if self.mode in ['r+','w', 'w-', 'x', 'a']:
            for h5path, path_content in filedict.iteritems():
                if path_content.has_key('DATASET'):
                    # If path exist, write only metadata
                    if h5path in self:
                        for key, value in path_content.iteritems():
                            if key != 'DATASET':
                                self[h5path].attrs[key] = value
                    else:
                        try:
                            group = self.create_group(os.path.dirname(h5path))
                        except ValueError:
                            group = self[os.path.dirname(h5path)]
                            pass # This pass has no effect?
                        new_dataset = group.create_dataset(os.path.basename(h5path), data=path_content['DATASET'])
                        for key, value in path_content.iteritems():
                            if key != 'DATASET':
                                new_dataset.attrs[key] = value
                else:
                    try:  
                        group = self.create_group(h5path)
                    except ValueError:
                        group = self[h5path]
                    for key, value in path_content.iteritems():
                        group.attrs[key] = value