Skip to content
Snippets Groups Projects
Commit 95d41b7b authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

Merge branch 'config-248-dsf' into 'main'

CalcConfig updates

Closes #248

See merge request !415
parents a23be4f8 0c487090
No related branches found
No related tags found
1 merge request!415CalcConfig updates
Pipeline #443110 passed
...@@ -24,7 +24,6 @@ import java.nio.file.Path; ...@@ -24,7 +24,6 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NavigableMap; import java.util.NavigableMap;
...@@ -341,7 +340,7 @@ public final class CalcConfig { ...@@ -341,7 +340,7 @@ public final class CalcConfig {
if (that.truncationLevel != null) { if (that.truncationLevel != null) {
this.truncationLevel = that.truncationLevel; this.truncationLevel = that.truncationLevel;
} }
if (that.imts != null) { if (that.imts != null && !that.imts.isEmpty()) {
this.imts = that.imts; this.imts = that.imts;
} }
if (that.tectonicSettings != null) { if (that.tectonicSettings != null) {
...@@ -797,10 +796,7 @@ public final class CalcConfig { ...@@ -797,10 +796,7 @@ public final class CalcConfig {
private Output(Builder b) { private Output(Builder b) {
this.directory = b.directory; this.directory = b.directory;
Set<DataType> dataTypes = EnumSet.copyOf(b.dataTypes); this.dataTypes = Collections.unmodifiableSet(b.dataTypes);
dataTypes.add(DataType.TOTAL);
dataTypes.add(DataType.MAP);
this.dataTypes = Collections.unmodifiableSet(dataTypes);
this.returnPeriods = List.copyOf(b.returnPeriods); this.returnPeriods = List.copyOf(b.returnPeriods);
} }
...@@ -819,7 +815,7 @@ public final class CalcConfig { ...@@ -819,7 +815,7 @@ public final class CalcConfig {
void copy(Output that) { void copy(Output that) {
this.directory = that.directory; this.directory = that.directory;
this.dataTypes = EnumSet.copyOf(that.dataTypes); this.dataTypes = that.dataTypes;
this.returnPeriods = that.returnPeriods; this.returnPeriods = that.returnPeriods;
} }
...@@ -827,8 +823,8 @@ public final class CalcConfig { ...@@ -827,8 +823,8 @@ public final class CalcConfig {
if (that.directory != null) { if (that.directory != null) {
this.directory = that.directory; this.directory = that.directory;
} }
if (that.dataTypes != null) { if (that.dataTypes != null && !that.dataTypes.isEmpty()) {
this.dataTypes = EnumSet.copyOf(that.dataTypes); this.dataTypes.addAll(that.dataTypes);
} }
if (that.returnPeriods != null) { if (that.returnPeriods != null) {
this.returnPeriods = that.returnPeriods; this.returnPeriods = that.returnPeriods;
...@@ -984,7 +980,8 @@ public final class CalcConfig { ...@@ -984,7 +980,8 @@ public final class CalcConfig {
/** /**
* Extend {@code this} builder to match {@code that} builder. Fields in * Extend {@code this} builder to match {@code that} builder. Fields in
* {@code that} builder take precedence unless they are not set. * {@code that} builder take precedence unless they are not set. Array based
* settings are replaced.
*/ */
public Builder extend(Builder that) { public Builder extend(Builder that) {
checkNotNull(that); checkNotNull(that);
......
...@@ -79,13 +79,17 @@ public class UsgsDampingScaling { ...@@ -79,13 +79,17 @@ public class UsgsDampingScaling {
* TODO Disable subduction below 0.1s * TODO Disable subduction below 0.1s
*/ */
/** The range of supported damping ratios: {@code [0.5..30]}. */ /** The range of supported damping scaling factors: {@code [0.5..30]}. */
public static final Range<Double> DAMPING_RATIO_RANGE = Range.closed(0.05, 30.0); public static final Range<Double> DAMPING_RATIO_RANGE = Range.closed(0.05, 30.0);
private static final String[] DSF_KEYS = private static final String[] DSF_KEYS =
{ "0.5", "1", "2", "3", "5", "7", "10", "15", "20", "25", "30" }; { "0.5", "1", "2", "3", "5", "7", "10", "15", "20", "25", "30" };
private static final List<Double> DSF_VALUES = Arrays.stream(DSF_KEYS) /**
* The list of supported damping scaling factors (percentage values):
* {@code [0.5, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30]}.
*/
public static final List<Double> DSF_VALUES = Arrays.stream(DSF_KEYS)
.map(Double::valueOf) .map(Double::valueOf)
.collect(toList()); .collect(toList());
...@@ -148,7 +152,7 @@ public class UsgsDampingScaling { ...@@ -148,7 +152,7 @@ public class UsgsDampingScaling {
return XySequence.create(DSF_VALUES, corrCoeffs); return XySequence.create(DSF_VALUES, corrCoeffs);
} }
/** The set of IMTs supported by this class. */ /** The set of IMTs supported by the damping models in this class. */
public static final Set<Imt> supportedImts() { public static final Set<Imt> supportedImts() {
return INSTANCE_MAP.get(ACTIVE_CRUST).coeffs.keySet(); return INSTANCE_MAP.get(ACTIVE_CRUST).coeffs.keySet();
} }
......
...@@ -249,7 +249,7 @@ class ModelTrees { ...@@ -249,7 +249,7 @@ class ModelTrees {
/* /*
* Convert a SourceTree to a logic tree of the total MFDs for each branch * Convert a SourceTree to a logic tree of the total MFDs for each branch
* (RuptureSet). A LogicGroup is accomodates null (do-nothing) branches in the * (RuptureSet). A LogicGroup accomodates null (do-nothing) branches in the
* source tree. * source tree.
*/ */
static LogicGroup<Mfd> toMfdTree(SourceTree sourceTree) { static LogicGroup<Mfd> toMfdTree(SourceTree sourceTree) {
......
...@@ -63,6 +63,8 @@ class CalcConfigTests { ...@@ -63,6 +63,8 @@ class CalcConfigTests {
static final CalcConfig DEFAULTS; static final CalcConfig DEFAULTS;
static final CalcConfig EXTENDS; static final CalcConfig EXTENDS;
static final CalcConfig EXTENDS_EMPTY; // same as DEFAULTS static final CalcConfig EXTENDS_EMPTY; // same as DEFAULTS
// used to test that arrays are both non-null and not empty
static final CalcConfig EXTENDS_EMPTY_ARRAYS; // imts, types
static { static {
try { try {
...@@ -73,6 +75,9 @@ class CalcConfigTests { ...@@ -73,6 +75,9 @@ class CalcConfigTests {
EXTENDS_EMPTY = CalcConfig.defaults() EXTENDS_EMPTY = CalcConfig.defaults()
.extend(CalcConfig.from(RESOURCES.resolve("calc-config-extends-empty.json"))) .extend(CalcConfig.from(RESOURCES.resolve("calc-config-extends-empty.json")))
.build(); .build();
EXTENDS_EMPTY_ARRAYS = CalcConfig.defaults()
.extend(CalcConfig.from(RESOURCES.resolve("calc-config-extends-empty-arrays.json")))
.build();
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(); throw new RuntimeException();
...@@ -278,6 +283,9 @@ class CalcConfigTests { ...@@ -278,6 +283,9 @@ class CalcConfigTests {
assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat); assertEquals(ValueFormat.ANNUAL_RATE, def.valueFormat);
assertEquals(true, def.distanceFilterUpdate); assertEquals(true, def.distanceFilterUpdate);
assertEquals(true, def.gridFocalMechUpdate); assertEquals(true, def.gridFocalMechUpdate);
def = EXTENDS_EMPTY_ARRAYS.hazard;
assertEquals(IMTS, def.imts);
} }
@Test @Test
...@@ -379,6 +387,9 @@ class CalcConfigTests { ...@@ -379,6 +387,9 @@ class CalcConfigTests {
assertEquals(Path.of("hazout"), def.directory); assertEquals(Path.of("hazout"), def.directory);
assertEquals(Set.of(DataType.TOTAL, DataType.MAP), def.dataTypes); assertEquals(Set.of(DataType.TOTAL, DataType.MAP), def.dataTypes);
assertEquals(defaultReturnPeroiods, def.returnPeriods); assertEquals(defaultReturnPeroiods, def.returnPeriods);
def = EXTENDS_EMPTY_ARRAYS.output;
assertEquals(Set.of(DataType.TOTAL, DataType.MAP), def.dataTypes);
} }
@Test @Test
......
{
"hazard": {
"imts": []
},
"output": {
"dataTypes": []
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment