/* JRG, the Resource Geology Seismic Processing System for Java, and Viewmat for Java are Copyright 1998-2007 by John N. Louie License is hereby granted for anyone to make any use of this software and its associated source and compiled binary codes, including free re-distribution, and incorporation into commercial products, provided this copyright notice is retained within all files, versions, and distribution media substantially incorporating John Louie's original work. 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.util.*; import java.io.*; import java.lang.Math; import java.net.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.applet.Applet; class testplane { public static void main(String args[]) { int i; FltPlane fltplane = new FltPlane(210, 1000); fltplane.readBinaryFile("test.flt", 0); float rms = fltplane.rms(); fltplane.viewinFrame("test.flt", true, (0.001F*2000F/2F)/15.24F, RgCtab.rwb, false, 3F*rms); FltPlane fp = new FltPlane(100, 178); fp.readBinaryFile("dixie-migvels", 0); fp.addc(-(fp.min())); fp.viewinFrame("dixie-migvels", false, 1F, RgCtab.yglobe, true, -1F); } } public class FltPlane extends FltVec { public int ne; public int vecs; public String VecUnits; public float Vec0; public float DVec; public Viewmat fpviewmat; public RgHead headers[]; public boolean geogr; public static Menu makeMethodsMenu(FltVol fvol) { Menu methods = new Menu("On Each Vector", true); methods.add(new MenuItem("agc")); methods.add(new MenuItem("ale")); methods.add(new MenuItem("autocor")); methods.add(new MenuItem("bpfilter")); methods.add(new MenuItem("conv2to3d")); methods.add(new MenuItem("ctr")); if (fvol == null) methods.add(new MenuItem("cutTime")); if (fvol == null) methods.add(new MenuItem("decimate")); methods.add(new MenuItem("demult")); methods.add(new MenuItem("despike")); methods.add(new MenuItem("differentiate")); if (fvol == null) methods.add(new MenuItem("dipfil")); methods.add(new MenuItem("fixCoords")); methods.add(new MenuItem("hann")); if (fvol == null) methods.add(new MenuItem("mirror")); if (fvol == null) methods.add(new MenuItem("pad")); methods.add(new MenuItem("powerspectra")); if (fvol == null) methods.add(new MenuItem("reduceT")); methods.add(new MenuItem("rev")); methods.add(new MenuItem("setHeader")); if (fvol == null) methods.add(new MenuItem("shade")); methods.add(new MenuItem("slant")); if (fvol == null) methods.add(new MenuItem("smooth")); if (fvol == null) methods.add(new MenuItem("sort")); if (fvol == null) methods.add(new MenuItem("stackHits")); methods.add(new MenuItem("sweep")); methods.add(new MenuItem("sweepTrig")); methods.add(new MenuItem("tegain")); methods.add(new MenuItem("tracedit")); if (fvol == null) methods.add(new MenuItem("vspect")); if (fvol == null) methods.add(new MenuItem("window")); methods.add(new MenuItem("xcor")); if (fvol == null) methods.add(new MenuItem("xcorInterf")); /* Add new FltPlane methods below: */ return methods; } public static void handleMethod(ViewmatFrame f, boolean inplace, String label) { f.setCursor(Cursor.WAIT_CURSOR); boolean redimension; redimension = false; boolean clipmax; clipmax = true; String title = f.vm.title + " + " + label; ViewmatAction vad = new ViewmatAction(f); vad.beginPanel(); if (label.equals("agc")) FltPlane.agcPanel(vad, f, inplace, label); else if (label.equals("ale")) FltPlane.alePanel(vad, f, inplace, label); else if (label.equals("autocor")) FltPlane.autocorPanel(vad, f, inplace, label); else if (label.equals("bpfilter")) FltPlane.bpfilterPanel(vad, f, inplace, label); else if (label.equals("conv2to3d")) FltPlane.conv2to3dPanel(vad, f, inplace, label); else if (label.equals("ctr")) FltPlane.ctrPanel(vad, f, inplace, label); else if (label.equals("cutTime")) { inplace = false; FltPlane.cutTimePanel(vad, f, inplace, label); } else if (label.equals("decimate")) { inplace = false; FltPlane.decimatePanel(vad, f, inplace, label); } else if (label.equals("demult")) { inplace = false; redimension = true; FltPlane.demultPanel(vad, f, inplace, label); } else if (label.equals("despike")) FltPlane.despikePanel(vad, f, inplace, label); else if (label.equals("differentiate")) FltPlane.differentiatePanel(vad, f, inplace, label); else if (label.equals("dipfil")) FltPlane.dipfilPanel(vad, f, inplace, label); else if (label.equals("fixCoords")) { inplace = true; FltPlane.fixCoordsPanel(vad, f, inplace, label); } else if (label.equals("hann")) FltPlane.hannPanel(vad, f, inplace, label); else if (label.equals("mirror")) FltPlane.mirrorPanel(vad, f, inplace, label); else if (label.equals("pad")) { inplace = false; FltPlane.padPanel(vad, f, inplace, label); } else if (label.equals("powerspectra")) { inplace = false; redimension = true; FltPlane.powerspectraPanel(vad, f, inplace, label); } else if (label.equals("reduceT")) { inplace = false; FltPlane.reduceTPanel(vad, f, inplace, label); } else if (label.equals("rev")) FltPlane.revPanel(vad, f, inplace, label); else if (label.equals("setHeader")) { inplace = true; FltPlane.setHeaderPanel(vad, f, inplace, label); } else if (label.equals("shade")) FltPlane.shadePanel(vad, f, inplace, label); else if (label.equals("slant")) { inplace = false; redimension = true; FltPlane.slantPanel(vad, f, inplace, label); } else if (label.equals("smooth")) FltPlane.smoothPanel(vad, f, inplace, label); else if (label.equals("sort")) { inplace = true; FltPlane.sortPanel(vad, f, inplace, label); } else if (label.equals("stackHits")) { inplace = false; FltPlane.stackHitsPanel(vad, f, inplace, label); } else if (label.equals("sweep")) { inplace = false; redimension = true; FltPlane.sweepPanel(vad, f, inplace, label); } else if (label.equals("sweepTrig")) { inplace = false; redimension = true; FltPlane.sweepTrigPanel(vad, f, inplace, label); } else if (label.equals("tegain")) FltPlane.tegainPanel(vad, f, inplace, label); else if (label.equals("tracedit")) FltPlane.traceditPanel(vad, f, inplace, label); else if (label.equals("vspect")) { Class haveReMi = null; try { haveReMi = Class.forName("ReMi"); } catch (ClassNotFoundException cnfe) { haveReMi = null; } if (haveReMi == null) { f.Errout("ReMi not licensed to this system.\n" + "Please contact John N. Louie at louie@seismo.unr.edu\n" + "for licensing information."); vad.dispose(); f.setCursor(Cursor.DEFAULT_CURSOR); return; } else { inplace = false; ReMi.vspectPanel(vad, f, inplace, label); } } else if (label.equals("window")) { inplace = false; FltPlane.windowPanel(vad, f, inplace, label); } else if (label.equals("xcor")) FltPlane.xcorPanel(vad, f, inplace, label); else if (label.equals("xcorInterf")) FltPlane.xcorInterfPanel(vad, f, inplace, label); /* Add new FltPlane methods below: */ if (inplace) vad.setTitle(label + " on " + f.getTitle() + " in-place"); else vad.setTitle(label + " on " + f.getTitle() + " to new window"); Button apply = new Button(label); vad.pp.add(apply); apply.addActionListener(vad); vad.finishPanel(); f.setCursor(Cursor.DEFAULT_CURSOR); vad.center(); vad.show(); if (vad.done == false) { vad.dispose(); return; } f.setCursor(Cursor.WAIT_CURSOR); FltPlane fp = null; FltPlane ofp = null; FltPlane tfp = null; FltVol fvol = null; MethodRun mrun = null; if (vad.noticeonly == true) { if (f.vm.fvol == null) fp = f.vm.fp; else fp = f.vm.fvol; } else if (inplace) { if (f.vm.fvol == null) { ofp = f.vm.fp; fp = new FltPlane(f.vm.fp, f.vm.fp.vec); } else { ofp = f.vm.fvol; fp = new FltPlane(f.vm.fvol, f.vm.fvol.vec); } } else { if (!redimension) { if (f.vm.fvol == null) { mrun = new MethodRun(f.vm.fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, f.vm.positive, f.vm.clip); ofp = mrun.fp; fp = new FltPlane(mrun.fp, mrun.fp.vec); } else { mrun = new MethodRun(f.vm.fvol, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, f.vm.positive, f.vm.clip); ofp = mrun.fvol; fp = new FltPlane(mrun.fvol, mrun.fvol.vec); } } } if (label.equals("agc")) { fp.doagc(vad); clipmax = false; } else if (label.equals("ale")) fp.doale(vad); else if (label.equals("autocor")) fp.autocor(); else if (label.equals("bpfilter")) fp.dobpfilter(vad); else if (label.equals("conv2to3d")) fp.doconv2to3d(vad); else if (label.equals("ctr")) fp.ctr(); else if (label.equals("cutTime")) { tfp = fp.docutTime(vad); ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; } else if (label.equals("decimate")) { tfp = fp.dodecimate(vad); ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; } else if (label.equals("demult")) { if (f.vm.fvol == null) fp = f.vm.fp.demult(); else fp = f.vm.fvol.demult(); mrun = new MethodRun(fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, f.vm.positive, f.vm.clip); } else if (label.equals("despike")) fp.dodespike(vad); else if (label.equals("differentiate")) fp.dodifferentiate(vad); else if (label.equals("dipfil")) fp.dodipfil(vad); else if (label.equals("fixCoords")) fp.dofixCoords(vad); else if (label.equals("hann")) fp.dohann(vad); else if (label.equals("mirror")) fp.domirror(vad); else if (label.equals("pad")) { tfp = fp.dopad(vad); mrun = new MethodRun(tfp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, f.vm.positive, f.vm.clip); } else if (label.equals("powerspectra")) { if (f.vm.fvol == null) { fp = new FltPlane(f.vm.fp, f.vm.fp.vec); fp.dopowerspectra(vad); mrun = new MethodRun(fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, RgCtab.yglobe, true, fp.max()); } else { fvol = new FltVol(f.vm.fvol, f.vm.fvol.vec); fvol.dopowerspectra(vad); mrun = new MethodRun(fvol, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, RgCtab.yglobe, true, fvol.max()); } } else if (label.equals("reduceT")) { tfp = fp.doreduceT(vad); ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; } else if (label.equals("rev")) fp.rev(); else if (label.equals("setHeader")) fp.dosetHeader(vad); else if (label.equals("shade")) { fp.doshade(vad); clipmax = true; /* f.vm.positive = true; f.vm.ctab = RgCtab.gray; */ } else if (label.equals("slant")) { if (f.vm.fvol == null) fp = f.vm.fp.doslant(vad); else fp = f.vm.fvol.doslant(vad); mrun = new MethodRun(fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, f.vm.positive, f.vm.clip); } else if (label.equals("smooth")) fp.dosmooth(vad); else if (label.equals("sort")) fp.dosort(vad); else if (label.equals("stackHits")) { tfp = fp.dostackHits(vad); if (tfp == null) { vad.dispose(); f.setCursor(Cursor.DEFAULT_CURSOR); return; } ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; } else if (label.equals("sweep")) { if (f.vm.fvol == null) fp = f.vm.fp.dosweep(vad); else fp = f.vm.fvol.dosweep(vad); mrun = new MethodRun(fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, false, fp.max()); } else if (label.equals("sweepTrig")) { if (f.vm.fvol == null) fp = f.vm.fp.dosweepTrig(vad); else fp = f.vm.fvol.dosweepTrig(vad); mrun = new MethodRun(fp, f.fd.getDirectory(), title, f.vm.rowsdown, f.vm.ve, f.vm.ctab, false, fp.max()); } else if (label.equals("tegain")) { fp.tegain(); clipmax = false; } else if (label.equals("tracedit")) fp.dotracedit(vad); else if (label.equals("vspect")) { tfp = ReMi.dovspectSum(fp, vad); ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; mrun.rowsdown = false; mrun.ve = 2.5F*ofp.ne/ofp.vecs/4.2F; mrun.positive = true; mrun.clip = 2.5F /*ofp.max()*/; mrun.ctab = RgCtab.yglobe; } else if (label.equals("window")) { tfp = fp.dowindow(vad); ofp.vec = new float[tfp.vec.length]; ofp.copyvals(tfp); fp.copyvals(tfp); ofp.copyvec(tfp); tfp.vec = null; tfp = null; } else if (label.equals("xcor")) fp.doxcor(vad); else if (label.equals("xcorInterf")) fp.doxcorInterf(vad); /* Add new FltPlane methods below: */ if (vad.noticeonly == true) { vad.dispose(); f.setCursor(Cursor.DEFAULT_CURSOR); return; } vad.dispose(); if (!redimension) ofp.copyvals(fp); if (inplace) { f.setTitle(title); f.props.setTitle(title + " Properties"); f.picks.setTitle(title + " Picks"); f.geom.setTitle(title + " Geometry"); f.vm.titletf.setText(title); f.vm.cvs.vmat.title = new String(title); f.vm.cvs.zoom(f.vm.fzoom); f.vm.resetPropsPanel(f.props, f.props.pp); f.vm.setParameters(f.props, f.props.pp); if (f.vm.fvol == null) { if (!clipmax) f.vm.cvs.vmat.clip = 3*f.vm.fp.rms(); f.vm.fp.replotinFrame(f); } else { if (!clipmax) f.vm.cliptf.setText("3*rms"); f.props.applyChanges(); } } else { if (!clipmax) mrun.clip = 3F*fp.rms(); /* altered 3/1/06 JNL to workaround MacOS 10.4 bug thanks to Leiph Preston! new Thread(mrun).start(); */ mrun.run(); } f.setCursor(Cursor.DEFAULT_CURSOR); return; } /* put implementations of new FltPlane methods below: */ public void agc(int Window, boolean Detect, int DetectWindow, float Threshold) { Notice("FltPlane.agc: gaining " + this.vecs + " vectors of " + this.ne + " elements by L1 norm of " + Window + "-element moving" + " window; Detect=" + Detect + "... "); for (int j=0; j 1000*this.ne) temp = nw; nw = temp; try {temp = Integer.valueOf(vad.tf1.getText()).intValue(); } catch (NumberFormatException nfe) {temp = ndel; } if (temp < 0) temp = -temp; if (temp < 0 || temp > 1000*this.ne) temp = ndel; ndel = temp; try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = alpha; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F) htemp = alpha; alpha = htemp; icon = vad.cb0.getState(); try {htemp = Float.valueOf(vad.tf3.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = beta; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F) htemp = beta; beta = htemp; try {htemp = Float.valueOf(vad.tf4.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = eps; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F) htemp = eps; eps = htemp; this.ale(nw, ndel, icon, alpha, beta, eps); } static void autocorPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "\n" + "The " + label + " method on class FltPlane data\n" + "separately computes the autocorrelation of\n" + "each trace, without any scaling.", 5, 35); vad.pp.add(vad.expl); } public void autocor() { Noticeln("Autocorrelating " + this.vecs + " vectors of " + this.ne + " elements each..."); for (int j=0; j nvec-1) temp = nvec-1; index = temp; Noticeln("Cross-correlating " + this.vecs + " vectors of " + this.ne + " elements each against trace at index " + index + " ... "); FltPlane trace = new FltPlane(1, this.ne); trace.setNoticeOn(false); trace.windowof(this, index, 1, 0, 1); for (int j=0; j 1) fp.nv = fp.vec.length/fp.getNMembofDim(2)/fp.ne; */ fp.AmpUnits = new String(this.AmpUnits); fp.ElemUnits = new String(this.VecUnits); fp.VecUnits = new String(this.ElemUnits); fp.Amp0 = this.Amp0; fp.AmpFac = this.AmpFac; fp.Elem0 = this.Vec0; fp.DElem = this.DVec; fp.Vec0 = this.Elem0; fp.DVec = this.DElem; fp.f = this.f; for (j=0; j max) max = val; } for (k=i+ SpikeWidth; k max) max = val; } for (k=i; k Factor*max) isspike = true; else { isspike = false; break; } } if (isspike) { for (k=i; k 1e28F) htemp = 1e28F; Factor = htemp; int itemp; try {itemp = Integer.valueOf(vad.tf2.getText()).intValue(); } catch (NumberFormatException nfe) {itemp = SampleInterval; } if (itemp < 2) itemp = 2; else if (itemp > this.ne/3) itemp = this.ne/3; SampleInterval = itemp; try {itemp = Integer.valueOf(vad.tf1.getText()).intValue(); } catch (NumberFormatException nfe) {itemp = SpikeWidth; } if (itemp > SampleInterval) itemp = SampleInterval/2; if (itemp < 1) itemp = 1; SpikeWidth = itemp; this.despike(Factor, SpikeWidth, SampleInterval); } /* J. Louie, 2007 */ public void differentiate() { differentiate(getDUnitofDim(0)); } public void differentiate(float Dt) { int ix, iy, nx, ny; nx = this.ne; ny = this.vecs; float fdx, sdx; if (Dt == 0F) { Noticeln("differentiate: Dt=" + Dt + " is zero, must abort."); return; } /* obtain space for buffer array */ float buf[] = new float[nx]; Notice("differentiate: finite-differencing along " + ny + " vectors of " + nx + " elements each with Dt=" + Dt + "... "); for (iy=0; iy 1) nx = this.getNMembofDim(1); boolean mode; mode = RejectLow; float rho,freq,alpha,pi,b,ac; rho = DipCut; freq = Freq; int ptm1,pt,qtm1,qt,rhs,temp; /* obtain space for arrays and initialize array pointers */ float ptv[] = new float[nx*5]; pt = 0; ptm1 = pt + nx; qt = ptm1 + nx; qtm1 = qt + nx; rhs = qtm1 + nx; /* calculate constants */ pi = 3.14159265F; alpha = 4F * pi * freq * rho * rho; ac = -1F; b = alpha + 2F; /**************/ /* dip filter */ /**************/ Notice("dipfil: dip-filtering " + np + " planes of " + nx + " vectors of " + nt + " elements each with DipCut=" + DipCut + " Freq=" + Freq + " RejectLow=" + RejectLow + "... "); for (ip=0; ip= 0; i--) xv[x+i] = xv[f+i] - xv[e+i] * xv[x+i+1]; } static void dipfilPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { float DipCut, Freq; boolean RejectLow; DipCut = 1F/f.vm.ve; Freq = 0.1F; RejectLow = false; vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "\n" + "The " + label + " method on class FltPlane data\n" + "irreversibly dip-filters across all vectors\n" + "with Dave Hale's x-t domain method. Since it\n" + "requires evenly spaced traces it ignores any trace headers.\n" + "Parameters below:\n" + "Dip Cut dip-cutoff (3db point) in samples/trace (pos. float).\n" + " (default is at 45 degrees based on vertical " + "exaggeration of plot.)\n" + "Frequency is frequency in cycles/sample at which " + "a dip of rho is attenuated by 3db (Nyquist = .5) (pos. float).\n" + " (This value should be the dominate frequency of " + "the phases most needing filtering, estimated from the data.)\n" + "High-dip reject is the default; check Reject Low Dip " + "for the reverse effect.", 5, 35); vad.pp.add(vad.expl); vad.lab0 = new Label("Dip Cut (samples/trace, pos. float):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("" + DipCut, 8); vad.pp.add(vad.tf0); vad.lab1 = new Label("Dom. Freq. (cycles/sample, >0, <0.5): "); vad.pp.add(vad.lab1); vad.tf1 = new TextField("" + Freq, 8); vad.pp.add(vad.tf1); vad.cb0 = new Checkbox("Reject Low Dip?"); vad.pp.add(vad.cb0); vad.cb0.setState(RejectLow); vad.lab2 = new Label("(Reject high dips if not checked.)"); vad.pp.add(vad.lab2); } public void dodipfil(ViewmatAction vad) { float DipCut, Freq; boolean RejectLow; DipCut = 1F/vad.f.vm.ve; Freq = 0.1F; RejectLow = false; float htemp; try {htemp = Float.valueOf(vad.tf0.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = DipCut; } if (htemp < 0F) htemp = -htemp; DipCut = htemp; try {htemp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = Freq; } if (htemp > 0.5F) htemp = Freq; if (htemp < 0F) htemp = -htemp; Freq = htemp; RejectLow = vad.cb0.getState(); this.dipfil(DipCut, Freq, RejectLow); } static void fixCoordsPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { vad.noticeonly = true; vad.expl = new TextArea(label + " of " + f.getTitle() + "\n" + "Always in-place.\n" + "The " + label + " method on class FltPlane data\n" + "will alter trace-header geometry values,\n" + "and re-calculate all offsets. Offsets will be fully 3-D", 5, 35); vad.pp.add(vad.expl); RgHead hd, headers[]; if (f.vm.fvol == null) { vad.lab3 = new Label(f.vm.fp.getOffsets()); headers = f.vm.fp.headers; vad.geogr = f.vm.fp.geogr; } else { vad.lab3 = new Label(f.vm.fvol.getOffsets()); headers = f.vm.fvol.headers; vad.geogr = f.vm.fvol.geogr; } if (headers == null) { vad.lab0 = new Label("This FltPlane has no headers."); vad.pp.add(vad.lab0); return; } hd = new RgHead(headers[0]); vad.lab0 = new Label("Multiply Coordinates By:"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("1.0", 6); vad.pp.add(vad.tf0); vad.lab1 = new Label("Multiply Elevations By:"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("1.0", 6); vad.pp.add(vad.tf1); vad.lab2 = new Label("Present Offset Range:"); vad.pp.add(vad.lab2); vad.pp.add(vad.lab3); vad.cb0 = new Checkbox("Coords will be Lat/Lon Degrees?"); vad.pp.add(vad.cb0); vad.cb0.setState(vad.geogr); } public void dofixCoords(ViewmatAction vad) { double temp, lscl, coscl; int i; boolean geogr; if (this.headers == null) return; try {temp = Float.valueOf(vad.tf0.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = 1.0; } coscl = temp; try {temp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = 1.0; } lscl = temp; geogr = vad.cb0.getState(); this.geogr = geogr; for (i=0; i0.0, <=1.0):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("1.0", 4); vad.pp.add(vad.tf0); vad.lab1 = new Label("Rise (float, >=0.0, <0.5):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("0.05", 4); vad.pp.add(vad.tf1); vad.cb0 = new Checkbox("Taper Across Traces?"); vad.pp.add(vad.cb0); vad.cb0.setState(false); } public void dohann(ViewmatAction vad) { float temp, portion, rise; portion = 1F; rise = 0.05F; try {temp = Float.valueOf(vad.tf0.getText()).floatValue(); } catch (NumberFormatException nfe) { Errout("hann: Cannot taper with portion of " + vad.tf0.getText() + " - must be a positive float <= 1.0."); return; } if (temp <= 0F || temp > 1F) { Errout("hann: Cannot taper with portion of " + vad.tf0.getText() + " - must be a positive float <= 1.0."); return; } portion = temp; try {temp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) { Errout("hann: Cannot taper with rise of " + vad.tf1.getText() + " - must be a positive float < 0.5."); return; } if (temp < 0F || temp >= 0.5F) { Errout("hann: Cannot taper with rise of " + vad.tf1.getText() + " - must be a positive float < 0.5."); return; } rise = temp; this.hann(portion, rise, vad.cb0.getState()); } public void mirror() { mirror(0, this.vecs-1); } public void mirror(int v0, int vf) { float buf1[]; buf1 = new float[ne]; RgHead hdbuf = new RgHead(); int i, j, itemp, nvm; if (v0 > vf) { itemp = v0; v0 = vf; vf = itemp; } if (v0 < 0) v0 = 0; if (vf > this.vecs-1) vf = this.vecs-1; nvm = vf-v0+1; Notice("FltPlane.mirror: reversing the order of " + nvm + " vectors within " + this.vecs + " of " + this.ne + " elements... "); /*for (j=0; j vf) { itemp = v0; v0 = vf; vf = itemp; } if (v0 < 0) v0 = 0; if (vf > nx-1) vf = nx - 1; this.mirror(v0, vf); } public FltPlane pad(int pad) { int ne, nv; nv = this.vecs; ne = this.ne + pad; FltPlane fp = new FltPlane(nv, ne); fp.copyvals(this); fp.ne = ne; for (int k=0; k 1e10) temp = 0; pad = temp; return this.pad(pad); } public void rev() { float buf1[]; buf1 = new float[ne]; int i, j; Notice("FltPlane.rev: reversing the order of " + this.ne + " elements in " + this.vecs + " vectors... "); for (j=0; j= this.headers.length) { Errout("setHeader: Trace header index=" + vad.tf0.getText() + "\nnot between 0 and " + (this.headers.length -1) + ", no values changed."); return; } RgHead hd = new RgHead(this.headers[ind]); try {dtemp = Integer.valueOf(vad.tf1.getText()).intValue(); } catch (NumberFormatException nfe) {dtemp = hd.rec; } if (ind < 0) dtemp = hd.rec; hd.rec = dtemp; try {dtemp = Integer.valueOf(vad.tf2.getText()).intValue(); } catch (NumberFormatException nfe) {dtemp = hd.svp; } hd.svp = dtemp; try {dtemp = Integer.valueOf(vad.tf3.getText()).intValue(); } catch (NumberFormatException nfe) {dtemp = hd.gvp; } hd.gvp = dtemp; try {temp = Float.valueOf(vad.tf4.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.sx; } hd.sx = temp; try {temp = Float.valueOf(vad.tf5.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.sy; } hd.sy = temp; try {temp = Float.valueOf(vad.tf6.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.sz; } hd.sz = temp; try {temp = Float.valueOf(vad.tf7.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.gx; } hd.gx = temp; try {temp = Float.valueOf(vad.tf8.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.gy; } hd.gy = temp; try {temp = Float.valueOf(vad.tf9.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.gz; } hd.gz = temp; try {temp = Float.valueOf(vad.tf10.getText()).floatValue(); } catch (NumberFormatException nfe) {temp = hd.off; } hd.off = temp; hd.allset = true; this.headers[ind].copy(hd); hd.print(System.out); } static void checkHeader(ViewmatAction vad) { RgHead hd, headers[]; if (vad.f.vm.fvol == null) headers = vad.f.vm.fp.headers; else headers = vad.f.vm.fvol.headers; if (headers == null) { vad.lab0.setText("This FltPlane has no headers."); return; } int ind = 0; try {ind = Integer.valueOf(vad.tf0.getText()).intValue(); } catch (NumberFormatException nfe) {ind = -1; } if (ind < 0 || ind >= headers.length) { (vad.f.vm.fvol == null ? vad.f.vm.fp : vad.f.vm.fvol).Errout( "setHeader: Trace header index=" + vad.tf0.getText() + "\nnot between 0 and " + (headers.length -1) + ", showing index 0."); vad.tf0.setText("0"); ind = 0; } hd = new RgHead(headers[ind]); vad.tf1.setText("" + hd.rec); vad.tf2.setText("" + hd.svp); vad.tf3.setText("" + hd.gvp); vad.tf4.setText(Viewmat.getSignif("" + hd.sx)); vad.tf5.setText(Viewmat.getSignif("" + hd.sy)); vad.tf6.setText(Viewmat.getSignif("" + hd.sz)); vad.tf7.setText(Viewmat.getSignif("" + hd.gx)); vad.tf8.setText(Viewmat.getSignif("" + hd.gy)); vad.tf9.setText(Viewmat.getSignif("" + hd.gz)); vad.tf10.setText(Viewmat.getSignif("" + hd.off)); } public RgFileHead makeRgFileHead() { RgFileHead fhd = new RgFileHead(); fhd.ntrace = this.vecs; fhd.nt = this.ne; fhd.starttime = this.getUnit0ofDim(0); fhd.dt = this.getDUnitofDim(0); return fhd; } public RgHead makeRgHead(int itrace) { RgHead hd = new RgHead(); hd.rec = (int)(itrace/getNMembofDim(1)) + 1; /* field record number */ hd.svp = hd.rec; /* source location number */ hd.gvp = itrace - getNMembofDim(1)*(hd.rec-1) + 1; /* receiver location number */ hd.sx = getUnit0ofDim(2) + (hd.svp-1)*getDUnitofDim(2); /* source x-coordinate, m */ hd.sy = 0; /* source y-coordinate, m */ hd.sz = 0; /* source z-coordinate, m */ hd.gx = getUnit0ofDim(1) + (hd.gvp-1)*getDUnitofDim(1); /* receiver x-coordinate, m */ hd.gy = 0; /* receiver y-coordinate, m */ hd.gz = 0; /* receiver z-coordinate, m */ hd.off = hd.gx; /* offset, m, may be signed */ hd.allset = false; return hd; } /* J. Louie, 2006 */ public void shade(float SunAzim, float SunHeight, float Dx, float Dy) { int ix, iy, ip, nx, ny, np, planesamp; nx = this.ne; ny = this.vecs; np = this.getNMembofDim(2); if (np > 1) ny = this.getNMembofDim(1); float fdx, fdy, fdz, sdx, sdy, sdz, intens, mag; /* obtain space for buffer array */ planesamp = nx*ny; float buf[] = new float[planesamp]; Notice("shade: generating shaded-relief of " + np + " planes of " + ny + " vectors of " + nx + " elements each with SunAzim=" + SunAzim + " SunHeight=" + SunHeight + " Dx=" + Dx + " Dy=" + Dy + "... "); SunAzim = SunAzim*(float)(Math.PI)/180F; SunHeight = SunHeight*(float)(Math.PI)/180F; /* compute vector to sun angle */ sdz = (float)(Math.sin((double)(SunHeight))); mag = (float)(Math.sqrt((double)(1 - sdz*sdz))); sdx = (-1F)*mag*(float)(Math.sin((double)(SunAzim))); sdy = mag*(float)(Math.cos((double)(SunAzim))); for (ip=0; ip0, <90):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("" + SunHeight, 4); vad.pp.add(vad.tf1); vad.lab2 = new Label("Dx (pos. float):"); vad.pp.add(vad.lab2); vad.tf2 = new TextField("" + Dx, 5); vad.pp.add(vad.tf2); vad.lab3 = new Label("Dy (pos. float):"); vad.pp.add(vad.lab3); vad.tf3 = new TextField("" + Dy, 5); vad.pp.add(vad.tf3); } public void doshade(ViewmatAction vad) { float SunAzim, SunHeight, Dx, Dy; SunAzim = 315F; SunHeight = 45F; if (f.vm.fvol == null) { if (f.vm.rowsdown) { Dx = f.vm.fp.getDUnitofDim(1); Dy = f.vm.fp.getDUnitofDim(0); } else { Dx = f.vm.fp.getDUnitofDim(0); Dy = f.vm.fp.getDUnitofDim(1); } } else { if (f.vm.rowsdown) { Dx = f.vm.fvol.getDUnitofDim(1); Dy = f.vm.fvol.getDUnitofDim(0); } else { Dx = f.vm.fvol.getDUnitofDim(0); Dy = f.vm.fvol.getDUnitofDim(1); } } if (Dx == 0F) Dx = 1F; if (Dy == 0F) Dy = 1F; if (Dx < 0F) Dx = -Dx; if (Dy < 0F) Dy = -Dy; float htemp; try {htemp = Float.valueOf(vad.tf0.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = SunAzim; } SunAzim = htemp; try {htemp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = SunHeight; } if (htemp < 0F) htemp = -htemp; if (htemp > 90F) htemp = 90F; SunHeight = htemp; try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = Dx; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F) htemp = 1F; Dx = htemp; try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = Dy; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F) htemp = 1F; Dy = htemp; SunAzim = SunAzim%360F; if (SunAzim < 0F) SunAzim = 360F + SunAzim; if (f.vm.rowsdown) { if (SunAzim > 270F) SunAzim = 630F - SunAzim; else SunAzim = 270F - SunAzim; htemp = Dx; Dx = Dy; Dy = htemp; } this.shade(SunAzim, SunHeight, Dx, Dy); } public FltPlane slant(float t0, float dt, float x0, float dx, float tau0, int ntau, float p0, int np, float dp, boolean scale) { int nt, noff; nt = this.ne; noff = this.vecs; float starttime; starttime = t0; int it, nit, taddr, iptdrop, ip, ix, itau0, scl, sclv[], pscl, ps, s, tr; float fhld, ppts[], drop, offset, a; int istarttime, ihld; if (headers == null) Notice("slant: slantstacking " + noff + " vectors of " + nt + " elements each with t0=" + t0 + " dt=" + dt + " x0=" + x0 + " dx=" + dx + " tau0=" + tau0 + " ntau=" + ntau + " p0=" + p0 + " np=" + np + " dp=" + dp + " scale=" + scale + "... "); else Notice("slant: slantstacking " + noff + " labeled traces of " + nt + " samples each with t0=" + t0 + " dt=" + dt + " " + getOffsets() + " tau0=" + tau0 + " ntau=" + ntau + " p0=" + p0 + " np=" + np + " dp=" + dp + " scale=" + scale + "... "); itau0 = (int)(tau0/dt); ppts = new float[np]; tr = 0; /* index of this.vec[0*nt + 0] */ FltPlane sfp = new FltPlane(np, ntau); s = 0; /* index of sfp.vec[0*ntau + 0] */ scl = 0; /* index of sclv[0*ntau + 0] */ sclv = null; pscl = 0; if (scale) sclv = new int[np*ntau]; /* find all p - values */ for (ip = 0; ip < np; ip++) ppts[ip] = p0 + ip * dp; /* stack each trace into tau - p wavefield */ for(ix=0; ix= itau0+ntau) continue; if (istarttime >= itau0) { ps = s + ip*ntau + istarttime-itau0; if (scale) pscl = scl + ip*ntau + istarttime-itau0; taddr = 0; nit = itau0+ntau >= istarttime+nt ? nt-1 : itau0+ntau-istarttime-1; } else { ps = s + ip*ntau; if (scale) pscl = scl + ip*ntau; taddr = itau0 - istarttime; nit = itau0+ntau >= istarttime+nt ? nt-(itau0-istarttime)-1 : ntau-1; } if (scale) { for(it=0; it 1) sfp.vec[ps] /= (float)(sclv[pscl]); ps++; pscl++; } } ppts = null; sfp.setUnitsofDim(0, "Intercept Time, s"); sfp.setUnit0ofDim(0, tau0); sfp.setDUnitofDim(0, dt); sfp.setUnitsofDim(1, "Slowness, sec/meter"); sfp.setUnit0ofDim(1, p0); sfp.setDUnitofDim(1, dp); sfp.setAmpUnits("Slantstacked " + this.getAmpUnits()); Noticeln("Done."); return sfp; } static void slantPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { float t0, dt, x0, dx, tau0, p0, dp; int ntau, np; boolean scale; RgHead headers[]; if (f.vm.fvol == null) { t0 = f.vm.fp.getUnit0ofDim(0); dt = f.vm.fp.getDUnitofDim(0); x0 = f.vm.fp.getUnit0ofDim(1); dx = f.vm.fp.getDUnitofDim(1); ntau = f.vm.fp.ne; np = f.vm.fp.vecs; headers = f.vm.fp.headers; } else { t0 = f.vm.fvol.getUnit0ofDim(0); dt = f.vm.fvol.getDUnitofDim(0); x0 = f.vm.fvol.getUnit0ofDim(1); dx = f.vm.fvol.getDUnitofDim(1); ntau = f.vm.fvol.ne; np = f.vm.fvol.vecs; headers = f.vm.fvol.headers; } tau0 = t0; p0 = 0F; dp = 0.01F/np; /* sec/meter */ scale = false; vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "The " + label + " method on class FltPlane data\n" + "computes the slantstack (or p-tau transform)\n" + "across all vectors\n" + "Parameters below:\n" + "t0=0: data start time, s\n" + "dt=0.004: time between samples, s\n" + "If traces are labeled with headers, the offset is used;\n" + "otherwise supply the following:\n" + " x0=0: distance of first vector, m\n" + " dx=1: distance between vectors, m\n" + "ntau=nt: number of elements in intercept time for stack\n" + "dtau=dt\n" + "tau0=0: initial intercept time\n" + "np=nx: number of slowness vectors\n" + "p0=0: first p slowness, s/m\n" + "dp=0.01/np: slowness interval, s/m\n" + "scale=false: no scaling applied to slantstack\n" + " true: apply scaling by averaging values summed\n" + " into slantstack", 5, 35); vad.pp.add(vad.expl); vad.lab0 = new Label("t0 (sec):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("" + t0, 4); vad.pp.add(vad.tf0); vad.lab1 = new Label("dt (sec):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("" + dt, 6); vad.pp.add(vad.tf1); if (headers == null) { vad.lab2 = new Label("x0 (meter):"); vad.pp.add(vad.lab2); vad.tf2 = new TextField("" + x0, 4); vad.pp.add(vad.tf2); vad.lab3 = new Label("dx (meter):"); vad.pp.add(vad.lab3); vad.tf3 = new TextField("" + dx, 4); vad.pp.add(vad.tf3); } else { vad.lab2 = new Label("Labeled Traces:"); vad.pp.add(vad.lab2); if (f.vm.fvol == null) vad.lab3 = new Label(f.vm.fp.getOffsets()); else vad.lab3 = new Label(f.vm.fvol.getOffsets()); vad.pp.add(vad.lab3); } vad.lab4 = new Label("tau0 (sec):"); vad.pp.add(vad.lab4); vad.tf4 = new TextField("" + tau0, 4); vad.pp.add(vad.tf4); vad.lab5 = new Label("p0 (s/m):"); vad.pp.add(vad.lab5); vad.tf5 = new TextField("" + p0, 6); vad.pp.add(vad.tf5); vad.lab6 = new Label("dp (s/m):"); vad.pp.add(vad.lab6); vad.tf6 = new TextField("" + dp, 6); vad.pp.add(vad.tf6); vad.lab7 = new Label("ntau (+int):"); vad.pp.add(vad.lab7); vad.tf7 = new TextField("" + ntau, 4); vad.pp.add(vad.tf7); vad.lab8 = new Label("np (+int):"); vad.pp.add(vad.lab8); vad.tf8 = new TextField("" + np, 4); vad.pp.add(vad.tf8); vad.cb0 = new Checkbox("scale?"); vad.pp.add(vad.cb0); vad.cb0.setState(scale); vad.height = 400; } public FltPlane doslant(ViewmatAction vad) { float t0, dt, x0, dx, tau0, p0, dp; int ntau, np; boolean scale; if (f.vm.fvol == null) { t0 = f.vm.fp.getUnit0ofDim(0); dt = f.vm.fp.getDUnitofDim(0); x0 = f.vm.fp.getUnit0ofDim(1); dx = f.vm.fp.getDUnitofDim(1); ntau = f.vm.fp.ne; np = f.vm.fp.vecs; } else { t0 = f.vm.fvol.getUnit0ofDim(0); dt = f.vm.fvol.getDUnitofDim(0); x0 = f.vm.fvol.getUnit0ofDim(1); dx = f.vm.fvol.getDUnitofDim(1); ntau = f.vm.fvol.ne; np = f.vm.fvol.vecs; } tau0 = t0; p0 = 0F; dp = 0.01F/np; /* sec/meter */ scale = false; float htemp; int temp; try {htemp = Float.valueOf(vad.tf0.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = t0; } t0 = htemp; try {htemp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = dt; } if (htemp < 0F) htemp = -htemp; dt = htemp; if (this.headers == null) { try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = x0; } x0 = htemp; try {htemp = Float.valueOf(vad.tf3.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = dx; } dx = htemp; } try {htemp = Float.valueOf(vad.tf4.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = tau0; } tau0 = htemp; try {htemp = Float.valueOf(vad.tf5.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = p0; } p0 = htemp; try {htemp = Float.valueOf(vad.tf6.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = dp; } dp = htemp; try {temp = Integer.valueOf(vad.tf7.getText()).intValue(); } catch (NumberFormatException nfe) {temp = ntau; } if (temp <= 0) temp = ntau; ntau = temp; try {temp = Integer.valueOf(vad.tf8.getText()).intValue(); } catch (NumberFormatException nfe) {temp = np; } if (temp <= 0) temp = np; np = temp; scale = vad.cb0.getState(); return this.slant(t0, dt, x0, dx, tau0, ntau, p0, np, dp, scale); } public void smooth(int xw, int tw, int norm) { int nx, nt, np; nt = this.ne; nx = this.vecs; np = this.getNMembofDim(2); if (np > 1) nx = this.getNMembofDim(1); int p, x, t, x1, t1, tad, addr, count, nxtrd; int readp, flag[], xwd, next; float hold, avbuf[], buf[], qbuf[], max; if (xw <= 0 || tw <= 0) { Errout("smooth: xw=" + xw + " and tw=" + tw + "; must be positive ints, no smoothing done"); return; } if (xw > nx) xw = nx; if (tw > nt) tw = nt; Notice("smooth: applying " + xw + "-vector by " + tw + "-element kernel, norm=" + norm + " on " + np + " planes of " + nx + " vectors of " + nt + " elements... "); this.setAmpUnits("" + xw + "x" + tw + "-Smoothed " + this.getAmpUnits()); xw = xw/2; xwd = 2*xw + 1; tw = tw/2; if (norm < 0 || norm > 2) { Errout("smooth: norm type " + norm + " not 0, 1, or 2, abort"); return; } buf = new float[xwd*nt]; qbuf = new float[xwd*(2*tw+1)]; avbuf = new float[nt]; flag = new int[xwd]; for (p=0; p=0 && tad < nt) { addr = x1*nt + tad; hold = buf[addr]; if (hold > max) { qbuf[count] = hold; max = hold; count++; } } } } } if (count > 2) avbuf[t] = qbuf[count/2]; else if (t > 0 && max != 0) avbuf[t] = avbuf[t-1]; else avbuf[t] = 0; } } else if (norm == 1) { for(t=0; t=0 && tad < nt) { addr = x1*nt + tad; qbuf[count] = buf[addr]; count++; } } } } avbuf[t] = FltVec.quant(count/2, qbuf, count); } } else { for(t=0; t=0 && tad < nt) { addr = x1*nt + tad; hold += buf[addr]; count++; } } } } if (count > 0) avbuf[t] = hold/count; else if (t > 0) avbuf[t] = avbuf[t-1]; else avbuf[t] = 0F; } } nxtrd += nt; next++; if (next >= xwd) { nxtrd = 0; next = 0; } System.arraycopy(avbuf, 0, this.vec, p*nx*nt + x*nt, nt); readp = x*nt + nt; } } /* end of loop over planes */ buf = null; qbuf = null; avbuf = null; flag = null; Noticeln("done."); } public void smooth() { smooth(1, 11, 0); } static void smoothPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { int xw, tw, norm; xw = 1; tw = 11; norm = 2; vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "The " + label + " method on class FltPlane data\n" + "smooths the amplitudes using an averaging\n" + "kernel of adjustable size.\n" + "Parameters are:\n" + "xw=1: width of averaging kernel across vectors,\n" + " will be made odd\n" + "tw=11 width of averaging kernel across elements\n" + " will be made odd\n" + "norm=2 2: uses L-2 norm (average)\n" + " 1: uses L-1 norm (median)\n" + " 0: uses a faster scheme that often\n" + " finds the median.", 5, 35); vad.pp.add(vad.expl); vad.lab0 = new Label("Kernel Vector Width (+ odd int):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("" + xw, 4); vad.pp.add(vad.tf0); vad.lab1 = new Label("Kernel Element Length (+ odd int):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("" + tw, 4); vad.pp.add(vad.tf1); vad.lab2 = new Label("Smoothing Operator:"); vad.pp.add(vad.lab2); vad.ch0 = new Choice(); vad.ch0.add("Fast Approx. Median"); vad.ch0.add("L-1 Norm (Median)"); vad.ch0.add("L-2 Norm (Average)"); vad.pp.add(vad.ch0); vad.ch0.select(2); } public void dosmooth(ViewmatAction vad) { int xw, tw, norm, temp; xw = 1; tw = 11; norm = 2; try {temp = Integer.valueOf(vad.tf0.getText()).intValue(); } catch (NumberFormatException nfe) {temp = xw; } if (temp == 0) temp = xw; if (temp < 0) temp = -temp; if (temp%2 == 0) temp++; xw = temp; norm = vad.ch0.getSelectedIndex(); try {temp = Integer.valueOf(vad.tf1.getText()).intValue(); } catch (NumberFormatException nfe) {temp = tw; } if (temp == 0) temp = tw; if (temp < 0) temp = -temp; if (temp%2 == 0) temp++; tw = temp; norm = vad.ch0.getSelectedIndex(); this.smooth(xw, tw, norm); } public void sort(int basis) { if (headers == null) { Errout("This FltPlane has no headers, sort aborted."); return; } if (basis < 0 || basis > 10) { Errout("Sort: basis=" + basis + " not between 0 and 10, aborted."); return; } Notice("Sorting " + vecs + " traces of " + ne + " elements each by basis " + basis + " ..."); RgHead tmphd = new RgHead(); float tmp[] = new float[ne]; quickSort(0, vecs-1, basis, tmphd, tmp); tmphd = null; tmp= null; Noticeln(" Done."); } public void quickSort(int left, int right, int basis, RgHead tmphd, float tmp[]) { int i, last; if (left >= right) return; swap(left, (left+right)/2, tmphd, tmp); last = left; for (i=left+1; i<=right; i++) if (compareHead(headers[i], headers[left], basis) == -1) swap( ++last, i, tmphd, tmp); swap(last, left, tmphd, tmp); quickSort(left, last-1, basis, tmphd, tmp); quickSort(last+1, right, basis, tmphd, tmp); } public static int compareHead(RgHead s, RgHead t, int basis) { int shold, thold; double sdhold, tdhold, sxmid, symid, txmid, tymid; if (basis == 0) /* Midpoint */ { sxmid = (s.gx + s.sx)/2; symid = (s.gy + s.sy)/2; txmid = (t.gx + t.sx)/2; tymid = (t.gy + t.sy)/2; sdhold = sxmid*sxmid + symid*symid; tdhold = txmid*txmid + tymid*tymid; if (sdhold < tdhold) return -1; else if (sdhold == tdhold) return 0; else return 1; } else if (basis >= 1 && basis <= 3) { if (basis == 1) /* Record */ { shold = s.rec; thold = t.rec; } else if (basis == 2) /* source location number */ { shold = s.svp; thold = t.svp; } else /* receiver location number */ { shold = s.gvp; thold = t.gvp; } if (shold < thold) return -1; else if (shold == thold) return 0; else return 1; } else { if (basis == 4) /* source x-coordinate */ { sdhold = s.sx; tdhold = t.sx; } else if (basis == 5) /* source y-coordinate */ { sdhold = s.sy; tdhold = t.sy; } else if (basis == 6) /* source z-coordinate */ { sdhold = s.sz; tdhold = t.sz; } else if (basis == 7) /* receiver x-coordinate */ { sdhold = s.gx; tdhold = t.gx; } else if (basis == 8) /* receiver y-coordinate */ { sdhold = s.gy; tdhold = t.gy; } else if (basis == 9) /* receiver z-coordinate */ { sdhold = s.gz; tdhold = t.gz; } else /* offset, m, may be signed */ { sdhold = s.off; tdhold = t.off; } if (sdhold < tdhold) return -1; else if (sdhold == tdhold) return 0; else return 1; } } public void swap(int d1, int d2, RgHead tmphd, float tmp[]) { int i; tmphd.copy(headers[d1]); headers[d1].copy(headers[d2]); headers[d2].copy(tmphd); for (i=0; i 0) { fp.hann((float)(2*taper*dt/len), 0.05F, false); fp.setAmpUnits("" + taper + "-Point Tapered " + f0 + "-" + fe + "-Hz Sweep"); } FltPlane tfp; if (listen > 0) { tfp = fp.pad(listen); fp = null; } else tfp = fp; Noticeln("done."); return tfp; } static void sweepPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { int nx, nt; float f0=8F, fe=48F, len=10F, phase=0F, dt; if (f.vm.fvol == null) { nx = f.vm.fp.vecs; nt = f.vm.fp.ne; dt = f.vm.fp.getDUnitofDim(0); } else { nx = f.vm.fvol.vecs; nt = f.vm.fvol.ne; dt = f.vm.fvol.getDUnitofDim(0); } len = nt*dt; vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "\n" + "The " + label + " method creates a new FltPlane object\n" + "of one or more (identical) vibrator sweep\n" + "traces, from the linear specifications below.", 5, 35); vad.pp.add(vad.expl); vad.lab0 = new Label("Number of Traces (+int):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("" + nx, 4); vad.pp.add(vad.tf0); vad.lab1 = new Label("Time Points per Sweep (+int):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("" + nt, 5); vad.pp.add(vad.tf1); vad.lab2 = new Label("Start Frequency, Hz (+flt):"); vad.pp.add(vad.lab2); vad.tf2 = new TextField("" + f0, 4); vad.pp.add(vad.tf2); vad.lab3 = new Label("End Frequency, Hz (+flt):"); vad.pp.add(vad.lab3); vad.tf3 = new TextField("" + fe, 4); vad.pp.add(vad.tf3); vad.lab4 = new Label("Sweep Length, seconds (+flt):"); vad.pp.add(vad.lab4); vad.tf4 = new TextField("" + len, 4); vad.pp.add(vad.tf4); vad.lab5 = new Label("Initial Phase, degrees (+/-flt):"); vad.pp.add(vad.lab5); vad.tf5 = new TextField("" + phase, 4); vad.pp.add(vad.tf5); vad.lab6 = new Label("Sweep Taper, samples (+int):"); vad.pp.add(vad.lab6); vad.tf6 = new TextField("0", 4); vad.pp.add(vad.tf6); vad.lab7 = new Label("Addl. Listen Time, samples (+int):"); vad.pp.add(vad.lab7); vad.tf7 = new TextField("" + nt, 5); vad.pp.add(vad.tf7); vad.height = 400; } public FltPlane dosweep(ViewmatAction vad) { int nx, nt, taper, listen, temp; float f0=8F, fe=48F, len=10F, phase=0F, htemp; if (vad.f.vm.fvol == null) { nx = vad.f.vm.fp.vecs; nt = vad.f.vm.fp.ne; } else { nx = vad.f.vm.fvol.vecs; nt = vad.f.vm.fvol.ne; } try {temp = Integer.valueOf(vad.tf0.getText()).intValue(); } catch (NumberFormatException nfe) {temp = nx; } if (temp < 0) temp = -temp; if (temp == 0 || temp > 1e20) temp = nx; nx = temp; try {temp = Integer.valueOf(vad.tf1.getText()).intValue(); } catch (NumberFormatException nfe) {temp = nt; } if (temp < 0) temp = -temp; if (temp == 0 || temp > 1e20) temp = nt; nt = temp; try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = f0; } if (htemp < 0F) htemp = -htemp; f0 = htemp; try {htemp = Float.valueOf(vad.tf3.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = fe; } if (htemp < 0F) htemp = -htemp; fe = htemp; try {htemp = Float.valueOf(vad.tf4.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = len; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F || htemp > 1e20F) htemp = len; len = htemp; try {htemp = Float.valueOf(vad.tf5.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = phase; } if (htemp < -1e20F || htemp > 1e20F) htemp = phase; phase = htemp; try {temp = Integer.valueOf(vad.tf6.getText()).intValue(); } catch (NumberFormatException nfe) {temp = 0; } if (temp < 0) temp = -temp; if (temp > nt) temp = 0; taper = temp; try {temp = Integer.valueOf(vad.tf7.getText()).intValue(); } catch (NumberFormatException nfe) {temp = nt; } if (temp < 0) temp = -temp; if (temp > 1e20) temp = nt; listen = temp; return this.sweep(nx, nt, f0, fe, len, phase, taper, listen); } static void sweepTrigPanel(ViewmatAction vad, ViewmatFrame f, boolean inplace, String label) { int nx, nt; float f0=100F, fe=500F, len=10F, phase=0F, dt; if (f.vm.fvol == null) { nx = f.vm.fp.vecs; nt = f.vm.fp.ne; dt = f.vm.fp.getDUnitofDim(0); } else { nx = f.vm.fvol.vecs; nt = f.vm.fvol.ne; dt = f.vm.fvol.getDUnitofDim(0); } nx /= 2; len = nt*dt; vad.expl = new TextArea(label + " of " + f.getTitle() + (inplace ? " in-place\n" : " in new window\n") + "\n" + "The " + label + " method creates a new FltPlane object\n" + "of one or more (identical) vibrator sweep\n" + "traces, alternating with traces containing\n" + "just a trigger pulse. This object can be written\n" + "as a sound file and played to control an\n" + "acoustic vibrator (left channel) and trigger a\n" + "seismograph (right channel).", 5, 35); vad.pp.add(vad.expl); vad.lab0 = new Label("Number of Stacks (+int):"); vad.pp.add(vad.lab0); vad.tf0 = new TextField("" + nx, 4); vad.pp.add(vad.tf0); vad.lab1 = new Label("Recorder Reset Time, sec. (+flt):"); vad.pp.add(vad.lab1); vad.tf1 = new TextField("0.5", 4); vad.pp.add(vad.tf1); vad.lab2 = new Label("Start Frequency, Hz (+flt):"); vad.pp.add(vad.lab2); vad.tf2 = new TextField("" + f0, 4); vad.pp.add(vad.tf2); vad.lab3 = new Label("End Frequency, Hz (+flt):"); vad.pp.add(vad.lab3); vad.tf3 = new TextField("" + fe, 4); vad.pp.add(vad.tf3); vad.lab4 = new Label("Sweep Length, seconds (+flt):"); vad.pp.add(vad.lab4); vad.tf4 = new TextField("" + ((len-0.5)/2), 4); vad.pp.add(vad.tf4); vad.lab5 = new Label("Trigger Length, seconds (+flt):"); vad.pp.add(vad.lab5); vad.tf5 = new TextField("0.05", 4); vad.pp.add(vad.tf5); vad.lab6 = new Label("Sweep Taper, seconds (+flt):"); vad.pp.add(vad.lab6); vad.tf6 = new TextField("" + ((len-0.5)/20), 5); vad.pp.add(vad.tf6); vad.lab7 = new Label("Addl. Listen Time, seconds (+flt):"); vad.pp.add(vad.lab7); vad.tf7 = new TextField("" + ((len-0.5)/2), 4); vad.pp.add(vad.tf7); vad.height = 400; } public FltPlane dosweepTrig(ViewmatAction vad) { int nx, nt, taper, listen, reset, trig, temp; float f0=8F, fe=48F, len=10F, ftaper, flisten, phase=0F, dt; float ftrig=0.02F, freset=0.5F, htemp; if (vad.f.vm.fvol == null) { nx = vad.f.vm.fp.vecs; nt = vad.f.vm.fp.ne; dt = f.vm.fp.getDUnitofDim(0); } else { nx = vad.f.vm.fvol.vecs; nt = vad.f.vm.fvol.ne; dt = f.vm.fvol.getDUnitofDim(0); } nx /= 2; len = (nx*dt - 0.5F)/2F; flisten = len; ftaper = len/20F; try {temp = Integer.valueOf(vad.tf0.getText()).intValue(); } catch (NumberFormatException nfe) {temp = nx; } if (temp < 0) temp = -temp; if (temp == 0 || temp > 1e20) temp = nx; nx = temp; try {htemp = Float.valueOf(vad.tf1.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = freset; } if (htemp < 0) htemp = -htemp; if (temp > 1000) htemp = freset; freset = htemp; try {htemp = Float.valueOf(vad.tf2.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = f0; } if (htemp < 0F) htemp = -htemp; f0 = htemp; try {htemp = Float.valueOf(vad.tf3.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = fe; } if (htemp < 0F) htemp = -htemp; if (htemp == f0 && f0 > 0F) htemp = 4F*f0; else if (htemp == f0 && f0 == 0F) htemp = 500F; fe = htemp; if (fe > f0) dt = 1/fe/2; else dt = 1/f0/2; reset = (int)(freset/dt); try {htemp = Float.valueOf(vad.tf4.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = len; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F || htemp > 1e9F) htemp = len; len = htemp; nt = (int)(len/dt); try {htemp = Float.valueOf(vad.tf5.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = ftrig; } if (htemp < 0F) htemp = -htemp; if (htemp == 0F || htemp > 1e9F) htemp = ftrig; ftrig = htemp; trig = (int)(ftrig/dt); try {htemp = Float.valueOf(vad.tf6.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = ftaper; } if (htemp < 0) htemp = -htemp; if (htemp > len/2F) htemp = ftaper; ftaper = htemp; taper = (int)(ftaper/dt); try {htemp = Float.valueOf(vad.tf7.getText()).floatValue(); } catch (NumberFormatException nfe) {htemp = flisten; } if (temp < 0) htemp = -htemp; if (temp > 1000F) htemp = len; flisten = htemp; listen = (int)(flisten/dt); FltPlane swp = this.sweep(1, nt, f0, fe, len, phase, taper, listen); FltPlane swtr = new FltPlane(2*nx, reset+swp.ne); swtr.copyvals(swp); swtr.vecs = 2*nx; swtr.ne = reset+swp.ne; for (int k=0; k= this.vecs) this.Errout("All traces in this data set have picks.\n" + "Check the text in the Pick Window.\n" + "The multiplier " + mult + " will be applied to " + (picked ? "all" : "none") + " of the " + this.vecs + " traces."); ViewmatPicks.tracedit(this, picked, mult); } public void readRGFile(String name, boolean oldrg) { int i, j; FileInputStream fis = null; BufferedInputStream bis = null; DataInputStream dis = null; try {fis = new FileInputStream(name); } catch(FileNotFoundException fnf) { Errout("RG file " + name + " not found: " + fnf.toString()); return; } bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); OldRGFileHead ofhd = new OldRGFileHead(); OldRGTraceHead othd = new OldRGTraceHead(); RgFileHead fhd = new RgFileHead(); RgHead thd = new RgHead(); headers = new RgHead[this.vecs]; if (oldrg) { try {ofhd.read(dis); } catch(IOException ioe) { Errout("Could not read 12-byte RG file header from\n" + name + " : " + ioe); return; } fhd.copyOldRGFileHead(ofhd); } else { try {fhd.read(dis); } catch(IOException ioe) { Errout("Could not read 16-byte RG file header from\n" + name + " : " + ioe); return; } } if (fhd.isValid() != true) { Errout("File " + name + "\ndoes not appear to have an RG file header:\n" + fhd); return; } if (fhd.ntrace < headers.length) { Errout("File " + name + "\ndoes not declare enough traces in the RG file header;" + headers.length + " needed:\n" + fhd); return; } if (fhd.nt != ne) { Errout("File " + name + "\ndeclares a different number of samples per trace in the RG file header;" + ne + " needed:\n" + fhd); return; } else if (fhd.ntrace > headers.length) { Noticeln("Warning: file " + name + "\ndeclares more traces in the RG file header than the " + headers.length + " now being read:\n" + fhd); } Noticeln("readRGFile: reading " + vecs + " traces of " + ne + " samples each from RG file " + name + " ... "); for (j=0; j 0) { raf.seek(0); raf.write(baos.toByteArray(), 0, bytes); } raf.close(); } catch(Exception e) { Errout("Could not write " + bytes + " file header bytes to file " + name + ":\n" + e.toString()); return; } Noticeln("done."); } public String getOffsets() { float min, max; if (headers == null) return "Vector0=" + Viewmat.getSignif("" + getUnit0ofDim(1)) + " " + getUnitsofDim(1) + " Vector" + (vecs-1) + "=" + Viewmat.getSignif("" + (getUnit0ofDim(1) + getDUnitofDim(1)*(vecs-1))) + " " + getUnitsofDim(1); else { min = (float)(headers[0].off); max = min; for (int i=1; i max) max = (float)(headers[i].off); if ((float)(headers[i].off) < min) min = (float)(headers[i].off); } return "Min. Offset=" + Viewmat.getSignif("" + min) + " m, Max. Offset=" + Viewmat.getSignif("" + max) + " m"; } } public void setElem(int Vec, int Elem, float val) { this.vec[Vec*this.ne + Elem] = val; } public float getElem(int Vec, int Elem) { return this.vec[Vec*this.ne + Elem]; } public void windowof(FltPlane fp, int v0, int dv, int e0, int de) { int i, j; Notice("windowof: windowing " + this.ne + " elements and " + this.vecs + " vectors from plane, with v0=" + v0 + " dv=" + dv + " e0=" + e0 + " de=" + de + "... "); for (j=0; j