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

hazard export takes path instead of optional vs30

parent 3923bee9
No related branches found
No related tags found
1 merge request!251Export updates
......@@ -65,7 +65,7 @@ public final class HazardExport {
private static final String CURVE_FILE_ASCII_TRUNCATED = "curves-truncated.csv";
private static final String VALUE_FMT = "%.8e";
private final Path dir;
private final Path out;
private final HazardModel model;
private final CalcConfig config;
private final boolean exportGmm;
......@@ -82,9 +82,9 @@ public final class HazardExport {
HazardModel model,
CalcConfig config,
List<Site> sites,
OptionalDouble vs30) throws IOException {
Path out) throws IOException {
this.dir = createOutputDir(config.output.directory, vs30);
this.out = out;
this.model = model;
this.config = config;
this.exportGmm = config.output.dataTypes.contains(DataType.GMM);
......@@ -107,16 +107,17 @@ public final class HazardExport {
* @param model being run
* @param config that specifies output options and formats
* @param sites reference to the sites to be processed (not retained)
* @param vs30 optional vs30 value used when running multiple site classes
* @param out results directory; this may have been been modified from
* {@code config.output.directory} by calling program
* @param log shared logging instance from calling class
*/
public static HazardExport create(
HazardModel model,
CalcConfig config,
List<Site> sites,
OptionalDouble vs30) throws IOException {
Path out) throws IOException {
return new HazardExport(model, config, sites, vs30);
return new HazardExport(model, config, sites, out);
}
/* Initialize output directories. */
......@@ -124,7 +125,7 @@ public final class HazardExport {
for (Imt imt : config.hazard.imts) {
Path imtDir = dir.resolve(imt.name());
Path imtDir = out.resolve(imt.name());
Files.createDirectory(imtDir);
Path totalFile = imtDir.resolve(CURVE_FILE_ASCII);
Path totalFileTruncated = imtDir.resolve(CURVE_FILE_ASCII_TRUNCATED);
......@@ -176,6 +177,7 @@ public final class HazardExport {
}
if (vs30.isPresent()) {
String vs30dir = "vs30-" + ((int) vs30.getAsDouble());
outDir = outDir.resolve(vs30dir);
}
Files.createDirectories(outDir);
......@@ -212,7 +214,7 @@ public final class HazardExport {
* The target output directory established by this handler.
*/
public Path outputDir() {
return dir;
return out;
}
/* Write the supplied hazard results to file(s). */
......@@ -240,7 +242,7 @@ public final class HazardExport {
String emptyLine = locStr + "0.0" + ",0.0".repeat(totalCurve.size() - 1);
Imt imt = imtEntry.getKey();
Path imtDir = dir.resolve(imt.name());
Path imtDir = out.resolve(imt.name());
String totalLine = locStr + valueStr(totalCurve, valueFormatter);
String totalLineTrunc = locStr + truncValueStr(totalCurve, valueFormatter, TRUNCATION_LIMIT);
......
......@@ -214,7 +214,7 @@ class LoaderTests {
List<Site> sites) throws IOException {
ExecutorService exec = initExecutor(config.performance.threadCount);
HazardExport handler = HazardExport.create(model, config, sites, OptionalDouble.empty());
HazardExport handler = HazardExport.create(model, config, sites, config.output.directory);
for (Site site : sites) {
Hazard hazard = HazardCalcs.hazard(model, config, site, exec);
handler.write(hazard);
......
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