예제 #1
0
        /// <summary>
        /// Method to create the result file.
        /// </summary>
        /// <param name="result">Result as DepositDensityResult</param>
        /// <param name="ModelID">Model Id</param>
        /// <param name="plot">Result plot image</param>
        private void CreateResultFile(DepositDensityResult result, string ModelID, string plot)
        {
            try
            {
                string outputFolder = Path.Combine(result.Env.RootPath, "UndiscDep", TractId, "DensModel");

                if (!System.IO.Directory.Exists(outputFolder))
                {
                    System.IO.Directory.CreateDirectory(outputFolder);
                }

                string        strFilePath = Path.Combine(outputFolder, ModelID + "_results_" + DateTime.Now.ToFileTime() + ".txt");
                StringBuilder sbOutput    = new StringBuilder();
                sbOutput.AppendLine("N10: " + result.N10);
                sbOutput.AppendLine("N50: " + result.N50);
                sbOutput.AppendLine("N90: " + result.N90);
                sbOutput.AppendLine("NExp: " + result.NExp);
                sbOutput.AppendLine("BiblInfo: " + result.BiblInfo);
                File.WriteAllText(strFilePath, sbOutput.ToString());

                //Copy plot image to result folder
                File.Copy(plot, Path.Combine(outputFolder, "plot_" + ModelID + ".jpeg"), true);
            }
            catch (Exception ex)
            {
                logger.Trace(ex + "Failed to create result File");
                throw new Exception(ex + "Failed to create result File");
            }
        }
