Example #1
0
 public void ShouldStopReadingWhenCancellationPending()
 {
     var subject = new SegyReader();
     var segy = subject.Read(@"./Examples/lineE.sgy", new CancelsAtThirty());
     var expected = (int)(.3 * 111);
     Assert.That(segy.Traces.Count, Is.EqualTo(expected));
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)           //клик на кнопку открыть файл
        {
            if (!is_Drag_Drop)                                           //если запуск произошел не из-за драг-дропа
            {
                if (openFileDialog1.ShowDialog() == DialogResult.Cancel) //то показываем диалог на открытие файла
                {
                    return;                                              // если отмена то выходим
                }
                filename = openFileDialog1.FileName;                     //имя файла
            }
            else
            {
                filename = filename_Drag_Drop;//имя файла
            }

            try
            {
                var reader = new SegyReader();//чтение
                line = reader.Read(filename);
            }
            catch (Exception ex)//если не получилось
            {
                is_File_Ok = false;
                MessageBox.Show(null, "Не удалось открыть файл: \n" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            is_File_Ok             = true;
            label_name.Text        = "Файл: " + Path.GetFileName(filename);
            label_traces_dots.Text = "Трасс / точек: " + line.Traces.Count.ToString() + " / " + line.Traces[0].Values.Count.ToString();
            Text = filename + " — файл открыт";
            FindStepSizeForTrace();
            is_Drag_Drop = false;
        }
Example #3
0
 public void ShouldReadSegyFile()
 {
     var subject = new SegyReader();
     var segy = subject.Read(@"./Examples/lineE.sgy");
     Console.WriteLine(segy.Header.Text);
     Assert.That(segy.Traces.Count, Is.EqualTo(111));
 }
Example #4
0
        /// <summary>
        /// Is called when a user requests to import a ."sgy file.
        /// It is actually up to this method to read the file itself.
        /// </summary>
        /// <param name="filename">The complete path to the new file.</param>
        /// <param name="index">The index of the file type as it had been specified by the AddFileTypes method.</param>
        /// <param name="doc">The document to be written.</param>
        /// <param name="options">Options that specify how to write file.</param>
        /// <returns>A value that defines success or a specific failure.</returns>
        protected override bool ReadFile(string filename, int index, RhinoDoc doc, Rhino.FileIO.FileReadOptions options)
        {
            bool read_success = false;

            var       reader = new SegyReader();
            ISegyFile file   = reader.Read(filename);

            RhinoApp.WriteLine("SEGY: Header Text: {0}", file.Header.Text);
            RhinoApp.WriteLine("SEGY: Nº of Traces: {0}", file.Traces.Count);
            for (int i = 0; i < file.Traces.Count; i++)
            {
                var trace = file.Traces[0];
                RhinoApp.WriteLine("SEGY: Trace #" + trace.Header.TraceNumber + " Count #: " + i + " Sample Count: {0}", trace.Header.SampleCount);
                RhinoApp.WriteLine("SEGY: Trace #" + trace.Header.TraceNumber + " Count #: " + i + " Crossline Nº: {0}", trace.Header.CrosslineNumber);
                RhinoApp.WriteLine("SEGY: Trace #" + trace.Header.TraceNumber + " Count #: " + i + " Inline Nº: {0}", trace.Header.InlineNumber);

                for (int j = 0; j < trace.Values.Count; j++)
                {
                    RhinoApp.WriteLine("SEGY: Trace #" + trace.Header.TraceNumber + " Count #: " + i + " Value Nº " + j + ": {0}", trace.Values[j]);
                }
            }

            read_success = true;

            return(read_success);
        }
Example #5
0
        public void ShouldStopReadingWhenCancellationPending()
        {
            var subject  = new SegyReader();
            var segy     = subject.Read(@"./Examples/lineE.sgy", new CancelsAtThirty());
            var expected = (int)(.3 * 111);

            Assert.That(segy.Traces.Count, Is.EqualTo(expected));
        }
Example #6
0
        public void ShouldReadSegyFile()
        {
            var subject = new SegyReader();
            var segy    = subject.Read(@"./Examples/lineE.sgy");

            Console.WriteLine(segy.Header.Text);
            Assert.That(segy.Traces.Count, Is.EqualTo(111));
        }
Example #7
0
 public void ShouldGetImageBytes()
 {
     var reader = new SegyReader();
     var segy = reader.Read(@"./Examples/lineE.sgy");
     var imageWriter = new ImageWriter();
     var bytes = imageWriter.GetRaw32BppRgba(segy.Traces);
     var expected = 4 * segy.Traces.Count * segy.Traces[0].Values.Count;
     Assert.That(bytes.Length, Is.EqualTo(expected));
 }
Example #8
0
        public void ShouldGetImageBytes()
        {
            var reader      = new SegyReader();
            var segy        = reader.Read(@"./Examples/lineE.sgy");
            var imageWriter = new ImageWriter();
            var bytes       = imageWriter.GetRaw32BppRgba(segy.Traces);
            var expected    = 4 * segy.Traces.Count * segy.Traces[0].Values.Count;

            Assert.That(bytes.Length, Is.EqualTo(expected));
        }
Example #9
0
 public void ShouldReadBigEndianIEEEFloatingPoint()
 {
     var subject = new SegyReader();
     var segy = subject.Read(@"./Examples/bigEndianIEEEFloat.sgy");
     Console.WriteLine(segy.Header.Text);
     Assert.That(segy.Traces.Count, Is.EqualTo(120));
     Assert.That(segy.Traces[0].Values[0], Is.EqualTo(0));
     Assert.That(segy.Traces[60].Values[159], Is.EqualTo(0.896f).Within(0.001f));
     Assert.That(segy.Traces[60].Values[160], Is.EqualTo(1.000f).Within(0.001f));
     Assert.That(segy.Traces[60].Values[161], Is.EqualTo(0.896f).Within(0.001f));
 }
Example #10
0
        public void ShouldReadBigEndianIEEEFloatingPoint()
        {
            var subject = new SegyReader();
            var segy    = subject.Read(@"./Examples/bigEndianIEEEFloat.sgy");

            Console.WriteLine(segy.Header.Text);
            Assert.That(segy.Traces.Count, Is.EqualTo(120));
            Assert.That(segy.Traces[0].Values[0], Is.EqualTo(0));
            Assert.That(segy.Traces[60].Values[159], Is.EqualTo(0.896f).Within(0.001f));
            Assert.That(segy.Traces[60].Values[160], Is.EqualTo(1.000f).Within(0.001f));
            Assert.That(segy.Traces[60].Values[161], Is.EqualTo(0.896f).Within(0.001f));
        }
Example #11
0
        public void ImageFromExample()
        {
            // Arrange
            var segy = new SegyReader().Read("lineE.sgy");
            var path = TestPath() + ".png";

            // Act
            Subject.Write(segy, path);

            // Assert
            BinaryFileAssert.Exists(path);
            TestContext.AddResultFile(path);
        }
Example #12
0
        public void ShouldReportProgress()
        {
            var subject = new SegyReader();
            var testProgressReporter = new TestProgressReporter();

            subject.Read(@"./Examples/lineE.sgy", testProgressReporter);

            // Assert that message received for each percentage 0 to 100
            // (The example has more than 100 traces, so this is reasonable)
            var p = testProgressReporter.ProgressReported;
            for (int i = 0; i < 101; i++)
                Assert.That(p.Contains(i), i.ToString());
        }
Example #13
0
        public void PrepareImageData()
        {
            var reader = new SegyReader {
                InlineNumberLocation = 17, CrosslineNumberLocation = 13
            };
            var segyPath = @"C:\Users\jfoshee\Desktop\RMOTC Data\RMOTC Seismic data set\3D_Seismic\filt_mig.sgy";
            var segy     = reader.Read(segyPath);

            using (var inlineBitmap = GetBitmapForMiddle(segy, t => t.Header.InlineNumber))
                MakeTiles("Inline", inlineBitmap);
            using (var crosslineBitmap = GetBitmapForMiddle(segy, t => t.Header.CrosslineNumber))
                MakeTiles("Crossline", crosslineBitmap);
        }
Example #14
0
        public void ShouldReportProgress()
        {
            var subject = new SegyReader();
            var testProgressReporter = new TestProgressReporter();

            subject.Read(@"./Examples/lineE.sgy", testProgressReporter);

            // Assert that message received for each percentage 0 to 100
            // (The example has more than 100 traces, so this is reasonable)
            var p = testProgressReporter.ProgressReported;

            for (int i = 0; i < 101; i++)
            {
                Assert.That(p.Contains(i), i.ToString());
            }
        }
Example #15
0
        public void ReadTeapotDome3D()
        {
            using (SegyReader reader = new SegyReader(teapotDome3DFileInfo))
            {
                var fileTextualHeaders = reader.FileTextualHeaders;

                CodeContract.Assume(fileTextualHeaders.Length == 1, "There should be at least 1 text file header in the file.");
                CodeContract.Assume(reader.TraceCount > 0);
                CodeContract.Assume(reader.FileBinaryHeader.SamplesPerTraceOfFile > 0);

                var traces     = reader.ReadTraces();
                var traceCount = traces.Count();
                var minmax     = reader.GetAmplitudeRange();

                CodeContract.Assume(traceCount == reader.TraceCount);
            }
        }
Example #16
0
        public void CopySegyFileAndCompareToOriginal(FileInfo oldFileInfo)
        {
            var newFile = oldFileInfo.FullName.Replace(".sgy", "_tmp.sgy");

            FileInfo newFileInfo = new FileInfo($@"{newFile}");

            using (SegyReader reader = new SegyReader(oldFileInfo))
            {
                using (SegyWriter writer = new SegyWriter(newFileInfo))
                {
                    writer.Write(reader.FileTextualHeaders[0]);
                    writer.Write(reader.FileBinaryHeader);
                    writer.Write(reader.ReadTraces());
                }
            }

            using (SegyReader oldFileReader = new SegyReader(oldFileInfo))
            {
                using (SegyReader newFileReader = new SegyReader(newFile))
                {
                    CodeContract.Assume(oldFileReader.FileTextualHeaders[0] == newFileReader.FileTextualHeaders[0]);
                    CodeContract.Assume(oldFileReader.FileBinaryHeader.Equals(newFileReader.FileBinaryHeader));

                    var oldTraces = oldFileReader.ReadTraces().ToArray();
                    var newTraces = newFileReader.ReadTraces().ToArray();

                    CodeContract.Assume(oldTraces.Length == newTraces.Length);

                    var traceCount = oldTraces.Length;
                    for (int i = 0; i < traceCount; i++)
                    {
                        var oldTrace = oldTraces[i];
                        var newTrace = newTraces[i];

                        CodeContract.Assume(oldTrace.Equals(newTrace));
                    }
                }
            }
            newFileInfo.Delete();
        }