Saturday, December 3, 2011

Reading SEG-Y from Command Line

Yes, I've been gone for a month or so...

Here it is. If you don't have your favorite reader use these fun dd & hexdump commands from the command line.

Reading the EBCDIC header:
dd if=input_file.sgy conv=ascii conv=unblock


Reading the job number
hexdump -C -s 3201x -n 3 input_file.sgy | awk '{print $2 $3 $4;}'

Reading the line number:
hexdump -C -s 3205x -n 3 10_770.sgy | awk '{print $2 $3 $4;}'

Reading the reel number:
hexdump -C -s 3209x -n 3 10_770.sgy | awk '{print $2 $3 $4;}'

Reading the format code:
hexdump -C -s 3224x -n 2 10_770.sgy | awk '{print $2 $3;}'

Reading the sample interval:
hexdump -C -s 3216x -n 3 10_770.sgy | awk '{print $2 $3;}'

Reading the samples per trace:
hexdump -C -s 3220x -n 2 10_770.sgy | awk '{print $2 $3;}'

Reading the sort code:
hexdump -C -s 3228x -n 2 10_770.sgy | awk '{print $2 $3;}'

Thursday, October 27, 2011

Arc Seconds to Degrees

Wouldn't you know it. I thought that I was just dim-witted or the people who were writing the SEG-Y were completely zonked - but there is a reason behind putting X/Y data in arc seconds. For a long time, every once in a while you'll come across SEG-Y byte location 98 and it'll have a 2 there (meaning the coordinates are in Arc Seconds. I'm scratching my head saying - who on earth, why on earth? Okay, here's the rhyme - not sure of the reason.

Arc Seconds = 3599.99999712 * degree
while
Degree = 0.0002778 * arc seconds

go figure. I got this all from here.

Grazie

Thursday, October 20, 2011

Nav2KML update

Yeah, I know script files are not that fun.  Here's the actual application that I put together the past few days.  I added the function of color to it.  It works the same way the script worked (the input) which should look like:

-122.19785 37.5686 101A
-122.19785 37.56863 101A
-122.19785 37.56865 101A


Added a few other things.  Hope you enjoy it.  Here's a screen shot and it's result.

Screen shot

What it should look like in GoogleEarth

Thursday, October 6, 2011

SEG-Y Summary Update

Hey people,

I've been working on this program to add a little bit more functionality to it.  I added an EBCDIC/ASCII header viewer and a trace header viewer.  I might (if I have the time) add some functionality to it regarding being able to load large 3D files.  Get the app here.

SEG-Y Summary screen shot

Wednesday, September 28, 2011

SEG-Y Summary

Okay, here it goes.  My first professional swing at VB (the compiled version).  SEG-Y summary is a real application that reads in SEG-Y files, gives you info from the binary header and some (here's the some) -> It give you the first/last min/max info.  I couldn't find any other free application which gives you min/max info which I could find.   It's cheap & free and here.  Enjoy.  Careful of 3D files, it's a memory hog.  I might be working on a quicker way to load the files - but more of that later.

Here's how to use it:
Load the file you want look at
Select the header you want to summarize

Real tough.

Saturday, September 24, 2011

Leave My Files Alone!

A big thumbs up for the SEG-Y Viewer brought to you by IHS.  I think you have to pay for it now.  It lets you view SEG-Y files without locking them up.  Unlike SeiSee, you get to see the full amplitudes.  For whatever reason, SeiSee only lets you look at 3 decimals to the right.  SEG-Y Viewer lets you look at the whole shebang.  And SegY Detective lets you as well - but it locks up the file.

Yes, I know that you need to keep the file open to look at it, but after everything's loaded into memory - let go of it.  Are people afraid of someone else in the network will change the file you're working on?  Nunno.

Locking files up can be disastrous for people trying to view seismic files in multiple application.  Yes, you might have worked long and hard on your software, but it doesn't do everything.

My two cents.

Thursday, September 22, 2011

The SEG-Y Structure, Part 1

Okay.  I've been analysing 2D SEG-Y files all day today - on the binary level.  There may be a more in-depth analysis of it - but here's my shot.

SEG-Y Structure
We all know SEG-Y files are structured as
File Header
3200 byte EBCDIC/ASCII header
400 byte binary header
Trace Info
240 byte trace header
Sample Info
.....
wash, rinse, repeat with the trace header info - sample info

DWord/Word
After looking over the binary header & header info, I know we have the 2 byte integer type and the 4 byte integer types.  There seems to be more to it than that if you want to be able to translate things to the normal/rational world.

Here's my first example:
If you look at things on the binary level of this file you'll see:
Now, You have the -1000 number represented as FC18.  Remember it's a 16 bit WORD.  After you bring it into the real world it'll become a -1000.

Hex DWORD:  FFFFFC18 = -1000
Hex WORD:  FC10 = -1000

Look at byte location 73-76 and you're going to expect to find -293373438.  Okay, since it's a DWORD Int we're looking for:

Hex DWORD:  EE837A02 = and suddenly you get -293373438.  Whala!

If you worked for the SEG-Y subcommitee or commitee you probably already understand this.  I just figured it out in my lowly-mentality-self.

Saturday, September 17, 2011

Decimal 2 Degrees

Okay, my next venture - I downloaded my free copy of visual basic because I figured out that visual basic scripting didn't cut it for what I was after.  Here's a really really cheep program that converts decimal coordinates into degrees, minutes, seconds.  I could probably convert them back . . . which I'll figure out on a later date.  (Yes I know how to do the math, it's just how to do both in the same application).

