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

lib update with config ret period --> double

parent d6a4e7a2
No related branches found
No related tags found
1 merge request!801lib update with config ret period --> double
......@@ -12,7 +12,7 @@ micronautVersion = 3.2.3
micronautRxVersion = 2.1.1
nodePluginVersion = 3.0.1
nodeVersion = 16.3.0
nshmpLibVersion = 1.5.1
nshmpLibVersion = 1.5.2
nshmpUtilsJavaVersion = 0.4.0
openApiVersion = 4.0.0
shadowVersion = 7.1.2
......
......@@ -27,7 +27,7 @@ public class HazardMaps {
private static final String COMMA = ",";
private static final String CURVES_FILE = "curves.csv";
private static final List<Integer> DEFAULT_RETURN_PERIODS = List.of(475, 975, 2475);
private static final List<Double> DEFAULT_RETURN_PERIODS = List.of(475.0, 975.0, 2475.0);
private static final Interpolator INTERPOLATOR = Interpolator.builder()
.logx()
.logy()
......@@ -61,14 +61,13 @@ public class HazardMaps {
}
Path curvesPath = Path.of(args[0]);
List<Integer> returnPeriods = DEFAULT_RETURN_PERIODS;
List<Double> returnPeriods = DEFAULT_RETURN_PERIODS;
Logger log = Logger.getLogger(HazardMaps.class.getName());
if (args.length > 1) {
returnPeriods = Arrays.stream(args)
.skip(1)
.mapToInt(Integer::valueOf)
.boxed()
.map(Double::valueOf)
.collect(Collectors.toList());
}
......@@ -83,7 +82,7 @@ public class HazardMaps {
static void createDataSets(
Path curvesPath,
List<Integer> returnPeriods,
List<Double> returnPeriods,
Logger log) throws IOException {
log.info(PROGRAM + ": Creating hazard map datasets...");
log.info(" Return periods: " + returnPeriods.toString());
......@@ -97,7 +96,7 @@ public class HazardMaps {
}
}
private static List<String> create(List<String> lines, List<Integer> returnPeriods) {
private static List<String> create(List<String> lines, List<Double> returnPeriods) {
int headerCount = lines.get(0).startsWith("name") ? 3 : 2;
List<String> header = Arrays.asList(lines.get(0).split(COMMA));
......@@ -126,7 +125,7 @@ public class HazardMaps {
return linesOut;
}
private static void processCurveFile(Path curves, List<Integer> returnPeriods) {
private static void processCurveFile(Path curves, List<Double> returnPeriods) {
try (Stream<String> stream = Files.lines(curves)) {
List<String> linesIn = stream.collect(Collectors.toList());
List<String> linesOut = create(linesIn, returnPeriods);
......@@ -138,9 +137,9 @@ public class HazardMaps {
}
private static class CurvesVisitor extends SimpleFileVisitor<Path> {
List<Integer> returnPeriods;
List<Double> returnPeriods;
public CurvesVisitor(List<Integer> returnPeriods) {
public CurvesVisitor(List<Double> returnPeriods) {
this.returnPeriods = returnPeriods;
}
......@@ -155,11 +154,11 @@ public class HazardMaps {
}
private static class Slicer {
private final List<Integer> returnPeriods;
private final List<Double> returnPeriods;
private final double[] imls;
private final int headerCount;
private Slicer(List<Integer> returnPeriods, double imls[], int headerCount) {
private Slicer(List<Double> returnPeriods, double imls[], int headerCount) {
this.returnPeriods = returnPeriods;
this.imls = imls;
this.headerCount = headerCount;
......
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