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

simplified hazardExport

parent b76e202e
No related branches found
No related tags found
1 merge request!244Program edits
......@@ -22,10 +22,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Function;
import java.util.logging.Logger;
import java.util.stream.IntStream;
import com.google.common.base.Stopwatch;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
......@@ -66,7 +64,6 @@ public final class HazardExport {
private static final String CURVE_FILE_ASCII_TRUNCATED = "curves-truncated.csv";
private static final String VALUE_FMT = "%.8e";
private final Logger log;
private final Path dir;
private final HazardModel model;
private final CalcConfig config;
......@@ -75,9 +72,6 @@ public final class HazardExport {
private final Function<Double, String> valueFormatter;
private final Stopwatch batchWatch;
private final Stopwatch totalWatch;
private int batchCount = 0;
private int resultCount = 0;
private final boolean namedSites;
......@@ -86,10 +80,8 @@ public final class HazardExport {
private HazardExport(
HazardModel model,
CalcConfig config,
List<Site> sites,
Logger log) throws IOException {
List<Site> sites) throws IOException {
this.log = log;
this.dir = createOutputDir(config.output.directory);
this.model = model;
this.config = config;
......@@ -104,9 +96,6 @@ public final class HazardExport {
Site demoSite = sites.get(0);
this.namedSites = demoSite.name() != Site.NO_NAME;
this.batchWatch = Stopwatch.createStarted();
this.totalWatch = Stopwatch.createStarted();
init(sites);
}
......@@ -121,10 +110,9 @@ public final class HazardExport {
public static HazardExport create(
HazardModel model,
CalcConfig config,
List<Site> sites,
Logger log) throws IOException {
List<Site> sites) throws IOException {
return new HazardExport(model, config, sites, log);
return new HazardExport(model, config, sites);
}
/* Initialize output directories. */
......@@ -195,13 +183,6 @@ public final class HazardExport {
checkState(!used, "This result handler is expired");
writeHazard(hazard);
resultCount++;
if (resultCount % 10 == 0) {
batchCount++;
log.info(String.format(
" batch: %s in %s – %s sites in %s",
batchCount, batchWatch, resultCount, totalWatch));
batchWatch.reset().start();
}
}
/**
......@@ -209,26 +190,16 @@ public final class HazardExport {
* 'used'; no more results may be added.
*/
public void expire() {
batchWatch.stop();
totalWatch.stop();
used = true;
}
/**
* The number of hazard [and disagg] results passed to this handler thus far.
* The number of hazard results passed to this handler thus far.
*/
public int resultCount() {
return resultCount;
}
/**
* A string representation of the time duration that this result handler has
* been running.
*/
public String elapsedTime() {
return totalWatch.toString();
}
/**
* The target output directory established by this handler.
*/
......@@ -236,7 +207,7 @@ public final class HazardExport {
return dir;
}
/* Write the supplied hazard and possible disagg results to file(s). */
/* Write the supplied hazard results to file(s). */
private void writeHazard(Hazard hazard) throws IOException {
Set<Gmm> gmms = hazard.model.gmms();
......
......@@ -71,7 +71,7 @@ public final class Sites {
* If a sites file contains columns for basin depths, a 'null' value string
* indicates a GMM should do whatever it defines as default behavior and
* will override values that may be included in the site data of a model. If
* the value is empty, then whatever defaults from (2) or (3) will be used.
* the value is empty, then whatever values from (2) or (3) will be used.
*/
Location loc = Location.create(
......
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