gher-uliege / DIVAnd.jl

DIVAnd performs an n-dimensional variational analysis of arbitrarily located observations
GNU General Public License v2.0
72 stars 11 forks source link

Interpolation can fail when using a quite high resolution (compared to NetCDF File) #45

Closed Alexander-Barth closed 5 years ago

Alexander-Barth commented 5 years ago
bathname = "../data/gebco_30sec_8.nc"
#bathname = "../data/gebco_30sec_4.nc"

if !isfile(bathname)
    @info("Download bathymetry")
    download("https://dox.ulg.ac.be/index.php/s/wS6Y8P8NhIF60eG/download", bathname)
    #download("https://dox.ulg.ac.be/index.php/s/RSwm4HPHImdZoQP/download", bathname)
else
    @info("Bathymetry file already downloaded")
end
bathisglobal = true;

dx = dy = 0.005
lonr = 19.45:dx:20.675
latr = 59.5:dy:59.9;

bx,by,b = load_bath(bathname,bathisglobal,lonr,latr)
@show size(b);
BoundsError: attempt to access 11×4 interpolate((19.399999999988694:0.13333333333332575:20.73333333332195,59.533333333340764:0.13333333333333997:59.933333333340784), ::Array{Float64,2}, Gridded(Interpolations.Linear())) with element type Float64 at index [19.45:0.005:20.675, 59.5:0.005:59.9]

Stacktrace:
 [1] throw_boundserror(::Interpolations.GriddedInterpolation{Float64,2,Float64,Interpolations.Gridded{Interpolations.Linear},Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}, ::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}) at ./abstractarray.jl:484
 [2] (::Interpolations.GriddedInterpolation{Float64,2,Float64,Interpolations.Gridded{Interpolations.Linear},Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}})(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at /home/jovyan/.julia/packages/Interpolations/jXoPW/src/gridded/indexing.jl:75
 [3] load_bath(::String, ::Bool, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at /home/jovyan/.julia/dev/DIVAnd/src/load_mask.jl:104
 [4] top-level scope at In[27]:1
jmbeckers commented 5 years ago

should now be fixed in Alex branch. extract_bath adapted to make sure piece from netcdf covers the desired domain.