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

📄 ml.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

            if (debug) System.out.println ("DELETE: off scale " +
                    amp[i].getChannelObj().toDelimitedSeedString());

            amp[i].delete();
            changed = true;
*/

        }
        return changed;
    }

    /** Examine the Amp list AFTER the waveforms are scanned and cull out any
    * channels you don't what to use or keep. You have three choices:<br>
    * 1) Use amp in the mag calc. and write to the dbase<br>
    * 2) Don't use it in mag but save it. These are given a weight of 0.0 but
    * can potentially contribute to future calibrations.<br>
    * 3) Don't use or save it (throw it out completely).<br>
    * Returns 'true' if the list is changed by the scan. */
    public boolean postScanAmpList (Magnitude mag) {

      // NOTE: 2 type of rejection:
      //  1) amps we want to save for future calibration (delete from mag)
      //  2) amps we do NOT want to save for future calibration (delete from origin)

      boolean changed = false;
      String str = "";

      // distance trim
      changed = trimByDistance(mag);

//      Amplitude amp[] = mag.ampList.getArray();
      Amplitude amp[]  = mag.ampList.getGood();  // don't get zero wt'ed amps
      for (int i=0; i<amp.length; i++) {

        if (amp[i].getWeight() > 0.0) { // don't review already 0 wt'ed amps

          if (!amp[i].isOnScale() ) {

            if (debug) System.out.println ("DELETE: off scale " +
                amp[i].getChannelObj().toDelimitedSeedString());

            // expunge the CLIPPED amp, its ccrrraap
            amp[i].delete();
            changed = true;

          }

          if (amp[i].getWeight() > 0.0) {  // Optimization step: only test if it would be used.

            // Exceeds max channels
            if (i >= getMaxChannels()) {

              if (debug)System.out.println ( "NO-USE: exceeds maxChannels " +
                  amp[i].getChannelObj().toDelimitedSeedString());

              amp[i].setWeight(0.0);
              changed = true;

              // corrections are required and there is none for this channel
              } else if (getRequireCorrection() &&
                         (!amp[i].hasCorrection() && !amp[i].isCorrected()) ) {

                if (debug) System.out.println ( "NO-USE: no correction " +
                    amp[i].getChannelObj().toDelimitedSeedString());

                amp[i].setWeight(0.0);
                changed = true;

                // SNR too low
              } else if (amp[i].snr.doubleValue() < getMinSNR()) {

                if (debug) System.out.println ( "NO-USE: low SNR " +
                    amp[i].getChannelObj().toDelimitedSeedString());

                amp[i].setWeight(0.0);
                changed = true;

              }

          } // end if (amp[i].getWeight() > 0.0)
        }
       }

  // trim by residual and redo if needed. Must do this as 2nd pass because
  // residuals are only available after 1st pass.
// Replaced with Chauvenet's
//	if  (getTrimResidual() != Double.MAX_VALUE) changed = trimByResidual (mag);
       changed = changed || chauvenetTrim(mag);

       return changed;
    }

    /** Trim outliers and recalculate the mag. Amps with residuals greater then
    * that set in setTrimResidual() have their weights set to 0.0.
    * Returns 'true' if the list is changed by the scan. */
    public boolean trimByResidual (Magnitude mag) {
        return trimByResidual (mag, getTrimResidual());

    }

    /** Trim outliers and recalculate the mag. Amps with residuals greater then
    * the given value have their weights set to 0.0.
    * Returns 'true' if the list is changed by the scan. */
    public boolean trimByResidual (Magnitude mag, double trimValue) {

       boolean changed = false;

       if  (trimValue == Double.MAX_VALUE) return false;      // no trimResidual value set

//       Amplitude amp[]  = mag.ampList.getArray();
       Amplitude amp[]  = mag.ampList.getGood();  // don't get zero wt'ed amps
//       double magList[] = new double[amp.length];

       /** Trim outliers */
       for (int i=0; i<amp.length; i++) {
           if (Math.abs(amp[i].channelMag.residual.doubleValue()) > trimValue) {
            // expunge the amp, its ccrrraap
//            mag.removeAmp(amp[i]);
            amp[i].setWeight(0.0);
//            amp[i].delete();
            changed = true;

            if (debug) System.out.println ("REJECT: big residual " +
                       amp[i].getChannelObj().toDelimitedSeedString());
     }
       }
       return changed;
    }

    /** Trim outliers using Chauvenet's criterion. Returns 'true' if mags were
    trimmed and 'false' if not.
    @see: Chauvenet*/
    public boolean chauvenetTrim(Magnitude mag) {

       boolean changed = false;

       if (mag.ampList.size() < 1) return changed;

//       Amplitude amp[]  = mag.ampList.getArray();
       Amplitude amp[]  = mag.ampList.getGood();  // don't get zero wt'ed amps

       double magv[] = new double[amp.length];

       // get a simple list of mags
       for (int i=0; i<amp.length; i++) {
           magv[i] = amp[i].channelMag.value.doubleValue();
       }
       double mean = Stats.mean(magv);
       double std  = Stats.standardDeviation(magv);
       double stdDevsAway;

       /** Trim outliers */
       for (int i=0; i<magv.length; i++) {
           stdDevsAway = (mean - magv[i])/std;
           if (Chauvenet.reject(stdDevsAway, magv.length)) {

            // expunge the amp, its ccrrraap
//            mag.removeAmp(amp[i]);
            amp[i].setWeight(0.0);
//            amp[i].delete();
            changed = true;

            if (debug) System.out.println ("REJECT: Chauvenet outlier " +
                       amp[i].getChannelObj().toDelimitedSeedString() +
                       " mag = "+amp[i].channelMag);
           }
       }
       return changed;
    }


  /* Configuration Methods */
  /** Default configuration mode.  Configure the magnitude engine. (presumably
      with hardcoded defaults)
   **************************************/
  public void ConfigureMagnitudeMethod()
  {
  }

  /** Catch-all configuration method
       iConfigurationSource, specifies the source of configuration
         information (DB, file, string),
       sConfigurationLocation could be a filename, DB URL, etc.
       sConfigurationSection could be a DB table, portion of a file, etc.
   *********************************************************************/
  public void ConfigureMagnitudeMethod(int iConfigurationSource,
                                                String sConfigurationLocation,
                                                String sConfigurationSection
                                               )
 {
 }


    // ///////////////////////////////////////////////////////////////////
    // test
    public static void main (String args[])
    {
  MagnitudeMethod ml = MagnitudeMethod.CreateMagnitudeMethod("org.trinet.jasi.ML");
  System.out.println ("-- Ricther MLs --");
  System.out.println ("Should be  3.56 -> " + ml.getValue( 31.8, 18.945));
  System.out.println ("Should be  3.78 -> " + ml.getValue( 71.4,  9.491));
  System.out.println ("Should be  1.10 -> " + ml.getValue( 22.9,  0.125));
  System.out.println ("Should be  3.96 -> " + ml.getValue(252.6,  1.437));
  System.out.println ("Should be  2.17 -> " + ml.getValue( 62.5,  0.148));

  ml = MagnitudeMethod.CreateMagnitudeMethod("org.trinet.jasi.ML");
  System.out.println ("-- Socal MLs --");
  System.out.println ("Should be  3.56 -> " + ml.getValue( 31.8, 18.945));
  System.out.println ("Should be  3.78 -> " + ml.getValue( 71.4,  9.491));
  System.out.println ("Should be  1.10 -> " + ml.getValue( 22.9,  0.125));
  System.out.println ("Should be  3.96 -> " + ml.getValue(252.6,  1.437));
  System.out.println ("Should be  2.17 -> " + ml.getValue( 62.5,  0.148));
    }

} // ML





⌨️ 快捷键说明

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