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

Merge branch 'hawaii-disagg' into 'master'

Repo docs and disagg updates

See merge request ghsc/nshmp/nshmp-haz-v2!524
parents 3a63cccd f341ddf4
No related branches found
No related tags found
1 merge request!524Repo docs and disagg updates
Pipeline #52198 passed
# Acknowledgements
This software was developed to meet the U.S. Geological Survey's need for a
high-performance probabilistic seismic hazard (PSHA) engine capable of supporting
increasingly complex earthquake hazard models via web-services. It leverages and
benefits from many design and performance features found in
[OpenSHA](http://www.opensha.org) and the legacy [USGS fortran codes](/usgs/nshmp-haz-fortran),
both of which have been supported by the USGS and others over many years. In particular,
the Southern California Earthquake Center ([SCEC](https://www.scec.org)) has been instrumental
in the continued development of OpenSHA, which is in use worldwide.
This software is not a replacement for OpenSHA and does not provide a public API for PSHA
development. In the near future, `nshmp-haz` will likely be added as a dependency in OpenSHA
so that it's users may gain access to the most current USGS hazard models.
# Code of Conduct
All contributions to and interactions surrounding this project will abide by
the [USGS Code of Scientific Conduct][1].
[1]: https://www2.usgs.gov/fsp/fsp_code_of_scientific_conduct.asp
# Contributing
Contributions are welcome from the community. Questions can be asked on the
[issues page][1]. Before creating a new issue, please take a moment to search
and make sure a similar issue does not already exist. If one does exist, you
can comment (most simply even with just a `:+1:`) to show your support for that
issue.
If you have direct contributions you would like considered for incorporation
into the project you can [fork this repository][2] and
[submit a merge request][3] for review.
[1]: https://code.usgs.gov/ghsc/nshmp/nshm-fault-sections/issues
[2]: https://docs.gitlab.com/ee/gitlab-basics/fork-project.html
[3]: https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html
# Disclaimer
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Information provided by this software may be preliminary or provisional and is subject to
revision. It is being provided to meet the need for timely best science. The information is
provided on the condition that neither the U.S. Geological Survey nor the U.S. Government
shall be held liable for any damages resulting from the authorized or unauthorized use of the information.
This software has been approved for release by the U.S. Geological Survey
(USGS). Although the software has been subjected to rigorous review, the USGS
reserves the right to update the software as needed pursuant to further analysis
and review. No warranty, expressed or implied, is made by the USGS or the U.S.
Government as to the functionality of the software and related material nor
shall the fact of release constitute any such warranty. Furthermore, the
software is released on condition that neither the USGS nor the U.S. Government
shall be held liable for any damages resulting from its authorized or
unauthorized use.
# License
Unless otherwise noted, this software is in the public domain because it contains materials
that originally came from the U.S. Geological Survey (USGS), an agency of the U.S. Department
of Interior. For more information, see the official USGS
[copyright policy](http://www.usgs.gov/visual-id/credit_usgs.html#copyright).
Unless otherwise noted, this project is in the public domain in the United
States because it contains materials that originally came from the United
States Geological Survey, an agency of the United States Department of
Interior. For more information, see the official USGS copyright policy at
<https://www2.usgs.gov/visual-id/credit_usgs.html#copyright>
Dependent libraries managed by the [Gradle](https://gradle.org) build tool are distributed
under open source (or open source-like) licenses. Links to appropriate license agreements
for each can be found below.
Additionally, we waive copyright and related rights in the work
worldwide through the CC0 1.0 Universal public domain dedication.
## Runtime language and libraries
## CC0 1.0 Universal Summary
- [Java 8](http://www.oracle.com/technetwork/java/javase/terms/license)
- [Google Guava 26.0](https://github.com/google/guava/blob/master/COPYING)
- [Google Gson 2.8.5](https://github.com/google/gson/blob/master/LICENSE)
This is a human-readable summary of the
[Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
## Build tools and libraries
### No Copyright
- [Gradle](https://github.com/gradle/gradle/blob/master/LICENSE)
- [JUnit](http://junit.org/junit4/license.html)
- [JaCoCo](http://www.jacoco.org/jacoco/trunk/doc/license.html)
The person who associated a work with this deed has dedicated the work to
the public domain by waiving all of his or her rights to the work worldwide
under copyright law, including all related and neighboring rights, to the
extent allowed by law.
You can copy, modify, distribute and perform the work, even for commercial
purposes, all without asking permission.
### Other Information
In no way are the patent or trademark rights of any person affected by CC0,
nor are the rights that other persons may have in the work or in how the
work is used, such as publicity or privacy rights.
Unless expressly stated otherwise, the person who associated a work with
this deed makes no warranties about the work, and disclaims liability for
all uses of the work, to the fullest extent permitted by applicable law.
When using or citing the work, you should not imply endorsement by the
author or the affirmer.
# nshmp-haz
U.S. Geological Survey ([USGS](https://www.usgs.gov)) National Seismic Hazard Mapping Project
([NSHMP](https://earthquake.usgs.gov/hazards/)) code for performing probabilistic seismic hazard
(PSHA) and related analyses. These codes are intended for use with seismic hazard models
developed by the NSHMP for the U.S. and its territories.
U.S. Geological Survey ([USGS](https://www.usgs.gov)) National Seismic Hazard Model Project
([NSHMP](https://earthquake.usgs.gov/hazards/)) codes for performing probabilistic seismic
hazard (PSHA) and related analyses. These codes are intended for use with seismic hazard models
developed by the NSHMP for the U.S. and its territories. This project includes a variety of
command line applications and web service classes and relies on the
[*nshmp-lib*](https://code.usgs.gov/ghsc/nshmp/nshmp-lib) hazard library, among other
dependencies.
Please see the [wiki](https://code.usgs.gov/ghsc/nshmp/nshmp-haz-v2/wikis/home)
for more information.
Please see the [docs](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/docs) for more information.
......@@ -10,7 +10,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
......@@ -91,11 +90,7 @@ public class DeaggEpsilon {
log.info(PROGRAM + ": " + HazardCalc.VERSION);
Path modelPath = Paths.get(args[0]);
Path wusPath = modelPath.resolve("Western US");
Path ceusPath = modelPath.resolve("Central & Eastern US");
HazardModel wusModel = HazardModel.load(wusPath);
HazardModel ceusModel = HazardModel.load(ceusPath);
HazardModel model = HazardModel.load(modelPath);
log.info("");
Path siteFile = Paths.get(args[1]);
......@@ -105,22 +100,16 @@ public class DeaggEpsilon {
int colsToSkip = headerCount(siteFile);
List<Imt> imts = readImtList(siteFile, colsToSkip);
CalcConfig wusConfig = wusModel.config();
CalcConfig ceusConfig = ceusModel.config();
CalcConfig config = model.config();
if (argCount == 3) {
Path userConfigPath = Paths.get(args[2]);
wusConfig = CalcConfig.copyOf(wusModel.config())
.extend(CalcConfig.from(userConfigPath))
.imts(EnumSet.copyOf(imts))
.build();
ceusConfig = CalcConfig.copyOf(ceusModel.config())
config = CalcConfig.copyOf(model.config())
.extend(CalcConfig.from(userConfigPath))
.imts(EnumSet.copyOf(imts))
.build();
}
log.info(wusConfig.toString());
log.info(config.toString());
List<Site> sites = ImmutableList.copyOf(Sites.fromCsv(siteFile, wusConfig, true));
List<Site> sites = ImmutableList.copyOf(Sites.fromCsv(siteFile, config, true));
log.info("Sites: " + sites.size());
log.info("Site data columns: " + colsToSkip);
......@@ -129,14 +118,14 @@ public class DeaggEpsilon {
checkArgument(sites.size() == imtImlMaps.size(), "Sites and spectra lists different sizes");
Path out = calc(wusModel, wusConfig, ceusModel, ceusConfig, sites, imtImlMaps, log);
Path out = calc(model, config, sites, imtImlMaps, log);
log.info(PROGRAM + ": finished");
/* Transfer log and write config, windows requires fh.close() */
fh.close();
Files.move(tmpLog, out.resolve(PROGRAM + ".log"));
wusConfig.write(out);
config.write(out);
return Optional.empty();
......@@ -196,16 +185,14 @@ public class DeaggEpsilon {
* HazardCalc.calc() that will trigger deaggregations if the value is present.
*/
private static Path calc(
HazardModel wusModel,
CalcConfig wusConfig,
HazardModel ceusModel,
CalcConfig ceusConfig,
HazardModel model,
CalcConfig config,
List<Site> sites,
List<Map<Imt, Double>> rtrSpectra,
Logger log) throws IOException {
ExecutorService exec = null;
ThreadCount threadCount = wusConfig.performance.threadCount;
ThreadCount threadCount = config.performance.threadCount;
if (threadCount == ThreadCount.ONE) {
exec = MoreExecutors.newDirectExecutorService();
log.info("Threads: Running on calling thread");
......@@ -215,7 +202,7 @@ public class DeaggEpsilon {
}
log.info(PROGRAM + ": calculating ...");
Path outDir = createOutputDir(wusConfig.output.directory);
Path outDir = createOutputDir(config.output.directory);
Path siteDir = outDir.resolve("vs30-" + (int) sites.get(0).vs30);
Files.createDirectory(siteDir);
......@@ -226,24 +213,11 @@ public class DeaggEpsilon {
Site site = sites.get(i);
Map<Imt, Double> spectrum = rtrSpectra.get(i);
Hazard wusHazard = null;
if (site.location.longitude <= -100.0) {
wusHazard = HazardCalcs.hazard(wusModel, wusConfig, site, exec);
}
Hazard ceusHazard = null;
if (site.location.longitude > -115.0) {
ceusHazard = HazardCalcs.hazard(ceusModel, ceusConfig, site, exec);
}
Hazard cousHazard = (wusHazard == null)
? ceusHazard
: (ceusHazard == null)
? wusHazard
: Hazard.merge(wusHazard, ceusHazard);
Disaggregation disagg = Disaggregation.atImls(cousHazard, spectrum, exec);
Hazard hazard = HazardCalcs.hazard(model, config, site, exec);
Disaggregation disagg = Disaggregation.atImls(hazard, spectrum, exec);
List<Response> responses = new ArrayList<>(spectrum.size());
for (Imt imt : wusConfig.hazard.imts) {
for (Imt imt : config.hazard.imts) {
ResponseData imtMetadata = new ResponseData(
ImmutableList.of(),
site,
......
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