import java.util.*; import java.io.*; import java.lang.Math; class SACieeetoShake { public static void main(String args[]) { FltPlane tfp; if (args.length != 1) { System.err.println("Usage: java -cp jrg.jar SACieeetoShake sacfile"); return; } String infile = args[0]; RgFileHead fhd = SACTraceHead.scanSACFile(infile, 1, false); if (fhd.ntrace < 1) { System.err.println("SACieeetoShake: cannot open " + infile + " as a SAC file, abort."); return; } FltPlane fp = new FltPlane(fhd.ntrace, fhd.nt); SACTraceHead.readSACFiletoFP(fp, infile, fhd, false); fp.setAmpUnits("Ground Velocity, meter/sec"); int decim = (int)(0.05/fhd.dt); if (decim > 1) { tfp = fp.decimate(1, decim); fp = tfp; fhd.dt *= decim; fhd.nt = fp.ne; } fp.conv2to3d(fhd.dt); fp.differentiate(fhd.dt); FileOutputStream fos = null; BufferedOutputStream bos = null; String outfile = infile + ".asc"; try { fos = new FileOutputStream(outfile); } catch(IOException ioe) { System.err.println("Can't create ascii Shake file " + outfile + "\nSAC file not converted, due to: " + ioe.toString()); return; } bos = new BufferedOutputStream(fos); writeShake(outfile, fp, fhd, bos); try { fos.close(); } catch(IOException ioe) { System.err.println("Can't close ascii Shake file " + outfile + ",\ndue to: " + ioe.toString()); } } public static void writeShake(String name, FltPlane fp, RgFileHead fhd, OutputStream out) { int i, j; String value; float val; float max = fp.max(); PrintStream p = new PrintStream(out); for (j=0; j1 ? (" trace " + (j+1) + " of " + fhd.ntrace) : "") + "; units: " + fp.getAmpUnits()); p.println("" + fhd.nt + " " + Viewmat.getSignif("" + fhd.dt, 6) + " " + Viewmat.getSignif("" + max, 8)); for (i=0; i -1e-3F) val = 0F; value = Viewmat.getSignif("" + val, 10); if (val >= 0F) value = "+" + value; while (value.length() < 12) value += " "; p.println(value); /* if ((i+1)%8 == 0) p.println(value); else p.print(value + " "); */ } p.println(""); p.flush(); } } }