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)); }
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; }
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)); }
/// <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); }
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)); }
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)); }
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); }
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()); }
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); }
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()); } }
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); } }
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(); }