From e081374c91efcbce382b4cf674f9e19450a30441 Mon Sep 17 00:00:00 2001 From: Jason Altekruse <jaltekruse@usgs.gov> Date: Wed, 29 Mar 2023 16:13:25 -0600 Subject: [PATCH 01/11] enable pretty print for disag calc results --- src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java b/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java index 6275df2b..227d1796 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java @@ -64,6 +64,7 @@ public class DisaggCalc { private static final Gson GSON = new GsonBuilder() .serializeSpecialFloatingPointValues() + .setPrettyPrinting() .serializeNulls() .create(); -- GitLab From 741db4e1054ebd88c7a289a4aae757ae38d487bc Mon Sep 17 00:00:00 2001 From: Jason Altekruse <jaltekruse@usgs.gov> Date: Wed, 29 Mar 2023 16:32:38 -0600 Subject: [PATCH 02/11] add note about unicode error and work around for windows users --- docs/pages/Building-&-Running.md | 4 ++++ etc/examples/7-disaggregation/README.md | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/docs/pages/Building-&-Running.md b/docs/pages/Building-&-Running.md index df822889..35d8685b 100644 --- a/docs/pages/Building-&-Running.md +++ b/docs/pages/Building-&-Running.md @@ -90,6 +90,10 @@ Disaggregations build on and output `HazardCalc` results along with other disagg files. Disaggregations also have some independent [configuration](./Calculation-Configuration.md#calculation-configuration-parameters) options. +Windows users may run into errors caused by unicode characters in the disaggregation configuration +options. As a work around, add `-Dfile.encoding="UTF-8"` to the java call (see +[example 7](../../etc/examples/7-disaggregation/README.md) for more details). + ## Customizing Code Whereas *nshmp-haz* contains code to run command line applications and web services, model diff --git a/etc/examples/7-disaggregation/README.md b/etc/examples/7-disaggregation/README.md index e6578d88..1cf4ab99 100644 --- a/etc/examples/7-disaggregation/README.md +++ b/etc/examples/7-disaggregation/README.md @@ -11,6 +11,12 @@ to create a second system alias: alias disagg='java -Xms4g -Xmx8g -cp /path/to/nshmp-haz/build/libs/nshmp-haz.jar gov.usgs.earthquake.nshmp.DisaggCalc' ``` +Note for Windows users: running `nshmp-haz` in command prompt, Power Shell, or GitBash may +result in errors caused by the unicode characters in the disaggregation configuration parameters. +For example: `java.lang.IllegalArgumentException: Invalid ? [0.0]`. To avoid this, try adding +'`-Dfile.encoding="UTF-8"`' before `-cp` in the disagg alias shown above. This error does not +seem to occur if `nshmp-haz` is built and run in the Windows Subsystem for Linux (WSL). + The command line arguments for `DisaggCalc` are the same as those for `HazardCalc`. The target return period for a disaggregation is specified in the config [`disagg.returnPeriod`](../../../docs/pages/Calculation-Configuration.md#calculation-configuration-parameters) -- GitLab From 71ecb0561adcd2c810162bd70b1475a608f56bac Mon Sep 17 00:00:00 2001 From: Jason Altekruse <jaltekruse@usgs.gov> Date: Wed, 29 Mar 2023 17:23:40 -0600 Subject: [PATCH 03/11] instruct users to use nshm-conus v5.2.0 instead of main --- etc/examples/5-complex-model/README.md | 16 ++++++++++++++-- etc/examples/6-enhanced-output/README.md | 4 ++-- etc/examples/7-disaggregation/README.md | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/etc/examples/5-complex-model/README.md b/etc/examples/5-complex-model/README.md index b76e83b6..fc5db9d3 100644 --- a/etc/examples/5-complex-model/README.md +++ b/etc/examples/5-complex-model/README.md @@ -15,11 +15,23 @@ alias hazard='java -Xms4g -Xmx8g -cp /path/to/nshmp-haz/build/libs/nshmp-haz.jar This will increase the minimum amount of memory Java requires to 4GB and will allow it to claim up to 8GB, assuming that much is available. -First, clone the CONUS NSHM repository. Assuming you are in the current working directory -(above), the following will create a copy of the model adjacent to nshmp-haz: +First, download the +[CONUS NSHM version 5.2.0](https://code.usgs.gov/ghsc/nshmp/nshms/nshm-conus/-/archive/5.2.0/nshm-conus-5.2.0.zip) +and unzip adjacent to nshmp-haz. Note that in subsequent examples, the name of the model +should match the unzipped directory name (e.g. `../../../../nshm-conus-5.2.0`). + +Alternatively, clone the CONUS NSHM repository. The `main` branch is under active development and +may break some of the examples, so you need to checkout a stable version of the NSHM. Assuming you +are in the current working directory (above), the following will create a copy of the model +adjacent to nshmp-haz and checkout version 5.2.0. See [CONTRIBUTING.md](../../../CONTRIBUTING.md) +for more information about contributing to nshmp-haz or nshm-conus. ```Shell git clone https://code.usgs.gov/ghsc/nshmp/nshms/nshm-conus.git ../../../../nshm-conus +cd ../../../../nshm-conus +git fetch origin refs/tags/5.2.0 +git checkout -b ver-5.2.0 5.2.0 +cd ../nshmp-haz/etc/examples/5-complex-model ``` To compute hazard for a few sites at 1.0s and 2.0s spectral periods, execute: diff --git a/etc/examples/6-enhanced-output/README.md b/etc/examples/6-enhanced-output/README.md index 08143bda..b8d8a0ad 100644 --- a/etc/examples/6-enhanced-output/README.md +++ b/etc/examples/6-enhanced-output/README.md @@ -4,8 +4,8 @@ __Working directory:__ `/path/to/nshmp-haz/etc/examples/6-enhanced-output` While mean hazard is of broad interest, it can be useful to preserve individual components of a total curve, particularly with more complex models. Execute the following to write curves for -each source type and ground motion model (GMM) used in the CONUS NSHM (cloned in the previous -example): +each source type and ground motion model (GMM) used in the CONUS NSHM (downloaded and unzipped, +or cloned in the previous example - use version 5.2.0): ```Shell hazard ../../../../nshm-conus sites.geojson config.json diff --git a/etc/examples/7-disaggregation/README.md b/etc/examples/7-disaggregation/README.md index e6578d88..aaf2a481 100644 --- a/etc/examples/7-disaggregation/README.md +++ b/etc/examples/7-disaggregation/README.md @@ -14,7 +14,7 @@ alias disagg='java -Xms4g -Xmx8g -cp /path/to/nshmp-haz/build/libs/nshmp-haz.jar The command line arguments for `DisaggCalc` are the same as those for `HazardCalc`. The target return period for a disaggregation is specified in the config [`disagg.returnPeriod`](../../../docs/pages/Calculation-Configuration.md#calculation-configuration-parameters) -field. For compute the disaggregation in this example, execute: +field. To compute the disaggregation in this example (use NSHM CONUS v5.2.0), execute: ```Shell disagg ../../../../nshm-conus sites.csv config.json -- GitLab From 37429bbd6f589bab5f48339f095749b7f0309648 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:01:53 -0600 Subject: [PATCH 04/11] remove vscode --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index afda252d..d4c5e0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .project .settings .gradle -.vscode bin build classes -- GitLab From 922633c1c3b6d2486235585e61732d1864dc4740 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:02:03 -0600 Subject: [PATCH 05/11] Add extension file --- .vscode/extensions.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..f5397ad3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,17 @@ +{ + /* + * VS Code recommended extensions for nshmp-haz. + * + * For more information on extension, + * visit: https://code.visualstudio.com/docs/editor/extension-marketplace + */ + "recommendations": [ + "davidanson.vscode-markdownlint", + "editorconfig.editorconfig", + "gitlab.gitlab-workflow", + "jumpinjackie.vscode-map-preview", + "redhat.vscode-yaml", + "vscjava.vscode-gradle", + "vscjava.vscode-java-pack", + ] +} -- GitLab From 9c7e6848f93b317abc0ae8f0c276ee1fd19ddfd0 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:02:10 -0600 Subject: [PATCH 06/11] Add settings file --- .vscode/settings.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..c32ef434 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + /* + * VS Code settings for nshmp-haz. + * + * For more information on settings, + * visit: https://code.visualstudio.com/docs/getstarted/settings + */ + "editor.rulers": [ + { + "column": 100 + } + ], + "editor.tabSize": 2, + "files.associations": { + "*.geojson": "json" + }, + "java.compile.nullAnalysis.mode": "automatic", + "java.configuration.updateBuildConfiguration": "automatic", + "java.import.generatesMetadataFilesAtProjectRoot": true, + "files.exclude": { + "**/.classpath": true, + "**/.DS_Store": true, + "**/.factorypath": true, + "**/.git": true, + "**/.gradle": true, + "**/.project": true, + "**/.settings": true, + "**/bin": true, + "**/node_modules": true, + } +} -- GitLab From 356b2f894cd53057ee57cdbd2eefc222552a196f Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:02:16 -0600 Subject: [PATCH 07/11] Add tasks file --- .vscode/tasks.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..99096d8e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + /* + * VS Code tasks for nshmp-haz. + * + * For more information on tasks, visit: https://code.visualstudio.com/docs/editor/tasks + */ + "version": "2.0.0", + "tasks": [ + /* + * Task to automatically run the `./gradlew eclipse` task on startup to + * keep the `.classpath` file updated. + */ + { + "label": "Update Classpath File", + "type": "shell", + "command": "./gradlew eclipse", + "windows": { + "command": "gradle.bat eclipse" + }, + "presentation": { + "close": true, + }, + "group": "none", + "runOptions": { + "runOn": "folderOpen" + } + } + ] +} -- GitLab From d6698fd81bd8865f32c71dc624d589755bdbfe0b Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:06:09 -0600 Subject: [PATCH 08/11] Cleanup ext gradle --- gradle/ext.gradle | 63 ----------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/gradle/ext.gradle b/gradle/ext.gradle index 9e568162..5da88c0d 100644 --- a/gradle/ext.gradle +++ b/gradle/ext.gradle @@ -9,67 +9,4 @@ ext { nshmpLibGradleDir = "${nshmpLib}/gradle" spotbugsDir = "${nshmpLib}/gradle" spotlessDir = "${nshmpLib}/src/main/resources" - - /* Multi-model repository paths for version tracking */ - repo_cous_2008 = '../nshm-cous-2008' - repo_cous_2014 = '../nshm-cous-2014' - repo_cous_2014b = '../nshm-cous-2014b' - repo_cous_2018 = '../nshm-cous-2018' - repo_hi_2020 = '../nshm-hi-2020' - repo_ak_2007 = '../nshm-ak-2007' - - /* Explicit model paths */ - model_wus_2008 = "${repo_cous_2008}/Western US" - model_ceus_2008 = "${repo_cous_2008}/Central & Eastern US" - model_wus_2014 = "${repo_cous_2014}/Western US" - model_ceus_2014 = "${repo_cous_2014}/Central & Eastern US" - model_wus_2014b = "${repo_cous_2014b}/Western US" - model_wus_2018 = "${repo_cous_2018}/Western US" - model_ceus_2018 = "${repo_cous_2018}/Central & Eastern US" - model_hi_2020 = "${repo_hi_2020}" - model_ak_2007 = "${repo_ak_2007}" - - /* Production models */ - prod_models = [ - [ - model_ak_2007, - 'models/ak/2007' - ], - [ - model_ceus_2008, - 'models/ceus/2008' - ], - [ - model_wus_2008, - 'models/wus/2008' - ], - [ - model_ceus_2014, - 'models/ceus/2014' - ], - [ - model_wus_2014, - 'models/wus/2014' - ], - [ - model_wus_2014b, - 'models/wus/2014b' - ] - ] - - /* Development models */ - dev_models = [ - [ - model_ceus_2018, - 'models/ceus/2018' - ], - [ - model_wus_2018, - 'models/wus/2018' - ], - [ - model_hi_2020, - 'models/hi/2020' - ] - ] } -- GitLab From 76d3e72d406609ce510ecb05c25d6f4a66e992e4 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:06:58 -0600 Subject: [PATCH 09/11] update package --- package-lock.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package-lock.json b/package-lock.json index fd03b78e..dc72624b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "nshmp-haz", "version": "2.0.0", "devDependencies": { "markdownlint-cli": "^0.31.1", -- GitLab From 2da9d544f8e9beee8a439ec08b5c8ef5644f3fa2 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 3 Apr 2023 14:18:06 -0600 Subject: [PATCH 10/11] cleanup --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f5397ad3..5998446b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,7 +5,7 @@ * For more information on extension, * visit: https://code.visualstudio.com/docs/editor/extension-marketplace */ - "recommendations": [ + "recommendations": [ "davidanson.vscode-markdownlint", "editorconfig.editorconfig", "gitlab.gitlab-workflow", -- GitLab From 7c88566850e1d7329986bf4febd3906ff8b1e072 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Tue, 4 Apr 2023 09:08:40 -0600 Subject: [PATCH 11/11] add shell check --- .vscode/extensions.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5998446b..c29927f2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -11,6 +11,7 @@ "gitlab.gitlab-workflow", "jumpinjackie.vscode-map-preview", "redhat.vscode-yaml", + "timonwong.shellcheck", "vscjava.vscode-gradle", "vscjava.vscode-java-pack", ] -- GitLab