Example #1
0
 /**
  * See https://bugs.launchpad.net/openquake/+bug/931453.
  *
  * <p>Tests that the SA Period Parameter's change listener is set properly.
  */
 @Test
 public void testResetSaPeriodParamEventListener() {
   ca03AttenRel.resetParameterEventListeners();
   ParameterAPI param = ca03AttenRel.getParameter(PeriodParam.NAME);
   List<ParameterChangeListener> listeners = param.getChangeListeners();
   assertEquals(1, listeners.size());
   assertEquals(ca03AttenRel, listeners.get(0));
 }
Example #2
0
 private void validateStdDev(String stdDevType, double[][] table) {
   String[] columnDescr = TABLE_HEADER_STD[0].trim().split("\\s+");
   // check for SA
   for (int i = 3; i < columnDescr.length - 1; i++) {
     for (int j = 0; j < table.length; j++) {
       double mag = table[j][0];
       double expectedStd = table[j][i];
       double computedStd = ca03AttenRel.getStdDev(i - 2, mag, stdDevType);
       assertEquals(expectedStd, computedStd, TOLERANCE);
     }
   }
   // check for PGA
   for (int j = 0; j < table.length; j++) {
     double mag = table[j][0];
     double expectedStd = table[j][columnDescr.length - 1];
     double computedStd = ca03AttenRel.getStdDev(0, mag, stdDevType);
     assertEquals(expectedStd, computedStd, TOLERANCE);
   }
 }
Example #3
0
 private void validateMedian(double[][] table) {
   String[] columnDescr = TABLE_HEADER_MEDIAN[0].trim().split("\\s+");
   // check for SA
   for (int i = 3; i < columnDescr.length - 1; i++) {
     System.out.println(columnDescr.length);
     for (int j = 0; j < table.length; j++) {
       int iper = i - 2;
       double mag = table[j][0];
       double rJB = table[j][1];
       double expectedMedian = table[j][i];
       double computedMedian = Math.exp(ca03AttenRel.getMean(iper, mag, rJB));
       assertEquals(expectedMedian, computedMedian, TOLERANCE);
     }
   }
   // check for PGA
   for (int j = 0; j < table.length; j++) {
     double mag = table[j][0];
     double rJB = table[j][1];
     double expectedMedian = table[j][columnDescr.length - 1];
     double computedMedian = Math.exp(ca03AttenRel.getMean(0, mag, rJB));
     assertEquals(expectedMedian, computedMedian, TOLERANCE);
   }
 }
Example #4
0
  /**
   * Set up attenuation relationship object, and tables for tests.
   *
   * @throws Exception
   */
  @Before
  public final void setUp() throws Exception {
    ca03AttenRel = new Campbell_2003_AttenRel(this);
    ca03AttenRel.setParamDefaults();

    stdTotalTable = new double[TABLE_NUM_ROWS][TABLE_NUM_COL_STD];
    AttenRelTestHelper.readNumericTableWithHeader(
        new File(ClassLoader.getSystemResource(SIGMA_TOTAL_HARD_ROCK_TABLE).toURI()),
        stdTotalTable,
        TABLE_HEADER_STD);
    medianHardRockTable = new double[TABLE_NUM_ROWS][TABLE_NUM_COL_MEDIAN];
    AttenRelTestHelper.readNumericTableWithHeader(
        new File(ClassLoader.getSystemResource(MEDIAN_HARD_ROCK_TABLE).toURI()),
        medianHardRockTable,
        TABLE_HEADER_MEDIAN);
  }