コード例 #1
2
        public DateAxisSampleDemo()
            : base("Code Project Date Axis Sample",
			"Date Axis Sample", DemoType.Tutorial)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "My Test Date Graph";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();
            for ( int i=0; i<36; i++ )
            {
                double x = (double) new XDate( 1995, 5, i+11 );
                double y = Math.Sin( (double) i * Math.PI / 15.0 );
                list.Add( x, y );
            }

            // Generate a red curve with diamond
            // symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve( "My Curve",
                list, Color.Red, SymbolType.Diamond );

            // Set the XAxis to date type
            myPane.XAxis.Type = AxisType.Date;

            base.ZedGraphControl.AxisChange();
        }
コード例 #2
0
        static PointPairList getData(string site_code, string var_code, DateTime dStart, DateTime dEnd, dbConnection dataObject, double lBnd, double upBnd)
        {
            PointPairList graphPoints = new PointPairList();

            DataTable values1yr = dataObject.getDVCstm(site_code, var_code, dStart, dEnd, lBnd, upBnd);
            Double NoDV = dataObject.getNoDV(var_code);

            double testBnds;
            foreach (DataRow row in values1yr.Rows)
            {
                testBnds = Convert.ToDouble(row["DataValue1"]);
                DateTime dateShowing = convDate(row["LocalDateTime"].ToString());

                try
                {
                    if (!(Convert.ToDouble(row["DataValue1"]) == NoDV || Convert.ToDouble(row["DataValue1"]) < lBnd || Convert.ToDouble(row["DataValue1"]) > upBnd))
                    {
                        graphPoints.Add((double)new XDate(dateShowing.Year, dateShowing.Month, dateShowing.Day, dateShowing.Hour, dateShowing.Minute, dateShowing.Second), Convert.ToDouble(row["DataValue1"]));
                    }
                    else
                    {
                        graphPoints.Add((double)new XDate(dateShowing.Year, dateShowing.Month, dateShowing.Day, dateShowing.Hour, dateShowing.Minute, dateShowing.Second), double.NaN);
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("found error " +ex.Message);
                }

            }
            graphPoints = cleanValues(graphPoints, values1yr);
            return graphPoints;
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Lipotam/DSP
        public PointPairList Histogram(PictureBox pb)
        {
            int width, height;

            width = pb.Image.Width;
            height = pb.Image.Height;

            byte[] inputBytes = GetBytes((Bitmap)pb.Image);
            int[] intencity = new int[256];
            int index;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    byte r = inputBytes[4 * (width * y + x) + 0];
                    byte g = inputBytes[4 * (width * y + x) + 1];
                    byte b = inputBytes[4 * (width * y + x) + 2];

                    index = (int)(0.3 * r + 0.59 * g + 0.11 * b);

                    intencity[index]++;
                }
            }
            PointPairList points = new PointPairList();
            for (int i = 0; i < 256; i++)
            {
                points.Add(i, intencity[i]);
            }
            return points;
        }
コード例 #4
0
ファイル: JpegHist.cs プロジェクト: 6hellraiser/InfSec
        private void Draw(int[] x, int[] y, int[] z)
        {
            GraphPane pane = zgcHist.GraphPane;
            pane.CurveList.Clear();
            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            for (long j = 0; j < x.Length; j++)
            {
                if (x[j] != 0)
                {
                    list.Add(x[j], y[j]);
                    list2.Add(x[j], z[j]);
                }
            }

            //BurlyWood Coral DarkMagenta
            LineItem myCurve = pane.AddCurve("Гистограмма", list, Color.Coral, SymbolType.None);
            //Color color = Color.FromArgb(100, Color.Coral);
            //myCurve.Line.Fill = new ZedGraph.Fill(color);
            pane.AddCurve("Ожидаемый результат", list2, Color.BurlyWood, SymbolType.None);
            pane.YAxis.Scale.Min = 0;
            pane.YAxis.Scale.Max = 1.1*y.Max();

            pane.Title.Text = filename;
            zgcHist.AxisChange();
            zgcHist.Invalidate();
        }
コード例 #5
0
ファイル: frmBodePlot.cs プロジェクト: jnzim/dev-repo
        public void CreateGraph()
        {
            // get a reference to the GraphPane
            GraphPane myPane = this.zedGraphControlBode.GraphPane;
            a = this.myBodeFunction.bode(10, 20, 10, 10);

            zedGraphControlBode.Invalidate();
            zedGraphControlBode.AxisChange();

            // Generate a red curve with diamond
            // symbols, and "Porsche" in the legend

            // Generate a blue curve with circle
            // symbols, and "Piper" in the legend
             BodeCurve = myPane.AddCurve("Command", this.a, Color.Blue, SymbolType.None);
             this.BodeCurve.Line.Width = 3.0F;

            // Tell ZedGraph to refigure the`
            // axes since the data have changed
             myPane.XAxis.Type = AxisType.Linear;

            // myPane.XAxis.Scale.Format = "mm:ss"; // 24 hour clock for HH

             myPane.XAxis.MajorGrid.IsVisible = true;

            zedGraphControlBode.AxisChange();
        }
コード例 #6
0
        private void DrawGraphics()
        {
            int length = resultsList.Count();
            PointPairList avgsValues = new PointPairList();
            PointPairList sigmasValues = new PointPairList();

            foreach (double d in resultsList[length - 1].trajectoryAvgs.Keys)
            {
                avgsValues.Add(d, resultsList[length - 1].trajectoryAvgs[d]);
            }

            foreach (double d in resultsList[length - 1].trajectorySigmas.Keys)
            {
                sigmasValues.Add(d, resultsList[length - 1].trajectorySigmas[d]);
            }

            avgsGraphic.GraphPane.Legend.FontSpec.Size = 8;
            LineItem avgsL = avgsGraphic.GraphPane.AddCurve(resultsList[length - 1].parameterLine,
                avgsValues, currentColor, SymbolType.Circle);
            avgsL.IsVisible = this.currentPointView;

            avgsGraphic.AxisChange();
            avgsGraphic.Invalidate();
            avgsGraphic.Refresh();

            sigmasGraphic.GraphPane.Legend.FontSpec.Size = 8;
            LineItem sigmasL = sigmasGraphic.GraphPane.AddCurve(resultsList[length - 1].parameterLine,
                sigmasValues, currentColor, SymbolType.Circle);
            sigmasL.IsVisible = this.currentPointView;

            sigmasGraphic.AxisChange();
            sigmasGraphic.Invalidate();
            sigmasGraphic.Refresh();
        }
コード例 #7
0
        /// <summary>
        /// Constructs with the details of teh function regression problem to be visualized. 
        /// </summary>
        /// <param name="func">The function being regressed.</param>
        /// <param name="xMin">The minimum value of the input range being sampled.</param>
        /// <param name="xIncr">The increment between input sample values.</param>
        /// <param name="sampleCount">The number of samples over the input range.</param>
        /// <param name="genomeDecoder">Genome decoder.</param>
        public FunctionRegressionView2D(IFunction func, double xMin, double xIncr, int sampleCount, IGenomeDecoder<NeatGenome,IBlackBox> genomeDecoder)
        {
            InitializeComponent();
            InitGraph(string.Empty, string.Empty, string.Empty);

            _func = func;
            _xMin = xMin;
            _xIncr = xIncr;
            _sampleCount = sampleCount;
            _genomeDecoder = genomeDecoder;

            // Prebuild plot point objects.
            _plotPointListTarget = new PointPairList();
            _plotPointListResponse = new PointPairList();
            
            double[] args = new double[]{xMin};
            for(int i=0; i<sampleCount; i++, args[0] += xIncr)
            {
                _plotPointListTarget.Add(args[0], _func.GetValue(args));
                _plotPointListResponse.Add(args[0], 0.0);
            }

            // Bind plot points to graph.
            zed.GraphPane.AddCurve("Target", _plotPointListTarget, Color.Black, SymbolType.None);
            zed.GraphPane.AddCurve("Network Response", _plotPointListResponse, Color.Red, SymbolType.None);
        }
コード例 #8
0
        /// <summary>
        /// Filters the <see cref="DataFrameBuilder.Points"/> down to just those that are 
        /// visible if the graph has been zoomed in.
        /// This method only filters based on the value on the Base Axis 
        /// (i.e. the X-Axis for most curves).
        /// </summary>
        public virtual DataFrameBuilder FilterToZoomedRange(DataFrameBuilder dataFrameBuilder)
        {
            var graphPane = dataFrameBuilder.GraphPane;
            var pointList = dataFrameBuilder.Points;
            var baseAxis = dataFrameBuilder.CurveItem.BaseAxis(graphPane);
            if (baseAxis.Scale.IsAnyOrdinal)
            {
                // If the Scale is either Ordinal or Text, then don't
                // filter the PointList, because the point values
                // are derived from their position in the list.
                return dataFrameBuilder;
            }
            Func<PointPair, double> valueOfPointFunc = ValueOfPointFuncForAxis(dataFrameBuilder, baseAxis);
            if (null == valueOfPointFunc)
            {
                return dataFrameBuilder;
            }

            double min = baseAxis.Scale.Min;
            double max = baseAxis.Scale.Max;
            var pointPairList = new PointPairList();
            for (int i = 0; i < pointList.Count; i++)
            {
                var pointPair = pointList[i];
                double value = valueOfPointFunc(pointPair);
                if (value < min || value > max)
                {
                    continue;
                }
                pointPairList.Add(pointPair);
            }
            return dataFrameBuilder.SetPoints(pointPairList);
        }
コード例 #9
0
ファイル: HistForm.cs プロジェクト: 6hellraiser/InfSec
        private void DrawLSB(double[] B, ZedGraphControl zgc, string filename)
        {
            GraphPane pane = zgc.GraphPane;
            pane.CurveList.Clear();
            PointPairList list = new PointPairList();
            int x = 0;
            for (long j = 0; j < B.Length; j++)
            {
                //if (x[j] != 0)
                {
                    list.Add(x, B[j]);
                    x++;
                }
            }

            //BurlyWood Coral DarkMagenta
            //LineItem myCurve = pane.AddCurve("Гистограмма", list, Color.Coral, SymbolType.None);
            //Color color = Color.FromArgb(100, Color.Coral);
            //myCurve.Line.Fill = new ZedGraph.Fill(color);
            pane.AddCurve("B = (m00 - m01)/2 + (m11 - m10)/2", list, Color.Crimson, SymbolType.None);
            //pane.AddBar("Ожидаемый результат", list2, Color.CadetBlue);
            pane.YAxis.Scale.Min = 0;
            pane.YAxis.Scale.Max = 1.1 * B.Max();

            pane.XAxis.Scale.Min = 0;
            pane.XAxis.Scale.Max = x;

            pane.Title.Text = filename;
            zgc.AxisChange();
            zgc.Invalidate();
        }
