## #' musoGlue
## #'
## #' This ...
## #' #' @author Roland Hollos
## #' @param monteCarloFile If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information.
## #' @param outputFile The filename in which the output of musoSensi function will be saved. It's default value is: "sensitivity.csv"
## #' @param plotName The name of the output barplot. It's default value is: "sensitivity.jpg"
## #' @param settings A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically. 
## #' @param parameters This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.
## #' @param calibrationPar You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)
## #' @param inputDir The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file. 
## #' @param iterations number of the monteCarlo run.
## #' @param preTag It will be the name of the output files. For example preTag-1.csv, pretag-2csv...
## #' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet. 
## #' @param fun If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.
## #' @param varIndex This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.
## #' @param skipSpinup With this parameter, you can turn of the spinup phase after the first spinup. I will decrease the time significantly.
## #' @import dplyr
## #' @import graphics
## #' @import grDevices
## #' @import ggplot2
## #' @export

## musoGLUE <- function(monteCarloFile = NULL,
##                      parameters = NULL,
##                      settings = NULL,
##                      inputDir = "./",
##                      outLoc = "./calib",
##                      filterCol=8,
##                      filterFlag=1,
##                      iterations = 30,
##                      preTag = "mont-",
##                      outputType = "moreCsv",
##                      fun = mean,
##                      varIndex = 1,
##                      obsIndex = 
##                      outputFile = "sensitivity.csv",
##                      plotName = "sensitivity.png",
##                      plotTitle = "Sensitivity",
##                      skipSpinup = FALSE,
##                      dpi=300){


##     rmse <- function(modelled, observed){
##         (modelled-observed) %>%
##             (function(x) {x*x}) %>% # It is more clear than `^`(.,2) form, even it is longer
##             sum %>%
##             sqrt
##     }

    

##     likelihoodNormal <- function(modelled, observed){
##         if (sd <= 0){
##             return(-Inf)
##         } else {
##             filtered <- observed[,filterCol]!=filterFlag
            
            
##         }
            

##     }

                     






## }
