Skip to content

Commit

Permalink
bugfix and constant deopth option
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskaus committed Feb 22, 2024
1 parent ef265ec commit 0026517
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ext/GMT_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ImportTopo(; lat=[37,49], lon=[4,20], file::String="@earth_relief_01m.grd") = Im


"""
data_GMT = ImportGeoTIFF(fname::String; fieldname=:layer1, negative=false, iskm=true)
data_GMT = ImportGeoTIFF(fname::String; fieldname=:layer1, negative=false, iskm=true, NorthernHemisphere=true, constantDepth=false)
This imports a GeoTIFF dataset (usually containing a surface of some sort) using GMT.
The file should either have `UTM` coordinates of `longlat` coordinates. If it doesn't, you can
Expand All @@ -118,14 +118,15 @@ Optional keywords:
- `negative` : if true, the depth is multiplied by -1 (default=false)
- `iskm` : if true, the depth is multiplied by 1e-3 (default=true)
- `NorthernHemisphere`: if true, the UTM zone is set to be in the northern hemisphere (default=true); only relevant if the data uses UTM projection
- `constantDepth`: if true we will not warp the surface by z-values, but use a constant value instead
"""
function ImportGeoTIFF(fname::String; fieldname=:layer1, negative=false, iskm=true, NorthernHemisphere=true)
function ImportGeoTIFF(fname::String; fieldname=:layer1, negative=false, iskm=true, NorthernHemisphere=true, constantDepth=false)
G = gmtread(fname);

# Transfer to GeoData
nx,ny = length(G.x)-1, length(G.y)-1
Lon,Lat,Depth = LonLatDepthGrid(G.x[1:nx],G.y[1:ny],0);
if hasfield(typeof(G),:z)
if hasfield(typeof(G),:z) & !constantDepth
Depth[:,:,1] = G.z';
if negative
Depth[:,:,1] = -G.z';
Expand Down
3 changes: 1 addition & 2 deletions src/data_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,7 @@ function Base.show(io::IO, d::CartData)
println(io," size : $(size(d.x))")
println(io," x ϵ [ $(minimum(d.x.val)) : $(maximum(d.x.val))]")
println(io," y ϵ [ $(minimum(d.y.val)) : $(maximum(d.y.val))]")
println(io," z ϵ [ $(minimum(d.z.val)) : $(maximum(d.z.val))]")


if any(isnan.(NumValue(d.z)))
z_vals = extrema(d.z.val[isnan.(d.z.val).==false])
println(io," z ϵ [ $(z_vals[1]) : $(z_vals[2])]; has NaN's")
Expand Down

0 comments on commit 0026517

Please sign in to comment.