コード例 #10
0
ファイル: ZedGraphDataLoader.cs プロジェクト: usbr/Pisces
        public void DrawSorted(SeriesList list, string title, string subTitle,string xAxisTitle)
        {
            Clear();

            if (list.Count == 0)
            {
                return;
            }

            for (int i = 0; i < list.Count; i++)
            {
                PointPairList pairs = new PointPairList();
                foreach (var pt in list[i])
                {
                    pairs.Add(pt.Percent, pt.Value);
                }

                var color = Default.GetSeriesColor(pane.CurveList.Count);
                LineItem myCurve = pane.AddCurve(list[i].Appearance.LegendText,
                    pairs, color);
                myCurve.Symbol.IsVisible = false;
                myCurve.Line.Width = Default.GetSeriesWidth(pane.CurveList.Count);
            }
            pane.Title.Text = title + "\n" + subTitle;
            pane.XAxis.Title.Text = xAxisTitle;

            FormatBottomAxisNumeric();
            pane.XAxis.Scale.Format = "";
            pane.XAxis.Scale.MajorStep = 5;

            FormatYAxisStandard();
            SetPaneVisible(true);
            LabelYaxis(list);
            RefreshChart(chart1);
        }
コード例 #11
0
ファイル: LinearScaleTool.cs プロジェクト: atdgroup/Mosaic
        public LinearScaleForm(MosaicWindow window)
        {
            InitializeComponent();

            mosaicWindow = window;

            // Set the Titles
            this.zedGraphControl.GraphPane.Title.Text = "LUT";
            this.zedGraphControl.GraphPane.XAxis.Title.Text = "Input Intensity";
            this.zedGraphControl.GraphPane.YAxis.Title.Text = "Output Intensity";

            this.list = new PointPairList();

            this.cursor1 =
               new VerticalZedGraphCursor(this.zedGraphControl, Color.Red);

            this.cursor2 =
                new VerticalZedGraphCursor(this.zedGraphControl, Color.Green);

            zedGraphControl.ZedGraphCursorChangingHandler +=
                new ZedGraphCursorHandler<ZedGraphWithCursorsControl, ZedGraphCursorEventArgs>(OnCursorChangingHandler);

            zedGraphControl.ZedGraphCursorChangedHandler += new ZedGraphCursorHandler<ZedGraphWithCursorsControl, ZedGraphCursorEventArgs>(OnCursorChangedHandler);

            this.cursor1.Position = this.min;
            this.cursor2.Position = this.max;

            this.zedGraphControl.AddVerticalCursor(cursor1);
            this.zedGraphControl.AddVerticalCursor(cursor2);
        }
コード例 #12
0
ファイル: InitialSampleDemo.cs プロジェクト: Jungwon/ZedGraph
        public InitialSampleDemo()
            : base("Code Project Initial Sample",
			"Initial Sample", DemoType.Tutorial)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "My Test Graph\n(For CodeProject Sample)";
            myPane.XAxis.Title.Text = "My X Axis";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data arrays based on the Sine function
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            for ( int i=0; i<36; i++ )
            {
                double x = (double) i + 5;
                double y1 = 1.5 + Math.Sin( (double) i * 0.2 );
                double y2 = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 ) );
                list1.Add( x, y1 );
                list2.Add( x, y2 );
            }

            // Generate a red curve with diamond
            // symbols, and "Porsche" in the legend
            LineItem myCurve = myPane.AddCurve( "Porsche",
                list1, Color.Red, SymbolType.Diamond );

            // Generate a blue curve with circle
            // symbols, and "Piper" in the legend
            LineItem myCurve2 = myPane.AddCurve( "Piper",
                list2, Color.Blue, SymbolType.Circle );

            base.ZedGraphControl.AxisChange();
        }
コード例 #13
0
ファイル: CurveObject.cs プロジェクト: Zordonia/AdvisIXAccel
 /// <summary>
 /// Cunstructor for CurveObject, accepts the PointPairList of points contained within
 /// the curve.
 /// </summary>
 /// <param name="ppl">The PointPairList containing the pointpairs for this curve.</param>
 /// <param name="index">The zIndex of this curve.</param>
 public CurveObject(PointPairList ppl, int index)
     : base()
 {
     zIndex = index;
     pointPL = ppl;
     populateVertexArray();
 }
コード例 #14
0
ファイル: Form1.cs プロジェクト: DVitinnik/UniversityApps
        private void ChordPrepare(double a, double b)
        {
            zedChord.GraphPane.CurveList.Clear();

            MyExtension.Function f = (x => x*x*x - 18*x - 83);
            
            zedChord.Graph(f, 2, 10, 0.1, Color.Blue);

           double x0 = a, x1 = b, x2;

            PointPairList list = new PointPairList();
            ChordLogger.Items.Clear();

            do
            {
                x2 = x1 - f(x1)*(x1 - x0)/(f(x1) - f(x0));
                x0 = x1;
                x1 = x2;
                list.Add(x2, f(x2));

                ChordLogger.Items.Add(
                    String.Format("x = {0:0.#####}, f(x) = {1:0.##########}", x2, f(x2)));

            } while (Math.Abs(f(x2)) > Eps);


            LineItem line = zedChord.GraphPane.AddCurve("", list, Color.Green, SymbolType.Diamond);
            line.Line.IsVisible = false;

            zedChord.AxisChange();
        }
コード例 #15
0
    private void DrawLine()
    {
        ZedGraph1.Type          = AnalyticsType.Line;
        ZedGraph1.Title         = DateTime.Now.Year.ToString() + " . " + DateTime.Now.Month.ToString();
        ZedGraph1.XAxisTitle    = "Month";
        ZedGraph1.YAxisTitle    = "Amount";
        ZedGraph1.ZGWidth       = 780;
        ZedGraph1.ZGHeight      = 250;
        ZedGraph1.IsChangeColor = false;
        ZedGraph.PointPairList ppl = new ZedGraph.PointPairList();

        DateTime  current = DateTime.Now;
        ArrayList al      = new ArrayList();

        for (int i = 0; i < 12; i++)
        {
            int      iMM   = i + 1;
            DateTime start = new DateTime(current.Year, iMM, 1);
            DateTime end   = new DateTime(current.Year, iMM, DateTime.DaysInMonth(current.Year, iMM));

            string where = string.Empty;
            where        = "StatusID>0 and StatusID<4 and CreateDate >='" + start.ToString("yyyy-MM-dd") + " 00:00:00' and CreateDate <='" + end.ToString("yyyy-MM-dd") + " 23:59:59'";
            decimal iCount = MojoCube.Web.Sql.GetResultSum("Order_List", "Amount", where);

            double x = i;
            double y = (double)iCount;
            ppl.Add(x, y);
        }
        ZedGraph1.DataSource.Add(ppl);
        ZedGraph1.CurveNameList.Add("");
    }
コード例 #16
0
ファイル: StepChartDemo.cs プロジェクト: Jungwon/ZedGraph
        public StepChartDemo()
            : base("A sample step chart",
									"Step Chart Demo", DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Demo for Step Charts";
            myPane.XAxis.Title.Text = "Time, Days";
            myPane.YAxis.Title.Text = "Widget Production (units/hour)";

            // Generate some sine-based data values
            PointPairList list = new PointPairList();
            for ( double i=0; i<36; i++ )
            {
                double x = i * 5.0;
                double y = Math.Sin( i * Math.PI / 15.0 ) * 16.0;
                list.Add( x, y );
            }

            // Add a red curve with circle symbols
            LineItem curve = myPane.AddCurve( "Step", list, Color.Red, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50), 90F );
            // Fill the symbols with white to make them opaque
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 5;

            // Set the curve type to forward steps
            curve.Line.StepType = StepType.ForwardStep;

            base.ZedGraphControl.AxisChange();
        }
コード例 #17
0
ファイル: HiLowBarDemo.cs プロジェクト: Jungwon/ZedGraph
        public HiLowBarDemo()
            : base("A demo demonstrating HiLow Bars.\n" +
									"These are bars in which the top and the bottom of the bar is defined with user data",
										"Hi-Low Bar", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Hi-Low Bar Graph Demo";
            myPane.XAxis.Title.Text = "Event";
            myPane.YAxis.Title.Text = "Range of Values";

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();
            for ( int i=1; i<45; i++ )
            {
                double y = Math.Sin( (double) i * Math.PI / 15.0 );
                double yBase = y - 0.4;
                list.Add( (double) i, y, yBase );
            }

            // Generate a red bar with "Curve 1" in the legend
            HiLowBarItem myCurve = myPane.AddHiLowBar( "Curve 1", list, Color.Red );
            // Fill the bar with a red-white-red gradient for a 3d look
            myCurve.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red, 0 );
            // Make the bar width based on the available space, rather than a size in points
            //			myCurve.Bar.IsAutoSize = true;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White,
                Color.FromArgb( 255, 255, 166), 45.0F );

            base.ZedGraphControl.AxisChange();
        }
コード例 #18
0
ファイル: HistogramXY.cs プロジェクト: jmdbo/SS
        public HistogramXY(int [] x, String axis)
        {
            int i;

            InitializeComponent();

            // get a reference to the GraphPane
            GraphPane myPane = zedGraphControl1.GraphPane;

            //Set the titles
            myPane.Title.Text = "Histograma";
            myPane.XAxis.Title.Text = axis;
            myPane.YAxis.Title.Text = "Contagem";
            //list points
            PointPairList list1 = new PointPairList();
            for (i = 0; i < x.Length; i++)
            {
                list1.Add(i, x[i]);
            }
            //add bar series
            myPane.AddCurve(axis, list1, Color.Gray, SymbolType.None);
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = x.Length-1;
            zedGraphControl1.AxisChange();
        }
 //double finK;
 //int cantPtos;
 public FrmDatos(PointPairList polos, PointPairList ceros, RootLocus rl)
 {
     InitializeComponent();
     this.rl = rl;
     this.polos = polos;
     this.ceros = ceros;
 }
コード例 #20
0
ファイル: EveryNumCycle.cs プロジェクト: windygu/asxinyunet
		void EveryNumCycleLoad(object sender, EventArgs e)
		{
			MasterPane myMaster = zedGraphControl1 .MasterPane ;			
			myMaster.PaneList.Clear();
			myMaster.Title.Text = "MasterPane Test";
			myMaster.Title.IsVisible = true;
			myMaster.Fill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );
			int[][] everyRes = DataProcess .AllSingleCycle (MainForm .arr ) ;
			for ( int j=0; j< 10; j++ )
			{
				GraphPane myPane = new GraphPane();
				myPane.Title.Text = "My Test Graph #" + (j+1).ToString();
				myPane.XAxis.Title.Text = "X Axis";
				myPane.YAxis.Title.Text = "Y Axis";
				//myPane.Fill = new Fill( Color.White, Color.LightYellow, 45.0F );
				//myPane.BaseDimension = 6.0F;
				PointPairList list = new PointPairList();
				for ( int i=0; i < everyRes [j ].Length ; i++ )
				{
					int x = i ;
					int y = everyRes [j ][i ] ;
					list.Add( x, y );
				}
				LineItem myCurve = myPane.AddCurve( "label" + j.ToString(),list, Color.Red, SymbolType.Diamond );
				myMaster.Add( myPane );
			}
			using ( Graphics g = this.CreateGraphics() )
			{
				 myMaster .SetLayout( g, PaneLayout.SquareColPreferred );
			}
		}
コード例 #21
0
        private void CreateGraph( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "My Test Graph";
            myPane.XAxis.Title.Text = "X Value";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points from the Sine function
            PointPairList list = new PointPairList();
            for ( double x = 0; x < 36; x++ )
            {
                double y = Math.Sin( x * Math.PI / 15.0 );

                list.Add( x, y );
            }

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve = myPane.AddCurve( "My Curve", list, Color.Blue,
                                    SymbolType.Circle );
            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F );

            // Fill the pane background with a color gradient
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45F );

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: Hartigan/MathematicModeling
 private void btnCalc_Click(object sender, EventArgs e)
 {
     int seed = int.Parse(Seed.Text);
     IRandomMethod method = new MethodMiddleOfSquare(seed);
     if (radioButton1.Checked) method = new MethodMiddleOfSquare(seed);
     if (radioButton2.Checked) method = new MultiplicativeCongruentialMethod(seed, 3453, 5675673);
     int countNumbers = int.Parse(CountNumbers.Text);
     int countNumbers2 = int.Parse(CountNumbers2.Text);
     int numberSections = int.Parse(textBox1.Text);
     ITestingMethod testingMethod = new EasyTesting();
     double M, D;
     double[] values = testingMethod.TestingUniformity(method, numberSections, countNumbers2, out M, out D);
     double C = testingMethod.TestingtestingIndependence(method, countNumbers);
     Correlation.Text = string.Format("Correlation = {0}", C);
     MValue.Text = string.Format("M = {0}", M);
     DValue.Text = string.Format("D = {0}", D);
     ZedGraph.PointPairList table = new PointPairList();
     for(int i=0;i<numberSections;i++)
     {
         table.Add(i,values[i]);
     }
     zedGraphControl1.GraphPane.AddCurve("", table, Color.Blue, SymbolType.Square);
     zedGraphControl1.AxisChange();
     zedGraphControl1.Invalidate();
 }
コード例 #23
0
        private void CreateGraph()
        {
            GraphPane myPane = zedGraphControl1.GraphPane;
            myPane.Title.Text = "Plot of " + foot + " foot motion.\n";
            myPane.XAxis.Title.Text = "Time (seconds)";
            myPane.YAxis.Title.Text =foot + "foot motion (mm)";

            //lists to save points as they come from the MCE
            xData = new PointPairList();
            yData = new PointPairList();
            zData = new PointPairList();
            
            // Initially, a curve is added with no data points (list is empty)
            // Color is blue, and there will be no symbols
            // 2nd line graph (red) added to show peaks
            curve = myPane.AddCurve("z-position", zData, Color.Blue, SymbolType.None);
            curve = myPane.AddCurve("y-position", yData, Color.Red, SymbolType.None);
            curve = myPane.AddCurve("x-position", yData, Color.Green, SymbolType.None);
            //curve = myPane.AddCurve("Peak", peakData, Color.Red, SymbolType.Plus);

            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 6.0;
            myPane.YAxis.Scale.Min = -700; //if needed, fix Y-axis to a max and min 
            myPane.YAxis.Scale.Max = 400;
            myPane.XAxis.Scale.MinorStep = 0.2;
            myPane.XAxis.Scale.MajorStep = 1.0;

            // Scale the axes
            zedGraphControl1.AxisChange();
        }
コード例 #24
0
        public RTGraph(TelemetryLapManager telemetryLapManager, bool cbest, bool clast, String xlabel, String YLabel)
        {
            this.cbest = cbest;
            this.clast = clast;
            this.Xlabel = xlabel;
            this.Ylabel = YLabel;

            InitializeComponent();

            this.telemetryLapManager = telemetryLapManager;
            GraphPane myPane = zedGraphControl1.GraphPane;

            if (cbest && telemetryLapManager.ComparisonLap != null)
            {
                var fastestLap = telemetryLapManager.ComparisonLap;
                LoadLap(fastestLap, "FastLap", Color.Green);
            }

            PointPairList pl = new PointPairList();
            var myCurve = myPane.AddCurve("RealTime", pl, Color.Red, SymbolType.None);
            myPane.Title.Text = Xlabel + " " + Ylabel;
            myPane.XAxis.Title.Text = Xlabel;
            myPane.YAxis.Title.Text = Ylabel;
            myCurve.Line.Width = 3.0F;

            telemetryLapManager.PacketProcessed += telemetryLapManager_PacketProcessed;
            telemetryLapManager.CompletedFullLap += telemetryLapManager_CompletedFullLap;
            telemetryLapManager.SetFastestLap += telemetryLapManager_SetFastestLap;
            telemetryLapManager.FinishedOutLap += telemetryLapManager_FinishedOutLap;
            telemetryLapManager.RemovedLap += telemetryLapManager_RemovedLap;

            t1.Interval = F1SpeedSettings.RefreshRate;
            t1.Tick += t1_Tick;
            t1.Start();
        }
コード例 #25
0
ファイル: FormEnergyCurve.cs プロジェクト: corebob/crash
        private void FormEnergyCurve_Load(object sender, EventArgs e)
        {
            if (CoeffList.Count < 2)
                return;

            string curveName = "";
            int counter = 0;
            foreach (double coeff in CoeffList)
            {
                curveName += coeff.ToString("E") + " * x^" + counter.ToString() + " + ";
                counter++;
            }
            curveName = curveName.Substring(0, curveName.Length - 3);

            Det.EnergyCurveCoefficients.Clear();
            Det.EnergyCurveCoefficients.AddRange(CoeffList);

            GraphPane pane = graph.GraphPane;
            PointPairList list = new PointPairList();
            for (int i = 0; i < Det.CurrentNumChannels; i++)
                list.Add((double)i, Det.GetEnergy(i));            

            LineItem energyCurve = pane.AddCurve(curveName, list, Color.Green, SymbolType.None);

            graph.RestoreScale(pane);
            graph.AxisChange();
            graph.Refresh();
        }
コード例 #26
0
ファイル: Form1.cs プロジェクト: DVitinnik/UniversityApps
        private void IterativePrepare(double xs)
        {

            zedIterative.GraphPane.CurveList.Clear();
            MyExtension.Function f = (x =>Math.Pow(Math.Abs(Math.Cos(x)),0.5));

            zedIterative.Graph(f, -10, 10, 0.1, Color.Red);
            zedIterative.Graph(x => x, -10, 10, 1, Color.Blue);


            PointPairList list = new PointPairList();

            double x0,x1 = xs;
            iterativeLogger.Items.Clear();
            list.Add(x1, f(x1));
            do
            {
                x0 = x1;
                x1 = f(x0);
                list.Add(x0, x1);
                iterativeLogger.Items.Add(
                    String.Format("X =  + {0:0.#####} + ; f(x) =  + {1:0.########}", x1, f(x1)));
            } while (Math.Abs(x1 - x0) > Eps);

            
            LineItem line = zedIterative.GraphPane.AddCurve("", list, Color.Green, SymbolType.Diamond);
            line.Line.IsVisible = false;

            zedIterative.AxisChange();
        }
コード例 #27
0
        private void CreateGraph(ZedGraphControl zgc)
        {
            string[] mesi = { "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" };
            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "Km percorsi per anno";
            myPane.XAxis.Title.Text = "Mese";
            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.Scale.TextLabels = mesi;
            myPane.YAxis.Title.Text = "Km percorsi";

            PointPairList list = new PointPairList();
            for (double x = 1; x < 13; x++)
            {
                double y = MesiKm[int.Parse(x.ToString())];
                list.Add(x, y, mesi[int.Parse((x-1).ToString())].ToString() +" "+ textBox1.Text);
            }

            BarItem bar =  myPane.AddBar(textBox1.Text, list, Color.Blue);

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            // Fill the pane background with a color gradient
            myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }
コード例 #28
0
ファイル: Form2.cs プロジェクト: Innazvrtn/Numerical-Methods
        public Form2(Form1 f2)
        {
            
           
            InitializeComponent();
            GraphPane pane = zedGraph.GraphPane;

            // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы
            pane.CurveList.Clear();

            // Создадим список точек
           PointPairList list = new PointPairList();
           PointPairList list2 = new PointPairList();
            // Заполняем список точек

            // Создадим кривую с названием "Функція", 
            // которая будет рисоваться голубым цветом (Color.Blue),
            // Опорные точки выделяться не будут (SymbolType.None)
            LineItem myCurve = pane.AddCurve("Функція Y", list, Color.Blue, SymbolType.None);
            LineItem myCurve2 = pane.AddCurve("Функція Y(точ)", list2, Color.Red, SymbolType.None);
           
            for (int i = 0; i < f2.dataGridView1.RowCount-1; i++)
            {
                list.Add(Convert.ToDouble( f2.dataGridView1[0, i].Value),Convert.ToDouble( f2.dataGridView1[1, i].Value));
                list2.Add(Convert.ToDouble(f2.dataGridView1[0, i].Value), Convert.ToDouble(f2.dataGridView1[2, i].Value));
                
            }

         
            zedGraph.AxisChange();
            pane.Title.Text = "Графік";
            // Обновляем график
            zedGraph.Invalidate();
        }
