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

removed site defaults and tests

parent 2e93458e
No related branches found
No related tags found
1 merge request!245Site defaults cleanup
......@@ -77,9 +77,6 @@ public final class CalcConfig {
/** Earthquake rate configuration. */
public final Rate rate;
/** Default site settings. */
public final SiteDefaults site;
/** Output configuration. */
public final Output output;
......@@ -88,7 +85,6 @@ public final class CalcConfig {
private CalcConfig(Builder builder) {
hazard = builder.hazard.build();
site = builder.site.build();
performance = builder.performance.build();
output = builder.output.build();
disagg = builder.disagg.build();
......@@ -101,7 +97,6 @@ public final class CalcConfig {
public static Builder copyOf(CalcConfig config) {
Builder b = new Builder();
b.hazard.copy(config.hazard);
b.site.copy(config.site);
b.performance.copy(config.performance);
b.output.copy(config.output);
b.disagg.copy(config.disagg);
......@@ -688,87 +683,6 @@ public final class CalcConfig {
}
}
/**
* Default site settings.
*/
public static final class SiteDefaults {
/**
* The default average shear-wave velocity down to 30 meters depth.
*
* <p><b>Default:</b> {@code 760.0} m/sec
*/
public final double vs30;
/**
* Whether Vs30 was inferred, {@code true}, or measured, {@code false}.
*
* <p><b>Default:</b> {@code true} (inferred)
*/
public final boolean vsInferred;
/**
* Depth to the shear-wave velocity horizon of 1.0 km/sec, in km.
*
* <p><b>Default:</b> {@code NaN} ({@link GroundMotionModel}s will use a
* default value or model)
*/
public final double z1p0;
/**
* Depth to the shear-wave velocity horizon of 2.5 km/sec, in km;
*
* <p><b>Default:</b> {@code NaN} ({@link GroundMotionModel}s will use a
* default value or model)
*/
public final double z2p5;
private SiteDefaults(Builder b) {
this.vs30 = b.vs30;
this.vsInferred = b.vsInferred;
this.z1p0 = b.z1p0;
this.z2p5 = b.z2p5;
}
private static final class Builder {
Double vs30;
Boolean vsInferred;
Double z1p0;
Double z2p5;
SiteDefaults build() {
checkNotNull(vs30);
checkNotNull(vsInferred);
z1p0 = (z1p0 == null) ? Double.NaN : z1p0;
z2p5 = (z2p5 == null) ? Double.NaN : z2p5;
return new SiteDefaults(this);
}
void copy(SiteDefaults that) {
this.vs30 = that.vs30;
this.vsInferred = that.vsInferred;
this.z1p0 = that.z1p0;
this.z2p5 = that.z2p5;
}
void extend(Builder that) {
if (that.vs30 != null) {
this.vs30 = that.vs30;
}
if (that.vsInferred != null) {
this.vsInferred = that.vsInferred;
}
if (that.z1p0 != null) {
this.z1p0 = that.z1p0;
}
if (that.z2p5 != null) {
this.z2p5 = that.z2p5;
}
}
}
}
/**
* Data and file output settings.
*/
......@@ -931,21 +845,9 @@ public final class CalcConfig {
.setPrettyPrinting()
.enableComplexMapKeySerialization()
.serializeNulls()
.registerTypeAdapter(Double.class, new DoubleSerializer())
.registerTypeHierarchyAdapter(Path.class, new PathConverter())
.create();
private static class DoubleSerializer implements JsonSerializer<Double> {
@Override
public JsonElement serialize(
Double value,
Type type,
JsonSerializationContext context) {
return Double.isNaN(value) ? null : new JsonPrimitive(value);
}
}
private static class PathConverter implements JsonSerializer<Path>, JsonDeserializer<Path> {
@Override
......@@ -984,7 +886,6 @@ public final class CalcConfig {
public static final class Builder {
private Hazard.Builder hazard;
private SiteDefaults.Builder site;
private Performance.Builder performance;
private Output.Builder output;
private Disagg.Builder disagg;
......@@ -992,7 +893,6 @@ public final class CalcConfig {
private Builder() {
hazard = new Hazard.Builder();
site = new SiteDefaults.Builder();
performance = new Performance.Builder();
output = new Output.Builder();
disagg = new Disagg.Builder();
......@@ -1006,7 +906,6 @@ public final class CalcConfig {
public Builder extend(Builder that) {
checkNotNull(that);
this.hazard.extend(that.hazard);
this.site.extend(that.site);
this.performance.extend(that.performance);
this.output.extend(that.output);
this.disagg.extend(that.disagg);
......
......@@ -43,15 +43,6 @@
"valueFormat": "ANNUAL_RATE",
"timespan": 30.0
},
"siteData": {
"service": null
},
"site": {
"vs30": 760.0,
"vsInferred": true,
"z1p0": null,
"z2p5": null
},
"output": {
"directory": "hazout",
"dataTypes": [
......
......@@ -121,8 +121,6 @@ class CalcConfigTests {
.timespan(timespan)
.build();
assertEquals(imts, config.hazard.imts);
System.out.println(dataTypes);
System.out.println(config.output.dataTypes);
assertEquals(dataTypes, config.output.dataTypes);
assertEquals(distance, config.rate.distance);
assertEquals(timespan, config.rate.timespan);
......@@ -340,27 +338,6 @@ class CalcConfigTests {
assertEquals(30.0, def.timespan);
}
@Test
void testSiteMember() {
CalcConfig.SiteDefaults def = DEFAULTS.site;
assertEquals(760.0, def.vs30);
assertEquals(true, def.vsInferred);
assertEquals(Double.NaN, def.z1p0);
assertEquals(Double.NaN, def.z2p5);
def = EXTENDS.site;
assertEquals(530.0, def.vs30);
assertEquals(false, def.vsInferred);
assertEquals(0.3, def.z1p0);
assertEquals(1.0, def.z2p5);
def = EXTENDS_EMPTY.site;
assertEquals(760.0, def.vs30);
assertEquals(true, def.vsInferred);
assertEquals(Double.NaN, def.z1p0);
assertEquals(Double.NaN, def.z2p5);
}
@Test
void testOutputMember() {
List<Integer> defaultReturnPeroiods = List.of(475, 975, 2475, 10000);
......
......@@ -41,15 +41,6 @@
"valueFormat": "POISSON_PROBABILITY",
"timespan": 20.0
},
"siteData": {
"service": "http://localhost"
},
"site": {
"vs30": 530.0,
"vsInferred": false,
"z1p0": 0.3,
"z2p5": 1.0
},
"output": {
"directory": "custom",
"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