// 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; }
private Builder(InputList inputs, Set<Imt> imts, Set<Gmm> gmms) { checkArgument(checkNotNull(inputs).size() > 0); checkArgument(checkNotNull(gmms).size() > 0); this.inputs = inputs; means = initValueMaps(imts, gmms, inputs.size()); sigmas = initValueMaps(imts, gmms, inputs.size()); size = imts.size() * gmms.size() * inputs.size(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(getClass().getSimpleName()); sb.append(" [").append(inputs.parentName()).append("]"); sb.append(": ").append(LINE_SEPARATOR.value()); for (int i = 0; i < inputs.size(); i++) { sb.append(inputs.get(i)); sb.append(" "); for (Entry<Imt, Map<Gmm, List<Double>>> imtEntry : means.entrySet()) { Imt imt = imtEntry.getKey(); sb.append(imt.name()).append(" ["); for (Entry<Gmm, List<Double>> gmmEntry : imtEntry.getValue().entrySet()) { Gmm gmm = gmmEntry.getKey(); sb.append(gmm.name()).append(" "); sb.append(String.format("μ=%.3f", gmmEntry.getValue().get(i))).append(" "); sb.append(String.format("σ=%.3f", sigmas.get(imt).get(gmm).get(i))).append(" "); } sb.append("] "); } sb.append(LINE_SEPARATOR.value()); } return sb.toString(); }