# Locate the objects
        objName = catalogue_df.iloc[i].name
        ouput_folder = "{}{}/".format(catalogue_dict["Obj_Folder"], objName)
        fits_file = catalogue_df.iloc[i].reduction_fits
        lineslog_address = "{objfolder}{codeName}{lineslog_extension}".format(
            objfolder=ouput_folder, codeName=objName, lineslog_extension=AbundancesFileExtension
        )

        # Load object data
        lineslog_frame = dz.load_lineslog_frame(lineslog_address)
        wave, flux, header_0 = dz.get_spectra_data(fits_file)

        # Perform the reddening correction
        cHbeta = catalogue_df.iloc[i][cHbeta_type]
        dz.deredden_lines(cHbeta, lineslog_frame)
        spectrum_dered = dz.derreddening_continuum(wave, flux, cHbeta.nominal_value)

        # Import cHbeta coefficient
        #     Te          = catalogue_df.iloc[i].TeSIII if notnull(catalogue_df.iloc[i].TeSIII) else 10000.0
        #     nHeII_HII   = catalogue_df.iloc[i].HeII_HII_from_S if notnull(catalogue_df.iloc[i].HeII_HII_from_S) else 0.1
        #     nHeIII_HII  = catalogue_df.iloc[i].HeIII_HII_from_S if notnull(catalogue_df.iloc[i].HeIII_HII_from_S) else 0.0
        #     Hbeta_Flux  = lineslog_frame.loc['H1_4861A', 'line_Int']
        #     Halpha_Flux = lineslog_frame.loc['H1_6563A', 'line_Int']

        Te = 10000.0
        nHeII_HII = 0.1
        nHeIII_HII = 0.0
        Hbeta_Flux = lineslog_frame.loc["H1_4861A", "line_Int"]
        Halpha_Flux = lineslog_frame.loc["H1_6563A", "line_Int"]

        print "--Using physical parameters", Te, nHeII_HII, nHeIII_HII, Hbeta_Flux, Halpha_Flux
#Loop through files
for i in range(len(catalogue_df.index)):
    
    #Locate the objects
    objName             = catalogue_df.iloc[i].name
    ouput_folder        = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName) 
    fits_file           = catalogue_df.iloc[i].reduction_fits
    nebular_fits        = ouput_folder + objName + nebular_fits_exten
    
    Wave_T, Int_T, header_T = dz.get_spectra_data(fits_file)
    Wave_N, Int_N, header_T = dz.get_spectra_data(ouput_folder + objName + nebular_fits_exten)

    #Perform the reddening correction
    cHbeta = catalogue_df.iloc[i][cHbeta_type]
    spectrum_dered = dz.derreddening_continuum(Wave_T, Int_T - Int_N, cHbeta.nominal_value)
    
    #Generating the starlight files
    FileName = basename(fits_file)
    Grid_FileName, Sl_OutputFile, Sl_OutputFolder, X_1Angs, Y_1Angs = dz.GenerateStarlightFiles(ouput_folder, FileName, objName, catalogue_df.iloc[i], Wave_T, spectrum_dered)
    
    print '--Output file ', Sl_OutputFile
    
    #Plot the data
    dz.data_plot(Wave_T,    spectrum_dered, "Reduced spectrum")
    dz.data_plot(X_1Angs,   Y_1Angs,  "Resampled spectrum", linestyle='--')       
    
    # Set titles and legend  
    PlotTitle = 'Object {} Resampled spectrum for starlight'.format(objName)
    dz.FigWording(r'Wavelength $(\AA)$', 'Flux' + r'$(erg\,cm^{-2} s^{-1} \AA^{-1})$', PlotTitle)   
    print '-- Treating {} @ {}'.format(catalogue_df.iloc[i].name, AbundancesFileExtension)

    #Locate the objects
    objName             = catalogue_df.iloc[i].name
    ouput_folder        = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName) 
    fits_file           = catalogue_df.iloc[i].reduction_fits
    lineslog_address = '{objfolder}{codeName}{lineslog_extension}'.format(objfolder = ouput_folder, codeName=objName, lineslog_extension=AbundancesFileExtension)
    
    #Load object data
    lineslog_frame = dz.load_lineslog_frame(lineslog_address)
    wave, flux, header_0 = dz.get_spectra_data(fits_file)

    #Perform the reddening correction
    cHbeta = catalogue_df.iloc[i][cHbeta_type]
    dz.deredden_lines(cHbeta, lineslog_frame)
    spectrum_dered = dz.derreddening_continuum(wave, flux, cHbeta.nominal_value)

    #Import cHbeta coefficient
#     Te          = catalogue_df.iloc[i].TeSIII if notnull(catalogue_df.iloc[i].TeSIII) else 10000.0
#     nHeII_HII   = catalogue_df.iloc[i].HeII_HII_from_S if notnull(catalogue_df.iloc[i].HeII_HII_from_S) else 0.1
#     nHeIII_HII  = catalogue_df.iloc[i].HeIII_HII_from_S if notnull(catalogue_df.iloc[i].HeIII_HII_from_S) else 0.0
#     Hbeta_Flux  = lineslog_frame.loc['H1_4861A', 'line_Int']
#     Halpha_Flux = lineslog_frame.loc['H1_6563A', 'line_Int']

    Te          = 10000.0
    nHeII_HII   = 0.1
    nHeIII_HII  = 0.0
    Hbeta_Flux  = lineslog_frame.loc['H1_4861A', 'line_Int']
    Halpha_Flux = lineslog_frame.loc['H1_6563A', 'line_Int']
    
    print '--Using physical parameters', Te, nHeII_HII, nHeIII_HII, Hbeta_Flux, Halpha_Flux