def generate_error_graph(
    err_dirs,
    temperature_array,
    velocity_array,
    md_threshold_array,
    temperature_dict,
    flow_velocity_dict,
    md_threshold_dict,
    legendPosition='best',
    legendParam='None',
    graphPties='None',
    width=3,
    figPath='None',
    show=True,
    logScale=True,
    plot_ylim='None'):
    '''
    @description
    generate the graph showing the maximum of the error
    as a function of time
    '''


    # extract the error data
    data = []        

    for md_threshold in md_threshold_array:
        for flow_velocity in flow_velocity_array:
            for temperature in temperature_array:

                # get the path to the error data
                T_i  = temperature_dict[str(temperature)]
                v_i  = flow_velocity_dict[str(flow_velocity)]
                md_i = md_threshold_dict[str(md_threshold)]

                errorPath = err_dirs[T_i][v_i][md_i]

                # extract the error data
                [time_rescaled,error] = extract_max_error_in_time(errorPath)
        
                # stored the error data for the graph
                data.append([time_rescaled,error])

    # create the graph
    create_error_graph(
        data,
        legendPosition=legendPosition,
        legendParam=legendParam,
        graphPties=graphPties,
        width=width,
        figPath=figPath,
        show=show,
        logScale=logScale,
        plot_ylim=plot_ylim)
                    legendParam.append(dct_distance)

                    # set the graph properties
                    T_i   = temperature_dict[str(temperature)]
                    dct_i = dctDistance_dict[str(dct_distance)]
                    graphPties.append([color_temperature[T_i],style_detector[dct_i]])

                else:
                    print errorPath+' does not exist'

        # create the graph
        create_error_graph(
            data,
            legendPosition=legendPosition,
            legendParam=legendParam,
            graphPties=graphPties,
            width=width,
            figPath=figPath,
            show=show,
            logScale=logScale,
            plot_ylim=plot_ylim)


    #============================================================
    # 5) error ic_perturbations
    #============================================================
    if(errorIcPerturbation):

        temperature_array      = [0.95,0.99,0.995,0.999]
        flow_velocity          = 0.1
        md_threshold           = 0
        ic_perturbations_array = [0.00001,0.00005,0.0001,0.0005,0.001,0.005,0.01,0.05,0.1,0.5]