diff --git a/.gitignore b/.gitignore index 1d4aedc826db62eaeae637253d8d871be6c84dbe..45241b570473cd75ba69cb425c00868b06f3db49 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,3 @@ DisaggCalc.java node_modules package-lock.json package.json -src/test/java/gov/usgs/earthquake/nshmp/model/ -src/test/resources/e2e/ diff --git a/README.md b/README.md index f411459b25e9aa7127338dbbb05e9095f56044a7..245eba45471f0d5ece8fb60e4fc0cc20fda19800 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,26 @@ # nshmp-lib -***nshmp-lib*** is a USGS developed Java library that supports probabilistic seismic hazard (PSHA) -and related analyses. This project includes all the code required to load, process and query USGS -National Seismic Hazard Models (NSHMs). *nshmp-lib* is used by command line applications and web -services found in the [*nshmp-haz*](https://code.usgs.gov/ghsc/nshmp/nshmp-haz) project. See that -project for running PSHA calculations. +***nshmp-lib*** is a U.S. Geological Survey ([USGS][1]) developed Java library that supports +probabilistic seismic hazard (PSHA) and related analyses. This project includes all the code +required to load, process and query USGS National Seismic Hazard Models (NSHMs). *nshmp-lib* is +used by command line applications and web services found in the [*nshmp-haz*][2] project. See +that project for details on running PSHA calculations. -The project uses [Gradle](https://gradle.org/) for building and testing. To run unit tests and -create a JAR file for use in other projects, run `./gradlew build` from the root of the repository. +The project uses [Gradle][3] for building and testing. To run unit tests and create a JAR file +for use in other projects, run `./gradlew build` from the root of the repository. (or `./gradlew.bat build` if using Windows). See also: -* [*nshmp-haz*](https://code.usgs.gov/ghsc/nshmp/nshmp-haz) and related - [documentation](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/blob/main/docs/README.md) -* Project [Javadocs](https://earthquake.usgs.gov/nshmp/docs/nshmp-lib/) +* [*nshmp-haz*][4] and related [documentation][5] +* Project [Javadocs][6] + +DOI: <https://doi.org/10.5066/P9DKFJ5V> (version [1.0.0][7]) + +[1]: https://www.usgs.gov +[2]: https://code.usgs.gov/ghsc/nshmp/nshmp-haz +[3]: https://gradle.org/ +[4]: https://code.usgs.gov/ghsc/nshmp/nshmp-haz +[5]: https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/blob/main/docs/README.md +[6]: https://earthquake.usgs.gov/nshmp/docs/nshmp-lib/ +[7]: https://code.usgs.gov/ghsc/nshmp/nshmp-lib/-/tags/1.0.0 diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java index f41cfce9034beb4469a221fc9f5296c882c72c54..395f455308295b8b5bb5693f7d937a76c9a87a40 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/KuehnEtAl_2020.java @@ -81,6 +81,9 @@ import gov.usgs.earthquake.nshmp.tree.LogicTree; * basin term to exceed that for the Seattle basin. The Python code does not * seem to impose this constraint but I may not be seeing it. * + * * Uncertainty values obtained from: + * https://github.com/nikuehn/KBCG20/tree/master/UNCERTAINTY + * * @author U.S. Geological Survey */ 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 aca6c3d41cd0b1e20becc6f8b3082d367c8f019b..3d8f9526a88202b0c281ef76f467f6edafd08f3e 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/model/LoaderTests.java @@ -20,20 +20,17 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.Stream; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import com.google.common.util.concurrent.MoreExecutors; - import gov.usgs.earthquake.nshmp.calc.CalcConfig; import gov.usgs.earthquake.nshmp.calc.Hazard; import gov.usgs.earthquake.nshmp.calc.HazardCalcs; import gov.usgs.earthquake.nshmp.calc.HazardExport; import gov.usgs.earthquake.nshmp.calc.Site; import gov.usgs.earthquake.nshmp.calc.Sites; -import gov.usgs.earthquake.nshmp.calc.ThreadCount; import gov.usgs.earthquake.nshmp.data.XySequence; import gov.usgs.earthquake.nshmp.geo.Location; import gov.usgs.earthquake.nshmp.gmm.Imt; @@ -62,21 +59,18 @@ class LoaderTests { model = ModelLoader.load(MODEL_PATH); sites = Sites.fromCsv(SITES_PATH, model.siteData(), OptionalDouble.empty()); expecteds = loadExpecteds(); - exec = initExecutor(model.config().performance.threadCount); + int cores = Runtime.getRuntime().availableProcessors(); + exec = Executors.newFixedThreadPool(cores); } - @Test - void emptyTestEclipseBug() { - /* - * Silly workaround for junt5 tests in eclipse where no tests are found - * unless at least one @Test annotation exists. Doesn't fix fact that one - * test below cannot be run on its own. - */ + @AfterAll + static void tearDownAfterClass() { + exec.shutdown(); } @ParameterizedTest @MethodSource("siteStream") - final void testLocation2(Site site) { + final void testLocation(Site site) { Location loc = site.location(); Map<Imt, XySequence> expected = expecteds.get(loc); Hazard actual = HazardCalcs.hazard(model, model.config(), site, exec); @@ -213,7 +207,9 @@ class LoaderTests { CalcConfig config, List<Site> sites) throws IOException { - ExecutorService exec = initExecutor(config.performance.threadCount); + int cores = Runtime.getRuntime().availableProcessors(); + exec = Executors.newFixedThreadPool(cores); + ExecutorService exec = Executors.newFixedThreadPool(cores); boolean namedSites = sites.get(0).name() != Site.NO_NAME; HazardExport handler = HazardExport.create(model, config, namedSites, config.output.directory); for (Site site : sites) { @@ -223,11 +219,4 @@ class LoaderTests { exec.shutdown(); return config.output.directory; } - - private static ExecutorService initExecutor(ThreadCount threadCount) { - return (threadCount == ThreadCount.ONE) - ? MoreExecutors.newDirectExecutorService() - : Executors.newFixedThreadPool(threadCount.value()); - } - }