Sunday, September 11, 2011

Nav2KML File

Okay, I've come to understand that the navigation world does not like GoogleEarth.  After scouring all over the web I couldn't find anything that would suit what I wanted it to do - create a kml file from a navigation file.  Multiple lines with different linenames.  And, yes, I have more than 3 points in my path.  Let's say 800!  I sat down a few days ago and figured out GoogleEarth scripting and came up with this really cheesy vbs file.

Here it is:
infilename = inputbox("Enter the input file name")
outfilename = inputbox("Enter the output file name")
fname = inputbox("Enter the survey name:  ")

Const ForReading = 1
Dim strFileIn, objFSO, objTextRead

strFileIn = infilename
'strFileIn = "C:\Users\Cremer\Documents\SEG-Y\San Francisco Bay\Navigation\" & infilename ' use this if you want absolute pathname
Set objFSO = CreateObject("Scripting.FileSystemObject") ' File system object
Set objTextRead = objFSO.OpenTextFile(strFileIn, ForReading)  ' Open text file

strFileOut = outfilename
'strFileOut = "C:\Users\Cremer\Documents\SEG-Y\San Francisco Bay\Navigation\" & outfilename ' use this if you want absolute pathname
Set filestreamOUT = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFileOut,2,true)

Dim arrKML()
n = 0
Do Until objTextRead.AtEndOfStream
 Dim strSearchString
 Dim currentID
 strSearchString = objTextRead.ReadLine

 ReDim Preserve arrKML(3,n) ' Initialize array 4 characters, at n entry
 arrKML(0,n) = n ' add number
 arrKML(1,n) = CDbl(trim(mid(strSearchString,1,11))) ' add long
 arrKML(2,n) = CDbl(trim(mid(strSearchString,12,11))) ' add lat
 arrKML(3,n) = (trim(mid(strSearchString,23,11))) ' add line number
 n = n + 1 ' next iteration
Loop
objTextRead.Close
' ***********************************************************************

' msgbox "Number of elements in array: " & Ubound(arrKML,2)
dim currentLineName
currentLineName = arrKML(3,0)
filestreamOUT.WriteLine("<?xml version=" & chr(&H22) & "1.0" & chr(&H22) & " encoding=" & chr(&H22) & "UTF-8" & chr(&H22) & "?>")
filestreamOUT.WriteLine("<kml xmlns=" & chr(&H22) & "
http://www.opengis.net/kml/2.2" & chr(&H22) & " xmlns:gx=" & chr(&H22) & "http://www.google.com/kml/ext/2.2" & chr(&H22) & " xmlns:kml=" & chr(&H22) & "http://www.opengis.net/kml/2.2" & chr(&H22) & " xmlns:atom=" & chr(&H22) & "http://www.w3.org/2005/Atom" & chr(&H22) & ">")
filestreamOUT.WriteLine("<Document id=" & chr(&H22) & "Phil Cremer's Cheesy nav2kml script" & chr(&H22) & ">")
filestreamOUT.WriteLine(vbtab & "<name>" & fname & "</name>")
filestreamOUT.WriteLine(vbtab & vbtab & "<Placemark id=" & chr(&H22) & currentLineName & chr(&H22) & ">")
filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "<name>" & currentLineName & "</name>")
filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "<LineString id=" & chr(&H22) & currentLineName & chr(&H22) & ">")
filestreamOUT.WriteLine(vbtab & vbtab & vbtab & vbtab & "<coordinates>")

