The Linux box has Seismic Unix installed. A script listens for UDP broadcast telegrams and fetches data when available. Data is written to two files. One is called last-shot.su and keeps, as the name implies, data from the last GEODE shot. The other holds accumulated data, and the file name is identical to the file name on the GEODE laptop, except that file extension is *.su (it is in Seismic Unix format, see description here) instead of the original *.sgy. The program runs in terminal window>
read-GEODE.py terminal window output, showing UDP telegram from GEODE, on Linux box.
After file storage is completed the QC script (bash) called qc.sh is executed. This script uses Seismic Unix to make plots of interest. See program listing on this page.
Listing of QC/25July2005/read_GEODE.py. Download by right clicking here
1 #! /usr/bin/python 2 #===================================================================================== 3 # A r c t i c O c e a n T r a n s e c t - 2 0 0 5 4 # 5 # U S C G H E A L E Y 6 # 7 # 8 # Program listens for UDP telegrams on specified port. 9 # UDP telegram format: 10 # 11 # $PSHMES,<1>,<2>,<3>,<4>,<5> 12 # <1> = Vessel name 13 # <2> = ID string (e.g. type of data, to identify several GEODES 14 # <3> = Name of file where change was detected. 15 # NOTE: Filename must not contain "," 16 # <4> = Number of bytes 17 # <5> = * (termination) 18 # 19 # If matching conditions are met (proper ID string, and that GEODE datafile has *.sgy 20 # file extension), data is stored in Seismic Unix format in file "last-shot.su" and added 21 # to file with same name as GEODE laptop source file (except that *.sgy extension 22 # is replaced by *.su). Then QC shell script is started. 23 # 24 # University of Bergen, Dept. of Earth Science, Bergen, Norway 25 # http://www2.geo.uib.no/Healy-2005 26 # 27 # July 25, 2005 O. Meyer 28 #===================================================================================== 29 30 from socket import * 31 import string, time, sys, os 32 33 34 # ==== C O N S T A N T S ==== 35 36 PORT = 25000 # Port number, UDP telegrams from GEODE and TCP server on GEODE 37 DATA_TYPE = "STREAMER" # Type of data (case sensitive, must match value in UDP telegram) 38 39 40 # ==== S T A R T ==== 41 42 os.system("killall xgraph;killall ximage") 43 44 GPS_dgram_socket = socket( AF_INET, SOCK_DGRAM ) # Get UDP socket 45 GPS_dgram_socket.bind(('', PORT)) # BIND to address and port 46 print " Listening for UDP telegrams ..." 47 while True: 48 t,adr = GPS_dgram_socket.recvfrom(1000) # A blocking read ... 49 print "------------------------------------------" 50 print t # Print complete UDP telegram 51 s = t.split(',') 52 print "Data source: " + s[2] 53 print "From IP:",adr[0] 54 if ((len(s[4]) != 0) & (s[2] == DATA_TYPE)): # Was data of correct type, as specified by DATA_TYPE? 55 print " Match! GEODE file = " + s[3] + ", size = " + s[4] 56 host = adr[0] # Connect to TCP socket server on GEODE ... 57 s1 = socket(AF_INET, SOCK_STREAM) 58 s1.connect((host, PORT)) 59 fd = s1.makefile("r", 0) # Convert socket to file object 60 data = fd.read(int(s[4])) # and fetch data 61 fd.close() 62 s1.close() 63 64 if string.upper(s[3].split('.')[1]) != "SGY": # Was data from SEGY source? It should have *.sgy file extension (not case sensitive). 65 print "No *.sgy file extension - ignored" 66 else: 67 fd2 = open("tmp.sgy", "w") # Store data in temp file ... 68 fd2.write(data) 69 fd2.close() 70 71 # ------ Convert to Seismic Unix format and store in last_shot.su --- 72 os.system("segyread tape=tmp.sgy conv=0 endian=0 | segyclean > last_shot.su") 73 print " SU data written to file last_shot.su" 74 path = s[3].split('.')[0] + ".su" # Now prepare storage of accumulated data 75 if os.access(path, os.W_OK) != True: # Use same filename as on GEODE, does it exist already? 76 os.system("touch " + path) # No, create new file 77 print " New file! Created " + path 78 79 os.system("cat last_shot.su >> " + path) # Add data to file .. 80 print " Wrote data to " + path 81 82 os.system("./qc.sh " + path) # Execute QC script 83 84