コード例 #1
0
        private void ReadBands()
        {
            Console.WriteLine("Reading bands from {0} file.", bandFile);
            int numBands  = 0;
            int numPoints = 0;

            using (var r = new StreamReader(bandFile))
            {
                string first = r.ReadLine();
                if (first.StartsWith("#") == false)
                {
                    throw new Exception("Could not read bands file.");
                }

                first = first.Substring(1);
                double[] vals = GetVals(first);

                numPoints = (int)(vals[2] + 0.5);
                numBands  = (int)(vals[4] + 0.5);

                AgrDataset[] data = new AgrDataset[numBands];
                for (int j = 0; j < numBands; j++)
                {
                    data[j] = new AgrDataset();
                }

                for (int i = 0; i < numPoints; i++)
                {
                    // skip comment
                    r.ReadLine();

                    string line = r.ReadLine();
                    vals = GetVals(line);

                    for (int j = 0; j < numBands; j++)
                    {
                        AgrDataPoint dp = new AgrDataPoint();
                        dp.X = vals[0];
                        dp.Y = vals[j + 1];

                        data[j].Data.Add(dp);
                    }
                }

                this.data.AddRange(data);
            }

            Console.WriteLine("Found {0} bands, with {1} k-points.", numBands, numPoints);
            Console.WriteLine();
        }
コード例 #2
0
        private void ReadWeights()
        {
            Console.WriteLine("Reading weights from {0} file.", weightsFile);
            int numBands = 0;
            int numPoints = 0;
            int ptCount = 0;

            using (var r = new StreamReader(weightsFile))
            {
                string first = r.ReadLine();
                if (first.StartsWith("#") == false)
                    throw new Exception("Could not read bands file.");

                first = first.Substring(1);
                double[] vals = GetVals(first);

                numPoints = (int)(vals[2] + 0.5);
                numBands = (int)(vals[4] + 0.5);

                r.ReadLine();

                AgrDataset[] data = new AgrDataset[plots.Count];
                for (int i = 0; i < plots.Count; i++)
                {
                    data[i] = new AgrDataset();

                    data[i].DatasetType = DatasetType.xysize;
                    data[i].Legend = State(plots[i]).Name;

                    data[i].LineStyle = LineStyle.None;
                    data[i].Symbol = Symbol.Circle;
                    data[i].SymbolColor = (GraceColor)i + 1;
                    data[i].SymbolFillColor = (GraceColor)i + 1;
                    data[i].SymbolFill = SymbolFill.Solid;
                }

                const double scaleFactor = 1.5;

                for (int i = 0; i < numPoints; i++)
                {
                    for (int j = 0; j < numBands; j++)
                    {
                        string line = r.ReadLine();
                        vals = GetVals(line);

                        double x = vals[0];
                        double y = vals[1];

                        for (int k = 0; k < plots.Count; k++)
                        {
                            int index = plots[k] + 1;

                            AgrDataPoint dp = new AgrDataPoint { X = x, Y = y };

                            dp.Weight = vals[index] * scaleFactor;

                            if (dp.Weight < 0.03)
                                continue;

                            data[k].Data.Add(dp);
                            ptCount += 1;
                        }
                    }
                }

                this.data.AddRange(data);

            }

            Console.WriteLine("Found {0} bands, with {1} points with weight.", numBands, ptCount);
            Console.WriteLine();
        }
コード例 #3
0
        private void ReadWeights()
        {
            Console.WriteLine("Reading weights from {0} file.", weightsFile);
            int numBands  = 0;
            int numPoints = 0;
            int ptCount   = 0;

            using (var r = new StreamReader(weightsFile))
            {
                string first = r.ReadLine();
                if (first.StartsWith("#") == false)
                {
                    throw new Exception("Could not read bands file.");
                }

                first = first.Substring(1);
                double[] vals = GetVals(first);

                numPoints = (int)(vals[2] + 0.5);
                numBands  = (int)(vals[4] + 0.5);

                r.ReadLine();

                AgrDataset[] data = new AgrDataset[plots.Count];
                for (int i = 0; i < plots.Count; i++)
                {
                    data[i] = new AgrDataset();

                    data[i].DatasetType = DatasetType.xysize;
                    data[i].Legend      = State(plots[i]).Name;

                    data[i].LineStyle       = LineStyle.None;
                    data[i].Symbol          = Symbol.Circle;
                    data[i].SymbolColor     = (GraceColor)i + 1;
                    data[i].SymbolFillColor = (GraceColor)i + 1;
                    data[i].SymbolFill      = SymbolFill.Solid;
                }

                const double scaleFactor = 1.5;

                for (int i = 0; i < numPoints; i++)
                {
                    for (int j = 0; j < numBands; j++)
                    {
                        string line = r.ReadLine();
                        vals = GetVals(line);

                        double x = vals[0];
                        double y = vals[1];

                        for (int k = 0; k < plots.Count; k++)
                        {
                            int index = plots[k] + 1;

                            AgrDataPoint dp = new AgrDataPoint {
                                X = x, Y = y
                            };

                            dp.Weight = vals[index] * scaleFactor;

                            if (dp.Weight < 0.03)
                            {
                                continue;
                            }

                            data[k].Data.Add(dp);
                            ptCount += 1;
                        }
                    }
                }

                this.data.AddRange(data);
            }


            Console.WriteLine("Found {0} bands, with {1} points with weight.", numBands, ptCount);
            Console.WriteLine();
        }
コード例 #4
0
        private void ReadBands()
        {
            Console.WriteLine("Reading bands from {0} file.", bandFile);
            int numBands = 0;
            int numPoints = 0;

            using (var r = new StreamReader(bandFile))
            {
                string first = r.ReadLine();
                if (first.StartsWith("#") == false)
                    throw new Exception("Could not read bands file.");

                first = first.Substring(1);
                double[] vals = GetVals(first);

                numPoints = (int)(vals[2] + 0.5);
                numBands = (int)(vals[4] + 0.5);

                AgrDataset[] data = new AgrDataset[numBands];
                for (int j = 0; j < numBands; j++)
                {
                    data[j] = new AgrDataset();
                }

                for (int i = 0; i < numPoints; i++)
                {
                    // skip comment
                    r.ReadLine();

                    string line = r.ReadLine();
                    vals = GetVals(line);

                    for (int j = 0; j < numBands; j++)
                    {
                        AgrDataPoint dp = new AgrDataPoint();
                        dp.X = vals[0];
                        dp.Y = vals[j+1];

                        data[j].Data.Add(dp);
                    }
                }

                this.data.AddRange(data);
            }

            Console.WriteLine("Found {0} bands, with {1} k-points.", numBands, numPoints);
            Console.WriteLine();
        }