コード例 #29
0
 public GenericPlotForm(PlotPointSource plotPointSourceDelegate)
 {
     InitializeComponent();
     _plotPointSourceDelegate = plotPointSourceDelegate;
     _ppl = new PointPairList();
     zed.GraphPane.AddCurve("", _ppl, Color.Black, SymbolType.None);
 }
 public FrmDiagramaDeBloques(PointPairList polos, PointPairList ceros, RootLocus rl)
     : this()
 {
     this.rl = rl;
     this.polos = polos;
     this.ceros = ceros;
 }
コード例 #31
0
ファイル: StickItemDemo.cs プロジェクト: Jungwon/ZedGraph
        public StickItemDemo()
            : base("A demonstration of the 'StickItem', which is a single line for " +
			"each point running from the XAxis to the data value",
			"Stick Item Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "StickItem Demo Chart";
            myPane.XAxis.Title.Text = "X Label";
            myPane.YAxis.Title.Text = "My Y Axis";

            PointPairList list = new PointPairList();
            for ( int i=0; i<100; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( i / 8.0 );
                double z = Math.Abs(Math.Cos( i / 8.0 )) * y;
                list.Add( x, y, z );
            }

            StickItem myCurve = myPane.AddStick( "Some Sticks", list, Color.Blue );
            myCurve.Line.Width = 2.0f;
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.Scale.Max = 100;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White,
                Color.LightGoldenrodYellow, 45.0F );

            base.ZedGraphControl.AxisChange();
        }
コード例 #32
0
    private void DrawLine()
    {
        ZedGraph1.Type          = AnalyticsType.Line;
        ZedGraph1.Title         = DateTime.Now.Year.ToString() + " . " + DateTime.Now.Month.ToString();
        ZedGraph1.XAxisTitle    = "Date";
        ZedGraph1.YAxisTitle    = "Clicks";
        ZedGraph1.ZGWidth       = 800;
        ZedGraph1.ZGHeight      = 250;
        ZedGraph1.IsChangeColor = false;
        ZedGraph.PointPairList ppl = new ZedGraph.PointPairList();

        DateTime current = DateTime.Now;
        int      iMM     = current.Month;

        DateTime start = new DateTime(current.Year, iMM, 1);
        DateTime end   = new DateTime(current.Year, iMM, DateTime.DaysInMonth(current.Year, iMM));

        int iDays = (int)((TimeSpan)(end - start)).TotalDays + 1;

        ArrayList al     = new ArrayList();
        int       nowDay = DateTime.Now.Day;

        if (iMM != current.Month)
        {
            nowDay = iDays;
        }

        for (int i = 0; i < iDays; i++)
        {
            string where = string.Empty;
            string timeShort = start.AddDays(i).ToString("yyyy-MM-dd");
            where = "LogTime >='" + timeShort + " 00:00:00' and LogTime <='" + timeShort + " 23:59:59'";
            int iCount = MojoCube.Web.Sql.GetResultCount("Site_Log", where);

            double x = i;
            double y = (double)iCount;
            ppl.Add(x, y);
        }
        ZedGraph1.DataSource.Add(ppl);
        ZedGraph1.CurveNameList.Add("");
    }
コード例 #33
0
ファイル: fftui.cs プロジェクト: EShamaev/MissionPlanner
        private void but_fftimu13_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();
            using (
                OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.log;*.bin|*.log;*.bin;*.BIN;*.LOG";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var file = new DFLogBuffer(File.OpenRead(ofd.FileName));

                int bins = (int)NUM_bins.Value;

                int N = 1 << bins;

                Color[]           color = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Black, Color.Violet, Color.Orange };
                ZedGraphControl[] ctls  = new ZedGraphControl[]
                {
                    zedGraphControl1, zedGraphControl2, zedGraphControl3, zedGraphControl4, zedGraphControl5,
                    zedGraphControl6
                };

                // 3 imus * 2 sets of measurements(gyr/acc)
                FFT2.datastate[] alldata = new FFT2.datastate[3 * 2];
                for (int a = 0; a < alldata.Length; a++)
                {
                    alldata[a] = new FFT2.datastate();
                }

                foreach (var item in file.GetEnumeratorType(new string[] { "IMU", "IMU2", "IMU3" }))
                {
                    if (item.msgtype == null)
                    {
                        continue;
                    }

                    if (item.msgtype.StartsWith("IMU"))
                    {
                        int sensorno = 0;
                        if (item.msgtype == "IMU")
                        {
                            sensorno = 0;
                        }
                        if (item.msgtype == "IMU2")
                        {
                            sensorno = 1;
                        }
                        if (item.msgtype == "IMU3")
                        {
                            sensorno = 2;
                        }

                        alldata[sensorno + 3].type = item.msgtype + " ACC";

                        int offsetAX   = file.dflog.FindMessageOffset(item.msgtype, "AccX");
                        int offsetAY   = file.dflog.FindMessageOffset(item.msgtype, "AccY");
                        int offsetAZ   = file.dflog.FindMessageOffset(item.msgtype, "AccZ");
                        int offsetTime = file.dflog.FindMessageOffset(item.msgtype, "TimeUS");

                        double time = double.Parse(item.items[offsetTime],
                                                   CultureInfo.InvariantCulture) / 1000.0;

                        if (time != alldata[sensorno + 3].lasttime)
                        {
                            alldata[sensorno + 3].timedelta = alldata[sensorno + 3].timedelta * 0.99 +
                                                              (time - alldata[sensorno + 3].lasttime) * 0.01;
                        }

                        alldata[sensorno + 3].lasttime = time;

                        alldata[sensorno + 3].datax.Add(double.Parse(item.items[offsetAX],
                                                                     CultureInfo.InvariantCulture));
                        alldata[sensorno + 3].datay.Add(double.Parse(item.items[offsetAY],
                                                                     CultureInfo.InvariantCulture));
                        alldata[sensorno + 3].dataz.Add(double.Parse(item.items[offsetAZ],
                                                                     CultureInfo.InvariantCulture));

                        //gyro
                        alldata[sensorno].type = item.msgtype + " GYR";

                        int offsetGX = file.dflog.FindMessageOffset(item.msgtype, "GyrX");
                        int offsetGY = file.dflog.FindMessageOffset(item.msgtype, "GyrY");
                        int offsetGZ = file.dflog.FindMessageOffset(item.msgtype, "GyrZ");

                        if (time != alldata[sensorno].lasttime)
                        {
                            alldata[sensorno].timedelta = alldata[sensorno].timedelta * 0.99 +
                                                          (time - alldata[sensorno].lasttime) * 0.01;
                        }

                        alldata[sensorno].lasttime = time;

                        alldata[sensorno].datax.Add(double.Parse(item.items[offsetGX],
                                                                 CultureInfo.InvariantCulture));
                        alldata[sensorno].datay.Add(double.Parse(item.items[offsetGY],
                                                                 CultureInfo.InvariantCulture));
                        alldata[sensorno].dataz.Add(double.Parse(item.items[offsetGZ],
                                                                 CultureInfo.InvariantCulture));
                    }
                }

                int controlindex = 0;

                foreach (var sensordata in alldata)
                {
                    if (sensordata.datax.Count <= N)
                    {
                        continue;
                    }

                    double samplerate = 0;

                    samplerate = Math.Round(1000 / sensordata.timedelta, 1);

                    double[] freqt = fft.FreqTable(N, (int)samplerate);

                    double[] avgx = new double[N / 2];
                    double[] avgy = new double[N / 2];
                    double[] avgz = new double[N / 2];

                    int totalsamples = sensordata.datax.Count;
                    int count        = totalsamples / N;
                    int done         = 0;
                    while (count > 1) // skip last part
                    {
                        var fftanswerx = fft.rin(sensordata.datax.AsSpan().Slice(N * done, N), (uint)bins, indB);
                        var fftanswery = fft.rin(sensordata.datay.AsSpan().Slice(N * done, N), (uint)bins, indB);
                        var fftanswerz = fft.rin(sensordata.dataz.AsSpan().Slice(N * done, N), (uint)bins, indB);

                        for (int b = 0; b < N / 2; b++)
                        {
                            if (freqt[b] < (double)NUM_startfreq.Value)
                            {
                                continue;
                            }

                            avgx[b] += fftanswerx[b] / (done + count);
                            avgy[b] += fftanswery[b] / (done + count);
                            avgz[b] += fftanswerz[b] / (done + count);
                        }

                        count--;
                        done++;
                    }

                    ZedGraph.PointPairList pplx = new ZedGraph.PointPairList(freqt, avgx);
                    ZedGraph.PointPairList pply = new ZedGraph.PointPairList(freqt, avgy);
                    ZedGraph.PointPairList pplz = new ZedGraph.PointPairList(freqt, avgz);

                    var curvex = new LineItem(sensordata.type + " x", pplx, color[0], SymbolType.None);
                    var curvey = new LineItem(sensordata.type + " y", pply, color[1], SymbolType.None);
                    var curvez = new LineItem(sensordata.type + " z", pplz, color[2], SymbolType.None);

                    ctls[controlindex].GraphPane.Legend.IsVisible = true;

                    ctls[controlindex].GraphPane.XAxis.Title.Text = "Freq Hz";
                    ctls[controlindex].GraphPane.YAxis.Title.Text = "Amplitude";
                    ctls[controlindex].GraphPane.Title.Text       = "FFT " + sensordata.type + " - " +
                                                                    Path.GetFileName(ofd.FileName) + " - " + samplerate +
                                                                    "hz input";

                    ctls[controlindex].GraphPane.CurveList.Clear();

                    ctls[controlindex].GraphPane.CurveList.Add(curvex);
                    ctls[controlindex].GraphPane.CurveList.Add(curvey);
                    ctls[controlindex].GraphPane.CurveList.Add(curvez);

                    ctls[controlindex].Invalidate();
                    ctls[controlindex].AxisChange();

                    ctls[controlindex].GraphPane.XAxis.Scale.Max = samplerate / 2;

                    ctls[controlindex].Refresh();

                    controlindex++;
                }

                SetScale(ctls);
            }
        }
コード例 #34
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The PointPairList from which to copy</param>
        public PointPairList(PointPairList rhs)
        {
            Add(rhs);

            sorted = false;
        }
