⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coda.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.trinet.jasi;
import java.util.*;
import org.trinet.jasi.coda.*;
import org.trinet.jdbc.datatypes.*;
import org.trinet.util.*;

/**
 * A generic Coda object.
 */
abstract public class Coda extends JasiReading {

/** Describes the coda type, duration type, phase characteristics.  */
     public CodaPhaseDescriptor descriptor;                // maps to TN schema Coda.codaType, Coda.durType, Coda.iphase

/** Coda duration calculated from P-wave onset  (e.g. use q,a fitting 60mv cutoff ampi). */
    public DataDouble tau = new DataDouble();

/** Coda termination time  - used to calculate tau as tau = tCodaTerm - tPPhase */
    public DataDouble tCodaTerm = new DataDouble();

/** Coda log(amp)-log(tau) line fit parameter when slope (q) is fixed and tau = 1. */
    public DataDouble aFix = new DataDouble();

/** Coda line slope parameter determined by best fit of known calibration set of
    earthquake qFree data for known magnitudes. */
    public DataDouble qFix = new DataDouble();

/** Coda log(amp)-log(tau) line fit parameter when slope (q) is free and tau =
    1. */
    public DataDouble aFree = new DataDouble();

/** Coda line slope parameter determined by least absolute residual line fit of
    single events windowed time amp data. */
    public DataDouble qFree = new DataDouble();

/** Weight assigned by the operator or the waveform analysis algorithm.
* Estimate can be used to assign weights in summary mangnitude calculations.
* Value should be between 0.0 and 1.0.
*/
    public DataDouble  weightIn = new DataDouble(); // maps to TN schema Coda.quality and AssocCoM.in_wgt

/** Mininum residual difference from calculated fit of the observed amplitude time window data. */
//    public DataDouble  residual = new DataDouble();       // maps to TN schema Coda.rms

/** Size of the time window used for averaging amplitude, in seconds. */
    public DataDouble  windowSize = new DataDouble();     // derived from algorithm; NEED to map to a Coda table attribute called WINDOW

// Actual or estimated P-wave arrival time at station.
// protected DataDouble datetimeP = this.dateTime;        // aliased, calc or join AssocArO and Arrival where Phase=P; NEED to map to a Coda table attribute called DATETIME

/** Actual or estimated seconds difference between the S-arrival and P-arrival. */
    public DataDouble timeS = new DataDouble();     // calc or join AssocArO and Arrival where Phase = S

/** Algorithm name used to calculate derived coda values to be cached/stored. */
    public DataString algorithm = new DataString(); // NEED to map to a Coda table attribute called ALGORITHM

/** Collection of time and amplitude value pairs for time window. */
    protected ArrayList windowTimeAmpPairs = new ArrayList();  //  time and average rectified amp of window used in calculation
// Window start times measured relative to start of coda.
//    protected ArrayList windowTimes = new ArrayList();  //  time of window maps to Trinet schema Coda.time1 etc.
// Amplitude values associated with corresponding window times.
//    protected ArrayList windowAmps = new ArrayList();  //  average rectified amp at associated windowTime maps to Coda.amp1 etc.

/** Number of sample windows used to calculate the coda fit parameters. */
    public DataLong windowCount = new DataLong();   // maps to Coda.nsample in TN schema

/** Units of amplitude */
    public DataString ampUnits = new DataString();  // maps to Coda.units in TN schema

/** Estimated error of window amplitude in the same units as Amplitude itself. */
    public DataDouble uncertainty = new DataDouble();  // maps to Coda.eramp in TN schema

/**
* ChannelMag data member stores calculated channel coda magnitude,
* its weight contribution to the summary magnitude relative to other channels, and
* the difference between the summary coda magnitude and the channel magnitude.
*/
    protected ChannelMag channelMag = new ChannelMag(); // maps to AssocCoM table in TN schema
 // NEED to map channelMag.value to AssocCoM attribute called MAG
 // NEED to map channelMag.residual to AssocCoM attribute called MAGRES
 // NEED to map channelMag.correction to AssocCoM attribute called MAGCORR

/** Network magnitude associated with this Coda. */
    protected Magnitude magnitude ;

/**
* Default constructor is protected, so you must instantiate an instance with create().
* @see #create()
* @see #create(int)
* @see #create(String)
*/
    protected Coda() {} // protected access forces general users to use create() method.

// ////////////////////////////////////////////////////////////////////////////
    /**
     * Instantiate an object of this type. You do
     * NOT use a constructor. This "factory" method creates various
     * concrete implementations. Creates a Solution of the DEFAULT type.
     * @See: JasiObject
     */
     public static final Coda create() {
	return create(DEFAULT);
     }

    /**
     * Instantiate an object of this type. You do
     * NOT use a constructor. This "factory" method creates various
     * concrete implementations. The argument is an integer implementation type.
     * @See: JasiObject
     */
     public static final Coda create(int schemaType) {
        return create(JasiFactory.suffix[schemaType]);
     }

