From 724f5dc584717ac5145904d54b053dd9958a49d1 Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Mon, 18 Jan 2016 21:43:58 -0700 Subject: [PATCH] examples directory cleanup and testing --- .gitignore | 1 + etc/examples/README.md | 21 +++++++--------- ...nfig-region.json => config-region-la.json} | 7 +++--- etc/examples/config-region-sf.json | 22 +++++++++++++++++ etc/examples/config-sites.json | 9 +++---- etc/examples/sites-sf.csv | 24 +++++++++++++++++++ etc/matlab/README.md | 6 ++--- src/org/opensha2/programs/HazardCalc.java | 2 +- 8 files changed, 68 insertions(+), 24 deletions(-) rename etc/examples/{config-region.json => config-region-la.json} (89%) create mode 100644 etc/examples/config-region-sf.json create mode 100644 etc/examples/sites-sf.csv diff --git a/.gitignore b/.gitignore index 6895b20f5..d8a429dbb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /docs /tmp /results +/etc/results Scratch*.java /src/META-INF /etc/examples/results diff --git a/etc/examples/README.md b/etc/examples/README.md index 230a68e05..1ffb23593 100644 --- a/etc/examples/README.md +++ b/etc/examples/README.md @@ -1,32 +1,29 @@ -#### Tutorial - ##### Hazard Curves -The simplest way to run the HazardCurve program via the command-line is to supply it with a source model; all model initialization and calculation configuration data will be read from the model itself. Navigate to the examples directory and run: +The simplest way to run the HazardCalc program via the command-line is to supply it with a source model; all model initialization and calculation configuration data will be read from the model itself. Navigate to the `/etc` in the repository and run: ``` -java -cp ../../dist/nshmp-haz.jar org.opensha2.programs.HazardCurve model +java -cp ../dist/nshmp-haz.jar org.opensha2.programs.HazardCalc peer/models/Set1-Case1 ``` -By way of example, the [configuration file](https://github.com/usgs/nshmp-haz/blob/master/etc/examples/model/config.json) in the model above omits any site data and a default Los Angeles site is used. Remember that [calculation configuration](https://github.com/usgs/nshmp-haz/wiki/Configuration) parameters need not be supplied. The result of this calculation should be available as a single file containing one hazard curve for PGA in a newly created 'results' directory. - +The result of this calculation should be available as a single file containing several hazard curves for PGA in a newly created 'results' directory. Note that not all calculation [configuration](https://github.com/usgs/nshmp-haz/wiki/Configuration) parameters need be supplied; see the [configuration file](/usgs/nshmp-haz/blob/master/etc/peer/models/Set1-Case1/config.json) for this example model. One can override calculation configuration parameters by supplying an alternate configuration file. For example: ``` -java -cp ../../dist/nshmp-haz.jar org.opensha2.programs.HazardCurve model config-sites.json +java -cp ../dist/nshmp-haz.jar org.opensha2.programs.HazardCalc peer/models/Set1-Case1 examples/config-sites.json ``` In this case: -* the `truncationLevel` has been increased to `3.0`. +* a truncation will be applied at 3 standard deviations. * the list of `imts` (intensity measure types, or periods) for which curves will be calculated has been expanded to 3. -* the `imls` (the intensity measure levels or x-values) of the resultant curves, have been explicitely defined. +* the `imls` (the intensity measure levels or x-values) of the resultant curves, have been explicitely defined for each `imt`. * two sites have been specified -The 'results' directory should now include 3 files, one for each intensity measure type. +The 'results' directory should now include 3 files, one for each `imt`. One can also supply a comma-delimited site data file, which may be easier to work with in some applications. ``` -java -cp ../../dist/nshmp-haz.jar org.opensha2.programs.HazardCurve model config-sites.json sites-wus.csv +java -cp ../dist/nshmp-haz.jar org.opensha2.programs.HazardCalc peer/models/Set1-Case1 examples/config-sites.json examples/sites-sf.csv ``` See the site file itself for details on the expected file structure. Under all use cases, if the name of a site is supplied, it will be included in the first column of any result files. ##### Hazard Maps Hazard maps are generated from numerous uniformely spaced hazard curves. To compute such a curve set, the same program is used, but sites are instead specified as a region. ``` -java -cp ../../dist/nshmp-haz.jar org.opensha2.programs.HazardCurve model config-region.json +java -cp ../dist/nshmp-haz.jar org.opensha2.programs.HazardCalc peer/models/Set1-Case1 examples/config-region-sf.json ``` diff --git a/etc/examples/config-region.json b/etc/examples/config-region-la.json similarity index 89% rename from etc/examples/config-region.json rename to etc/examples/config-region-la.json index 5a17e7155..3e700ff36 100644 --- a/etc/examples/config-region.json +++ b/etc/examples/config-region-la.json @@ -1,4 +1,5 @@ { + "exceedanceModel": "TRUNCATION_UPPER_ONLY", "truncationLevel": 3.0, "imts": ["PGA", "SA0P2", "SA1P0"], "customImls": { @@ -14,10 +15,8 @@ [-118.5, 33.8], [-118.0, 34.3] ], - "vs30": 459, - "vsInf": true, - "z1p0": 0.48, - "z2p5": 1.62 + "vs30": , + "vsInf": true } } } \ No newline at end of file diff --git a/etc/examples/config-region-sf.json b/etc/examples/config-region-sf.json new file mode 100644 index 000000000..8b06f574d --- /dev/null +++ b/etc/examples/config-region-sf.json @@ -0,0 +1,22 @@ +{ + "exceedanceModel": "TRUNCATION_UPPER_ONLY", + "truncationLevel": 3.0, + "imts": ["PGA", "SA0P2", "SA1P0"], + "customImls": { + "PGA": [0.0050, 0.0070, 0.0098, 0.0137, 0.0192, 0.0269, 0.0376, 0.0527, 0.0738, 0.103, 0.145, 0.203, 0.284, 0.397, 0.556, 0.778, 1.09, 1.52, 2.2, 3.3], + "SA0P2": [0.0050, 0.0075, 0.0113, 0.0169, 0.0253, 0.0380, 0.0570, 0.0854, 0.128, 0.192, 0.288, 0.432, 0.649, 0.973, 1.46, 2.19, 3.28, 4.92, 7.38], + "SA1P0": [0.0025, 0.00375, 0.00563, 0.00844, 0.0127, 0.0190, 0.0285, 0.0427, 0.0641, 0.0961, 0.144, 0.216, 0.324, 0.487, 0.730, 1.09, 1.64, 2.46, 3.69, 5.54] + }, + "sites": { + "region": { + "name": "Downtown San Francisco", + "spacing": 0.1, + "border": [ + [-122.7, 37.5], + [-122.2, 38.0] + ], + "vs30": 760, + "vsInf": true + } + } +} \ No newline at end of file diff --git a/etc/examples/config-sites.json b/etc/examples/config-sites.json index 6a7c5178d..a96569992 100644 --- a/etc/examples/config-sites.json +++ b/etc/examples/config-sites.json @@ -1,4 +1,5 @@ { + "exceedanceModel": "TRUNCATION_UPPER_ONLY", "truncationLevel": 3.0, "imts": ["PGA", "SA0P2", "SA1P0"], "customImls": { @@ -8,14 +9,14 @@ }, "sites": [ { - "name": "Los Angeles", - "location": [-118.25, 34.05], + "name": "San Francisco", + "location": [-122.40, 37.75], "vs30": 760, "vsInf": true }, { - "name": "San Francisco", - "location": [-122.40, 37.75], + "name": "Oakland", + "location": [-122.25, 37.80], "vs30": 760, "vsInf": true } diff --git a/etc/examples/sites-sf.csv b/etc/examples/sites-sf.csv new file mode 100644 index 000000000..9bf046cab --- /dev/null +++ b/etc/examples/sites-sf.csv @@ -0,0 +1,24 @@ +# +# Comma-delimited site file example. +# +# Header row must identify columns. At a minimum, lon and lat +# must be defined. Columns can be in any order and any missing +# fields will be populated with default values. +# +# [name,] lon, lat [, vs30] [, vsInf] [, z1p0] [, z2p5] +# +# Defaults: +# name: Unnamed Site +# vs30: 760.0 +# vsInf: true +# z1p0: NaN (GMM will use default basin depth model) +# z2p5: NaN (GMM will use default basin depth model) +# +name, lon, lat +Concord, -122.00, 37.95 +Oakland, -122.25, 37.80 +San Francisco, -122.40, 37.75 +San Jose, -121.90, 37.35 +San Mateo, -122.30, 37.55 +Santa Rosa, -122.70, 38.45 +Vallejo, -122.25, 38.10 diff --git a/etc/matlab/README.md b/etc/matlab/README.md index 814afc6aa..05c8c7786 100644 --- a/etc/matlab/README.md +++ b/etc/matlab/README.md @@ -5,9 +5,9 @@ All recent versions of Matlab include a Java runtime environment and it is there #### Requirements -1. Matlab R2013B or higher (nshmp-haz targets Java 7; prior versions of Matlab use Java 6). -2. A [build](/usgs/nshmp-haz/wiki/Building-&-Running) of nshmp-haz. -3. nshmp-haz.jar on Matlab's classpath. Save a file with the name `javaclasspath.txt` to the Matlab preferences directory, as specified by the `prefdir` command, and with contents: +1. Matlab R2013B or higher (nshmp-haz targets Java 7; prior versions of Matlab use Java 6). +2. A [build](/usgs/nshmp-haz/wiki/Building-&-Running) of nshmp-haz. +3. nshmp-haz.jar on Matlab's classpath. Save a file with the name `javaclasspath.txt` to the Matlab preferences directory, as specified by the `prefdir` command, and with contents: ``` <before> diff --git a/src/org/opensha2/programs/HazardCalc.java b/src/org/opensha2/programs/HazardCalc.java index b867082c5..03a792207 100644 --- a/src/org/opensha2/programs/HazardCalc.java +++ b/src/org/opensha2/programs/HazardCalc.java @@ -44,7 +44,7 @@ import com.google.common.base.Throwables; */ public class HazardCalc { - private static final int FLUSH_LIMIT = 2; + private static final int FLUSH_LIMIT = 5; /** * Entry point for a hazard calculation. -- GitLab