import sys, os, fnmatch
import numpy as np
from galacticus.utils.progress import Progress
from galacticus.io import GalacticusHDF5
from galacticus.dust.Ferrara2000 import dustAtlas
from galacticus.dust.CharlotFall2000 import CharlotFall2000
from galacticus.dust.screens import dustScreen

hdf5File = sys.argv[1]

ATLAS = dustAtlas()
CHARLOTFALL = CharlotFall2000()
SLAB = dustScreen()

# Open HDF5 file for updating
GALACTICUS = GalacticusHDF5(hdf5File, 'a')

# Loop over outputs
redshifts = GALACTICUS.outputs.z
for i, z in enumerate(redshifts):

    print "-----> Processing z = " + str(z) + "  (iz = " + str(
        i + 1) + "/" + str(len(redshifts)) + ")"

    # Get list of available properties at this redshift
    allDatasets = GALACTICUS.availableDatasets(z)
    if len(allDatasets) == 0:
        continue

    visibleDatasets = list(np.unique(fnmatch.filter(allDatasets,"*LineLuminosity*"))) + \
        list(np.unique(fnmatch.filter(allDatasets,"*LuminositiesStellar*")))