From 77a30ab736f2d177e5cef8bdb5fb5cda0d133ecb Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Thu, 24 Feb 2022 11:01:30 -0700 Subject: [PATCH] named sites flag --- .../earthquake/nshmp/calc/HazardExport.java | 17 ++++++++--------- .../earthquake/nshmp/model/LoaderTests.java | 3 ++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardExport.java b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardExport.java index 47ccd92e..8a62bce2 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardExport.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/calc/HazardExport.java @@ -69,7 +69,7 @@ public final class HazardExport { private HazardExport( HazardModel model, CalcConfig config, - List<Site> sites, + boolean namedSites, Path out) throws IOException { this.out = out; @@ -83,10 +83,8 @@ public final class HazardExport { ? Maths.annualRateToProbabilityConverter().andThen(formatter) : formatter; - Site demoSite = sites.get(0); - this.namedSites = demoSite.name() != Site.NO_NAME; - - init(sites); + this.namedSites = namedSites; + init(); } /** @@ -94,21 +92,22 @@ 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 namedSites whether the sites being processed contain a 'name' column + * that should be preserved in output files * @param out results directory; this may have been been modified from * {@code config.output.directory} by calling program */ public static HazardExport create( HazardModel model, CalcConfig config, - List<Site> sites, + boolean namedSites, Path out) throws IOException { - return new HazardExport(model, config, sites, out); + return new HazardExport(model, config, namedSites, out); } /* Initialize output directories. */ - private void init(List<Site> sites) throws IOException { + private void init() throws IOException { for (Imt imt : config.hazard.imts) { diff --git a/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java b/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java index 0b795093..aca6c3d4 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java @@ -214,7 +214,8 @@ class LoaderTests { List<Site> sites) throws IOException { ExecutorService exec = initExecutor(config.performance.threadCount); - HazardExport handler = HazardExport.create(model, config, sites, config.output.directory); + boolean namedSites = sites.get(0).name() != Site.NO_NAME; + HazardExport handler = HazardExport.create(model, config, namedSites, config.output.directory); for (Site site : sites) { Hazard hazard = HazardCalcs.hazard(model, config, site, exec); handler.write(hazard); -- GitLab