@@ -86,26 +86,40 @@ OKADA85 Surface deformation due to a finite rectangular source.
8686- `open`: dislocation in tensile component (same unit as `slip`).
8787- `nu`: The Poisson's ratio, default is 0.25 for an isotropic medium.
8888"""
89- function okada (G:: GMTgrid ; kw... ):: Union{GMTgrid{Float32,2}, Tuple{GMTgrid{Float32,2}, GMTgrid{Float32,2}, GMTgrid{Float32,2}}}
90- #
89+ function okada (GI:: GItype ; kw... ):: Union{GMTgrid{Float32,2}, Tuple{GMTgrid{Float32,2}, GMTgrid{Float32,2}, GMTgrid{Float32,2}}}
90+ do_z3d = (get (kw, :z3d , nothing ) != = nothing )
91+ (do_z3d && ! isa (GI, GMTgrid)) && error (" z3d option is only available for GMTgrid input" )
92+ _G = (do_z3d) ? GI : GMTgrid {Float32,2} () # Need this guy in one case
93+ hdr = [GI. range[1 ], GI. range[2 ], GI. range[3 ], GI. range[4 ], GI. range[5 ], GI. range[6 ], GI. registration, GI. inc[1 ], GI. inc[2 ]]
94+ isgeog = guessgeog (GI)
95+ nx, ny = getsize (GI) # width (columns) and height (rows)
96+ okada (_G, hdr, isgeog, nx, ny; kw... )
97+ end
98+
99+ # -------------------------------------------------------------------------------------------------------
100+ function okada (G:: GMTgrid{Float32,2} , hdr:: Vector{Float64} , isgeog:: Bool , nx:: Int , ny:: Int ; kw... ):: Union{GMTgrid{Float32,2}, Tuple{GMTgrid{Float32,2}, GMTgrid{Float32,2}, GMTgrid{Float32,2}}}
101+ # G is empty in all but one case
91102 msg, x_start, y_start, depth, strike, dip, L, W, rake, slip, nu, U3, do_all3, do_z3d = okada_opt_parser (true ; kw... )
92103 (msg != " " ) && error (msg)
93104 if (do_all3)
94- okada_enz (G , x_start, y_start, W, L, depth, strike, dip, rake, slip, nu, U3)
105+ okada_enz (hdr, isgeog, nx, ny , x_start, y_start, W, L, depth, strike, dip, rake, slip, nu, U3)
95106 else
96- okada_z (G, x_start, y_start, W, L, depth, strike, dip, rake, slip, nu, U3; z3d= do_z3d)
107+ okada_z (G, hdr, isgeog, nx, ny, x_start, y_start, W, L, depth, strike, dip, rake, slip, nu, U3; z3d= do_z3d)
97108 end
98109end
99110
100111# -------------------------------------------------------------------------------------------------------
101- function helper_okd_grid (G:: GMTgrid , x_start:: Float64 , y_start:: Float64 , W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 , dip:: Float64 )
102- x = (G. registration == 0 ) ? copy (G. x) : collect (linspace (G. range[1 ]+ G. inc[1 ]/ 2 , G. range[2 ]- G. inc[1 ]/ 2 , size (G,2 )))
103- y = (G. registration == 0 ) ? copy (G. y) : collect (linspace (G. range[3 ]+ G. inc[2 ]/ 2 , G. range[4 ]- G. inc[2 ]/ 2 , size (G,1 )))
112+ function helper_okd_grid (hdr:: Vector{Float64} , isgeog:: Bool , nx:: Int , ny:: Int , x_start:: Float64 , y_start:: Float64 ,
113+ W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 , dip:: Float64 )
114+ dx2 = (hdr[7 ] == 0 ) ? 0.0 : hdr[8 ] / 2.0
115+ dy2 = (hdr[7 ] == 0 ) ? 0.0 : hdr[9 ] / 2.0
116+ x = collect (linspace (hdr[1 ]+ dx2, hdr[2 ]- dx2, nx))
117+ y = collect (linspace (hdr[3 ]+ dy2, hdr[4 ]- dy2, ny))
104118 L *= 1000 ; W *= 1000 ; depth *= 1000 ; # Convert to meters
105119 depth = depth + sind (dip) * W/ 2
106120
107121 x_centroid, y_centroid = NaN , NaN
108- if (guessgeog (G) )
122+ if (isgeog )
109123 fault_top_center:: Matrix{Float64} , = geod ([x_start y_start], strike, L/ 2 ) # lon,lat of fault's top center
110124 fault_LL:: Matrix{Float64} , = geod ([x_start y_start], strike+ 90 , W* cosd (dip)) # fault LowerLeft corner
111125 fault_bot_center:: Matrix{Float64} , = geod ([fault_LL[1 ] fault_LL[2 ]], strike, L/ 2 )
@@ -116,33 +130,35 @@ function helper_okd_grid(G::GMTgrid, x_start::Float64, y_start::Float64, W::Floa
116130end
117131
118132# -------------------------------------------------------------------------------------------------------
119- function okada_z (G:: GMTgrid , x_start:: Float64 , y_start:: Float64 , W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 ,
120- dip:: Float64 , rake:: Float64 , slip:: Float64 , nu:: Float64 , U3:: Float64 ; z3d= false ):: GMTgrid{Float32,2}
133+ function okada_z (G:: GMTgrid{Float32,2} , hdr:: Vector{Float64} , isgeog:: Bool , nx:: Int , ny:: Int , x_start:: Float64 , y_start:: Float64 ,
134+ W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 , dip:: Float64 , rake:: Float64 , slip:: Float64 ,
135+ nu:: Float64 , U3:: Float64 ; z3d= false ):: GMTgrid{Float32,2}
121136
122- x, y, W, L, depth, x_centroid, y_centroid = helper_okd_grid (G , x_start, y_start, W, L, depth, strike, dip)
123- uz = (isnan (x_centroid) ) ? okada_z (x, y, W, L, depth, strike, dip, rake, slip, nu, U3) :
124- z3d ? okada_geog_z3d (G, x, y, W, L, depth, strike, dip, rake, slip, nu, x_centroid, y_centroid) :
125- okada_geog_z (x, y, W, L, depth, strike, dip, rake, slip, nu, x_centroid, y_centroid, U3)
137+ x, y, W, L, depth, x_centroid, y_centroid = helper_okd_grid (hdr, isgeog, nx, ny , x_start, y_start, W, L, depth, strike, dip)
138+ uz = (! isgeog ) ? okada_z (x, y, W, L, depth, strike, dip, rake, slip, nu, U3) :
139+ z3d ? okada_geog_z3d (G, x, y, W, L, depth, strike, dip, rake, slip, nu, x_centroid, y_centroid) :
140+ okada_geog_z (x, y, W, L, depth, strike, dip, rake, slip, nu, x_centroid, y_centroid, U3)
126141
127- prj = ! isnan (x_centroid) ? prj4WGS84 : G. proj4
128- rng:: Vector{Float64} = [G . range [1 : 4 ]. .. , extrema (uz)... ]
129- GMTgrid (proj4= prj, range= rng, inc= G . inc , registration= G . registration , title= " Okada Vertical deformation" , x= G . x, y= G . y, z= uz, layout= " BCB" , hasnans= 1 )
142+ prj = isgeog ? prj4WGS84 : prj4WGS84 # G.proj4
143+ rng:: Vector{Float64} = [hdr [1 : 4 ]. .. , extrema (uz)... ]
144+ GMTgrid (proj4= prj, range= rng, inc= hdr[ 8 : 9 ] , registration= Int (hdr[ 7 ]) , title= " Okada Vertical deformation" , x= x, y= y, z= uz, layout= " BCB" , hasnans= 1 )
130145end
131146
132147# -------------------------------------------------------------------------------------------------------
133- function okada_enz (G:: GMTgrid , x_start:: Float64 , y_start:: Float64 , W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 ,
134- dip:: Float64 , rake:: Float64 , slip:: Float64 , nu:: Float64 , U3:: Float64 ):: Tuple{GMTgrid{Float32,2}, GMTgrid{Float32,2}, GMTgrid{Float32,2}}
135- x, y, W, L, depth, x_centroid, y_centroid = helper_okd_grid (G, x_start, y_start, W, L, depth, strike, dip)
136- if (! isnan (x_centroid))
148+ function okada_enz (hdr:: Vector{Float64} , isgeog:: Bool , nx:: Int , ny:: Int , x_start:: Float64 , y_start:: Float64 ,
149+ W:: Float64 , L:: Float64 , depth:: Float64 , strike:: Float64 , dip:: Float64 , rake:: Float64 ,
150+ slip:: Float64 , nu:: Float64 , U3:: Float64 ):: Tuple{GMTgrid{Float32,2}, GMTgrid{Float32,2}, GMTgrid{Float32,2}}
151+ x, y, W, L, depth, x_centroid, y_centroid = helper_okd_grid (hdr, isgeog, nx, ny, x_start, y_start, W, L, depth, strike, dip)
152+ if (isgeog)
137153 ue, un, uz = okada_geog_enz (x, y, W, L, depth, strike, dip, rake, slip, nu, x_centroid, y_centroid, U3)
138154 else
139155 ue, un, uz = okada_enz (x, y, W, L, depth, strike, dip, rake, slip, nu, U3)
140156 end
141157
142- prj = ! isnan (x_centroid) ? prj4WGS84 : G. proj4; reg = G . registration
143- Ge = GMTgrid (proj4= prj, range= [G . range [1 : 4 ]. .. , extrema (ue)... ], inc= G . inc , registration= reg, title= " Okada East deformation" , x= G . x, y= G . y, z= ue, layout= " BCB" , hasnans= 1 )
144- Gn = GMTgrid (proj4= prj, range= [G . range [1 : 4 ]. .. , extrema (un)... ], inc= G . inc , registration= reg, title= " Okada North deformation" , x= G . x, y= G . y, z= un, layout= " BCB" , hasnans= 1 )
145- Gz = GMTgrid (proj4= prj, range= [G . range [1 : 4 ]. .. , extrema (uz)... ], inc= G . inc , registration= reg, title= " Okada Vertical deformation" , x= G . x, y= G . y, z= uz, layout= " BCB" , hasnans= 1 )
158+ prj = isgeog ? prj4WGS84 : G. proj4; reg = Int (hdr[ 7 ])
159+ Ge = GMTgrid (proj4= prj, range= [hdr [1 : 4 ]. .. , extrema (ue)... ], inc= hdr[ 8 : 9 ] , registration= reg, title= " Okada East deformation" , x= x, y= y, z= ue, layout= " BCB" , hasnans= 1 )
160+ Gn = GMTgrid (proj4= prj, range= [hdr [1 : 4 ]. .. , extrema (un)... ], inc= hdr[ 8 : 9 ] , registration= reg, title= " Okada North deformation" , x= x, y= y, z= un, layout= " BCB" , hasnans= 1 )
161+ Gz = GMTgrid (proj4= prj, range= [hdr [1 : 4 ]. .. , extrema (uz)... ], inc= hdr[ 8 : 9 ] , registration= reg, title= " Okada Vertical deformation" , x= x, y= y, z= uz, layout= " BCB" , hasnans= 1 )
146162 return Ge, Gn, Gz
147163end
148164
0 commit comments