Esempio n. 1
0
  // single thread system calc
  static final HazardCurveSet systemToCurves(
      final SystemSourceSet sourceSet, final Site site, final CalcConfig config) {

    Stopwatch sw = Stopwatch.createStarted();

    Function<SystemSourceSet, InputList> inputFn = new SystemSourceSet.ToInputs(site);
    InputList inputs = inputFn.apply(sourceSet);
    System.out.println("Inputs: " + inputs.size() + "  " + sw);

    Set<Gmm> gmms = sourceSet.groundMotionModels().gmms();
    Table<Gmm, Imt, GroundMotionModel> gmmInstances = Gmm.instances(gmms, config.imts);
    Function<InputList, GroundMotions> gmFn = new InputsToGroundMotions(gmmInstances);
    GroundMotions groundMotions = gmFn.apply(inputs);
    System.out.println("GroundMotions: " + sw);

    Map<Imt, ArrayXY_Sequence> modelCurves = config.logModelCurves;
    Function<GroundMotions, HazardCurves> curveFn = new GroundMotionsToCurves(config);
    HazardCurves hazardCurves = curveFn.apply(groundMotions);
    System.out.println("HazardCurves: " + sw);

    Function<List<HazardCurves>, HazardCurveSet> consolidateFn =
        new CurveConsolidator(sourceSet, modelCurves);
    HazardCurveSet curveSet = consolidateFn.apply(ImmutableList.of(hazardCurves));
    System.out.println("CurveSet: " + sw);

    return curveSet;
  }
Esempio n. 2
0
  /** Convert a future List of SystemInputs to a future List of SystemGroundMotions. */
  static final ListenableFuture<GroundMotions> toSystemGroundMotions(
      final ListenableFuture<InputList> inputs,
      final SystemSourceSet sourceSet,
      final Set<Imt> imts,
      final Executor ex) {

    Set<Gmm> gmms = sourceSet.groundMotionModels().gmms();
    Table<Gmm, Imt, GroundMotionModel> gmmInstances = Gmm.instances(gmms, imts);
    Function<InputList, GroundMotions> function = new InputsToGroundMotions(gmmInstances);
    return transform(inputs, function, ex);
  }