for i = 0 to Ubound(arrKML,2)
 dim lineName
 lineName = arrKML(3,i)
 if lineName <> currentLineName then ' if it's different put a marker in it.
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & vbtab & "</coordinates>")
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "</LineString>")
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "</Placemark>")
  filestreamOUT.WriteLine(vbtab & vbtab & "<Placemark id=" & chr(&H22) & lineName & chr(&H22) & ">")
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "<name>" & lineName & "</name>")
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "<LineString id=" & chr(&H22) & lineName & chr(&H22) & ">")
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & vbtab & "<coordinates>")
  currentLineName = lineName
 else ' if it's the same put the coordiantes
  filestreamOUT.WriteLine(vbtab & vbtab & vbtab & vbtab & vbtab & arrKML(1,i) & "," & arrKML(2,i) & ",0  ")
 end if
next

filestreamOUT.WriteLine(vbtab & vbtab & vbtab & vbtab & "</coordinates>")
filestreamOUT.WriteLine(vbtab & vbtab & vbtab & "</LineString>")
filestreamOUT.WriteLine(vbtab & vbtab & "</Placemark>")
filestreamOUT.WriteLine("</Document>")
filestreamOUT.WriteLine("</kml>")

'for z = LBound(arrKML,2) to UBound(arrKML,2)
'    filestreamOUT.WriteLine(arrKML(3,z))
'Next
'
filestreamOUT.Close()
Set filestreamOUT = Nothing
msgbox "Done!"


Like mentioned is really cheesy and really easy to write.  You can probably do better job.  If you can fix my sloppy code!  All you have to do is safe what's in green to a text file and name it nav2kml.vbs in the directory of the navigation file.  Your navigation file should be a follows.

-122.19785 37.5686    101A
-122.19785 37.56863   101A
-122.19785 37.56865   101A


My suggestion is to put your nav into an Excel spreadsheet and export it to a .prn file where the column width is set to 11.  Long   Lat   Linename.  If you need to modify stuff, it's pretty easy to figure out what needs to be changed to suit your needs.  All the lines will be white written as one place.  Write the output file as a *.kml.  Import into GoogleEarth and whalla you get stuff like this!

Data from the San Francisco Bay.  Brought in from some navigation file.

Tuesday, September 6, 2011

The Other Side Under The Golden Gate Bridge

Okay... I got the whole kml thing down now it's a bit of a routine.  Here's the other side of the San Francisco Bay survey.  Why isn't there anything that GoogleEarth in all their FREE wisdom can put out where you can dump values from Excel or whereever and create these things.  Sure, I can tire my brain out by creating scripts to do ONE thing.. but instead of making GoogleDoodles for Freddie Mercury's bday they can.. oh never mind .. here you go.
from the nav -> kml

Imported SEG-Y from into SMT.  Sorry about that pesky SnagIt

Ho hum.  I got started on the other 1/4 of the data, over wrote the data.  You get the picture.  The SMT looks really ugly.  For whatever reason, there's not an option to limit the number of "ticks" or shotpoints noted on the SEG-Y.  Every 10th would at least be nice.

Sunday, September 4, 2011

Mapping San Francisco Bay via GoogleEarth

Okay this is all new to me.  Google Earth is a whole new to me.  The thing to know is "KML" and "KMZ".  Now, here's the big secret -> A KMZ is only a zipped KML file (there's probably more to it than that but that's it for now).  Unfortunately, I have not found anything (yet) that can convert a navigation file to anything GoogleEarth can understand.

