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

examples directory cleanup and testing

parent 19599c5b
No related branches found
No related tags found
1 merge request!59examples directory cleanup and modification; readme edits
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
/docs /docs
/tmp /tmp
/results /results
/etc/results
Scratch*.java Scratch*.java
/src/META-INF /src/META-INF
/etc/examples/results /etc/examples/results
#### Tutorial
##### Hazard Curves ##### 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: 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: 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 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 * 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. 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. 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
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. 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
``` ```
{ {
"exceedanceModel": "TRUNCATION_UPPER_ONLY",
"truncationLevel": 3.0, "truncationLevel": 3.0,
"imts": ["PGA", "SA0P2", "SA1P0"], "imts": ["PGA", "SA0P2", "SA1P0"],
"customImls": { "customImls": {
...@@ -14,10 +15,8 @@ ...@@ -14,10 +15,8 @@
[-118.5, 33.8], [-118.5, 33.8],
[-118.0, 34.3] [-118.0, 34.3]
], ],
"vs30": 459, "vs30": ,
"vsInf": true, "vsInf": true
"z1p0": 0.48,
"z2p5": 1.62
} }
} }
} }
\ No newline at end of file
{
"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
{ {
"exceedanceModel": "TRUNCATION_UPPER_ONLY",
"truncationLevel": 3.0, "truncationLevel": 3.0,
"imts": ["PGA", "SA0P2", "SA1P0"], "imts": ["PGA", "SA0P2", "SA1P0"],
"customImls": { "customImls": {
...@@ -8,14 +9,14 @@ ...@@ -8,14 +9,14 @@
}, },
"sites": [ "sites": [
{ {
"name": "Los Angeles", "name": "San Francisco",
"location": [-118.25, 34.05], "location": [-122.40, 37.75],
"vs30": 760, "vs30": 760,
"vsInf": true "vsInf": true
}, },
{ {
"name": "San Francisco", "name": "Oakland",
"location": [-122.40, 37.75], "location": [-122.25, 37.80],
"vs30": 760, "vs30": 760,
"vsInf": true "vsInf": true
} }
......
#
# 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
...@@ -5,9 +5,9 @@ All recent versions of Matlab include a Java runtime environment and it is there ...@@ -5,9 +5,9 @@ All recent versions of Matlab include a Java runtime environment and it is there
#### Requirements #### Requirements
1. Matlab R2013B or higher (nshmp-haz targets Java 7; prior versions of Matlab use Java 6). 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. 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: 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> <before>
......
...@@ -44,7 +44,7 @@ import com.google.common.base.Throwables; ...@@ -44,7 +44,7 @@ import com.google.common.base.Throwables;
*/ */
public class HazardCalc { public class HazardCalc {
private static final int FLUSH_LIMIT = 2; private static final int FLUSH_LIMIT = 5;
/** /**
* Entry point for a hazard calculation. * Entry point for a hazard calculation.
......
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