コード例 #35
0
        private void but_ISBH_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();
            using (
                OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.log;*.bin|*.log;*.bin;*.BIN;*.LOG";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var file = new DFLogBuffer(File.OpenRead(ofd.FileName));

                int bins = (int)NUM_bins.Value;

                int N = 1 << bins;

                Color[] color = new Color[]
                { Color.Red, Color.Green, Color.Blue, Color.Black, Color.Violet, Color.Orange };
                ZedGraphControl[] ctls = new ZedGraphControl[]
                {
                    zedGraphControl1, zedGraphControl2, zedGraphControl3, zedGraphControl4, zedGraphControl5,
                    zedGraphControl6
                };

                // 3 imus * 2 sets of measurements(gyr/acc)
                FFT2.datastate[] alldata = new FFT2.datastate[3 * 2];
                for (int a = 0; a < alldata.Length; a++)
                {
                    alldata[a] = new FFT2.datastate();
                }

                // state cache
                int    Ns         = 0;
                int    type       = 0;
                int    instance   = 0;
                int    sensorno   = 0;
                double multiplier = -1;

                foreach (var item in file.GetEnumeratorType(new string[] { "ISBH", "ISBD" }))
                {
                    if (item.msgtype == null)
                    {
                        continue;
                    }

                    if (item.msgtype.StartsWith("ISBH"))
                    {
                        Ns = int.Parse(item.items[file.dflog.FindMessageOffset(item.msgtype, "N")],
                                       CultureInfo.InvariantCulture);
                        type = int.Parse(item.items[file.dflog.FindMessageOffset(item.msgtype, "type")],
                                         CultureInfo.InvariantCulture);
                        instance = int.Parse(item.items[file.dflog.FindMessageOffset(item.msgtype, "instance")],
                                             CultureInfo.InvariantCulture);

                        sensorno = type * 3 + instance;

                        alldata[sensorno].sample_rate = double.Parse(item.items[file.dflog.FindMessageOffset(item.msgtype, "smp_rate")],
                                                                     CultureInfo.InvariantCulture);

                        multiplier = double.Parse(
                            item.items[file.dflog.FindMessageOffset(item.msgtype, "mul")],
                            CultureInfo.InvariantCulture);

                        if (type == 0)
                        {
                            alldata[sensorno].type = "ACC" + instance.ToString();
                        }
                        if (type == 1)
                        {
                            alldata[sensorno].type = "GYR" + instance.ToString();
                        }
                    }
                    else if (item.msgtype.StartsWith("ISBD"))
                    {
                        var Nsdata = int.Parse(item.items[file.dflog.FindMessageOffset(item.msgtype, "N")],
                                               CultureInfo.InvariantCulture);

                        if (Ns != Nsdata)
                        {
                            continue;
                        }

                        int offsetX    = file.dflog.FindMessageOffset(item.msgtype, "x");
                        int offsetY    = file.dflog.FindMessageOffset(item.msgtype, "y");
                        int offsetZ    = file.dflog.FindMessageOffset(item.msgtype, "z");
                        int offsetTime = file.dflog.FindMessageOffset(item.msgtype, "TimeUS");

                        double time = double.Parse(item.items[offsetTime],
                                                   CultureInfo.InvariantCulture) / 1000.0;

                        if (time < alldata[sensorno].lasttime)
                        {
                            continue;
                        }

                        if (time != alldata[sensorno].lasttime)
                        {
                            alldata[sensorno].timedelta = alldata[sensorno].timedelta * 0.99 +
                                                          (time - alldata[sensorno].lasttime) * 0.01;
                        }

                        alldata[sensorno].lasttime = time;

                        item.items[offsetX].Split(new[] { ' ', '[', ']' }, StringSplitOptions.RemoveEmptyEntries).ForEach(aa =>
                        {
                            alldata[sensorno].datax.Add(double.Parse(aa,
                                                                     CultureInfo.InvariantCulture) / multiplier);
                        });
                        item.items[offsetY].Split(new[] { ' ', '[', ']' }, StringSplitOptions.RemoveEmptyEntries).ForEach(aa =>
                        {
                            alldata[sensorno].datay.Add(double.Parse(aa,
                                                                     CultureInfo.InvariantCulture) / multiplier);
                        });
                        item.items[offsetZ].Split(new[] { ' ', '[', ']' }, StringSplitOptions.RemoveEmptyEntries).ForEach(aa =>
                        {
                            alldata[sensorno].dataz.Add(double.Parse(aa,
                                                                     CultureInfo.InvariantCulture) / multiplier);
                        });
                    }
                }

                int controlindex = 0;

                foreach (var sensordata in alldata)
                {
                    if (sensordata.datax.Count <= N)
                    {
                        continue;
                    }

                    double samplerate = 0;

                    samplerate = sensordata.sample_rate;// Math.Round(1000 / sensordata.timedelta, 1);

                    double[] freqt = fft.FreqTable(N, (int)samplerate);

                    double[] avgx = new double[N / 2];
                    double[] avgy = new double[N / 2];
                    double[] avgz = new double[N / 2];

                    int totalsamples = sensordata.datax.Count;
                    int count        = totalsamples / N;
                    int done         = 0;
                    while (count > 1) // skip last part
                    {
                        var fftanswerx = fft.rin(sensordata.datax.Skip(N * done).Take(N).ToArray(), (uint)bins);
                        var fftanswery = fft.rin(sensordata.datay.Skip(N * done).Take(N).ToArray(), (uint)bins);
                        var fftanswerz = fft.rin(sensordata.dataz.Skip(N * done).Take(N).ToArray(), (uint)bins);

                        for (int b = 0; b < N / 2; b++)
                        {
                            if (freqt[b] < (double)NUM_startfreq.Value)
                            {
                                continue;
                            }

                            avgx[b] += fftanswerx[b] / (done + count);
                            avgy[b] += fftanswery[b] / (done + count);
                            avgz[b] += fftanswerz[b] / (done + count);
                        }

                        count--;
                        done++;
                    }

                    ZedGraph.PointPairList pplx = new ZedGraph.PointPairList(freqt, avgx);
                    ZedGraph.PointPairList pply = new ZedGraph.PointPairList(freqt, avgy);
                    ZedGraph.PointPairList pplz = new ZedGraph.PointPairList(freqt, avgz);

                    var curvex = new LineItem(sensordata.type + " x", pplx, color[0], SymbolType.None);
                    var curvey = new LineItem(sensordata.type + " y", pply, color[1], SymbolType.None);
                    var curvez = new LineItem(sensordata.type + " z", pplz, color[2], SymbolType.None);

                    ctls[controlindex].GraphPane.Legend.IsVisible = true;

                    ctls[controlindex].GraphPane.XAxis.Title.Text = "Freq Hz";
                    ctls[controlindex].GraphPane.YAxis.Title.Text = "Amplitude";
                    ctls[controlindex].GraphPane.Title.Text       = "FFT " + sensordata.type + " - " +
                                                                    Path.GetFileName(ofd.FileName) + " - " + samplerate +
                                                                    "hz input";

                    ctls[controlindex].GraphPane.CurveList.Clear();

                    ctls[controlindex].GraphPane.CurveList.Add(curvex);
                    ctls[controlindex].GraphPane.CurveList.Add(curvey);
                    ctls[controlindex].GraphPane.CurveList.Add(curvez);

                    ctls[controlindex].Invalidate();
                    ctls[controlindex].AxisChange();

                    ctls[controlindex].GraphPane.XAxis.Scale.Max = samplerate / 2;

                    ctls[controlindex].Refresh();

                    controlindex++;
                }

                SetScale(ctls);
            }
        }
