diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index 4f906e0c811fc9e230eb44819f509cd0627f2600..1b6c787337ffb79f0e3cf8b1e9f00f680a959de1 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java b/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java index 8f656910ee4d472b69d07e4da54b9b6f382c0b67..9d1ca70acdbe619d773a7a9da11172927ac568ea 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/calc/CalcConfig.java @@ -224,6 +224,22 @@ public final class CalcConfig { */ public final ValueFormat valueFormat; + /** + * Whether to apply updated distance filter. Note: the + * {@code distanceFilterUpdate} flag is registered when a model loads and at + * this time cannot be changed with user supplied config. + * + * <p><b>Default:</b> false + */ + public final boolean distanceFilterUpdate; + + /** + * Whether to apply updated grid focal mechanism application. + * + * <p><b>Default:</b> false + */ + public final boolean gridFocalMechUpdate; + private final Map<Imt, double[]> customImls; /* Do not serialize to JSON */ @@ -239,6 +255,8 @@ public final class CalcConfig { this.vs30s = b.vs30s; this.useSiteData = b.useSiteData; this.valueFormat = b.valueFormat; + this.distanceFilterUpdate = b.distanceFilterUpdate; + this.gridFocalMechUpdate = b.gridFocalMechUpdate; this.customImls = b.customImls; this.modelCurves = b.curveMap; @@ -280,6 +298,8 @@ public final class CalcConfig { Set<Double> vs30s; Boolean useSiteData; ValueFormat valueFormat; + Boolean distanceFilterUpdate; + Boolean gridFocalMechUpdate; Map<Imt, double[]> customImls; Map<Imt, XySequence> curveMap; Map<Imt, XySequence> logCurveMap; @@ -294,6 +314,8 @@ public final class CalcConfig { checkNotNull(vs30s); checkNotNull(useSiteData); checkNotNull(valueFormat); + checkNotNull(distanceFilterUpdate); + checkNotNull(gridFocalMechUpdate); checkNotNull(customImls); return new Hazard(this); } @@ -307,6 +329,8 @@ public final class CalcConfig { this.vs30s = that.vs30s; this.useSiteData = that.useSiteData; this.valueFormat = that.valueFormat; + this.distanceFilterUpdate = that.distanceFilterUpdate; + this.gridFocalMechUpdate = that.gridFocalMechUpdate; this.customImls = that.customImls; } @@ -335,6 +359,12 @@ public final class CalcConfig { if (that.valueFormat != null) { this.valueFormat = that.valueFormat; } + if (that.distanceFilterUpdate != null) { + this.distanceFilterUpdate = that.distanceFilterUpdate; + } + if (that.gridFocalMechUpdate != null) { + this.gridFocalMechUpdate = that.gridFocalMechUpdate; + } if (that.customImls != null) { this.customImls.putAll(that.customImls); } @@ -841,22 +871,11 @@ public final class CalcConfig { */ public final ThreadCount threadCount; - /** - * Whether to apply updated distance filter. - * - * <p><b>Default:</b> false - */ - public final boolean distanceFilterUpdate; - - // note: distanceFilterUpdate is picked up when model loads - // and cannot be changed with user supplied config - private Performance(Builder b) { this.optimizeGrids = b.optimizeGrids; this.smoothGrids = b.smoothGrids; this.systemPartition = b.systemPartition; this.threadCount = b.threadCount; - this.distanceFilterUpdate = b.distanceFilterUpdate; } private static final class Builder { @@ -865,14 +884,12 @@ public final class CalcConfig { Boolean smoothGrids; Integer systemPartition; ThreadCount threadCount; - Boolean distanceFilterUpdate; Performance build() { checkNotNull(optimizeGrids); checkNotNull(smoothGrids); checkNotNull(systemPartition); checkNotNull(threadCount); - checkNotNull(distanceFilterUpdate); return new Performance(this); } @@ -881,7 +898,6 @@ public final class CalcConfig { this.smoothGrids = that.smoothGrids; this.systemPartition = that.systemPartition; this.threadCount = that.threadCount; - this.distanceFilterUpdate = that.distanceFilterUpdate; } void extend(Builder that) { @@ -897,9 +913,6 @@ public final class CalcConfig { if (that.threadCount != null) { this.threadCount = that.threadCount; } - if (that.distanceFilterUpdate != null) { - this.distanceFilterUpdate = that.distanceFilterUpdate; - } } } } diff --git a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java index 37a72c5986e21e507139673ae8886a45792b09bb..ee47a2ceff2386fd00604fc705d8fc7f2c2fbe16 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardCalcs.java @@ -146,7 +146,8 @@ public class HazardCalcs { immediateFuture(gss), GridRuptureSet.optimizer( site.location(), - config.performance.smoothGrids)::apply, + config.performance.smoothGrids, + config.hazard.gridFocalMechUpdate)::apply, ex)); break; } @@ -214,7 +215,8 @@ public class HazardCalcs { if (config.performance.optimizeGrids && gss.optimizable()) { ruptures = GridRuptureSet.optimizer( site.location(), - config.performance.smoothGrids).apply(gss); + config.performance.smoothGrids, + config.hazard.gridFocalMechUpdate).apply(gss); log(log, MSSG_GRID_INIT, ruptures.name(), duration(swSource)); } curveSets.add(sourcesToCurves(ruptures, site, config)); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/FaultRuptureSet.java b/src/main/java/gov/usgs/earthquake/nshmp/model/FaultRuptureSet.java index 9cd7827bcdb0194c1d58ca41be4ecb1ab4cf408c..255d93901ebe514de72d2813e15a26b58a55c69a 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/FaultRuptureSet.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/FaultRuptureSet.java @@ -153,7 +153,6 @@ public class FaultRuptureSet extends AbstractRuptureSet<FaultSource> { /* * Updated distance filter that checks endpoints of trace. If trace is longer * than 50 km, intermediate points on trace are also checked. - * */ static class DistanceFilterUpdate implements Predicate<FaultSource> { diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/GridRuptureSet.java b/src/main/java/gov/usgs/earthquake/nshmp/model/GridRuptureSet.java index 16a2f45a163b0c350125a66edc166d5abffb83a2..c6a718862370778c06f16ca70bb36f6e4a82e672 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/GridRuptureSet.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/GridRuptureSet.java @@ -246,7 +246,7 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { static class Builder extends AbstractRuptureSet.Builder { private SourceFeature feature; // Grid or Zone - private ModelData data; + private ModelData data; // unused; clean private List<Location> locations; private List<Mfd> mfds; @@ -629,8 +629,8 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { * @param loc reference point for table */ public static Function<GridRuptureSet, RuptureSet<? extends Source>> optimizer( - Location loc, boolean smooth) { - return new Optimizer(loc, smooth); + Location loc, boolean smooth, boolean focalMechUpdate) { + return new Optimizer(loc, smooth, focalMechUpdate); } private static class Optimizer implements @@ -638,15 +638,17 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { private final Location loc; private final boolean smooth; + private final boolean focalMechUpdate; - Optimizer(Location loc, boolean smooth) { + Optimizer(Location loc, boolean smooth, boolean focalMechUpdate) { this.loc = loc; this.smooth = smooth; + this.focalMechUpdate = focalMechUpdate; } @Override public Table apply(GridRuptureSet sources) { - return new Table(sources, loc, smooth); + return new Table(sources, loc, smooth, focalMechUpdate); } } @@ -680,6 +682,24 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { */ private static final class Table extends AbstractRuptureSet<PointSource> { + private static final Map<FocalMech, Double> SS_MECH_MAP = new EnumMap<>(FocalMech.class); + private static final Map<FocalMech, Double> R_MECH_MAP = new EnumMap<>(FocalMech.class); + private static final Map<FocalMech, Double> N_MECH_MAP = new EnumMap<>(FocalMech.class); + + static { + SS_MECH_MAP.put(FocalMech.STRIKE_SLIP, 1.0); + SS_MECH_MAP.put(FocalMech.REVERSE, 0.0); + SS_MECH_MAP.put(FocalMech.NORMAL, 0.0); + + R_MECH_MAP.put(FocalMech.STRIKE_SLIP, 0.0); + R_MECH_MAP.put(FocalMech.REVERSE, 1.0); + R_MECH_MAP.put(FocalMech.NORMAL, 0.0); + + N_MECH_MAP.put(FocalMech.STRIKE_SLIP, 0.0); + N_MECH_MAP.put(FocalMech.REVERSE, 0.0); + N_MECH_MAP.put(FocalMech.NORMAL, 1.0); + } + private final GridRuptureSet parent; private final Location origin; private final List<PointSource> sources; @@ -695,7 +715,11 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { private int maximumSize; private int parentCount; - private Table(GridRuptureSet parent, Location origin, boolean smoothed) { + private Table( + GridRuptureSet parent, + Location origin, + boolean smoothed, + boolean focalMechUpdate) { // This is dirty - arose from conversion to ass constructor taking // builder @@ -713,7 +737,7 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { this.origin = origin; this.sources = parent.singularMechs ? initSources(smoothed) - : initMultiMechSources(smoothed); + : initMultiMechSources(smoothed, focalMechUpdate); } /** @@ -840,7 +864,9 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { } /* always creates finite point sources */ - private List<PointSource> initMultiMechSources(boolean smoothed) { + private List<PointSource> initMultiMechSources( + boolean smoothed, + boolean focalMechUpdate) { /* For now, should only be getting here for GR MFDs */ Mfd modelMfd = parent.mfds.get(0); @@ -910,6 +936,10 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { // System.out.println("tableMfd:"); // System.out.println(tableMfdSum); + Map<FocalMech, Double> ssMechMap = focalMechUpdate ? SS_MECH_MAP : parent.mechMaps.get(0); + Map<FocalMech, Double> rMechMap = focalMechUpdate ? R_MECH_MAP : parent.mechMaps.get(0); + Map<FocalMech, Double> nMechMap = focalMechUpdate ? N_MECH_MAP : parent.mechMaps.get(0); + List<Double> distances = ssTable.rows(); maximumSize = distances.size(); List<PointSource> b = new ArrayList<>(); @@ -919,12 +949,13 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { Mfd ssMfd = Mfd.create(ssTable.row(r)); if (ssMfd.data().y(0) > 0.0 || !ssMfd.data().isClear()) { + b.add(new PointSourceFinite( parent, parent.type(), loc, ssMfd, - parent.mechMaps.get(0), + ssMechMap, parent.rupScaling, parent.depthModel, Optional.empty())); @@ -938,7 +969,7 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { parent.type(), loc, rMfd, - parent.mechMaps.get(0), + rMechMap, parent.rupScaling, parent.depthModel, Optional.empty())); @@ -952,7 +983,7 @@ public class GridRuptureSet extends AbstractRuptureSet<PointSource> { parent.type(), loc, nMfd, - parent.mechMaps.get(0), + nMechMap, parent.rupScaling, parent.depthModel, Optional.empty())); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java index 3823a2f84e58835df9f86f22decdfbf0cf9aa04b..1a6f9e796dbd9428b9060207983376993f7dab30 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java @@ -367,7 +367,7 @@ abstract class ModelLoader { GmmTree sourceGmms = readGmmTree(dir).or(() -> gmms).orElseThrow(); SourceConfig srcConfig = readFaultConfig(dir).orElseThrow(); ModelData data = ModelData.create(setting, sourceGmms, srcConfig); - data.useDistanceFilterUpdate(config.performance.distanceFilterUpdate); + data.useDistanceFilterUpdate(config.hazard.distanceFilterUpdate); return new Fault(dir).loadSourceDirectory(dir, data); } @@ -871,7 +871,7 @@ abstract class ModelLoader { GmmTree sourceGmms = readGmmTree(dir).or(() -> gmms).orElseThrow(); SourceConfig srcConfig = readInterfaceConfig(dir).orElseThrow(); ModelData data = ModelData.create(setting, sourceGmms, srcConfig); - data.useDistanceFilterUpdate(config.performance.distanceFilterUpdate); + data.useDistanceFilterUpdate(config.hazard.distanceFilterUpdate); return new Interface(dir).loadSourceDirectory(dir, data); } diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/PointSourceFinite.java b/src/main/java/gov/usgs/earthquake/nshmp/model/PointSourceFinite.java index 4608b7ec2cd0fa7a8d2069126a8634dfa71e0f00..3a45f3961b85fa7c7925f74276124ce736fdbda5 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/PointSourceFinite.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/PointSourceFinite.java @@ -90,7 +90,7 @@ class PointSourceFinite extends PointSource { /* * NOTE: Although there should not be many instances where a PointSourceFinite - * rupture rate is reduced to zero (a mag-depth weight [this is not curently + * rupture rate is reduced to zero (a mag-depth weight [this is not currently * checked] of an MFD rate could be zero), in the cases where it is, we're * doing a little more work than necessary below. We could alternatively * short-circuit updateRupture() this method to return null reference but diff --git a/src/main/resources/calc/calc-config-defaults.json b/src/main/resources/calc/calc-config-defaults.json index 667030ec7512b78c6daff20bee0ad66404c8d311..f42c84b7133cd3642f94cfa02547c5bf49e7307c 100644 --- a/src/main/resources/calc/calc-config-defaults.json +++ b/src/main/resources/calc/calc-config-defaults.json @@ -14,6 +14,8 @@ "vs30s": [], "useSiteData": true, "valueFormat": "ANNUAL_RATE", + "distanceFilterUpdate": true, + "gridFocalMechUpdate": true, "customImls": {} }, "gmm": { @@ -59,7 +61,6 @@ "optimizeGrids": true, "smoothGrids": true, "systemPartition": 1000, - "threadCount": "ALL", - "distanceFilterUpdate": true + "threadCount": "ALL" } } diff --git a/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java b/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java index 430d303bc70f6289546504b9d192ab6202689f20..91e2f1b3cb942c8e90e8a4aee2ce2edea77a2951 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/calc/CalcConfigTests.java @@ -137,6 +137,8 @@ class CalcConfigTests { assertEquals(EnumSet.noneOf(SourceType.class), def.sourceTypes); assertEquals(true, def.useSiteData); assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat); + assertEquals(true, def.distanceFilterUpdate); + assertEquals(true, def.gridFocalMechUpdate); Map<Imt, XySequence> imlMap = def.modelCurves(); Map<Imt, XySequence> imlMapExpect = new EnumMap<>(Imt.class); @@ -258,6 +260,8 @@ class CalcConfigTests { assertEquals(Set.of(260.0, 760.0), def.vs30s); assertEquals(false, def.useSiteData); assertEquals(ValueFormat.POISSON_PROBABILITY, def.valueFormat); + assertEquals(false, def.distanceFilterUpdate); + assertEquals(false, def.gridFocalMechUpdate); assertArrayEquals( IMLS_PGA_CUSTOM, @@ -272,6 +276,8 @@ class CalcConfigTests { assertEquals(Set.of(), def.vs30s); assertEquals(true, def.useSiteData); assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat); + assertEquals(true, def.distanceFilterUpdate); + assertEquals(true, def.gridFocalMechUpdate); } @Test @@ -382,21 +388,18 @@ class CalcConfigTests { assertEquals(true, def.smoothGrids); assertEquals(1000, def.systemPartition); assertEquals(ThreadCount.ALL, def.threadCount); - assertEquals(true, def.distanceFilterUpdate); def = EXTENDS.performance; assertEquals(false, def.optimizeGrids); assertEquals(false, def.smoothGrids); assertEquals(500, def.systemPartition); assertEquals(ThreadCount.ONE, def.threadCount); - assertEquals(false, def.distanceFilterUpdate); def = EXTENDS_EMPTY.performance; assertEquals(true, def.optimizeGrids); assertEquals(true, def.smoothGrids); assertEquals(1000, def.systemPartition); assertEquals(ThreadCount.ALL, def.threadCount); - assertEquals(true, def.distanceFilterUpdate); } static double[] imlsForImt(Imt imt) { diff --git a/src/test/resources/calc/calc-config-extends.json b/src/test/resources/calc/calc-config-extends.json index 39726d13bd87e17672d9c2c77caee082bbe83eb9..8a16c44ded7298ef56bc79e4d13a4b166fdac5a6 100644 --- a/src/test/resources/calc/calc-config-extends.json +++ b/src/test/resources/calc/calc-config-extends.json @@ -10,6 +10,8 @@ "vs30s": [ 260, 760 ], "useSiteData": false, "valueFormat": "POISSON_PROBABILITY", + "distanceFilterUpdate": false, + "gridFocalMechUpdate": false, "customImls": { "PGA": [0.0025, 0.0075, 0.0169, 0.0380, 0.0854, 0.192, 0.432, 0.973, 2.19, 4.92] } @@ -56,7 +58,6 @@ "optimizeGrids": false, "smoothGrids": false, "systemPartition": 500, - "threadCount": "ONE", - "distanceFilterUpdate": false + "threadCount": "ONE" } } diff --git a/src/test/resources/model/test-model/calc-config.json b/src/test/resources/model/test-model/calc-config.json index c86e4964bf0f5c2d9e8108e269da59adc2ac5cad..458a33e71b251f184a56945743651a8cabd5a609 100644 --- a/src/test/resources/model/test-model/calc-config.json +++ b/src/test/resources/model/test-model/calc-config.json @@ -8,7 +8,8 @@ "SA0P2": [0.0025, 0.0045, 0.0075, 0.0113, 0.0169, 0.0253, 0.038, 0.057, 0.0854, 0.128, 0.192, 0.288, 0.432, 0.649, 0.973, 1.46, 2.19, 3.28, 4.92, 7.38], "SA1P0": [0.0025, 0.0045, 0.0075, 0.0113, 0.0169, 0.0253, 0.038, 0.057, 0.0854, 0.128, 0.192, 0.288, 0.432, 0.649, 0.973, 1.46, 2.19, 3.28, 4.92, 7.38], "SA5P0": [0.0025, 0.0045, 0.0075, 0.0113, 0.0169, 0.0253, 0.038, 0.057, 0.0854, 0.128, 0.192, 0.288, 0.432, 0.649, 0.973, 1.46, 2.19, 3.28, 4.92, 7.38] - } + }, + "gridFocalMechUpdate": false }, "output": { "directory": "tmp/model-tests"