Exemplo n.º 1
0
        /// <summary>
        /// read an SEGY file in XML format
        /// </summary>
        /// <param name="inputXMLFileName">input SEGYFile XML file name</param>
        /// <returns>pointer to SEGYFile</returns>
        public static SEGYFile ReadXML(string inputXMLFileName)
        {
            SEGYFile overview = new SEGYFile();

            System.Xml.Serialization.XmlSerializer reader =
                new System.Xml.Serialization.XmlSerializer(overview.GetType());
            System.IO.StreamReader file = new System.IO.StreamReader(
                inputXMLFileName);
            overview = (SEGYFile)reader.Deserialize(file);
            file.Close();
            return(overview);
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
     {
         return;
     }
     SEGYlib.SEGYFile sf = new SEGYlib.SEGYFile();
     foreach (var f in openFileDialog1.FileNames)
     {
         if (sf.Open(f) == 1)
         {
             if (sf.isSEGY())
             {
                 listBox1.Items.Add(f);
             }
         }
         sf.Close();
     }
 }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.folderBrowserDialog1.Description = "Enter the destination for the corrected SEGY file";
            if (this.folderBrowserDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            // read throught input file and make corrections to trace positions as needed
            sf            = new SEGYlib.SEGYFile();
            inputSEGYfile = this.openFileDialog1.FileName;
            sf.Open(this.openFileDialog1.FileName);
            if (!sf.isSEGY())
            {
                sf.Close();
                return;
            }

            string outputFileName = this.folderBrowserDialog1.SelectedPath + System.IO.Path.DirectorySeparatorChar.ToString() + System.IO.Path.GetFileNameWithoutExtension(inputSEGYfile) + "fix.sgy";


            SEGYlib.SEGYFile sf2 = new SEGYlib.SEGYFile();
            sf2.Open(outputFileName);

            sf2.FileHeader = sf.FileHeader.Copy();
            sf2.Write(sf2.FileHeader);

            while (sf.ReadNextTrace())
            {
                SEGYlib.SEGYTrace tr = sf.currentTrace;

                SEGYlib.SEGYTrace newTr = tr.Copy();
                newTr.TraceHeader.scalarToBeAppliedToAllCoordinates *= -1;
                newTr.sourcePositionX = newTr.sourcePositionX / 10;
                newTr.sourcePositionY = newTr.sourcePositionY / 10;

                sf2.Write(newTr);
            }

            sf.Close();
            sf2.Close();
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.Title = "Enter Name of SEGY File";
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (SEGY != null)
                {
                    SEGY.Close();
                }

                SEGY = new SEGYFile();
                if (SEGY.Open(openFileDialog1.FileName) == 0)
                {
                    label2.Text = " Could not opn " + openFileDialog1.FileName;
                    return;
                }
                SEGYfilename = openFileDialog1.FileName;
                SEGY.ReadAllTraceHeaders();
                label2.Text = SEGYfilename + " Loaded; " + SEGY.NumberOfTracesInBuffer.ToString() + " traces loaded";
            }
        }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.folderBrowserDialog1.Description = "Enter the destination for the corrected SEGY file";
            if (this.folderBrowserDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }


            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                int c = 0;
                // read throught input file and make corrections to trace positions as needed
                SEGYlib.SEGYFile sf            = new SEGYlib.SEGYFile();
                string           inputSEGYfile = (string)listBox1.Items[i];
                sf.Open(this.openFileDialog1.FileName);

                string outputFileName = this.folderBrowserDialog1.SelectedPath + System.IO.Path.DirectorySeparatorChar.ToString() + System.IO.Path.GetFileNameWithoutExtension(inputSEGYfile) + "rev0.sgy";
                this.toolStripStatusLabel1.Text = "Writing " + outputFileName;
                Application.DoEvents();

                SEGYlib.SEGYFile sf2 = new SEGYlib.SEGYFile();
                sf2.Open(outputFileName);

                sf2.FileHeader = sf.FileHeader.Copy();

                sf2.FileHeader.segyFormatRevisionNumber = 0; // convert to version 0
                sf2.FileHeader.numberOfExtendedTextualFileHeaderRecordsFollowing = 0;
                if (sf2.FileHeader.ExtendedTextHeader.Count > 1)
                {
                    sf2.FileHeader.ExtendedTextHeader.RemoveRange(1, sf2.FileHeader.ExtendedTextHeader.Count - 1);
                }

                sf2.Write(sf2.FileHeader);

                while (sf.ReadNextTrace())
                {
                    SEGYlib.SEGYTrace tr = sf.currentTrace;

                    SEGYlib.SEGYTrace newTr = tr.Copy();

                    sf2.Write(newTr);
                    c++;
                    if ((c % 100) == 0)
                    {
                        toolStripStatusLabel2.Text += ".";
                        if (toolStripStatusLabel2.Text.Length > 50)
                        {
                            toolStripStatusLabel2.Text = ".";
                        }
                        Application.DoEvents();
                    }
                }

                sf.Close();
                sf2.Close();
            }
            toolStripStatusLabel2.Text      = "";
            this.toolStripStatusLabel1.Text = "Done";
            Application.DoEvents();
        }