コード例 #36
0
ファイル: fftui.cs プロジェクト: ketjow4/HFMissionPlanner
        //FMT, 131, 43, IMU, IffffffIIf, TimeMS,GyrX,GyrY,GyrZ,AccX,AccY,AccZ,ErrG,ErrA,Temp
        //FMT, 135, 43, IMU2, IffffffIIf, TimeMS,GyrX,GyrY,GyrZ,AccX,AccY,AccZ,ErrG,ErrA,Temp
        //FMT, 149, 43, IMU3, IffffffIIf, TimeMS,GyrX,GyrY,GyrZ,AccX,AccY,AccZ,ErrG,ErrA,Temp

        //FMT, 172, 23, ACC1, IIfff, TimeMS,TimeUS,AccX,AccY,AccZ
        //FMT, 173, 23, ACC2, IIfff, TimeMS,TimeUS,AccX,AccY,AccZ
        //FMT, 174, 23, ACC3, IIfff, TimeMS,TimeUS,AccX,AccY,AccZ
        //FMT, 175, 23, GYR1, IIfff, TimeMS,TimeUS,GyrX,GyrY,GyrZ
        //FMT, 176, 23, GYR2, IIfff, TimeMS,TimeUS,GyrX,GyrY,GyrZ
        //FMT, 177, 23, GYR3, IIfff, TimeMS,TimeUS,GyrX,GyrY,GyrZ

        private void myButton1_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.log;*.bin|*.log;*.bin";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var file = new CollectionBuffer(File.OpenRead(ofd.FileName));

                int bins = (int)NUM_bins.Value;

                int N = 1 << bins;

                double[] datainGX = new double[N];
                double[] datainGY = new double[N];
                double[] datainGZ = new double[N];
                double[] datainAX = new double[N];
                double[] datainAY = new double[N];
                double[] datainAZ = new double[N];

                List <double[]> avg = new List <double[]>();

                // 6
                avg.Add(new double[N / 2]);
                avg.Add(new double[N / 2]);
                avg.Add(new double[N / 2]);
                avg.Add(new double[N / 2]);
                avg.Add(new double[N / 2]);
                avg.Add(new double[N / 2]);

                object[] datas     = new object[] { datainGX, datainGY, datainGZ, datainAX, datainAY, datainAZ };
                string[] datashead = new string[]
                { "GYR1-GyrX", "GYR1-GyrY", "GYR1-GyrZ", "ACC1-AccX", "ACC1-AccY", "ACC1-AccZ" };
                Color[] color = new Color[]
                { Color.Red, Color.Green, Color.Black, Color.Violet, Color.Blue, Color.Orange };
                ZedGraphControl[] ctls = new ZedGraphControl[]
                {
                    zedGraphControl1, zedGraphControl2, zedGraphControl3, zedGraphControl4, zedGraphControl5,
                    zedGraphControl6
                };

                int samplecounta = 0;
                int samplecountg = 0;

                double   lasttime   = 0;
                double   timedelta  = 0;
                double[] freqt      = null;
                double   samplerate = 0;

                Log.DFLog dflog = new Log.DFLog();

                while (!file.EndOfStream)
                {
                    var item = dflog.GetDFItemFromLine(file.ReadLine(), 0);

                    if (item.msgtype == "ACC1")
                    {
                        int offsetAX   = dflog.FindMessageOffset("ACC1", "AccX");
                        int offsetAY   = dflog.FindMessageOffset("ACC1", "AccY");
                        int offsetAZ   = dflog.FindMessageOffset("ACC1", "AccZ");
                        int offsetTime = dflog.FindMessageOffset("ACC1", "TimeUS");

                        double time = double.Parse(item.items[offsetTime]) / 1000.0;

                        timedelta = timedelta * 0.99 + (time - lasttime) * 0.01;

                        // we missed gyro data
                        if (samplecounta >= N)
                        {
                            continue;
                        }

                        datainAX[samplecounta] = double.Parse(item.items[offsetAX]);
                        datainAY[samplecounta] = double.Parse(item.items[offsetAY]);
                        datainAZ[samplecounta] = double.Parse(item.items[offsetAZ]);

                        samplecounta++;

                        lasttime = time;
                    }
                    else if (item.msgtype == "GYR1")
                    {
                        int offsetGX   = dflog.FindMessageOffset("GYR1", "GyrX");
                        int offsetGY   = dflog.FindMessageOffset("GYR1", "GyrY");
                        int offsetGZ   = dflog.FindMessageOffset("GYR1", "GyrZ");
                        int offsetTime = dflog.FindMessageOffset("ACC1", "TimeUS");

                        double time = double.Parse(item.items[offsetTime]) / 1000.0;

                        // we missed accel data
                        if (samplecountg >= N)
                        {
                            continue;
                        }

                        datainGX[samplecountg] = double.Parse(item.items[offsetGX]);
                        datainGY[samplecountg] = double.Parse(item.items[offsetGY]);
                        datainGZ[samplecountg] = double.Parse(item.items[offsetGZ]);

                        samplecountg++;
                    }

                    if (samplecounta >= N && samplecountg >= N)
                    {
                        int inputdataindex = 0;

                        foreach (var itemlist in datas)
                        {
                            var fftanswer = fft.rin((double[])itemlist, (uint)bins);

                            for (int b = 0; b < N / 2; b++)
                            {
                                avg[inputdataindex][b] += fftanswer[b] * (1.0 / (N / 2.0));
                            }

                            samplecounta = 0;
                            samplecountg = 0;
                            inputdataindex++;
                        }
                    }
                }

                if (freqt == null)
                {
                    samplerate = Math.Round(1000 / timedelta, 1);
                    freqt      = fft.FreqTable(N, (int)samplerate);
                }

                // 0 out all data befor cutoff
                for (int inputdataindex = 0; inputdataindex < 6; inputdataindex++)
                {
                    for (int b = 0; b < N / 2; b++)
                    {
                        if (freqt[b] < (double)NUM_startfreq.Value)
                        {
                            avg[inputdataindex][b] = 0;
                            continue;
                        }

                        break;
                    }
                }

                int controlindex = 0;
                foreach (var item in avg)
                {
                    ZedGraph.PointPairList ppl = new ZedGraph.PointPairList(freqt, item);

                    //double xMin, xMax, yMin, yMax;

                    var curve = new LineItem(datashead[controlindex], ppl, color[controlindex], SymbolType.None);

                    //curve.GetRange(out xMin, out xMax, out yMin, out  yMax, true, false, ctls[c].GraphPane);

                    ctls[controlindex].GraphPane.Legend.IsVisible = false;

                    ctls[controlindex].GraphPane.XAxis.Title.Text = "Freq Hz";
                    ctls[controlindex].GraphPane.YAxis.Title.Text = "Amplitude";
                    ctls[controlindex].GraphPane.Title.Text       = "FFT " + datashead[controlindex] + " - " +
                                                                    Path.GetFileName(ofd.FileName) + " - " + samplerate +
                                                                    "hz input";

                    ctls[controlindex].GraphPane.CurveList.Clear();

                    ctls[controlindex].GraphPane.CurveList.Add(curve);

                    ctls[controlindex].Invalidate();
                    ctls[controlindex].AxisChange();

                    ctls[controlindex].Refresh();

                    controlindex++;
                }
            }
        }
コード例 #37
0
ファイル: Form1.cs プロジェクト: OlgaSelezneva28/Spline
        public void DrawGraph(int z, int n, double a, double b)
        {
            ZedGraph.PointPairList F  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList F1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList F2 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S2 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e2 = new ZedGraph.PointPairList();

            double h = (b - a) / n;

            for (int i = 0; i < n + 1; i++)
            {
                if (i % 4 == 0 && i != 0 && i != n)
                {
                    continue;
                }
                double x0  = a + i * h;
                double FF  = Function(x0, z);
                double SS  = Spline(z, n, a, b, x0);
                double FF1 = Function1(x0, z);
                double SS1 = Spline1(z, n, a, b, x0);
                double FF2 = Function2(x0, z);
                double SS2 = Spline2(z, n, a, b, x0);
                double E   = FF - SS;
                double E1  = FF1 - SS1;
                double E2  = FF2 - SS2;

                F.Add(x0, FF);
                S.Add(x0, SS);
                F1.Add(x0, FF1);
                S1.Add(x0, SS1);
                F2.Add(x0, FF2);
                S2.Add(x0, SS2);
                e.Add(x0, E);
                e1.Add(x0, E1);
                e2.Add(x0, E2);
            }

            ZedGraph.GraphPane.CurveList.Clear();

            if (comboBox1.SelectedIndex == 0)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F(x)", F, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S(x)", S, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F(x)-S(x)", e, Color.Red, SymbolType.None);
            }
            if (comboBox1.SelectedIndex == 1)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F'(x)", F1, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S'(x)", S1, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F'(x)-S'(x)", e1, Color.Red, SymbolType.None);
            }
            if (comboBox1.SelectedIndex == 2)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F''(x)", F2, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S''(x)", S2, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F''(x)-S''(x)", e2, Color.Red, SymbolType.None);
            }


            ZedGraph.AxisChange();

            ZedGraph.Invalidate();
        }
コード例 #38
0
        private void BUT_run_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.wav|*.wav";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var st = File.OpenRead(ofd.FileName);

                int bins = 10;

                double[] buffer = new double[1 << bins];

                int a = 0;

                while (st.Position < st.Length)
                {
                    byte[] temp = new byte[2];
                    var    read = st.Read(temp, 0, temp.Length);

                    var val = (double)BitConverter.ToInt16(temp, 0);

                    buffer[a] = val;

                    a++;

                    if (a == (1 << bins))
                    {
                        var fftanswer = fft.rin(buffer, (uint)bins);

                        var freqt = fft.FreqTable(buffer.Length, 1000);

                        ZedGraph.PointPairList ppl = new ZedGraph.PointPairList();

                        for (int b = 0; b < fftanswer.Length; b++)
                        {
                            ppl.Add(freqt[b], fftanswer[b]);
                        }

                        double xMin, xMax, yMin, yMax;

                        var curve = new LineItem("FFT", ppl, Color.Red, SymbolType.Diamond);

                        curve.GetRange(out xMin, out xMax, out yMin, out yMax, true, false, zedGraphControl1.GraphPane);

                        zedGraphControl1.GraphPane.XAxis.Title.Text = "Freq Hz";
                        zedGraphControl1.GraphPane.YAxis.Title.Text = "Amplitude";
                        zedGraphControl1.GraphPane.Title.Text       = "FFT";
                        zedGraphControl1.GraphPane.CurveList.Clear();
                        zedGraphControl1.GraphPane.CurveList.Add(curve);

                        zedGraphControl1.Invalidate();
                        zedGraphControl1.AxisChange();

                        zedGraphControl1.Refresh();

                        int width  = Console.WindowWidth - 1;
                        int height = Console.WindowHeight - 1;

                        int r = 1;
                        foreach (var ff in fftanswer)
                        {
                            int col = (int)((r / (double)fftanswer.Length) * width);
                            int row = (int)((ff * 0.2) + 0.5);

                            //Console.SetCursorPosition(col, height - row);
                            Console.Write("*");
                            r++;
                        }

                        // 50% overlap
                        st.Seek(-(1 << bins) / 2, SeekOrigin.Current);
                        a      = 0;
                        buffer = new double[buffer.Length];
                        //Console.Clear();
                    }
                }
            }
        }
