Skip to content

Commit

Permalink
- add keyword arguments to gmpe_* functions
Browse files Browse the repository at this point in the history
- update docs
- update tests
  • Loading branch information
jamm1985 committed Jan 30, 2018
1 parent 4ebd336 commit 073c2e1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ The ground motion evaluation module (earthquake seismology)
Pkg.add("GroundMotion.jl")
```

**WORK IN PROGRESS!**

## Basic principles

The names of GMPE functions looks like: `gmpe_{Name_of_gmpe_function}`. For example: `gmpe_as2008`, where `as2008` is Abrahamson and Silva 2008 GMPE Model. Configuration for any model (see `examples/*.conf`) has the `ground_motion_type` that can be `PGA`,`PGV`,`PSA` and define the type of output data points.
Expand All @@ -28,7 +26,7 @@ For example: function `gmpe_as2008` with parameters
```julia
pga_as2008(eq::Earthquake,
config_as2008::Params_as2008,
grid::Array{Point_vs30},
grid::Array{Point_vs30};
min_val::Number)
```
where `ground_motion_type = "PGA"` at `config`, return 1-d is `Array{Point_pga_out}` with points based on input grid and `pga > min_val` (`pga` is Acceleration of gravity in percent (%g) rounded to `ggg.gg`).
Expand All @@ -41,7 +39,7 @@ In case of without any grid GMPE functions return simple 1-d `Array{Float64}` wi
Example:
```julia
pga_as2008(eq::Earthquake,
config::Params_as2008,
config::Params_as2008;
VS30::Number=350,
distance::Int64=1000)
```
Expand Down Expand Up @@ -115,6 +113,8 @@ Latitude and longitude assumes degrees for WGS84 ellipsoid. Depth in km. `Mw` us

## Abrahamson and Silva 2008 GMPE Model

**WORK IN PROGRESS!**

### Reference

Abrahamson, Norman, and Walter Silva. "Summary of the Abrahamson & Silva NGA ground-motion relations." Earthquake spectra 24.1 (2008): 67-97.
Expand All @@ -124,14 +124,15 @@ Abrahamson, Norman, and Walter Silva. "Summary of the Abrahamson & Silva NGA gro
## ON GRID
gmpe_as2008(eq::Earthquake,
config_as2008::Params_as2008,
grid::Array{Point_vs30,N},
grid::Array{Point_vs30};
min_val::Number)
## Without grid
gmpe_as2008(eq::Earthquake,
config::Params_as2008,
config::Params_as2008;
VS30::Number=350,
distance::Int64=1000)
```
Keyword arguments: `min_val`,`VS30`,`distance`.

### Model Parameters

Expand Down Expand Up @@ -159,14 +160,15 @@ Actually they are not presented at code.
## ON GRID
gmpe_simidorikawa1999(eq::Earthquake,
config::Params_simidorikawa1999,
grid::Array{Point_vs30,N},
grid::Array{Point_vs30};
min_val::Number)
## Without grid
gmpe_simidorikawa1999(eq::Earthquake,
config::Params_simidorikawa1999,
config::Params_simidorikawa1999;
VS30::Number=350,
distance::Int64=1000)
```
Keyword arguments: `min_val`,`VS30`,`distance`.

### Model Parameters

Expand Down
6 changes: 3 additions & 3 deletions src/as2008.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
**ON GRID**
`gmpe_as2008(eq::Earthquake,config_as2008::Params_as2008,grid::Array{Point_vs30},min_val::Number)`
`gmpe_as2008(eq::Earthquake,config_as2008::Params_as2008,grid::Array{Point_vs30};min_val::Number)`
where `min_val=0` by default
Expand All @@ -43,7 +43,7 @@ gmpe_as2008(eq,config_as2008) # for without input grid
Please, see `examples/as-2008.conf`
"""
## AS2008 PGA modeling ON GRID
function gmpe_as2008(eq::Earthquake,config::Params_as2008,grid::Array{Point_vs30},min_val::Number=0)
function gmpe_as2008(eq::Earthquake,config::Params_as2008,grid::Array{Point_vs30};min_val::Number=0)
vs30_row_num = length(grid[:,1])
eq.moment_mag == 0 ? magnitude = eq.local_mag : magnitude = eq.moment_mag
epicenter = LatLon(eq.lat, eq.lon)
Expand Down Expand Up @@ -107,7 +107,7 @@ function gmpe_as2008(eq::Earthquake,config::Params_as2008,grid::Array{Point_vs30
return output_data
end
## AS2008 PGA modeling for PLOTTING
function gmpe_as2008(eq::Earthquake,config::Params_as2008,VS30::Number=350,distance::Number=1000)
function gmpe_as2008(eq::Earthquake,config::Params_as2008;VS30::Number=350,distance::Number=1000)
eq.moment_mag == 0 ? magnitude = eq.local_mag : magnitude = eq.moment_mag
# define t6
if magnitude < 5.5
Expand Down
4 changes: 2 additions & 2 deletions src/morikawafujiwara2013.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Output will be 1-d `Array{Float64}` with `1:distance` values of `pga`,`psa` (tha
**EXAMPLES:**
```
gmpe_mf2013(eq,config_mf2013,grid) # for PGA on GRID
gmpe_mf2013(eq,config_mf2013) # for without input grid
gmpe_mf2013(eq,config_mf2013,grid) # for PGA,PGV,PSA on GRID
gmpe_mf2013(eq,config_mf2013) # for PGA,PGV,PSA without input grid
```
**Model parameters**
Expand Down
14 changes: 7 additions & 7 deletions src/simidorikawa1999.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@
"""
**ON GRID**
`pga_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,grid::Array{Point_vs30},min_val::Number)`
`gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,grid::Array{Point_vs30};min_val::Number)`
where `min_val=0` by default
Output will be 1-d `Array{Point_pga_out}` with points based on the input grid with `pga > min_val` (pga is Acceleration of gravity (g) in percent rounded to ggg.gg)
Output will be 1-d `Array{Point_pga_out}` with points based on the input grid with `pga > min_val` (pga is Acceleration of gravity in percent (%g) rounded to ggg.gg)
**without grid**
`pga_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,VS30::Number=350,distance::Int64=1000)`
`gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999;VS30::Number=350,distance::Int64=1000)`
where `VS30=30` [m/s^2], `distance=1000` [km] by default.
Output will be 1-d `Array{Float64,1}` with `1:distance` values of `pga` (that is Acceleration of gravity (g) in percent rounded to ggg.gg)
**EXAMPLES:**
```
pga_simidorikawa1999(eq,config_simidorikawa1999_interplate,grid) # for PGA on GRID
pga_simidorikawa1999(eq,config_simidorikawa1999_intraplate) # for PGA without input grid
gmpe_simidorikawa1999(eq,config_simidorikawa1999_interplate,grid) # for PGA on GRID
gmpe_simidorikawa1999(eq,config_simidorikawa1999_intraplate) # for PGA without input grid
```
**Model parameters**
Please, see `examples/si-midorikawa-1999.conf`
"""
## Si-Midorikawa (1999) PGA modeling ON GRID
function gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,grid::Array{Point_vs30},min_val::Number=0)
function gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,grid::Array{Point_vs30};min_val::Number=0)
vs30_row_num = length(grid[:,1])
eq.moment_mag == 0 ? magnitude = eq.local_mag : magnitude = eq.moment_mag
epicenter = LatLon(eq.lat, eq.lon)
Expand Down Expand Up @@ -85,7 +85,7 @@ function gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,gr
return output_data
end
## Si-Midorikawa (1999) PGA modeling for PLOTTING
function gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999,VS30::Number=350,distance::Number=1000)
function gmpe_simidorikawa1999(eq::Earthquake,config::Params_simidorikawa1999;VS30::Number=350,distance::Number=1000)
#vs30_row_num = length(grid[:,1])
eq.moment_mag == 0 ? magnitude = eq.local_mag : magnitude = eq.moment_mag
# define g_global
Expand Down
6 changes: 3 additions & 3 deletions test/test_as2008.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@test length(A) == TEST_GRID_SIZE
@test round(sum([A[i].pga for i=1:length(A)]),2) == 4.39
# run PGA modeling on grid with minpga M6.0
A = gmpe_as2008(eq_6,config_as2008_pga,grid,0.22)
A = gmpe_as2008(eq_6,config_as2008_pga,grid,min_val=0.22)
@test length(A) == WITH_MINPGA
@test round(sum([A[i].pga for i=1:length(A)]),2) == 2.86
# run PGA modeling with M4.0
Expand All @@ -25,7 +25,7 @@
# run PGA Modeling M=7
@test round(sum(gmpe_as2008(eq_7,config_as2008_pga)),2) == 1486.84
# run PGA Modeling M=7 with VS30 = 900
@test round(sum(gmpe_as2008(eq_7,config_as2008_pga,900)),2) == 1031.1
@test round(sum(gmpe_as2008(eq_7,config_as2008_pga,VS30=900)),2) == 1031.1
# run PGA Modeling M=7 with VS30 = 1600
@test round(sum(gmpe_as2008(eq_7,config_as2008_pga,1600)),2) == 817.23
@test round(sum(gmpe_as2008(eq_7,config_as2008_pga,VS30=1600)),2) == 817.23
end
4 changes: 2 additions & 2 deletions test/test_simidorikawa1999.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
@test length(S_intra) == TEST_GRID_SIZE
@test round(sum([S_intra[i].pga for i=1:length(S_intra)]),2) == 13.9
## run PGA modeling on grid with minpga Depth <= 30 M6.0
S_c = gmpe_simidorikawa1999(eq_6,config_simidorikawa1999_crustal_pga,grid,0.34)
S_c = gmpe_simidorikawa1999(eq_6,config_simidorikawa1999_crustal_pga,grid,min_val=0.34)
@test length(S_c) == WITH_MINPGA
@test round(sum([S_c[i].pga for i=1:length(S_c)]),2) == 4.61
## run PGA modeling on grid with minpga Depth > 30 M6.0
eq_30 = Earthquake(143.04,51.92,35,6.0)
S_c = gmpe_simidorikawa1999(eq_30,config_simidorikawa1999_crustal_pga,grid,0.15)
S_c = gmpe_simidorikawa1999(eq_30,config_simidorikawa1999_crustal_pga,grid,min_val=0.15)
@test length(S_c) == WITH_MINPGA
@test round(sum([S_c[i].pga for i=1:length(S_c)]),2) == 2.04
## run PGA modeling for plotting Depth <= 30 M6.0
Expand Down

0 comments on commit 073c2e1

Please sign in to comment.