Exemplo n.º 6
0
        private void fixTraceLengths(string f, string g)
        {
            // setup datum trasformation
            DataRow r = datumDT.Rows[datum_number];

            //find ellipsoid parameters
            int ellipse_number = ellipsoidDT.Rows.Count - 1; // last entry is wgs 84

            for (int i = 0; i < ellipsoidDT.Rows.Count - 1; i++)
            {
                if (String.Compare(r[1].ToString(), ellipsoidDT.Rows[i][0].ToString()) == 0)
                {
                    ellipse_number = i;
                    break;
                }
            }

            double a_in   = Convert.ToDouble(ellipsoidDT.Rows[ellipse_number][1]);
            double fi_in  = Convert.ToDouble(ellipsoidDT.Rows[ellipse_number][2]);
            double dX     = Convert.ToDouble(r[2]);
            double dY     = Convert.ToDouble(r[3]);
            double dZ     = Convert.ToDouble(r[4]);
            double a_out  = Convert.ToDouble(ellipsoidDT.Rows[ellipsoidDT.Rows.Count - 1][1]);
            double fi_out = Convert.ToDouble(ellipsoidDT.Rows[ellipsoidDT.Rows.Count - 1][2]);

            NETGeographicLib.Geocentric fw = new NETGeographicLib.Geocentric(a_in, 1.0 / fi_in);
            NETGeographicLib.Geocentric rw = new NETGeographicLib.Geocentric(a_out, 1.0 / fi_out);

            SEGYlib.SEGYFile sf = new SEGYFile();
            sf.Open(f);                                    // open an existing SEGY file

            SEGYlib.SEGYFile sf2 = new SEGYlib.SEGYFile(); // create a new SEGY file
            sf2.Open(g);

            sf2.FileHeader = sf.FileHeader.Copy();  // copy the input trace header
            if (checkBox2.Checked)
            {
                sf2.FileHeader.numberOfSamplesPerDataTrace = Convert.ToUInt16((maxTime - minTime) * 1e3 / sf2.FileHeader.sampleIntervalInMicroseconds);
            }
            if (checkBox3.Checked)
            {
                sf2.FileHeader.SetFileHeader(0, 36, "C36 Positions coverted to Lat/Lon : " + DateTime.Now.ToShortDateString());
            }
            sf2.Write(sf2.FileHeader);  // write out the header
            int  c    = 0;
            bool flip = true;

            System.IO.StreamWriter tw = null;

            if (checkBox1.Checked)
            {
                // create a zone report
                string z = System.IO.Path.ChangeExtension(g, ".prj");
                tw = System.IO.File.CreateText(z);
            }
            while (sf.ReadNextTrace())
            {
                SEGYlib.SEGYTrace tr    = sf.currentTrace;
                SEGYlib.SEGYTrace newTr = tr.Copy();
                if (checkBox2.Checked)
                {
                    // pad top and bottom of trace
                    maxTraceLength = Convert.ToInt32((maxTime - minTime) * 1e3 / tr.TraceHeader.sampleIntervalUsec);
                    // delay offset
                    int delayoffset = (int)((newTr.TraceHeader.delayRecordingTimeMsec - minTime) * 1e3 / (double)newTr.TraceHeader.sampleIntervalUsec);
                    // pad top of trace
                    newTr.Resize(maxTraceLength, delayoffset);
                    newTr.TraceHeader.delayRecordingTimeMsec = (short)minTime;
                }


                if (checkBox1.Checked || checkBoxDatum.Checked || checkBox3.Checked)
                {
                    // switch to UTM
                    if (tr.isLatLon)
                    {
                        double lon = tr.sourcePositionX;
                        double lat = tr.sourcePositionY;
                        if (checkBoxDatum.Checked)
                        {
                            double h = 0;
                            double X, Y, Z;
                            fw.Forward(lat, lon, 0.0, out X, out Y, out Z);
                            X += dX;
                            Y += dY;
                            Z += dZ;
                            rw.Reverse(X, Y, Z, out lat, out lon, out h);
                            newTr.sourcePositionX = lon;
                            newTr.sourcePositionY = lat;
                        }
                        if (checkBox1.Checked)
                        {
                            // convert to geocentric
                            double x, y;
                            int    setzone, zone;
                            bool   north;
                            setzone = Convert.ToInt32(this.numericUpDown1.Value);
                            NETGeographicLib.UTMUPS.Forward(lat, lon, out zone, out north, out x, out y, setzone, false);
                            tw.WriteLine(lat.ToString() + " " + lon.ToString() + " " + x.ToString() + " " + y.ToString() + " " + zone.ToString());

                            newTr.TraceHeader.coordinateUnits = 1;
                            newTr.TraceHeader.scalarToBeAppliedToAllCoordinates = -100;
                            newTr.sourcePositionY = y;
                            newTr.sourcePositionX = x;
                        }
                    }
                    else
                    {
                        int    setzone, zone;
                        bool   north;
                        double lat, lon;

                        double x = tr.sourcePositionX;
                        double y = tr.sourcePositionY;
                        if (x > 0 && x < 1000000.0)
                        {
                            setzone = Convert.ToInt32(this.numericUpDown1.Value);
                            NETGeographicLib.UTMUPS.Reverse(setzone, true, x, y, out lon, out lat, false);
                        }
                        else
                        {
                            lon = 0;
                            lat = 0;
                        }
                        newTr.TraceHeader.coordinateUnits = 2;
                        newTr.TraceHeader.scalarToBeAppliedToAllCoordinates = -100;
                        newTr.sourcePositionY = lon;
                        newTr.sourcePositionX = lat;
                        if (checkBoxDatum.Checked)
                        {
                            double h = 0;
                            double X, Y, Z;
                            fw.Forward(lat, lon, 0.0, out X, out Y, out Z);
                            X += dX;
                            Y += dY;
                            Z += dZ;
                            rw.Reverse(X, Y, Z, out lat, out lon, out h);
                            newTr.sourcePositionX = lon;
                            newTr.sourcePositionY = lat;
                        }
                    }
                }



                sf2.Write(newTr);
                c++;
                if (c >= 4949)
                {
                    int ibreak = 0;
                }
                if (c % 100 == 0)
                {
                    toolStripStatusLabel1.Text = "Writing  " + g + " ";
                    if (flip)
                    {
                        toolStripStatusLabel1.Text += "\\";
                        flip = false;
                    }
                    else
                    {
                        toolStripStatusLabel1.Text += "/";
                        flip = true;
                    }
                    Application.DoEvents();
                }
            }

            if (tw != null)
            {
                tw.Close();
            }
            sf.Close();
            sf2.Close();
        }