Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
  /** 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 Element toXMLMetadata(Element root, String name) {

    Element el = root.addElement(name);
    el.addAttribute("sectionId", this.getSectionId() + "");
    el.addAttribute("sectionName", this.getSectionName());
    el.addAttribute("shortName", this.getShortName());
    el.addAttribute("aveLongTermSlipRate", this.getOrigAveSlipRate() + "");
    el.addAttribute("slipRateStdDev", this.getOrigSlipRateStdDev() + "");
    el.addAttribute("aveDip", this.getAveDip() + "");
    el.addAttribute("aveRake", this.getAveRake() + "");
    el.addAttribute("aveUpperDepth", this.getOrigAveUpperDepth() + "");
    el.addAttribute("aveLowerDepth", this.getAveLowerDepth() + "");
    el.addAttribute("aseismicSlipFactor", this.getAseismicSlipFactor() + "");
    el.addAttribute("couplingCoeff", this.getCouplingCoeff() + "");
    el.addAttribute("dipDirection", this.getDipDirection() + "");
    String parentSectionName = this.getParentSectionName();
    if (parentSectionName != null) el.addAttribute("parentSectionName", parentSectionName);
    el.addAttribute("parentSectionId", getParentSectionId() + "");
    el.addAttribute("connector", isConnector() + "");
    if (getZonePolygon() != null) zonePolygon.toXMLMetadata(el, "ZonePolygon");
    if (getDateOfLastEvent() > Long.MIN_VALUE)
      el.addAttribute("dateOfLastEventMillis", getDateOfLastEvent() + "");
    if (!Double.isNaN(getSlipInLastEvent()))
      el.addAttribute("slipInLastEvent", getSlipInLastEvent() + "");

    FaultTrace trace = this.getFaultTrace();

    Element traceEl = el.addElement("FaultTrace");
    traceEl.addAttribute("name", trace.getName());

    for (int j = 0; j < trace.getNumLocations(); j++) {
      Location loc = trace.get(j);

      traceEl = loc.toXMLMetadata(traceEl);
    }

    return root;
  }
 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;
  }
  @SuppressWarnings("unchecked")
  public static FaultSectionPrefData fromXMLMetadata(Element el) {

    int sectionId = Integer.parseInt(el.attributeValue("sectionId"));
    String sectionName = el.attributeValue("sectionName");
    String shortName = el.attributeValue("shortName");
    double aveLongTermSlipRate = Double.parseDouble(el.attributeValue("aveLongTermSlipRate"));
    double aveDip = Double.parseDouble(el.attributeValue("aveDip"));
    double aveRake = Double.parseDouble(el.attributeValue("aveRake"));
    double aveUpperDepth = Double.parseDouble(el.attributeValue("aveUpperDepth"));
    double aveLowerDepth = Double.parseDouble(el.attributeValue("aveLowerDepth"));
    double aseismicSlipFactor = Double.parseDouble(el.attributeValue("aseismicSlipFactor"));
    float dipDirection = Float.parseFloat(el.attributeValue("dipDirection"));

    Attribute parentSectNameAtt = el.attribute("parentSectionName");
    String parentSectionName;
    if (parentSectNameAtt != null) parentSectionName = parentSectNameAtt.getStringValue();
    else parentSectionName = null;

    Attribute parentSectIDAtt = el.attribute("parentSectionId");
    int parentSectionId;
    if (parentSectIDAtt != null)
      parentSectionId = Integer.parseInt(parentSectIDAtt.getStringValue());
    else parentSectionId = -1;

    Element traceEl = el.element("FaultTrace");

    String traceName = traceEl.attributeValue("name");

    FaultTrace trace = new FaultTrace(traceName);

    Iterator<Element> traceIt = (Iterator<Element>) traceEl.elementIterator();
    while (traceIt.hasNext()) {
      Element locEl = traceIt.next();

      trace.add(Location.fromXMLMetadata(locEl));
    }

    boolean connector = false;
    Attribute connectorAtt = el.attribute("connector");
    if (connectorAtt != null) connector = Boolean.parseBoolean(connectorAtt.getStringValue());

    Region zonePolygon = null;
    Element zonePolygonEl = el.element("ZonePolygon");
    if (zonePolygonEl != null) {
      zonePolygon = Region.fromXMLMetadata(zonePolygonEl);
    }

    FaultSectionPrefData data = new FaultSectionPrefData();
    data.setSectionId(sectionId);
    data.setSectionName(sectionName);
    data.setShortName(shortName);
    data.setAveSlipRate(aveLongTermSlipRate);
    data.setAveDip(aveDip);
    data.setAveRake(aveRake);
    data.setAveUpperDepth(aveUpperDepth);
    data.setAveLowerDepth(aveLowerDepth);
    data.setAseismicSlipFactor(aseismicSlipFactor);
    Attribute couplingAtt = el.attribute("couplingCoeff");
    if (couplingAtt != null)
      data.setCouplingCoeff(Double.parseDouble(couplingAtt.getStringValue()));
    data.setDipDirection(dipDirection);
    data.setFaultTrace(trace);
    data.setParentSectionName(parentSectionName);
    data.setParentSectionId(parentSectionId);
    data.setConnector(connector);
    data.setZonePolygon(zonePolygon);

    Attribute lastEventAtt = el.attribute("dateOfLastEventMillis");
    if (lastEventAtt != null)
      data.setDateOfLastEvent(Long.parseLong(lastEventAtt.getStringValue()));
    Attribute lastSlipAtt = el.attribute("slipInLastEvent");
    if (lastSlipAtt != null)
      data.setSlipInLastEvent(Double.parseDouble(lastSlipAtt.getStringValue()));

    return data;
  }