/* JRG, the Resource Geology Seismic Processing System for Java, and Viewmat for Java are Copyright 1998-2000 by John N. Louie The software and methods here are the subject of academic research, not commercial products. I would like to know what use you make of my methods, and have your feedback on their success or failure. Also, by letting me know who you are, I can inform you if bugs or errors are discovered. Please send me an email message with: your name and email address; whether you are a student or faculty member, consultant or employee; the name of your university or company, and department; and a sentence or two describing what use you intend to make of these methods. Send your message to louie@seismo.unr.edu */ import java.io.*; public class RgFileHead { public int ntrace; /* no. of traces in file */ public int nt; /* no. of samples per trace */ public float starttime; /* time after source initiation of 1st sample, seconds */ public float dt; /* time sample interval, seconds */ public static final int RGFILEHEADBYTES = 16; /* Constructor */ public RgFileHead() { dt = 1F; } /* Construct a copy */ public RgFileHead(RgFileHead fhd) { ntrace = fhd.ntrace; nt = fhd.nt; starttime = fhd.starttime; dt = fhd.dt; } /* Construct a file header from FltPlane properties */ public RgFileHead(FltPlane fp) { ntrace = fp.vecs; nt = fp.getNMembofDim(0); starttime = fp.getUnit0ofDim(0); dt = fp.getDUnitofDim(0); } public void copySEGYFileHead(SEGYFileHead fhd) { copySEGYFileHead(fhd, 1); } public void copySEGYFileHead(SEGYFileHead fhd, int planes) { fhd.regularize(); this.ntrace = fhd.ntrace*planes; this.nt = fhd.getnt(); this.dt = fhd.mudt/1e6F; this.starttime = 0F; } public void copySEGYFileHead(SEGYFileHead fhd, int planes, SEGYTraceHead thd) { thd.regularize(); copySEGYFileHead(fhd, planes); this.starttime = thd.delay/1e3F; } public void copyOldRGFileHead(OldRGFileHead ofhd) { this.ntrace = ofhd.ntrace; this.nt = ofhd.nt; this.starttime = ofhd.starttime; } public String toString() { return "ntrace=" + ntrace + " nt=" + nt + " starttime=" + Viewmat.getSignif("" + starttime) + " dt=" + Viewmat.getSignif("" + dt); } public boolean isValid() { if (ntrace < 1 || ntrace > 1000000000 || nt < 1 || nt > 1000000000 || starttime < -1e10F || starttime > 1e10F || dt < -1e10F || dt > 1e10F || dt == 0F) return false; return true; } public void readRgFileHead(String name) { FileInputStream fis = null; BufferedInputStream bis = null; DataInputStream dis = null; System.out.println("readRgFileHead: reading header from file " + name + " ... "); try {fis = new FileInputStream(name); } catch(FileNotFoundException fnf) { System.out.println(fnf.toString()); return; } bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); try {read(dis); } catch(IOException ioe) { System.out.println("Could not read RG header from file " + name); return; } try {fis.close(); } catch(IOException ioe) { System.out.println(ioe.toString()); return; } System.out.println("readRgFileHead done."); } public void read(DataInputStream dis) throws IOException { ntrace = dis.readInt(); nt = dis.readInt(); starttime = dis.readFloat(); dt = dis.readFloat(); } public void write(DataOutputStream dos) throws IOException { dos.writeInt(ntrace); dos.writeInt(nt); dos.writeFloat(starttime); dos.writeFloat(dt); } }