コード例 #39
0
        private void BUT_log2_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();
            using (
                OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.log|*.log";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var file = new StreamReader(File.OpenRead(ofd.FileName));

                int bins = (int)NUM_bins.Value;

                int N = 1 << bins;

                Color[] color = new Color[]
                { Color.Red, Color.Green, Color.Blue, Color.Black, Color.Violet, Color.Orange };
                ZedGraphControl[] ctls = new ZedGraphControl[]
                {
                    zedGraphControl1, zedGraphControl2, zedGraphControl3, zedGraphControl4, zedGraphControl5,
                    zedGraphControl6
                };

                // 3 imus * 2 sets of measurements(gyr/acc)
                datastate[] alldata = new datastate[3 * 2];
                for (int a = 0; a < alldata.Length; a++)
                {
                    alldata[a] = new datastate();
                }

                Log.DFLog dflog = new Log.DFLog();

                while (!file.EndOfStream)
                {
                    var item = dflog.GetDFItemFromLine(file.ReadLine(), 0);

                    if (item.msgtype == null)
                    {
                        continue;
                    }

                    if (item.msgtype.StartsWith("ACC"))
                    {
                        int sensorno = int.Parse(item.msgtype.Substring(3)) - 1 + 3;
                        alldata[sensorno].type = item.msgtype;

                        int offsetAX   = dflog.FindMessageOffset(item.msgtype, "AccX");
                        int offsetAY   = dflog.FindMessageOffset(item.msgtype, "AccY");
                        int offsetAZ   = dflog.FindMessageOffset(item.msgtype, "AccZ");
                        int offsetTime = dflog.FindMessageOffset(item.msgtype, "TimeUS");

                        double time = double.Parse(item.items[offsetTime]) / 1000.0;

                        if (time != alldata[sensorno].lasttime)
                        {
                            alldata[sensorno].timedelta = alldata[sensorno].timedelta * 0.99 +
                                                          (time - alldata[sensorno].lasttime) * 0.01;
                        }

                        alldata[sensorno].lasttime = time;

                        alldata[sensorno].datax.Add(double.Parse(item.items[offsetAX]));
                        alldata[sensorno].datay.Add(double.Parse(item.items[offsetAY]));
                        alldata[sensorno].dataz.Add(double.Parse(item.items[offsetAZ]));
                    }
                    else if (item.msgtype.StartsWith("GYR"))
                    {
                        int sensorno = int.Parse(item.msgtype.Substring(3)) - 1;
                        alldata[sensorno].type = item.msgtype;

                        int offsetGX   = dflog.FindMessageOffset(item.msgtype, "GyrX");
                        int offsetGY   = dflog.FindMessageOffset(item.msgtype, "GyrY");
                        int offsetGZ   = dflog.FindMessageOffset(item.msgtype, "GyrZ");
                        int offsetTime = dflog.FindMessageOffset(item.msgtype, "TimeUS");

                        double time = double.Parse(item.items[offsetTime]) / 1000.0;

                        if (time != alldata[sensorno].lasttime)
                        {
                            alldata[sensorno].timedelta = alldata[sensorno].timedelta * 0.99 +
                                                          (time - alldata[sensorno].lasttime) * 0.01;
                        }

                        alldata[sensorno].lasttime = time;

                        alldata[sensorno].datax.Add(double.Parse(item.items[offsetGX]));
                        alldata[sensorno].datay.Add(double.Parse(item.items[offsetGY]));
                        alldata[sensorno].dataz.Add(double.Parse(item.items[offsetGZ]));
                    }
                }

                int controlindex = 0;

                foreach (var sensordata in alldata)
                {
                    if (sensordata.datax.Count <= N)
                    {
                        continue;
                    }

                    double samplerate = 0;

                    samplerate = Math.Round(1000 / sensordata.timedelta, 1);

                    double[] freqt = fft.FreqTable(N, (int)samplerate);

                    double[] avgx = new double[N / 2];
                    double[] avgy = new double[N / 2];
                    double[] avgz = new double[N / 2];

                    int totalsamples = sensordata.datax.Count;
                    int count        = totalsamples / N;
                    int done         = 0;
                    while (count > 1) // skip last part
                    {
                        var fftanswerx = fft.rin(sensordata.datax.Skip(N * done).Take(N).ToArray(), (uint)bins);
                        var fftanswery = fft.rin(sensordata.datay.Skip(N * done).Take(N).ToArray(), (uint)bins);
                        var fftanswerz = fft.rin(sensordata.dataz.Skip(N * done).Take(N).ToArray(), (uint)bins);

                        for (int b = 0; b < N / 2; b++)
                        {
                            if (freqt[b] < (double)NUM_startfreq.Value)
                            {
                                continue;
                            }

                            avgx[b] += fftanswerx[b] / (N / 2);
                            avgy[b] += fftanswery[b] / (N / 2);
                            avgz[b] += fftanswerz[b] / (N / 2);
                        }

                        count--;
                        done++;
                    }

                    ZedGraph.PointPairList pplx = new ZedGraph.PointPairList(freqt, avgx);
                    ZedGraph.PointPairList pply = new ZedGraph.PointPairList(freqt, avgy);
                    ZedGraph.PointPairList pplz = new ZedGraph.PointPairList(freqt, avgz);

                    var curvex = new LineItem(sensordata.type + " x", pplx, color[0], SymbolType.None);
                    var curvey = new LineItem(sensordata.type + " y", pply, color[1], SymbolType.None);
                    var curvez = new LineItem(sensordata.type + " z", pplz, color[2], SymbolType.None);

                    ctls[controlindex].GraphPane.Legend.IsVisible = true;

                    ctls[controlindex].GraphPane.XAxis.Title.Text = "Freq Hz";
                    ctls[controlindex].GraphPane.YAxis.Title.Text = "Amplitude";
                    ctls[controlindex].GraphPane.Title.Text       = "FFT " + sensordata.type + " - " +
                                                                    Path.GetFileName(ofd.FileName) + " - " + samplerate +
                                                                    "hz input";

                    ctls[controlindex].GraphPane.CurveList.Clear();

                    ctls[controlindex].GraphPane.CurveList.Add(curvex);
                    ctls[controlindex].GraphPane.CurveList.Add(curvey);
                    ctls[controlindex].GraphPane.CurveList.Add(curvez);

                    ctls[controlindex].Invalidate();
                    ctls[controlindex].AxisChange();

                    ctls[controlindex].GraphPane.XAxis.Scale.Max = samplerate / 2;

                    ctls[controlindex].Refresh();

                    controlindex++;
                }
            }
        }
コード例 #40
0
        private void draw_yoriginalline()
        {
            //获取引用
            GraphPane myPane1 = zedGraphControl1.GraphPane;
            double    x       = 0;
            string    CHname;

            //清空原图像
            myPane1.CurveList.Clear();
            myPane1.GraphObjList.Clear();
            zedGraphControl1.Refresh();

            //设置标题
            myPane1.Title.Text = "";
            //设置X轴说明文字
            myPane1.XAxis.Title.Text = "距离/mm";
            //设置Y轴说明文字
            myPane1.YAxis.Title.Text = "磁场变化/nT";

            myPane1.XAxis.Scale.Min       = 0;      //X轴最小值0
            myPane1.XAxis.Scale.Max       = length; //X轴最大值
            myPane1.XAxis.Scale.MinorStep = 0;
            myPane1.XAxis.Scale.MajorStep = 500;



            PointPairList mylist0 = new ZedGraph.PointPairList();

            ZedGraph.LineItem myCurve0;



            for (int i = 0; i < original_num - 1; i++)
            {
                x = (float)i * length / (original_num - 1);
                if (Channel.SelectedIndex == 0)
                {
                    mylist0.Add(x, ysdata[0, i]);
                    mylist0.Add(x, ysdata[3, i]);
                    mylist0.Add(x, ysdata[6, i]);
                    mylist0.Add(x, ysdata[9, i]);
                }
                if (Channel.SelectedIndex == 1)
                {
                    mylist0.Add(x, ysdata[1, i]);
                    mylist0.Add(x, ysdata[4, i]);
                    mylist0.Add(x, ysdata[7, i]);
                    mylist0.Add(x, ysdata[10, i]);
                }
                if (Channel.SelectedIndex == 2)
                {
                    mylist0.Add(x, ysdata[2, i]);
                    mylist0.Add(x, ysdata[5, i]);
                    mylist0.Add(x, ysdata[8, i]);
                    mylist0.Add(x, ysdata[11, i]);
                }
            }

            CHname   = "Abnormal Signal";
            myCurve0 = zedGraphControl1.GraphPane.AddCurve(CHname, mylist0, Color.Red, ZedGraph.SymbolType.None);

            myPane1.AxisChange();
            zedGraphControl1.Invalidate();
        }
コード例 #41
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The PointPairList from which to copy</param>
 public PointPairList(PointPairList rhs)
 {
     Add(rhs);
     m_bVSWRValues = rhs.m_bVSWRValues;
     _sorted       = false;
 }
コード例 #42
0
        private void Draw(ZedGraphControl pane, double[] vals)
        {
            double sigma = Convert.ToDouble(textBox1.Text);
            int    N     = Convert.ToInt32(textBox3.Text);
            int    n     = vals.Length;

            double[] interval = new double[N + 1];
            double[] value    = new double[N];
            double[] f        = new double[N];

            //строим функции распределения

            ZedGraph.PointPairList F_list  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList Fn_list = new ZedGraph.PointPairList();

            zedGraphControl1.GraphPane.Title.Text       = "График функций распределения";
            zedGraphControl1.GraphPane.XAxis.Title.Text = "X";
            zedGraphControl1.GraphPane.YAxis.Title.Text = "F(x)";

            double D = 0.0; // Мера расхождения


            double h = vals[n - 1] / 1000;

            int sum = 0;

            for (int i = 0; i < 1000; i++)
            {
                sum = 0;
                for (int j = 0; j < n; j++)
                {
                    double temp = vals[0] + h * i;
                    if (vals[j] < vals[0] + h * i)
                    {
                        sum++;
                    }
                }
                Fn_list.Add(vals[0] + h * i, (double)sum / (double)n);
                F_list.Add(vals[0] + h * i, 1 - Math.Exp(-(vals[0] + h * i) * (vals[0] + h * i) / (2 * sigma * sigma)));
                D = Math.Max(D, Math.Abs((double)sum / (double)n - (1 - Math.Exp(-(vals[0] + h * i) * (vals[0] + h * i) / (2 * sigma * sigma)))));
            }
            zedGraphControl1.GraphPane.CurveList.Clear();

            textBox4.Text = D.ToString();
            ZedGraph.LineItem CurveF  = zedGraphControl1.GraphPane.AddCurve("F", F_list, Color.FromName("Red"), ZedGraph.SymbolType.None);
            ZedGraph.LineItem CurveFn = zedGraphControl1.GraphPane.AddCurve("Fn", Fn_list, Color.FromName("Blue"), ZedGraph.SymbolType.None);


            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();


            //гистограмма

            double h2 = (vals[n - 1] - vals[0]) / N;



            for (int i = 0; i < N; i++)
            {
                interval[i] = vals[0] + (double)i * h2;
            }
            interval[N] = vals[n - 1];


            int sum2;

            for (int i = 0; i < N; i++)
            {
                sum2 = 0;
                for (int j = 0; j < n; j++)
                {
                    if ((interval[i] < vals[j]) && (vals[j] <= interval[i + 1]))
                    {
                        sum2++;
                    }
                }

                value[i] = (double)sum2 / (h2 * (double)n);
            }

            GraphPane pane1 = zedGraphControl2.GraphPane;

            pane1.CurveList.Clear();

            BarItem curve1 = pane1.AddBar(null, null, value, Color.Blue);

            zedGraphControl2.GraphPane.Title.Text = "Гистограмма";

            pane1.YAxis.Scale.Min           = 0.0;
            pane1.YAxis.Scale.Max           = value.Max() + 0.001;
            pane1.BarSettings.MinClusterGap = 0.0f;

            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();

            //3 таблица

            double max = 0.0;

            for (int i = 0; i < N; i++)
            {
                dataGridView3.ColumnCount = N;
                dataGridView3.RowCount    = 3;
                dataGridView3.Rows[0].HeaderCell.Value = "z [ j ] ";
                dataGridView3.Rows[1].HeaderCell.Value = "f ( z [ j ] )";
                dataGridView3.Rows[2].HeaderCell.Value = "n [ j ] / n ∆[ j ] ";


                dataGridView3.Columns[i].HeaderText  = string.Format("z" + (i + 1), i);
                dataGridView3.Rows[0].Cells[i].Value = interval[i] + h2 * 0.5;
                f[i] = ((interval[i] + h2 * 0.5) * Math.Exp(-(interval[i] + h2 * 0.5) * (interval[i] + h2 * 0.5) / (2 * sigma * sigma))) / (sigma * sigma);
                dataGridView3.Rows[1].Cells[i].Value = f[i];
                dataGridView3.Rows[2].Cells[i].Value = value[i];
                if (Math.Abs(value[i] - f[i]) > max)
                {
                    max = Math.Abs(value[i] - f[i]);
                }
            }
            textBox5.Text = max.ToString();
        }