예제 #2
0
        /// <summary>
        /// Excecutes tool and returns results as parameters
        /// </summary>
        /// <param name="inputParams">Input parameters</param>
        /// <returns>Result as DepositDensityResult</returns>
        public ToolResult Execute(ToolParameters inputParams)
        {
            DepositDensityInputParams input = inputParams as DepositDensityInputParams;
            string outputFolder             = Path.Combine(input.Env.RootPath, "UndiscDep", input.TractId);

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            //input.Save(Path.Combine(outputFolder, "deposit_density_input_params.json"));
            modelId = input.ExistingDepositDensityModelID;
            Area    = Convert.ToDouble(input.AreaOfTrack);
            MedTons = Convert.ToDouble(input.MedianTonnage);
            NKnown  = input.NumbOfKnownDeposits != "" ? Convert.ToDouble(input.NumbOfKnownDeposits) : 0;
            TractId = input.TractId;
            DepositDensityResult result = new DepositDensityResult();
            string CSVPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "scripts", "DepositDensity");

            if (input.ExistingDepositDensityModelID == "General")
            {
                CSVPath = Path.Combine(CSVPath, "General_data.csv");
            }
            else if (input.ExistingDepositDensityModelID == "PodiformCr")
            {
                CSVPath = Path.Combine(CSVPath, "PodiformCr_data.csv");
            }
            else if (input.ExistingDepositDensityModelID == "VMS")
            {
                CSVPath = Path.Combine(CSVPath, "VMS_data.csv");
            }
            else if (input.ExistingDepositDensityModelID == "PorCu")
            {
                CSVPath = Path.Combine(CSVPath, "PorphyryCu_data.csv");  // TAGGED: Fix path.
            }
            ReadinputParamsFromCSV(CSVPath);
            //Calculate values based as which deposit type selected
            if (input.ExistingDepositDensityModelID == "General")
            {
                result = GeneralCalculation();
            }
            else
            {
                result = DepositTypeCalculation(input.ExistingDepositDensityModelID);
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Calculate deposit density (Type PodiformCr, VSM, or PorCu).
        /// </summary>
        /// <param name="DepositDensityModelID">Deposit density model Id</param>
        /// <returns>Result as DepositDensityResult</returns>
        private DepositDensityResult DepositTypeCalculation(string DepositDensityModelID)
        {
            try
            {
                DepositDensityResult result = new DepositDensityResult();

                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                string plot = Path.Combine(path, "scripts", "DepositDensity");

                switch (DepositDensityModelID)
                {
                case "PodiformCr":
                    plot = Path.Combine(plot, "Podiformplot.jpeg");
                    break;

                case "VMS":
                    plot = Path.Combine(plot, "VMSplot.jpeg");
                    break;

                case "PorCu":
                    plot = Path.Combine(plot, "porphyryPlot.jpeg");
                    break;

                default:
                    break;
                }

                //N50
                logN50 = a + b * Math.Log10(Area);
                N50    = Math.Pow(10, logN50);

                //N10
                logN10 = Math.Log10(N50) + t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow((MeanLogArea - Math.Log10(Area)), 2) / ((N - 1) * sLogArea));
                N10    = Math.Pow(10, logN10);

                //N90
                double mlal  = Math.Pow((MeanLogArea - Math.Log10(Area)), 2);
                double mlmtl = Math.Pow((MeanLogMedTons - Math.Log10(MedTons)), 2);
                logN90 = Math.Log10(N50) - t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow(MeanLogArea - Math.Log10(Area), 2) / ((N - 1) * sLogArea));
                N90    = Math.Pow(10, logN90);

                //Nexp
                varN    = Math.Pow(((Math.Log10(N10) - Math.Log10(N50)) / t10n), 2);
                logNexp = Math.Log10(N50) + (varN) / 2;
                NExp    = Math.Pow(10, logNexp);

                if (NKnown > NExp)
                {
                    result.N50           = " - ";
                    result.N10           = " - ";
                    result.N90           = " - ";
                    result.NExp          = Math.Round(NExp).ToString();
                    result.BiblInfo      = biblInfo;
                    result.PlotImagePath = plot;
                    result.Note          = "The number of undiscovered deposits cannot be estimated using the global deposit density model. The number of known deposits is larger than the expected number of deposits estimated by the global deposit density model for a permissive tract of the given size. This suggests that there might be a problem with the number of known deposits.";
                    return(result);
                }

                //if NKnown > 0, values are calculated again
                if (NKnown > 0)
                {
                    logN50 = Math.Log10(NExp - NKnown) - (varN) / 2;
                    N50    = Math.Pow(10, logN50);
                    //N10
                    logN10 = Math.Log10(N50) + t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow((MeanLogArea - Math.Log10(Area)), 2) / ((N - 1) * sLogArea));
                    N10    = Math.Pow(10, logN10);
                    //N90
                    mlal   = Math.Pow((MeanLogArea - Math.Log10(Area)), 2);
                    mlmtl  = Math.Pow((MeanLogMedTons - Math.Log10(MedTons)), 2);
                    logN90 = Math.Log10(N50) - t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow(MeanLogArea - Math.Log10(Area), 2) / ((N - 1) * sLogArea));
                    N90    = Math.Pow(10, logN90);
                    //Nexp
                    varN    = Math.Pow(((Math.Log10(N10) - Math.Log10(N50)) / t10n), 2);
                    logNexp = Math.Log10(N50) + (varN) / 2;
                    NExp    = Math.Pow(10, logNexp);
                }

                //Add values to result
                result.N50           = Math.Round(N50).ToString();
                result.N10           = Math.Round(N10).ToString();
                result.N90           = Math.Round(N90).ToString();
                result.NExp          = Math.Round(NExp).ToString();
                result.BiblInfo      = biblInfo;
                result.PlotImagePath = plot;
                result.Note          = null;
                CreateResultFile(result, DepositDensityModelID, plot);
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("Error on deposit type calculation: " + ex);
            }
        }
예제 #4
0
        /// <summary>
        /// Calculate deposit density (General)
        /// </summary>
        /// <returns>Result as DepositDensityResult</returns>
        private DepositDensityResult GeneralCalculation()
        {
            DepositDensityResult result = new DepositDensityResult();
            string path = System.AppDomain.CurrentDomain.BaseDirectory;

            string GeneralPlot = Path.Combine(path, "scripts", "DepositDensity", "GeneralPlot.jpeg");

            try
            {
                //N50
                logN50 = a + b * Math.Log10(Area) + c * Math.Log10(MedTons);
                N50    = Math.Pow(10, logN50);

                //N10
                logN10 = Math.Log10(N50) + t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow(2, (MeanLogArea - Math.Log10(Area)) * Math.Pow(2, MeanLogMedTons - Math.Log10(MedTons))) / ((N - 1) * sLogArea * sLogMedTons));
                N10    = Math.Pow(10, logN10);

                //N90
                double mlal  = Math.Pow((MeanLogArea - Math.Log10(Area)), 2);
                double mlmtl = Math.Pow((MeanLogMedTons - Math.Log10(MedTons)), 2);
                logN90 = Math.Log10(N50) - t10n * Syx * Math.Sqrt(1 + 1 / N + (mlal * mlmtl) / ((N - 1) * sLogArea * sLogMedTons));
                N90    = Math.Pow(10, logN90);

                //Nexp
                varN    = Math.Pow(((Math.Log10(N10) - Math.Log10(N50)) / t10n), 2);
                logNexp = Math.Log10(N50) + (varN) / 2;
                NExp    = Math.Pow(10, logNexp);

                if (NKnown > NExp)
                {
                    result.N50           = " - ";
                    result.N10           = " - ";
                    result.N90           = " - ";
                    result.NExp          = Math.Round(NExp).ToString();
                    result.BiblInfo      = biblInfo;
                    result.PlotImagePath = GeneralPlot;
                    result.Note          = "The number of undiscovered deposits cannot be estimated using the global deposit density model. The number of known deposits is larger than the expected number of deposits estimated by the global deposit density model for a permissive tract of the given size. This suggests that there might be a problem with the number of known deposits.";
                    return(result);
                }
                //if NKnown > 0, values are calculated again NExp must be calculated before this can be done, so values must be calculated again with NKnown value
                if (NKnown > 0)
                {
                    logN50 = Math.Log10(NExp - NKnown) - (varN) / 2;
                    N50    = Math.Pow(10, logN50);
                    //N10
                    logN10 = Math.Log10(N50) + t10n * Syx * Math.Sqrt(1 + 1 / N + Math.Pow(2, (MeanLogArea - Math.Log10(Area)) * Math.Pow(2, MeanLogMedTons - Math.Log10(MedTons))) / ((N - 1) * sLogArea * sLogMedTons));
                    N10    = Math.Pow(10, logN10);
                    //N90
                    mlal   = Math.Pow((MeanLogArea - Math.Log10(Area)), 2);
                    mlmtl  = Math.Pow((MeanLogMedTons - Math.Log10(MedTons)), 2);
                    logN90 = Math.Log10(N50) - t10n * Syx * Math.Sqrt(1 + 1 / N + (mlal * mlmtl) / ((N - 1) * sLogArea * sLogMedTons));
                    N90    = Math.Pow(10, logN90);
                    //Nexp
                    varN    = Math.Pow(((Math.Log10(N10) - Math.Log10(N50)) / t10n), 2);
                    logNexp = Math.Log10(N50) + (varN) / 2;
                    NExp    = Math.Pow(10, logNexp);
                }

                //Add values to result.
                result.N50           = Math.Round(N50).ToString();
                result.N10           = Math.Round(N10).ToString();
                result.N90           = Math.Round(N90).ToString();
                result.NExp          = Math.Round(NExp).ToString();
                result.BiblInfo      = biblInfo;
                result.PlotImagePath = GeneralPlot;
                result.Note          = null;
                CreateResultFile(result, "General", GeneralPlot);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in general type calculation:" + ex);
            }
            return(result);
        }