Exemplo n.º 1
0
  // single thread calc
  static final List<HazardCurveSet> sourceSetToCurves(
      final SourceSet<? extends Source> sourceSet, final Site site, final CalcConfig config) {

    //		Stopwatch sw = Stopwatch.createStarted();

    List<HazardCurveSet> curveSetList = new ArrayList<>();
    for (Source source : sourceSet.iterableForLocation(site.location)) {

      Function<Source, InputList> inputFn = new SourceToInputs(site);
      InputList inputs = inputFn.apply(source);
      //			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);

      curveSetList.add(curveSet);
    }

    return curveSetList;
  }
Exemplo n.º 2
0
  /** Convert a SourceSet to a List of future HazardInputs. */
  static final AsyncList<InputList> toInputs(
      final SourceSet<? extends Source> sourceSet, final Site site, final Executor ex) {

    Function<Source, InputList> function = new SourceToInputs(site);
    AsyncList<InputList> result = AsyncList.create();
    for (Source source : sourceSet.iterableForLocation(site.location)) {
      result.add(transform(immediateFuture(source), function, ex));
    }
    return result;
  }
Exemplo n.º 3
0
  /** Convert a List of future HazardInputs to a List of future HazardGroundMotions. */
  static final AsyncList<GroundMotions> toGroundMotions(
      final AsyncList<InputList> inputsList,
      final SourceSet<? extends Source> 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);
    AsyncList<GroundMotions> result = createWithCapacity(inputsList.size());
    for (ListenableFuture<InputList> hazardInputs : inputsList) {
      result.add(transform(hazardInputs, function, ex));
    }
    return result;
  }