コード例 #1
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //::  It is the main Function to start                              :::
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        private void RunBtn_Click(object sender, EventArgs e)
        {
            frmParent.BusyState();
            var CheckedModels = ModelChk.CheckedItems.OfType <string>().ToList();
            var CheckedSens   = ScenarioChk.CheckedItems.OfType <string>().ToList();

            if (CruModel.Checked)
            {
                CheckedModels = new List <string>()
                {
                    "ObservedData"
                };
                CheckedSens = new List <string>()
                {
                    "ObservedCru"
                };
            }
            else if (ObserveModel.Checked)
            {
                CheckedModels = new List <string>()
                {
                    "ObservedData"
                };
                CheckedSens = new List <string>()
                {
                    "ObservedUser"
                };
            }
            try
            {
                commentLbl.Text = "Starting...";
                var fileFolders = "";
                if (DirectRb.Checked)
                {
                    fileFolders = DirectFilesTxt.Text;
                    MainRun(fileFolders, false);
                }
                else
                {
                    var parentFolder = ManualFilesTxt.Text;
                    foreach (var model in CheckedModels)
                    {
                        var modelDirectory = parentFolder + @"\" + model;
                        Directory.CreateDirectory(modelDirectory);
                        foreach (var senario in CheckedSens)
                        {
                            var senarioDirectory = modelDirectory + @"\" + senario;
                            Directory.CreateDirectory(senarioDirectory);
                            if (Precipitation.Checked)
                            {
                                var pcpDirectory = senarioDirectory + @"\pcp";
                                Directory.CreateDirectory(pcpDirectory);

                                MainRun(pcpDirectory, true);
                            }
                            if (Temperature.Checked)
                            {
                                var tmpDirectory = senarioDirectory + @"\tmp";
                                Directory.CreateDirectory(tmpDirectory);

                                MainRun(tmpDirectory, false);
                            }
                        }
                    }
                }
                var inputs = "";
                var models = CheckedModels.Cast <object>().Aggregate("", (current, model) => current + (model + ","));
                models = models.Length > 0? models.Remove(models.Length - 1):models;
                var sens = CheckedSens.Cast <object>().Aggregate("", (current, sen) => current + (sen + ","));
                sens    = sens.Length > 0? sens.Remove(sens.Length - 1):sens;
                inputs += "Main Database Folder : " + Environment.NewLine + ManualFilesTxt.Text + Environment.NewLine;
                inputs += "Historic Climate Data : " + Environment.NewLine + CruModel.Checked + Environment.NewLine;
                inputs += "Future Climate Models : " + Environment.NewLine + models + Environment.NewLine;
                inputs += "Carbon Emission Scenarios : " + Environment.NewLine + sens + Environment.NewLine;
                inputs += "Precipitation : " + Environment.NewLine + Precipitation.Checked + Environment.NewLine;
                inputs += "Temperature : " + Environment.NewLine + Temperature.Checked + Environment.NewLine;
                inputs += "Output Folder  : " + Environment.NewLine + OutputTxt.Text + Environment.NewLine;
                inputs += "Simulation File : " + Environment.NewLine + AnomalyTxt.Text + Environment.NewLine;
                inputs += "Measured File : " + Environment.NewLine + MeasuredTxt.Text + Environment.NewLine;
                inputs += "Correction Method : " + Environment.NewLine + (RatioRb.Checked ? RatioRb.Text : PlusRb.Text) + Environment.NewLine;

                File.WriteAllText(ManualFilesTxt.Text.Replace(@"\UserDatabase", @"\Bias-Corrected").Replace(@"\DownScaling", @"\Bias-Corrected") + "/inputs.txt", inputs);

                MessageBox.Show("End!");
                commentLbl.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            frmParent.ReadyState();
        }
コード例 #2
0
        private void RunBtn_Click(object sender, EventArgs e)
        {
            var msg = @"We recommend to run (interpolate) the module for each variable (precipitation or temperature) separately. 

Extents numbers must contain 0.25 or 0.75 decimals.

Do you want to continue?";

            if (MessageBox.Show(msg, "Check Your input data!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
            {
                var CheckedModels = ModelChk.CheckedItems.OfType <string>().ToList();
                var CheckedSens   = ScenarioChk.CheckedItems.OfType <string>().ToList();
                if (CruModel.Checked)
                {
                    CheckedModels = new List <string>()
                    {
                        "ObservedData"
                    };
                    CheckedSens = new List <string>()
                    {
                        "ObservedCru"
                    };
                }
                else if (ObserveModel.Checked)
                {
                    CheckedModels = new List <string>()
                    {
                        "ObservedData"
                    };
                    CheckedSens = new List <string>()
                    {
                        "ObservedUser"
                    };
                }

                frmParent.BusyState();
                Directory.CreateDirectory(curentDir + @"\backup");
                File.Copy(curentDir + @"\positionDB.mdb", curentDir + @"\backup\" + DateTime.Now.Ticks + "-positionDB.mdb", true);
                //try
                //{
                var fileFolders = "";
                if (DirectRb.Checked)
                {
                    fileFolders = DirectFilesTxt.Text;
                    MainRun(fileFolders);
                }
                else
                {
                    var parentFolder = ManualFilesTxt.Text;
                    foreach (var model in CheckedModels)
                    {
                        var modelDirectory = parentFolder + @"\" + model;
                        Directory.CreateDirectory(modelDirectory);
                        foreach (var senario in CheckedSens)
                        {
                            var senarioDirectory = modelDirectory + @"\" + senario;
                            Directory.CreateDirectory(senarioDirectory);
                            if (Precipitation.Checked)
                            {
                                var pcpDirectory = senarioDirectory + @"\pcp";
                                Directory.CreateDirectory(pcpDirectory);

                                MainRun(pcpDirectory);
                            }
                            if (Temperature.Checked)
                            {
                                var tmpDirectory = senarioDirectory + @"\tmp";
                                Directory.CreateDirectory(tmpDirectory);

                                MainRun(tmpDirectory);
                            }
                        }
                    }
                }
                var inputs = "";
                var models = CheckedModels.Cast <object>().Aggregate("", (current, model) => current + (model + ","));
                models = models.Length > 0? models.Remove(models.Length - 1):models;
                var sens = CheckedSens.Cast <object>().Aggregate("", (current, sen) => current + (sen + ","));
                sens    = sens.Length > 0? sens.Remove(sens.Length - 1):sens;
                inputs += "Main Database Folder : " + Environment.NewLine + ManualFilesTxt.Text + Environment.NewLine;
                inputs += "Historic Climate Data : " + Environment.NewLine + CruModel.Checked + Environment.NewLine;
                inputs += "Future Climate Models : " + Environment.NewLine + models + Environment.NewLine;
                inputs += "Carbon Emission Scenarios : " + Environment.NewLine + sens + Environment.NewLine;
                inputs += "Precipitation : " + Environment.NewLine + Precipitation.Checked + Environment.NewLine;
                inputs += "Temperature : " + Environment.NewLine + Temperature.Checked + Environment.NewLine;
                inputs += "Latitude From : " + Environment.NewLine + LatFrom.Text + Environment.NewLine;
                inputs += "Latitude To : " + Environment.NewLine + LatTo.Text + Environment.NewLine;
                inputs += "Longitude From : " + Environment.NewLine + LongFrom.Text + Environment.NewLine;
                inputs += "Longitude To : " + Environment.NewLine + LongTo.Text + Environment.NewLine;
                inputs += "Considering Elevation : " + elevChk.Checked + Environment.NewLine;
                inputs += "Current Grid Size : " + stepTxt.Text + Environment.NewLine;

                File.WriteAllText(ManualFilesTxt.Text.Replace("UserDatabase", "Interpolation").Replace("Bias-Corrected", "Interpolation") + "/inputs.txt", inputs);
                MessageBox.Show("End!");
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}

                frmParent.ReadyState();
            }
        }