コード例 #43
0
        private void BUT_run_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.wav|*.wav";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var st = File.OpenRead(ofd.FileName);

                int bins = (int)NUM_bins.Value;

                List <double[]> avg = new List <double[]>
                {
                    new double[1 << bins]
                };
                Color[] color = new Color[]
                { Color.Red, Color.Green, Color.Black, Color.Violet, Color.Blue, Color.Orange };

                int hz = 8000;
                InputBox.Show("fft sample rate", "nter source file sample rate", ref hz);

                double[] buffer = new double[1 << bins];

                int a       = 0;
                int samples = 0;

                while (st.Position < st.Length)
                {
                    byte[] temp = new byte[2];
                    var    read = st.Read(temp, 0, temp.Length);

                    var val = (double)BitConverter.ToInt16(temp, 0);

                    buffer[a] = val;

                    a++;

                    if (a == (1 << bins))
                    {
                        samples++;

                        var fftanswer = fft.rin(buffer, (uint)bins);

                        var freqt = fft.FreqTable(buffer.Length, hz);

                        ZedGraph.PointPairList ppl = new ZedGraph.PointPairList();

                        for (int b = 0; b < fftanswer.Length; b++)
                        {
                            ppl.Add(freqt[b], fftanswer[b]);
                        }

                        double xMin, xMax, yMin, yMax;

                        var curve = new LineItem("FFT", ppl, Color.Red, SymbolType.Diamond);

                        curve.GetRange(out xMin, out xMax, out yMin, out yMax, true, false, zedGraphControl1.GraphPane);

                        zedGraphControl1.GraphPane.XAxis.Title.Text = "Freq Hz";
                        zedGraphControl1.GraphPane.YAxis.Title.Text = "Amplitude";
                        zedGraphControl1.GraphPane.Title.Text       = "FFT - " + hz;
                        zedGraphControl1.GraphPane.Y2Axis.IsVisible = true;
                        zedGraphControl1.GraphPane.CurveList.Clear();
                        zedGraphControl1.GraphPane.CurveList.Add(curve);

                        for (int b = 0; b < (1 << bins) / 2; b++)
                        {
                            avg[0][b] = avg[0][b] * (1.0 - (1.0 / samples)) + fftanswer[b] * (1.0 / samples);
                        }

                        // 0 out all data befor cutoff
                        for (int b = 0; b < 1 << bins / 2; b++)
                        {
                            if (freqt[b] < (double)NUM_startfreq.Value)
                            {
                                avg[0][b] = 0;
                                continue;
                            }

                            break;
                        }

                        ppl   = new ZedGraph.PointPairList(freqt, avg[0]);
                        curve = new LineItem("Avg", ppl, color[1], SymbolType.None)
                        {
                            IsY2Axis = true
                        };
                        zedGraphControl1.GraphPane.CurveList.Add(curve);

                        zedGraphControl1.Invalidate();
                        zedGraphControl1.AxisChange();

                        zedGraphControl1.Refresh();

                        // 50% overlap
                        st.Seek(-(1 << bins) / 2, SeekOrigin.Current);
                        a      = 0;
                        buffer = new double[buffer.Length];
                    }
                }
            }
        }
コード例 #44
0
        private void test_Load(object sender, EventArgs e)
        {
            checkBox2.Text = "Kütüphanedeki Toplam Kitap Sayısı" + Environment.NewLine + "Grafiğini Göster/Gizle";
            checkBox3.Text = "Kütüphanede Verilmeye Hazır Kitap Sayısı" + Environment.NewLine + "Grafiğini Göster/Gizle";
            //ms access bağlantısı
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\kutuphane.accdb");
            //query sorgusu
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT *from odunc_kitap", con);
            DataSet          ds;

            ds = new DataSet();
            da.Fill(ds, "odunc_kitap");
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; //tüm sütunları datagridview'e sığdırma
            dataGridView1.DataSource = ds.Tables["odunc_kitap"];                           //db'deki ödünçkitap tablosunu datagridview'e çekme
            dataGridView1.ReadOnly   = true;
            dataGridView1.Columns[0].DefaultCellStyle.BackColor = Color.White;

            // DATAGRİDVİEW 0.SÜTUNU YANİ ID SUTUNUNU DOLAŞIP ÖDÜNÇ KİTAP SAYISINI BULMA
            if (dataGridView1.Rows.Count > 0)
            {
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value != DBNull.Value)
                    {
                        string rak = Convert.ToString((dataGridView1.Rows[i].Cells[0].Value));
                        if (rak == null)
                        {
                            MessageBox.Show("odunc kitap yok");
                        }
                        else
                        {
                            toplam = toplam + 1;
                        }
                    }
                }
            }
            label1.Text = "Toplam ödünç kitap sayısı = " + (toplam - 1);


            GraphPane grafik1 = zedGraphControl1.GraphPane;               //graphane sınıfından grafik1 adında yeni bir graphane türet.

            grafik1.Title.Text       = "Toplam Ödünç Kitap Sayısı";       //grafik1 adı
            grafik1.YAxis.Title.Text = "Kitap Sayısı";                    //grafik1 y eksen adı
            grafik1.XAxis.Title.Text = "   ";                             //grafik1 x eksen adı

            ZedGraph.PointPairList liste1 = new ZedGraph.PointPairList(); //pointpairlist sınıfından liste1 adında yeni bir pointpairlist türet.
            liste1.Add(0, toplam - 1);
            BarItem bar1 = zedGraphControl1.GraphPane.AddBar("Toplam Ödünç Kitap Sayısı", liste1, Color.Red);

            bar1.Bar.Fill            = new Fill(Color.Green);
            grafik1.BarSettings.Type = BarType.Cluster; // bar tipi
            grafik1.BarSettings.ClusterScaleWidth = 1;  //bar sıklığı
            zedGraphControl1.AxisChange();              // grafiği güncelle



            OleDbCommand xy = new OleDbCommand("SELECT COUNT(id) FROM kitap", con);  // kitap tablosundaki id'i sayıp kütüphanedeki toplam-

            con.Open();                                                              //kitap sayısını bulma

            Int32 zt = (Int32)xy.ExecuteScalar();

            GraphPane grafik2 = zedGraphControl2.GraphPane;                 //graphane sınıfından grafik2 adında yeni bir graphane türet.

            grafik2.Title.Text       = "Kütüphanedeki Toplam Kitap Sayısı"; //grafik2 adı
            grafik2.YAxis.Title.Text = "Kitap Sayısı";                      //grafik2 y eksen adı
            grafik2.XAxis.Title.Text = "   ";                               //grafik2 x eksen adı

            ZedGraph.PointPairList liste2 = new ZedGraph.PointPairList();   //pointpairlist sınıfından liste2 adında yeni bir pointpairlist türet.
            liste2.Add(0, zt);
            BarItem bar2 = zedGraphControl2.GraphPane.AddBar("Kütüphanedeki Toplam Kitap Sayısı", liste2, Color.Red);

            bar2.Bar.Fill            = new Fill(Color.Yellow);
            grafik2.BarSettings.Type = BarType.Cluster; // bar tipi
            grafik2.BarSettings.ClusterScaleWidth = 1;  //bar sıklığı
            zedGraphControl2.AxisChange();              // grafiği güncelle
            label2.Text = "Toplam Kitap sayısı = " + zt;



            GraphPane grafik3 = zedGraphControl3.GraphPane;                        //graphane sınıfından grafik1 adında yeni bir graphane türet.

            grafik3.Title.Text       = "Kütüphanede Verilmeye Hazır Kitap Sayısı"; //grafik3 adı
            grafik3.YAxis.Title.Text = "Kitap Sayısı";                             //grafik3 y eksen adı
            grafik3.XAxis.Title.Text = "   ";                                      //grafik1 x eksen adı

            ZedGraph.PointPairList liste3 = new ZedGraph.PointPairList();          //pointpairlist sınıfından liste1 adında yeni bir pointpairlist türet.
            //KÜTÜPHANEDEKİ TOPLAM KİTAP SAYISINDAN ÖDÜNÇ KİTAP SAYISI ÇIKARILDI.
            liste3.Add(0, zt - toplam + 1);
            BarItem bar3 = zedGraphControl3.GraphPane.AddBar("Kütüphanede Verilmeye Hazır Kitap Sayısı", liste3, Color.Orange);

            bar3.Bar.Fill            = new Fill(Color.Orange);
            grafik3.BarSettings.Type = BarType.Cluster; // bar tipi
            grafik3.BarSettings.ClusterScaleWidth = 1;  //bar sıklığı
            zedGraphControl3.AxisChange();              // grafiği güncelle
            label3.Text = "Toplam Kitap sayısı = " + (zt - toplam + 1);
        }
コード例 #45
0
ファイル: ErrorBarItem.cs プロジェクト: koson/ResManagerAdmin
 /// <summary>
 /// Create a new <see cref="ErrorBarItem"/> using the specified properties.
 /// </summary>
 /// <param name="label">The label that will appear in the legend.</param>
 /// <param name="points">A <see cref="PointPairList"/> of double precision values that define
 /// the X, Y and lower dependent values for this curve</param>
 /// <param name="color">A <see cref="Color"/> value that will be applied to
 /// the <see cref="Line"/> properties.
 /// </param>
 public ErrorBarItem(string label, PointPairList points, Color color)
     : base(label, points)
 {
     errorBar = new ErrorBar(color);
 }