Ejemplo n.º 1
0
        public void validate_data_from_tsv()
        {
            int    linenumber = 5;
            string line;

            string[] row;

            Stream stream         = StreamFinder.GetFileStreamFromResources("Modeling/Spectroscopy/Resources/Spectra.txt", "Vts");
            var    testSpectra    = SpectralDatabase.GetSpectraFromFile(stream, true);
            var    testDictionary = testSpectra.ToDictionary();

            stream = StreamFinder.GetFileStreamFromResources("Modeling/Spectroscopy/Resources/Spectra.txt", "Vts");
            using (StreamReader readFile = new StreamReader(stream))
            {
                // read n lines (there is one line of header so
                for (int i = 0; i <= linenumber; i++)
                {
                    readFile.ReadLine();
                }
                // get a line from the stream and split the data
                line = readFile.ReadLine();
                row  = line.Split('\t');
            }
            Assert.AreEqual(testDictionary["Hb"].Wavelengths[linenumber], Convert.ToDouble(row[0]));
            // dc: this would be only for MolarExtinctionCoefficient or FractionalExtinctionCoefficient, not MolarAbsorptionCoefficient or FractionalAbsorptionCoefficient
            // multiply the value by ln(10)
            // double k =  Math.Log(10);
            double k       = 1D;
            double spectra = Convert.ToDouble(row[1]) * k;

            // test that the values in the text stream match the ones in the object
            Assert.AreEqual(testDictionary["HbO2"].Spectrum[linenumber], spectra);
            spectra = Convert.ToDouble(row[2]) * k;
            Assert.AreEqual(testDictionary["Hb"].Spectrum[linenumber], spectra);
        }
Ejemplo n.º 2
0
        public void validate_loading_spectral_database_and_header_from_tsv_no_conversion()
        {
            Stream stream = StreamFinder.GetFileStreamFromResources("Modeling/Spectroscopy/Resources/Spectra.txt", "Vts");

            var testSpectra    = SpectralDatabase.GetSpectraFromFile(stream, false);
            var testDictionary = testSpectra.ToDictionary();

            testDictionary.WriteToJson("dictionary5.txt");
            Assert.IsTrue(FileIO.FileExists("dictionary5.txt"));
        }
Ejemplo n.º 3
0
        public void validate_Loading_Spectral_Database_and_header_from_tsv_in_resources()
        {
            Stream stream = StreamFinder.GetFileStreamFromResources("Modeling/Spectroscopy/Resources/Spectra.txt", _assemblyName);

            var testSpectra    = SpectralDatabase.GetSpectraFromFile(stream, true);
            var testDictionary = testSpectra.ToDictionary();

            testDictionary.WriteToJson("dictionary4.txt");
            Assert.IsTrue(FileIO.FileExists("dictionary4.txt"));
        }