    /**
     * Instantiate an object of this type. You do
     * NOT use a constructor. This "factory" method creates various
     * concrete implementations. The argument is as 2-char implementation suffix.
     * @See: JasiObject
     */
     public static final Coda create(String suffix) {
	return (Coda) JasiObject.newInstance("org.trinet.jasi.Coda", suffix);
     }
// ////////////////////////////////////////////////////////////////////////////

/**
*  Return a string describing Coda data.
*/
    public String toString() {
        StringBuffer sb = new StringBuffer(1024);
        sb.append(idString());
        sb.append("\n");
        sb.append(inParmsString());
        sb.append("\n");
        sb.append(outParmsString());
        sb.append(magParmsString());
        sb.append("\n");
        sb.append(windowDataString());
        return sb.toString();
    }

    public static double Weight_HI2Jiggle(int IN_iWeight)
    {
      if(IN_iWeight == 0)
        return(1.0);
      else if(IN_iWeight == 1)
        return(0.75);
      else if(IN_iWeight == 2)
        return(0.5);
      else if(IN_iWeight == 3)
        return(0.25);
      else
        return(0.0);
    }

    public static int Weight_Jiggle2HI(double IN_dWeight)
    {
      if(IN_dWeight > 0.87)
        return(0);
      else if(IN_dWeight > .62)
        return(1);
      else if(IN_dWeight > .37)
        return(2);
      else if(IN_dWeight > .12)
        return(3);
      else
        return(4);
    }


    protected String windowDataString() {
        return windowTimeString() + "\n fit" + windowAmpString();
    }

    protected String windowTimeString() {
        if (windowTimeAmpPairs == null) return "";
        int count = windowTimeAmpPairs.size();
        if ( count == 0) return "";
        StringBuffer sb = new StringBuffer(16 * count);
        sb.append(" WindowTimes: ");
        for (int idx = 0; idx < count; idx++) {
            sb.append(((TimeAmp) ((ArrayList) windowTimeAmpPairs).get(idx)).getTime()).append(" ");
        }
        return sb.toString();
    }

    protected String windowAmpString() {
        if (windowTimeAmpPairs == null) return "";
        int count = windowTimeAmpPairs.size();
        if ( count == 0) return "";
        StringBuffer sb = new StringBuffer(12 * count);
        sb.append(" WindowAmps: ");
        for (int idx = 0; idx < count; idx++) {
            sb.append(((TimeAmp) ((ArrayList) windowTimeAmpPairs).get(idx)).getAmp()).append(" ");
        }
        return sb.toString();
    }

    public double [] getWindowTimes() {
        TimeAmp [] ta = (TimeAmp []) windowTimeAmpPairs.toArray(new TimeAmp [windowTimeAmpPairs.size()]);
        int size = ta.length;
        if (size == 0) return null;
        double [] retVal = new double [size];
        for (int idx = 0; idx < size; idx++) {
           retVal[idx] = ta[idx].getTime();
        }
        return retVal;
    }

    public double [] getWindowAmps() {
        TimeAmp [] ta = (TimeAmp []) windowTimeAmpPairs.toArray(new TimeAmp [windowTimeAmpPairs.size()]);
        int size = ta.length;
        if (size == 0) return null;
        double [] retVal = new double [size];
        for (int idx = 0; idx < size; idx++) {
           retVal[idx] = ta[idx].getAmp();
        }
        return retVal;
    }

    public Collection getWindowTimeAmpPairs() {
       return windowTimeAmpPairs;
    }

/** *  Return a summary string with the most important id info.
*/
    public String idString() {
        StringBuffer sb = new StringBuffer(128);
        if (isDeleted()) sb.append("*DEL* ");
        sb.append(getChannelObj().toDelimitedString(' ')).append(" ");
        if(descriptor != null) sb.append(descriptor.toString());
        if (sol != null) sb.append(" Sol id: ").append(sol.id.toStringSQL());
        if (magnitude != null) sb.append(" Mag id: ").append(magnitude.magid.toStringSQL());
        return sb.toString();
    }

/**
*  Return a string describing channel waveform phase parameters
*/
    protected String inParmsString() {
        StringBuffer sb = new StringBuffer(256);
        sb.append(" dist: ").append(getChannelObj().dist.toString());
        sb.append(" az: ").append(getChannelObj().azimuth.toString());
        sb.append(" PTime: ").append(getDateTime().toString());
        sb.append(" S-P: ").append(timeS.toString());
        sb.append("\n  ");
        sb.append(" ampU: ").append(ampUnits.toString());
        sb.append(" ampErr: ").append(uncertainty.toString());
        return sb.toString();
    }

/**
*  Return a string describing channel waveform coda decay fit parameters

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -