private void OutputRun(bool isAnomaly) { 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" }; } List <string> fileList = null; startDate = new DateTime(2006, 01, 01); var startPeriod = new DateTime(2006, 1, 1); var endPeriod = new DateTime(2099, 12, 31); if (CruModel.Checked) { startDate = new DateTime(1970, 01, 01); startPeriod = new DateTime(1970, 1, 1); endPeriod = new DateTime(2006, 12, 31); } else if (ObserveModel.Checked) { startDate = observeDate.Value; startPeriod = observeDate.Value; endPeriod = new DateTime(2096, 12, 31); } else if (CheckedSens.Contains("Historical")) { startDate = new DateTime(1950, 01, 01); startPeriod = new DateTime(1950, 1, 1); endPeriod = new DateTime(2006, 12, 31); } outputPath = Directory.GetParent(path).ToString();// path.Split(new[] { @"\UserDatabase" }, StringSplitOptions.None).FirstOrDefault(); //var x = Directory.GetParent(path).ToString(); outputPath = outputPath + @"\Average-Anomalies\Outputs_Average"; Directory.CreateDirectory(outputPath); foreach (var model in CheckedModels) { var modelDirectory = outputPath + @"\" + 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); CalcFiles(pcpDirectory, model.ToString(), senario.ToString(), true, "pcp_", fileList, startPeriod, endPeriod); } if (Temperature.Checked) { var tmpDirectory = senarioDirectory + "/tmp/"; Directory.CreateDirectory(tmpDirectory); CalcFiles(tmpDirectory, model.ToString(), senario.ToString(), false, "max_", fileList, startPeriod, endPeriod); CalcFiles(tmpDirectory, model.ToString(), senario.ToString(), false, "min_", fileList, startPeriod, endPeriod); } } } }
private void swatBtn_Click(object sender, EventArgs e) { 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" }; } List <string> fileList = null; if (SelectedArea.Checked) { var LatitudeFrom = Convert.ToDouble(LatFrom.Text); var LongitudeFrom = Convert.ToDouble(LongFrom.Text); var LatitudeTo = Convert.ToDouble(LatTo.Text); var LongitudeTo = Convert.ToDouble(LongTo.Text); if (CruModel.Checked || CheckedSens.Contains("Historical")) { fileList = FindFileNamesCru(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } else if (ObserveModel.Checked) { fileList = FindFileNamesObserve(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } else { fileList = FindFileNames(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } } var startPeriod = new DateTime(2006, 1, 1); var endPeriod = new DateTime(2099, 12, 31); if (SelectedPeriod.Checked) { startPeriod = SimStartDate.Value; endPeriod = SimEndDate.Value; } var outputPathSwat = outputPath + @"\UserDatabase"; Directory.CreateDirectory(outputPathSwat); foreach (var model in CheckedModels) { var modelDirectory = outputPathSwat + @"\" + 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); ReportSwat(pcpDirectory, model.ToString(), senario.ToString(), true, "", fileList, startPeriod, endPeriod); } if (Temperature.Checked) { var tmpDirectory = senarioDirectory + "/tmp/"; Directory.CreateDirectory(tmpDirectory); ReportSwat(tmpDirectory, model.ToString(), senario.ToString(), false, "max_", fileList, startPeriod, endPeriod); ReportSwat(tmpDirectory, model.ToString(), senario.ToString(), false, "min_", fileList, startPeriod, endPeriod); } } } // MessageBox.Show("End!"); }
private void downscalingBtn_Click(object sender, EventArgs e) { if (ObserveModel.Checked) { MessageBox.Show(@"ObservedUser cannot be downscaled. When having ObservedUser in your project, downscale GCMs (RCPs and Historical). Three steps for downscaling of GCMs while having ObservedUser in the project: 1- Click Run button for ObservedUser, 2- Click Run button for GCMs, 3- Click downscaling button for GCMs (RCPs and Historical).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var msg = @"Only if ObservedUser is being used in the project, GCMs must be downscaled. Coordinates of ObservedCru and GCMs are match and there is no need for downscaling of observed data. Continue downscaling of GCMs?"; if (MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { 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" }; } curentDir = System.IO.Directory.GetCurrentDirectory(); outputPath = OutputTxt.Text; inputPath = FileTxt.Text; var observes = new List <Position>(); if (CruModel.Checked || CheckedSens.Contains("Historical")) { observes = FindFileـJoinObserve(true); } else { observes = FindFileـJoinObserve(false); } var outputPathSwat = outputPath + @"\UserDatabase"; var outputPathDs = outputPathSwat.Replace(@"UserDatabase", "DownScaling"); Directory.CreateDirectory(outputPathDs); foreach (var model in CheckedModels) { var modelDirectory = outputPathDs + @"\" + model; Directory.CreateDirectory(modelDirectory); foreach (var senario in CheckedSens) { var senarioDirectory = modelDirectory + @"\" + senario; Directory.CreateDirectory(senarioDirectory); var pcpDirectory = senarioDirectory + @"\pcp\"; Directory.CreateDirectory(pcpDirectory); var tmpDirectory = senarioDirectory + "/tmp/"; Directory.CreateDirectory(tmpDirectory); foreach (var observe in observes) { var sourceFileName = observe.Main; var destinationFileName = observe.Cru; File.Copy( pcpDirectory.Replace("DownScaling", "UserDatabase") + sourceFileName + "p.txt", pcpDirectory + destinationFileName + "p.txt"); File.Copy( tmpDirectory.Replace("DownScaling", "UserDatabase") + sourceFileName + "t.txt", tmpDirectory + destinationFileName + "t.txt"); } } } } frmParent.ReadyState(); MessageBox.Show("End!"); }
private void CcdaBtn_Click(object sender, EventArgs e) { 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" }; } curentDir = System.IO.Directory.GetCurrentDirectory(); outputPath = OutputTxt.Text; inputPath = FileTxt.Text; List <string> fileList = null; if (SelectedArea.Checked) { var LatitudeFrom = Convert.ToDouble(LatFrom.Text); var LongitudeFrom = Convert.ToDouble(LongFrom.Text); var LatitudeTo = Convert.ToDouble(LatTo.Text); var LongitudeTo = Convert.ToDouble(LongTo.Text); if ((CruModel.Checked || CheckedSens.Contains("Historical")) && !ObservedUserDBChk.Checked) { fileList = FindFileNamesCru(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } else if (ObserveModel.Checked || ObservedUserDBChk.Checked) { fileList = FindFileNamesObserve(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } else { fileList = FindFileNames(LatitudeFrom, LongitudeFrom, LatitudeTo, LongitudeTo); } } var startPeriod = new DateTime(2006, 1, 1); var endPeriod = new DateTime(2099, 12, 31); if (SelectedPeriod.Checked) { startPeriod = SimStartDate.Value; endPeriod = SimEndDate.Value; } var outputPathCCDA = outputPath;// + @"\InputCCDA"; Directory.CreateDirectory(outputPathCCDA); Directory.CreateDirectory(outputPathCCDA + @"\DataAnalyzer"); Directory.CreateDirectory(outputPathCCDA + @"\DataAnalyzerOutput"); List <Position> oldNewName = new List <Position>(); foreach (var model in CheckedModels) { var modelDirectory = outputPathCCDA + @"\" + 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); ReportCcda(pcpDirectory, model.ToString(), senario.ToString(), true, "", fileList, startPeriod, endPeriod, ref oldNewName); } if (Temperature.Checked) { var tmpDirectory = senarioDirectory + "/tmp/"; Directory.CreateDirectory(tmpDirectory); ReportCcda(tmpDirectory, model.ToString(), senario.ToString(), false, "max_", fileList, startPeriod, endPeriod, ref oldNewName); ReportCcda(tmpDirectory, model.ToString(), senario.ToString(), false, "min_", fileList, startPeriod, endPeriod, ref oldNewName); } } } SaveSummeryCcdaToExcel(oldNewName); // MessageBox.Show("End!"); }