public void AreCloseDistance3_OpticalConst_DrudeLorentz() { // Arrange var distance = 2.9; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
public void Peaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.Set("xtics 0.5"); gp.Set("grid xtics ytics"); gp.Set("size square"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { Dictionary <double, double> peaks0 = this.getPeaks0(distances, radius, dirAzimuth0); Dictionary <double, double> peaks90 = this.getPeaks90(distances, radius, dirAzimuth90); //gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); } gp.Wait(); }
public void AreClose_Radius40_OpticalConst_DrudeLorentz() { // Arrange const double DistanceMax = 0.5; const double DistanceStep = 0.1; List <double> distances = getDistances(DistanceStep, DistanceMax); var radius = 40; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); foreach (double distance in distances) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
public void DimmerVsOne_Azimuth45_EffectiveCrossExt() { // Arrange var radiuses = new List <double> { 4, 10, 20, 40 }; var distance = 0; string dirAzimuth45 = "DimmerVsOne_Azimuth45_EffectiveCrossExt"; string dirAzimOne = "OneParticle_EffectiveCrossExt"; foreach (double radius in radiuses) { var gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)) .Where(x => x.Key <= 500) .ToDictionary(x => x.Key * 1e9, x => x.Value * 2); gp.Plot(azim45, string.Format(@"title ""{0}""", distance)); Dictionary <double, double> azimOne = SimpleFormatter.Read( this.getFileFormatOneParticle(dirAzimOne, radius)) .Where(x => x.Key <= 500) .ToDictionary(x => x.Key * 1e9, x => x.Value * 2); gp.Plot(azimOne, string.Format(@"title ""{0}""", 0)); } }
public void AreClose_Azimuth45_AzimuthSum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuthSum = "RadiusDistanceOutput_AzimuthSum"; string dirAzimuth45 = "RadiusDistanceOutput_Azimuth45"; var gp = new GnuPlot(); setLineStyle(gp); foreach (double radius in radiuses) { foreach (double distance in distances) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)); Dictionary <double, double> azimSum = SimpleFormatter.Read( this.getFileFormat(dirAzimuthSum, distance, radius)); gp.HoldOn(); gp.Plot(azim45); gp.Plot(azimSum); gp.HoldOff(); AssertHelper.DictionaryAreClose(azim45, azimSum, 0.5); } } }
public void CalculateOpticalConstants_DrudeLorentz_Gnuplot() { // Arrange var optConst = ParameterHelper.ReadOpticalConstants("opt_const.txt"); var drudeLorentz = new DrudeLorentz(); var dict = new Dictionary <double, Complex>(); foreach (var waveLength in optConst.WaveLengthList) { var freq = new SpectrumUnit(waveLength / OpticalConstants.WaveLengthMultiplier, SpectrumUnitType.WaveLength); dict.Add(waveLength, drudeLorentz.GetPermittivity(freq)); } ParameterHelper.WriteOpticalConstants("opt_const_drudeLorentz.txt", dict); using (var gp = new GnuPlot()) { gp.HoldOn(); gp.Set("style data lines"); gp.Plot(getPermitivittyFunc(optConst)); gp.Plot(dict); gp.Wait(); } // Act // Assert }
private void button1_Click(object sender, EventArgs e) { GnuPlot gp = new GnuPlot(); gp.HoldOn(); gp.Unset("key"); gp.Plot(NoisySine(1000, 1)); gp.Plot(NoisySine(1000, 1.5)); gp.Plot(NoisySine(1000, 2)); }
private void button2_Click(object sender, EventArgs e) { GnuPlot gp = new GnuPlot(); gp.HoldOn(); gp.Set("title 'Phase-Locked Signals'"); gp.Set("samples 2000"); gp.Unset("key"); gp.Plot("sin(x)"); gp.Plot("cos(x)"); }
public void RadiusChangeOutputPeaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; var radius1 = 4; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusChangeOutput_Azimuth0"; string dirAzimuth90 = "RadiusChangeOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { var peaks0 = new Dictionary <double, double>(); var peaks90 = new Dictionary <double, double>(); foreach (double distance in distances) { Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth0, distance, radius1, radius)); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth90, distance, radius1, radius)); peaks0.Add(distance, azim0.MaxPair().Key); peaks90.Add(distance, azim0.MaxPair().Key); } // gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); string basepath = Path.Combine(BasePath, this.TestContext.TestName); string filename0 = Path.Combine( basepath, string.Format("peaks_0deg_{0}.txt", radius)); SimpleFormatter.Write(filename0, peaks0); string filename90 = Path.Combine( basepath, string.Format("peaks_90deg_{0}.txt", radius)); SimpleFormatter.Write(filename90, peaks90); } gp.Wait(); }
[TestMethod]//todo public void RadiusChangeOutput_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.5; GnuPlot gp = null; var radius1 = 4; var radiuses = new List <double> { 4, 10, 20, 40 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusChangeOutput_Azimuth45_EffectiveExtinction"; string dirAzimuthOne = "OneParticle_EffectiveCrossExt"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); foreach (double distance in distances) { gp.HoldOn(); //gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { //Dictionary<decimal, List<double>> spectrum = this.zipToDictionaryDiffRadiuses(distances, // dirAzimuth45, radius1, radius); //string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); //SimpleFormatter.WriteDictionary(filename, spectrum, distances); Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); gp.Clear(); Dictionary <double, double> azim = SimpleFormatter.Read( this.getFileFormatOneParticle(dirAzimuthOne, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim, @"title ""single"""); } } //} gp.Wait(); }
public void Calculate_PerformanceMetrics() { var serialTicks = 192769194.79518071; List <double> all = new List <double>(); var gp = new GnuPlot(); gp.Set("style data linespoints"); gp.HoldOn(); for (int i = 256; i <= 1024; i = i * 2) { List <long> list = new List <long>(); for (int j = 0; j < 20; j++) { Stopwatch watch = Stopwatch.StartNew(); //ArrayExtensions.MaxDegreeOfParallelism = i; FDTDProgram.Calculate(); watch.Stop(); list.Add(watch.ElapsedTicks); } all.Add(list.Average()); } gp.Plot(all.Select(x => serialTicks / x)); gp.Wait(); }
public static void PlotData(Matrix <double> X, Vector <double> y) { List <(double x1, double x2)> pos = new List <(double x1, double x2)>(); List <(double x1, double x2)> neg = new List <(double x1, double x2)>(); for (int i = 0; i < y.Count; i++) { if (y[i] == 1) { pos.Add((X[i, 0], X[i, 1])); } else { neg.Add((X[i, 0], X[i, 1])); } } GnuPlot.HoldOn(); GnuPlot.Set("title \"\""); GnuPlot.Set("xlabel \"Microchip test 1\""); GnuPlot.Set("ylabel \"Microchip test 2\""); GnuPlot.Plot(pos.Select(p => p.x1).ToArray(), pos.Select(p => p.x2).ToArray(), "pt 1 ps 1 lc rgb \"black\" title \"y=1\""); GnuPlot.Plot(neg.Select(p => p.x1).ToArray(), neg.Select(p => p.x2).ToArray(), "pt 7 ps 1 lc rgb \"yellow\" title \"y=0\""); }
public void RadiusChangeOutput_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radius1 = 4; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusChangeOutput_Azimuth45"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <decimal, List <double> > spectrum = this.zipToDictionaryDiffRadiuses(distances, dirAzimuth45, radius1, radius); string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances.Take(5)) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); } gp.Clear(); } gp.Wait(); }
public void RadiusChangeOutput_InterparticleDistance_Spectrum() { // Arrange GnuPlot gp = null; var radius1 = 20; var radiuses = new List <double> { 4, 10, 15, 20 }; double distance = 70; string dirAzimuth45 = "RadiusChangeOutput_InterparticleDistance_Spectrum"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); setColorPalette(gp); gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)) .ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); //gp.Clear(); } //} gp.Wait(); }
private void PlotVector() { if (!Helper.Plot) { return; } if (!File.Exists(Helper.outputPath + "vectors.txt")) { using (var fs = File.Create(Helper.outputPath + "vectors.txt")) { } } foreach (var neuron in neurons) { if (neuron.PreviousWeights.Count == neuron.Weights.Count) { text += $"{neuron.PreviousWeights[0]} {neuron.PreviousWeights[1]} {neuron.Weights[0]} {neuron.Weights[1]}\r\n"; } } using (var stream = File.CreateText(Helper.outputPath + "vectors.txt")) { stream.Write(text); } GnuPlot.Plot(Helper.outputPath + "vectors.txt", $" using 1:2:($3-$1):($4-$2) with vectors head filled lt 2 lc rgb 'red', '{Helper.outputPath + "shape.txt"}' using 1:2 title 'shape' with points pt '+' lc rgb 'black'"); }
public static void PlotData(Matrix <double> X, Vector <double> y) { List <(double x1, double x2)> pos = new List <(double x1, double x2)>(); List <(double x1, double x2)> neg = new List <(double x1, double x2)>(); for (int i = 0; i < y.Count; i++) { if (y[i] == 1) { pos.Add((X[i, 0], X[i, 1])); } else { neg.Add((X[i, 0], X[i, 1])); } } GnuPlot.HoldOn(); GnuPlot.Set("title \"Data\""); //GnuPlot.Set("key bottom right"); GnuPlot.Set("key outside noautotitle"); //GnuPlot.Set("key title \"Legend\""); GnuPlot.Set("xlabel \"Exam 1 score\""); GnuPlot.Set("ylabel \"Exam 2 score\""); GnuPlot.Plot(pos.Select(p => p.x1).ToArray(), pos.Select(p => p.x2).ToArray(), "pt 1 ps 1 lc rgb \"black\" title \"Admitted\""); GnuPlot.Plot(neg.Select(p => p.x1).ToArray(), neg.Select(p => p.x2).ToArray(), "pt 7 ps 1 lc rgb \"yellow\" title \"Not admitted\""); }
public void TestMethod1() { Stopwatch watch = new Stopwatch(); var gp = new GnuPlot(); gp.HoldOn(); for (int j = 0; j < 5; j++) { List <TimeSpan> list = new List <TimeSpan>(); for (var i = 1; i <= 16; i++) { watch.Start(); ParallelIterator.MaxDegreeOfParallelism = i; FDTDProgram.Calculate(); watch.Stop(); list.Add(watch.Elapsed); watch.Reset(); } gp.Plot(list.Select(x => (double)x.Milliseconds)); } gp.Wait(); }
private static void PlotFit(double min_x, double max_x, Vector <double> mu, Vector <double> sigma, Vector <double> theta, int p, double lambda) { // Plot training data and fit var x = Matrix <double> .Build.DenseOfColumnArrays(Generate.LinearRange(min_x - 15, .05, max_x + 25)); Matrix <double> X_poly = MapPolyFeatures(x, p); for (int i = 0; i < X_poly.ColumnCount; i++) { Vector <double> v = X_poly.Column(i); v = v - mu[i]; v = v / sigma[i]; X_poly.SetColumn(i, v); } X_poly = X_poly.InsertColumn(0, Vector <double> .Build.Dense(X_poly.RowCount, 1)); var hypothesis = X_poly * theta; GnuPlot.Set(string.Format("title \"Polynomial Regression Fit (lambda = {0:f6})\"", lambda)); GnuPlot.Set("xlabel \"Change in water level (x)\""); GnuPlot.Set("ylabel \"Water flowing out of the dam (y)\""); GnuPlot.Set("autoscale xy"); //GnuPlot.Set("xr[-100:100]"); //GnuPlot.Set("yr[-200:400]"); GnuPlot.Plot(x.Column(0).ToArray(), hypothesis.ToArray(), "with lines dashtype 2 lw 1 lc rgb \"blue\" notitle"); }
public static void PlotData(double[] x, double[] y) { GnuPlot.Set("title \"Water flowing\""); GnuPlot.Set("key bottom right"); GnuPlot.Set("xlabel \"Change in water level (x)\""); GnuPlot.Set("ylabel \"Water flowing out of the dam (y)\""); GnuPlot.Plot(x, y, "pt 2 ps 1 lc rgb \"red\" notitle"); }
[TestMethod]//todo public void Radius10_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.5; int radius = 10; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0_EffectiveCrossExt"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90_EffectiveCrossExt"; var gp = new GnuPlot(); setLineStyle(gp); //Dictionary<decimal, List<double>> spectrum = this.zipToDictionary(distances, dirAzimuth45, radius); //string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); //SimpleFormatter.WriteDictionary(filename, spectrum, distances); //spectrum = this.zipToDictionary(distances, dirAzimuth0, radius); //filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim0.txt"); //SimpleFormatter.WriteDictionary(filename, spectrum, distances); //spectrum = this.zipToDictionary(distances, dirAzimuth90, radius); //filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim90.txt"); //SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances) { gp.HoldOn(); Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value * 2); gp.Plot(azim45, string.Format(@"title ""{0}""", distance)); Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth0, distance, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim0, string.Format(@"title ""{0}""", distance)); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth90, distance, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim90, string.Format(@"title ""{0}""", distance)); } //gp.Wait(); }
// plot the data public static void PlotData(double[] x, double[] y) { GnuPlot.Set("title \"Linear Regression\""); GnuPlot.Set("key bottom right"); //GnuPlot.Set("key title \"Legend\""); GnuPlot.Set("xlabel \"Population of City in 10,000s\""); GnuPlot.Set("ylabel \"Profit in $10,000s\""); GnuPlot.Plot(x, y, "pt 2 ps 1 lc rgb \"red\" title \"Training data\""); }
private static void PlotJ(Matrix <double> j_history, string title, string color) { double[] x = MathNet.Numerics.Generate.LinearRange(1, 1, j_history.RowCount); double[] y = j_history.Column(0).ToArray(); GnuPlot.Set("xlabel \"Number of iteration\""); GnuPlot.Set("ylabel \"Cost J\""); GnuPlot.Plot(x, y, "with lines linestyle 1 lc rgb \"" + color + "\" linewidth 2 title \"" + title + "\" "); }
public static void PlotPoints(List <Point> points, string options, string saveFileName = "") { double[] X = points.Select(p => p.x).ToArray(); double[] Y = points.Select(p => p.y).ToArray(); GnuPlot.Plot(X, Y, options); if (saveFileName != "") { GnuPlot.SaveData(X, Y, saveFileName); } }
public void CalculateOpticalConstants_Drude() { // Arrange var optConst = ParameterHelper.ReadOpticalConstants("opt_const.txt"); var EpsInfinity = 3.9943; var OmegaP = 1.369e+16; var DEps0 = 8.45e-1; var Gamma0 = 7.292e+13; var funcPermitivitty = new Dictionary <double, Complex>(); foreach (var waveLength in optConst.WaveLengthList) { var omeg = SpectrumUnitConverter.Convert(waveLength / OpticalConstants.WaveLengthMultiplier, SpectrumUnitType.WaveLength, SpectrumUnitType.CycleFrequency); var compl = EpsInfinity - OmegaP * OmegaP / (omeg * omeg - Complex.ImaginaryOne * Gamma0 * omeg); funcPermitivitty.Add(waveLength, compl); } ParameterHelper.WriteOpticalConstants("opt_const_new.txt", funcPermitivitty); using (var gnuplot = new GnuPlot()) { gnuplot.HoldOn(); gnuplot.Plot(funcPermitivitty); var permitivittyList = getPermitivittyFunc(optConst); gnuplot.Plot(permitivittyList); } // Act // Assert }
// Plot J cost function private static void PlotJ(Matrix <double> X, Matrix <double> y, Matrix <double> theta) { // Grid over which we will calculate J double[] theta0_vals = MathNet.Numerics.Generate.LinearSpaced(100, -10, 10); double[] theta1_vals = MathNet.Numerics.Generate.LinearSpaced(100, -1, 4); // initialize J_vals to a matrix of 0's int size = theta0_vals.Length * theta1_vals.Length; double[] sx = new double[size]; double[] sy = new double[size]; double[] sz = new double[size]; // Fill out J_vals int idx = 0; for (int i = 0; i < theta0_vals.Length; i++) { for (int k = 0; k < theta1_vals.Length; k++) { Matrix <double> t = Matrix <double> .Build.Dense(2, 1); t[0, 0] = theta0_vals[i]; t[1, 0] = theta1_vals[k]; sx[idx] = theta0_vals[i]; sy[idx] = theta1_vals[k]; sz[idx] = ComputeCost(X, y, t); idx++; } } GnuPlot.HoldOn(); GnuPlot.Set("terminal wxt 1"); GnuPlot.Set("title \"Cost function J\""); GnuPlot.Set("key bottom right"); GnuPlot.Set("xlabel \"{/Symbol q}_0\""); GnuPlot.Set("ylabel \"{/Symbol q}_1\""); // surface plot GnuPlot.SPlot(sx, sy, sz, "palette title \"J({/Symbol q}_0,{/Symbol q}_1)\""); // Contour plot GnuPlot.Set("terminal wxt 2"); GnuPlot.Set("cntrparam levels auto 10", "logscale z", "xr[-10:10]", "yr[-1:4]"); GnuPlot.Unset("key", "label"); GnuPlot.Contour(sx, sy, sz); GnuPlot.Plot(new double[] { theta[0, 0] }, new double[] { theta[1, 0] }, "pt 2 ps 1 lc rgb \"red\""); }
public void RadiusChangeOutput_Hybridization_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.5; GnuPlot gp = null; var radius1 = 10; var radiuses = new List <double> { 4, 10 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth90 = "RadiusChangeOutput_Azimuth90"; string dirAzimuth0 = "RadiusChangeOutput_Azimuth0"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); //gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { double distance = 0; gp.HoldOn(); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth90, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim90, @"title ""90"""); Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth0, distance, radius1, radius)).Where(x => x.Key <= 500).ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim0, @"title ""0"""); } //} gp.Wait(); }
private static void PlotValidationCurve(double[] x, double[] jtrain, double[] jvc) { GnuPlot.HoldOn(); GnuPlot.Set("title \"Validation curve\""); GnuPlot.Set("xlabel \"Lamda\""); GnuPlot.Set("key top right box"); GnuPlot.Set("ylabel \"Error\""); GnuPlot.Set("autoscale xy"); GnuPlot.Plot(x, jtrain, "with lines ls 1 lw 2 lc rgb \"cyan\" title \"Train\" "); GnuPlot.Plot(x, jvc, "with lines ls 1 lw 2 lc rgb \"orange\" title \"Cross Validation\" "); GnuPlot.HoldOff(); }
public void RadiusChangeOutputPeaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 10; const double DistanceStep = 0.02; var radiuses = new List <double> { 4, 10, 20, 40 }; var radius1 = 4; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusChangeOutput_Azimuth0_EffectiveExtinction"; string dirAzimuth90 = "RadiusChangeOutput_Azimuth90_EffectiveExtinction"; GnuPlot gp = null; gp = new GnuPlot(); gp.HoldOn(); radiuses.Reverse(); //foreach (var radius1 in radiuses) //{ gp.Set("style data lines"); foreach (double radius in radiuses) { Dictionary <double, double> peaks0 = this.getPeaksDiffRad0(distances, radius1, radius, dirAzimuth0); Dictionary <double, double> peaks90 = this.getPeaksDiffRad90(distances, radius1, radius, dirAzimuth90); // gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0, string.Format(@"smooth acsplines title ""0.{0}""", radius)); gp.Plot(peaks90, string.Format(@"smooth acsplines title ""90.{0}""", radius)); // gp.HoldOff(); } //} gp.Wait(); }
private static void PlotLinearLearningCurve(double[] x, double[] jtrain, double[] jvc) { GnuPlot.HoldOn(); GnuPlot.Set("title \"Learning curve for linear regression\""); GnuPlot.Set("xlabel \"Number of training examples\""); GnuPlot.Set("key top right box"); GnuPlot.Set("ylabel \"Error\""); GnuPlot.Set("xr[0:13]"); GnuPlot.Set("yr[0:150]"); GnuPlot.Plot(x, jtrain, "with lines ls 1 lw 2 lc rgb \"cyan\" title \"Train\" "); GnuPlot.Plot(x, jvc, "with lines ls 1 lw 2 lc rgb \"orange\" title \"Cross Validation\" "); GnuPlot.HoldOff(); }
protected void muestraVisualizacion(object sender, EventArgs e) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URLGET); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string dataObjects = ""; // List data response. HttpResponseMessage response = client.GetAsync(urlParametersGET).Result; if (response.IsSuccessStatusCode) { // Parse the response body. dataObjects = response.Content.ReadAsStringAsync().Result; Console.WriteLine("{0}", dataObjects); var serializer = new JavaScriptSerializer(); var obj = serializer.DeserializeObject(dataObjects); Dictionary <string, object> dString = obj as Dictionary <string, object>; //Console.WriteLine ("Ahora serializado: {0}", feedObj); IList feeds = dString["feeds"] as IList; int i = 0; Date = new double[feeds.Count]; Light = new double[feeds.Count]; foreach (var feed in feeds) { Dictionary <string, object> f = feed as Dictionary <string, object>; DateTime dateTime = Convert.ToDateTime(f ["created_at"]); var dateUNIX = (TimeZoneInfo.ConvertTimeToUtc(dateTime) - new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds; Date [i] = Convert.ToDouble(dateUNIX); //(string)f ["created_at"]; Light[i] = Convert.ToDouble(f ["field4"]); i++; } //GnuPlot.HoldOn(); GnuPlot.Plot(Date, Light, "with points pt 2"); } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } }