Exemplo n.º 1
0
        public static GrowthCurveCollection importPreviousDataFile(string file)
        {
            StreamReader          SR  = new StreamReader(file);
            GrowthCurveCollection GCC = new GrowthCurveCollection();

            //drop header lines
            SR.ReadLine();
            string        line            = "";
            List <string> FitSummaryLines = new List <string> ();

            while ((line = SR.ReadLine()) != null)
            {
                if (!line.StartsWith("Complete Data Listing Below"))
                {
                    FitSummaryLines.Add(line);
                }
                else
                {
                    break;
                }
            }
            //now to grab the more important data
            List <string[]> CompleteDataListing = new List <string[]> ();

            SR.ReadLine();             //blow through headerline
            while ((line = SR.ReadLine()) != null)
            {
                if (line.Length > 3)
                {
                    CompleteDataListing.Add(line.Split(','));
                }
            }
            //now to add the datetimes to the file
            DateTime[] AllDateTimes = new DateTime[CompleteDataListing.Count];
            for (int i = 0; i < CompleteDataListing.Count; i++)
            {
                AllDateTimes [i] = (Convert.ToDateTime(CompleteDataListing [i] [0]));
            }
            //now to convert this into something useful
            for (int i = 0; i < FitSummaryLines.Count; i++)
            {
                List <DateTime> DateTimeArray = new List <DateTime> ();
                List <double>   ODValuesArray = new List <double> ();

                string name = (string)FitSummaryLines [i];
                name = name.Split(',') [0];
                string notes = (string)FitSummaryLines [i];
                notes = notes.Split(',') [9];
                int        dataposition = 1 + i * 2;
                int        indexPos     = 0;
                List <int> IndexesToFit = new List <int> ();
                for (int j = 0; j < CompleteDataListing.Count; j++)
                {
                    if ((CompleteDataListing [j] as string[]) [dataposition] != "-999")
                    {
                        DateTimeArray.Add(Convert.ToDateTime(CompleteDataListing [j] [0]));
                        ODValuesArray.Add(Convert.ToDouble(CompleteDataListing [j] [dataposition]));
                        int flag = Convert.ToInt32(CompleteDataListing [j] [dataposition + 1]);
                        if (flag == 0)
                        {
                            IndexesToFit.Add(indexPos);
                        }
                        indexPos++;
                    }
                }
                DateTime[]  Times    = DateTimeArray.ToArray();
                double[]    ODvalues = ODValuesArray.ToArray();
                GrowthCurve GD       = new GrowthCurve(name, Times, ODvalues);
                GD.SetFittedRangeFromIndexes(IndexesToFit);
                GCC.Add(GD);
            }
            return(GCC);
        }