private void dataGridViewTraceSummary_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!changeActive) { return; } if (f == null) { return; // file not open } if (e.ColumnIndex != 3) { return; // only edit value } SEGYTrace fh = f.currentTrace; // active object int rowid = e.RowIndex; propertyInfos = typeof(SEGYTrace).GetProperties(); PropertyInfo p = propertyInfos[rowid]; object val; try { val = Convert.ChangeType(dataGridViewTraceSummary.Rows[rowid].Cells[e.ColumnIndex].Value, p.PropertyType); } catch (SystemException ex) { System.Windows.Forms.MessageBox.Show(ex.Message); dataGridViewTraceSummary.Rows[rowid].Cells[3].Value = p.GetValue(fh, null); return; } p.SetValue(fh, val, null); refreshTraceHeader(); }
private void button2_Click(object sender, EventArgs e) { foreach (var i in listBox1.Items) { String f = (string)i; string f0 = System.IO.Path.GetDirectoryName(f) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(f) + "_corr.sgy"; SEGYFile s0 = new SEGYFile(); if (s0.Open(f) == 0) { break; } SEGYFile s1 = new SEGYFile(); if (s1.Open(f0) == 0) { s0.Close(); break; } s0.ReadFileHeader(); s1.Write(s0.FileHeader.Copy()); while (s0.ReadNextTrace()) { SEGYTrace t = s0.currentTrace.Copy(); short waterDepthMsec = t.TraceHeader.delayRecordingTimeMsec; t.TraceHeader.delayRecordingTimeMsec = 0; //t.TraceHeader.waterDepthAtSource = (int)waterDepthMsec; s1.Write(t); } s0.Close(); s1.Close(); } }
private void button2_Click(object sender, EventArgs e) { foreach (var i in listBox1.Items) { String f = (string)i; string f0 = System.IO.Path.GetDirectoryName(f) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(f) + ".gps"; SEGYFile s0 = new SEGYFile(); if (s0.Open(f) == 0) { break; } var s1 = File.CreateText(f0); if (s1 == null) { break; } s0.ReadFileHeader(); while (s0.ReadNextTrace()) { SEGYTrace t = s0.currentTrace; if (t.TraceHeader.traceNumberWithinOriginalFieldRecord == 1) { s1.WriteLine(t.timeTracedRecorded.ToString(), " ", t.sourcePositionX.ToString(), " ", t.sourcePositionY.ToString()); } } s0.Close(); s1.Close(); } }
private void button2_Click(object sender, EventArgs e) { foreach (var i in listBox1.Items) { String f = (string)i; string f0 = System.IO.Path.GetDirectoryName(f) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(f) + "_corr.sgy"; SEGYFile s0 = new SEGYFile(); if (s0.Open(f) == 0) { break; } SEGYFile s1 = new SEGYFile(); if (s1.Open(f0) == 0) { s0.Close(); break; } s0.ReadFileHeader(); var fh = s0.FileHeader.Copy(); fh.SetFileHeader(0, 39, "C39 File processed by FixOBSSEGY Sept/2019"); s1.Write(fh); while (s0.ReadNextTrace()) { if (s0.currentTrace.TraceHeader.numberOfSamplesInTrace < 1000 || s0.currentTrace.TraceHeader.numberOfSamplesInTrace > 60000) { break; } if (s0.currentTrace.timeTracedRecorded < new DateTime(1950, 1, 1)) { break; } SEGYTrace t = s0.currentTrace.Copy(); if (checkBoxSwitch.Checked) { var s = t.TraceHeader.sourceCoordinateX; t.TraceHeader.sourceCoordinateX = t.TraceHeader.sourceCoordinateY; t.TraceHeader.sourceCoordinateY = s; s = t.TraceHeader.groupCoordinateX; t.TraceHeader.groupCoordinateX = t.TraceHeader.groupCoordinateY; t.TraceHeader.groupCoordinateY = s; } if (checkBoxlldec.Checked) { t.TraceHeader.coordinateUnits = 3; } if (checkBoxllsa.Checked) { t.TraceHeader.coordinateUnits = 2; } s1.Write(t); } s0.Close(); s1.Close(); } }
private void scanFile() { if (this.listBox1.SelectedIndex < 0) { return; } string f = (string)listBox1.SelectedItem; SEGYFile s = new SEGYFile(); s.Open(f); s.Traces = new List <SEGYlib.SEGYTrace>(); s.ReadFileHeader(); int c = 0; bool flip = true; l1norms = new System.Collections.ArrayList(); while (s.ReadNextTrace()) { SEGYTrace tr = s.currentTrace; // calculate l1 norm of trace enegy //double l1 = 0; //for (int i = 0; i < tr.TraceData.Data.Length; i++) l1 += Math.Abs(tr.TraceData.Data[i]); //l1norms.Add(l1); // tr.TraceData.TraceDataBuffer = null; s.Traces.Add(tr); c++; if (c % 100 == 0) { toolStripStatusLabel1.Text = "Reading " + f + " "; if (flip) { toolStripStatusLabel1.Text += "\\"; flip = false; } else { toolStripStatusLabel1.Text += "/"; flip = true; } Application.DoEvents(); } } //s.ReadAllTraceHeaders(); int tmin = s.Traces[0].TraceHeader.numberOfSamplesInTrace; int tmax = tmin; int delaymin = s.Traces[0].TraceHeader.delayRecordingTimeMsec; int delaymax = Convert.ToInt32(delaymin + s.Traces[0].TraceHeader.numberOfSamplesInTrace * s.Traces[0].TraceHeader.sampleIntervalUsec / 1e3); for (int i = 0; i < s.Traces.Count; i++) { int ti = s.Traces[i].TraceHeader.numberOfSamplesInTrace; if (ti < tmin) { tmin = ti; } if (ti > tmax) { tmax = ti; } if (s.Traces[i].TraceHeader.delayRecordingTimeMsec < delaymin) { delaymin = s.Traces[i].TraceHeader.delayRecordingTimeMsec; } int tm = Convert.ToInt32(s.Traces[i].TraceHeader.delayRecordingTimeMsec + s.Traces[i].TraceHeader.numberOfSamplesInTrace * s.Traces[i].TraceHeader.sampleIntervalUsec / 1e3); if (tm > delaymax) { delaymax = tm; } } s.Close(); this.toolStripStatusLabel1.Text = "Trace length varies from " + tmin.ToString() + " to " + tmax.ToString(); maxTraceLength = tmax; minTime = delaymin; maxTime = delaymax; }
private void button2_Click(object sender, EventArgs e) { foreach (var i in listBox1.Items) { String f = (string)i; string f0 = System.IO.Path.GetDirectoryName(f) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(f) + "_corr.sgy"; if (File.Exists(f0)) { File.Delete(f0); } SEGYFile s0 = new SEGYFile(); if (s0.Open(f) == 0) { break; } SEGYFile s1 = new SEGYFile(); if (s1.Open(f0) == 0) { s0.Close(); break; } s0.ReadFileHeader(); s1.Write(s0.FileHeader.Copy()); int count = 0; toolStripStatusLabel1.Text = "Writing " + f0 + " : "; while (s0.ReadNextTrace()) { SEGYTrace t = s0.currentTrace.Copy(); // seismic data if (t.TraceHeader.traceIdentificationCode != 1) { continue; } // find water depth of source in meters var srcDepth = Convert.ToDouble(t.TraceHeader.sourceDepthBelowSurface); var fac = t.TraceHeader.scalarForAllElevationsAndDepths; if (fac < 0) { srcDepth /= -fac; } else if (fac > 0) { srcDepth *= fac; } // calculate the corresponding time delay in seconds var twt = 2 * srcDepth / 1500; // assume vw = 1500 m/s var twtmsec = twt * 1e3; t.TraceHeader.delayRecordingTimeMsec = Convert.ToInt16(Math.Floor(twtmsec)); var remainder = twtmsec - t.TraceHeader.delayRecordingTimeMsec; // corresponding number of samples to pad trace for fractional delay times var nsamp = Convert.ToInt32(remainder * 1e3 / t.TraceHeader.sampleIntervalUsec); var data = t.TraceData.Data; // mute start of trace if (this.checkBox1.Checked) { int mutedelay = Convert.ToInt32(Convert.ToDouble(this.numericUpDown1.Value) * 1e3 / Convert.ToDouble(t.TraceHeader.sampleIntervalUsec)); for (int ii = 0; ii < mutedelay; ii++) { data[ii] = 0; } } var datanew = new double[data.Length]; // should be initializes to zero Array.Copy(data, 0, datanew, nsamp, data.Length - nsamp); t.TraceData.Data = datanew; s1.Write(t); count++; if (count % 100 == 0) { toolStripStatusLabel2.Text = count.ToString(); Application.DoEvents(); } } s0.Close(); s1.Close(); } toolStripStatusLabel1.Text = "."; toolStripStatusLabel2.Text = "."; }