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

updated reult generator

parent fe66da72
No related branches found
No related tags found
1 merge request!259Subduction basin term update; Zhao06 coeffs and site term smoothing
...@@ -9,7 +9,6 @@ import com.google.common.base.Function; ...@@ -9,7 +9,6 @@ import com.google.common.base.Function;
import com.google.common.base.StandardSystemProperty; import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.io.Files;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import com.google.common.primitives.Doubles; import com.google.common.primitives.Doubles;
...@@ -17,6 +16,10 @@ import java.io.File; ...@@ -17,6 +16,10 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -60,11 +63,14 @@ public class GmmTest { ...@@ -60,11 +63,14 @@ public class GmmTest {
} }
/* Use to generate Gmm result file */ /* Use to generate Gmm result file */
static void generateResults(Set<Gmm> gmms, Set<Imt> imts, String inputsFileName, static void generateResults(
Set<Gmm> gmms,
Set<Imt> imts,
String inputsFileName,
String resultsFileName) throws IOException { String resultsFileName) throws IOException {
List<GmmInput> inputs = loadInputs(inputsFileName); List<GmmInput> inputs = loadInputs(inputsFileName);
File out = new File("tmp/Gmm-tests/" + resultsFileName); List<String> lines = new ArrayList<>();
Files.write("", out, StandardCharsets.UTF_8);
for (Gmm gmm : gmms) { for (Gmm gmm : gmms) {
for (Imt imt : imts) { for (Imt imt : imts) {
GroundMotionModel gmModel = gmm.instance(imt); GroundMotionModel gmModel = gmm.instance(imt);
...@@ -76,12 +82,13 @@ public class GmmTest { ...@@ -76,12 +82,13 @@ public class GmmTest {
Lists.newArrayList(modelIndex++ + "-" + id, Lists.newArrayList(modelIndex++ + "-" + id,
String.format("%.6f", Math.exp(sgm.mean())), String.format("%.6f", Math.exp(sgm.mean())),
String.format("%.6f", sgm.sigma())), String.format("%.6f", sgm.sigma())),
Delimiter.COMMA) + Delimiter.COMMA);
StandardSystemProperty.LINE_SEPARATOR.value(); lines.add(result);
Files.append(result, out, StandardCharsets.UTF_8);
} }
} }
} }
Path out = Paths.get("tmp/Gmm-tests/", resultsFileName);
Files.write(out, lines, StandardCharsets.UTF_8);
} }
static List<Object[]> loadResults(String resource) throws IOException { static List<Object[]> loadResults(String resource) throws IOException {
......
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