From the GoogleEarth perspective, you have to create paths.  Of course, now these paths are the 2d lines but these lines are where the boat was floating around.

I was fiddling around with a VBScript to put everything in an array to automatically create a kml file but it seemed easier to do it by hand.  See below

It all looks okay. And I remembered I only had 4 more days left on my SMT license... so I went and fixed all the EBCDIC headers on it and loaded it into SMT. It looks like it matches up. :)

Looks like everything's there.  I'd be nice if I could go between the two but oh well.  SMT looks terrible for 2d IMHO.  There's probably a way around it but nothing stuck out in the viewing options.  Is there ANY way to view the seismic apart from the navigation data.  The nav data is great but the seismic (for whatever reason) has to display each shotpoint regardless of where you're viewing.

More later...

Saturday, September 3, 2011

I Left My Headers In The San Francisco Bay

No cable cars to the stars here.  This marine data from the San Francisco area (made up of Central San Francisco Bay, Golden Gate, the San Pablo Bay and Western  Sacramento Delta, and the San Francisco and San Pablo Bay Seistec areas are seriously disjointed.  A mishmash to put it politely.  Data was shot in 1993, 1994, 1995, & 1997.  I might need a few shotpoints w/ lime to figure this one out.

The trace headers are "okay".  They X/Ys match up with were they're supposed to be if the data's in UTM Zone 10.

But here's the real kicker - they divide the navigation up differently that the seismic.  Grrrr really steams my gills.  See below...
J8-93-SF
J2-94-SF
G2-95-SF
J4-97-SF
J8-93-SF
J2-94-SF
G2-95-SF
J4-97-SF

J2-92-SF
G2-95-SF

J2-94-SF
G2-95-SF

J2-94-SF

More tomorrow...

Friday, September 2, 2011

Beaufort's Cooling Down

From the ice cold...

I nixed the idea of figuring out the X/Ys.  I loaded the nav files into SMT and loaded each SEG-Y separately.  Seems to look okay as you can see. The X/Ys now match up to the correct UTM Zone 6 numbers. Unfortunately the demo copy from SMT doesn't let you modify the SEG-Y in any significant way. You have no control over the EBCDIC, no options for the trace headers at all. Ho hum. I'll check back later with OpendTect.

I mean all you get is:

C 1 CLIENT COMPANY CREW NO
C 2 LINE WB-844_AMPLITUDESFIX MAP ID
C 3 REEL NO DAY-START OF REEL YEAR OBSERVER
C 4 SHOTPOINT: 5 LONG SHOTPOINT FOR 2D AND 3D SURVEY DATA
C 5 LINE NUMBER: 17 LONG LINE RECORD
C 6 TRACE NUMBER: 25 LONG TRACE RECORD(CDP Number)
C 7 SHOTPOINT: 21 LONG SHOTPOINT FOR ARBITRARY LINE
C 8 CDP_X: 73 LONG CDPBIN NUMBER
C 9 CDP_Y: 77 LONG CDPBIN NUMBER
C10 NSAMPLE: 115 UNSIGNED SHORT NUMBER OF SAMPLES
C11 SRATE: 117 UNSIGNED SHORT SAMPLE RATE
C12

Not much. Ho hum. It was free. Back to SeiSee.

Thursday, September 1, 2011

Cold In The Beaufort Sea

Good Lord the problems I have with this one!  This data is from Westerngeco (my old employer) thanks to the USGS that was shot back in 1978.  Why can't I find data that is somewhat recent and that has data that's accurate.  Anyhow, here's what the data looks like.

Now based on the "MetaData" file, here are the details of the survey:

IDW-19-78-AR
Also Known As00019
AbstractWesternGeco. Geophysical data (navigation, seismic) of field activity W-19-78-AR in Beaufort Sea Streamer from 01/01/1978 to 02/13/1978
OrganizationWesternGeco
Activity TypeGeophysical
Area of OperationBeaufort Sea Streamer, Arctic Ocean
Bounding Coordinates
70.65183
-149.68971-145.53813
70.17886
Dates01/01/1978 (JD 001) to 02/13/1978 (JD 044)
Analog MaterialsNo analog holdings.
Information Specialist
Jon Childs
Equipment Used
navigation
seismic
Notes
Description of Survey Area  00019: Beaufort Sea Streamer 1978

    Date of Survey              Sept 1978

    Tape Version Identifier     SEG-P1


    Client Name                 WesternGeco Multiclient

    Coordinate Location         Vessel Locations

    Spheroid Definition-Survey  Clarke 1866 6378206.400 294.978698

    Spheroid Def. - Post Plot   Clarke 1866 6378206.400 294.978698

    Geodetic Datum - Survey     NAD 27

    Geodetic Datum - Post Plot  NAD 27


Datum Shifts

     Projection Type            Transverse Mercator

     Grid System                UTM Zone 6

     Grid Units                 Meters

     Central Meridian           147 0 0.000W

     Grid Origin                  0 0 0.000N147 0 0.000W

     Grid Coordinates at Origin   500000.00E       0.00N

     Scale Factor               0.9996000000

     Scale Factor Defined at      0 0 0.000N147 0 0.000W

Now here are the datatypes available:

Navigation
  • ArcInfo E00 files (thankfully)
  • Edited shotpoint data (looks like reliable lat,long,x,y info every 10 shotpoints but you never know.  The data look funny though)
  • A kmz file for you GoogleEarth people
Seismic
  • 2D Stack Lines
  • 2D Migration Lines
Alrighty now let's look at things....

Let's look at a migration EBCDIC header:
C01 CLIENT WESTERNGEC COMPANY CREW NO
C02 LINE WB-737 AREA 19
C03 REEL NO 782124 PROSPECT BEAUFORT SEA 1978 OBSERVER
C04 INSTRUMENT: MFG MODEL SERIAL NO
C05 DATA TRACES/RECORD 1 AUXILIARY TRACES/RECORD 0 CDP FOLD
C06 SAMPLE INTERVAL 4 SAMPLES/TRACE 1500 BITS/IN BYTES/SAMPLE 4
C07 RECORDING FORMAT FORMAT THIS REEL MEASUREMENT SYSTEM
C08 SAMPLE CODE: FLOATING PT FIXED PT FIXED PT-GAIN CORRELATED
C09
C10
C11
C12
C13
C14
C15
C16
C17
C18
C19 FIELD FILE SEQUENCE IN BYTES 21-24
C20
C CLIENT WGC
C LINE WB-737 S.P. 1400 - 100
C AREA O-ALK
C MAX REF TIME(MS) 6000 SAMPLING INTERVAL 4 REEL SEQUENCE NUMBER 1 TYPE FL
C DATA TRACE NO.(MAX) 24 UNITS OF DISTANCE FEET STACK RMS 2000
C TIME VALUE MULTIPLIER 1 REPLACEMENT VELOCITY DATUM ELEVATION
C TRACE HEADER LENGTH 100 CODE RELEASE DATE/VERSION /
C IDENT TYPE WGC TRACE HEADER START TIME
C EARLIEST TIME OF FIRST SAMPLE -200
C CDF ACCEPTANCE RADIUS
C STATION RANGE FIRST 1 LAST 99999 INCREMENT 1
C GS VELOCITY 5000 100 5000 600 6000 1600 7500 2200 9000 3000 9700
C GS VELOCITY 5000 12000
C USER PROCESSING COMMENTS
C Z5419VE8V 14- 6-89 15.13.49 HA91
C RESIDUAL AMPLITUDE COMPENSATION
C Z575AVA2S 14- 6-89 15.46.08 HA91
C CASCADED FINITE DIFFERENCE MIGRATION
C END OF USER PROCESSING COMMENTS
C MAP PROJECTION PARAMETERS


I get red in the face asking my self who put this together. If you have enough brains to process seismic data why don't you have enough brains to put together a 1/2 decent EBCDIC header. I mean . . . I'll go on to other things.  I mean, why do they repeat everything?  Hardly any byte locations, no loading info, no projection information, no grid.  I guess how WGC gets you on phone paying for more gobbledygook.  I mean - cell size?  lat/longs or X/Ys?  Sorry.

When we take a look at the trace headers next which have their troubles.  Instead of putting lat/long some sort of XY in 73-76/77-80 or 81-84/85-88 they put "something" in 81-84/85-88 as an X/Y.  Here's what I have for line WB-737 sp 1400:

Sesimic File:
77 1705911 25580523

Navigation File:
70.27954 -146.46993 519965  7796959

Then there's a number in there 2949120 (181-185) and 3473408 (189-192).  Of source there's no description of what those number are is.

Maybe I might be able to figure out how to create a proper coordinate file to match things up.  Let me work on it.

Tied To The Master Grid

Messing with grids today.  Pretty interesting.  Just remembering how to create grids in SMT and view them in Surfer. Let's get going as to what SMT thinks grids are all about. They know more about it than me.

Well, what is a grid? A grid is a rectangular mesh that has interpolated values in them. Two types:


Data Adaptive:  data is outputted to specific locations from a weighted combo of predefined values.
  • Flex Grid - Usually the FlexGrid is used because of its fast and give you pretty much what you're after.
  • Gradient Projection - The Gradient Projection is best if you're making 3D horizon maps.
  • Inverse Distance to a Power - Use the Inverse Distance to a Power when you have sparce values (velocity data, 2d horizons). Cannot estimate highs and lows between locations.
Mathematical Model:  does not used specified values.  Fits a mathematical surface to the data and then interpolated the values.  Give you smooth values and look great.  Looks are not always good.  You have to represent what the underground looks like.
  • Cubic Spline - Good when areas are over or under shot.  You can't do faulting.
The cell size is the most important part of gridding.  It's all about interpolating.  Once you go a few cell points outside the data, the software's guessing.  You don't want that.  Find other regional trends in those missing areas.

Wednesday, August 31, 2011

Essential Links

Free Seismic
  • USGS - from my uneducated experience, lots of scattered 2D seismic/nav/images.  A little bit of 3D to add a little flavor.
  • UTIG - lots of seismic,mainly marine stuff.  Offers a lots more bundled seismic/nav zip files when you put in a request.  Lots of data.
  • COCORP (Consortium for Continental Reflection Profiling) - a handful of seismic by US state (that I've looked at so far).
Navigation Stuff
  • APSalin - tons of navigational stuff.  Convert this to that.  Stuff to drool over.
  • UTM Conversion - this spreadsheet rocks!  A direct link to the spreadsheet brought to you by somebody to University of Wisconsin.
  • RCN - Lots of Lat/Long conversions.
Random Virtual Dust (But Very Essential)

Tools at my disposal

Just a quick list of tool I have at my disposal.  All free stuff collected off the web.
  • SeisSee - Excellent SEG-Y viewing software.  Modify the headers, EBCDIC, and binary headers.
  • OpendTect - Free opensource seismic interpretation software.
  • Excel - You know what that is.
  • Notepad++ - Excellent text editor.  You can do "a lot" on this one.  Forget notepad.exe (yuck!).
  • GoogleEarth - I have not formed an opinion on this one yet.
  • DNR Garmin - I'm still getting to know this one.  Converts shapefiles and kml files to stuff and back again.
  • ShapeViewer - Interesting little tool that loads shapefiles where you view and export them to xls.  You can additionally get summary from the shapefile.
  • Surfer (Demo Version) - Good for QC stuff.  It can handle more rows than Excel ever will.  I can live with the Demo version.  Shhhhh.  Don't tell Golden that.
  • ArcGIS Explorer - I'm kind of mixing on this one.  The standalone program doesn't like my video card so I have to use the online version of the software.  The online version has its limitation regarding importing those files.  If I want to do that, I have to use my wife desktop (grrr).

First day on the Underground

This is just a test. This is my underground world of seismic data. All data shown here is publicly available data from this or that place.  You can find it if you google it.  Don't go getting lawyered up.

This stuff discussed on this blog are my ramblings about seismic data, SEG-Y, navigation, velocities, googleearth, ArcGIS, and coordinates.  I mainly discuss my trails and tribulations of learning how to use this stuff to discover what-all's supposed to be going on beneath the earth.