public EqkRuptureDataForNrml(EqkRupture rup) {
   averageRake = rup.getAveRake();
   if (rup.getTectRegType() != null) {
     tectonicRegion = rup.getTectRegType().toString();
   } else {
     tectonicRegion = unknownTectonicRegionType;
   }
   magRupture = rup.getMag();
   EvenlyGriddedSurfaceAPI grid = rup.getRuptureSurface();
   /*
    * the site data
    */
   numberOfColumns = grid.getNumCols();
   numberOfRows = grid.getNumRows();
   int countSites = numberOfColumns * numberOfRows;
   latGrid = new double[countSites];
   lonGrid = new double[countSites];
   depthGrid = new double[countSites];
   for (int row = 0; row < numberOfRows; row++) {
     for (int col = 0; col < numberOfColumns; col++) {
       Location l = grid.get(row, col);
       int index = (row) * numberOfColumns + (col);
       latGrid[index] = l.getLatitude();
       lonGrid[index] = l.getLongitude();
       depthGrid[index] = l.getDepth();
     } // for columns
   } // for rows
 } // constructor()
  /** This makes and returns the nth probEqkRupture for this source. */
  public ProbEqkRupture getRupture(int nthRupture) {

    // set the magnitude
    double mag = mags.get(nthRupture).doubleValue();
    probEqkRupture.setMag(mag);

    // set the probability if it's Poissonian (otherwise this was already
    // set)
    if (isPoissonian)
      probEqkRupture.setProbability(
          1 - Math.exp(-duration * ((Double) rates.get(nthRupture)).doubleValue()));

    // set the rake, depth, and dip if necessary
    if (variableDepthRakeAndDip) {
      probEqkRupture.setAveRake(rakes.get(nthRupture).doubleValue());
      double depth;
      if (mag < this.aveRupTopVersusMag.getMinX()) depth = this.defaultHypoDepth;
      else depth = aveRupTopVersusMag.getClosestY(mag);
      // location.setDepth(depth);
      location = new Location(location.getLatitude(), location.getLongitude(), depth);
      probEqkRupture.setPointSurface(location, dips.get(nthRupture).doubleValue());
    }

    // return the ProbEqkRupture
    return probEqkRupture;
  }
 public String toString() {
   String str = new String();
   str += "sectionId = " + this.getSectionId() + "\n";
   str += "sectionName = " + this.getSectionName() + "\n";
   str += "shortName = " + this.getShortName() + "\n";
   str += "aveLongTermSlipRate = " + this.getOrigAveSlipRate() + "\n";
   str += "slipRateStdDev = " + this.getOrigSlipRateStdDev() + "\n";
   str += "aveDip = " + this.getAveDip() + "\n";
   str += "aveRake = " + this.getAveRake() + "\n";
   str += "aveUpperDepth = " + this.getOrigAveUpperDepth() + "\n";
   str += "aveLowerDepth = " + this.getAveLowerDepth() + "\n";
   str += "aseismicSlipFactor = " + this.getAseismicSlipFactor() + "\n";
   str += "couplingCoeff = " + this.getCouplingCoeff() + "\n";
   str += "dipDirection = " + this.getDipDirection() + "\n";
   str += "dateOfLastEventMillis = " + this.getDateOfLastEvent() + "\n";
   str += "slipInLastEvent = " + this.getSlipInLastEvent() + "\n";
   str += "faultTrace:\n";
   for (int i = 0; i < this.getFaultTrace().size(); i++) {
     Location loc = this.getFaultTrace().get(i);
     str += "\t" + loc.getLatitude() + ", " + loc.getLongitude() + ", " + loc.getDepth() + "\n";
   }
   return str;
 }
  public GEMFaultSourceData getFaultSourceData() {

    // Create the fault trace
    Location loc1 = new Location(this.lat, this.lon, this.depth);
    if (this.strike > 180) this.strike -= 360;
    // Location loctmp =
    // RelativeLocation.location(loc1,strike/180.0*Math.PI,this.rectangleLenght);
    Location loctmp = LocationUtils.location(loc1, strike / 180.0 * Math.PI, this.rectangleLenght);
    if (INFO) {
      System.out.printf("  Fault origin   : %6.2f %6.2f\n", this.lon, this.lat);
      System.out.printf(
          "  Fault end point: %6.2f %6.2f\n", loctmp.getLongitude(), loctmp.getLatitude());
    }

    System.out.printf("New fault strike .......: %+6.2f\n", this.strike);
    FaultTrace trace = new FaultTrace(String.format("%d", this.id));
    Location loc2 = new Location(loctmp.getLatitude(), loctmp.getLongitude(), this.depth);
    if (this.dip > 90.0) {
      trace.add(loc2);
      trace.add(loc1);
      this.dip = 180.0 - this.dip;
      System.out.println("reverting");
    } else {
      trace.add(loc1);
      trace.add(loc2);
    }

    // Magnitude-frequency distribution - mmin, mmax, numInt
    IncrementalMagFreqDist mfd = new IncrementalMagFreqDist(this.magnitude, this.magnitude, 1);
    mfd.add(0, this.averageActivity);

    // Lower seismogenic depth
    double seismDepthLow = this.depth + this.rectangleWidth * Math.sin(this.dip / 180.0 * Math.PI);

    if (INFO) System.out.println(this.id);

    // Checking dip value
    if (dip > 90.0 || this.dip < 0.0) {
      System.out.println("ID" + id + " dip:" + dip);
      throw new RuntimeException("dip out of range");
    }

    // Checking depth value
    if (depth < 0.0) {
      System.out.println("ID" + id + " depth:" + depth);
      throw new RuntimeException("depth out of range");
    }

    // Checking Seismogenic layer
    if (seismDepthLow < this.depth) {
      System.out.println("ID" + id + " Depth upp:" + depth + " Depth low" + seismDepthLow);
      throw new RuntimeException("inconsistent depths");
    }

    // Create the GEM fault source data
    GEMFaultSourceData srcData =
        new GEMFaultSourceData(
            String.format("%d", this.id),
            this.name,
            TectonicRegionType.ACTIVE_SHALLOW,
            mfd,
            trace,
            this.dip,
            -90.0,
            seismDepthLow,
            this.depth,
            true);

    return srcData;
  }