Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on opening multiple files #94

Closed
melodyjulia opened this issue Aug 12, 2020 · 2 comments
Closed

Problem on opening multiple files #94

melodyjulia opened this issue Aug 12, 2020 · 2 comments

Comments

@melodyjulia
Copy link

melodyjulia commented Aug 12, 2020

The timeseries are split among two netCDF files with different number of time records. Each file can be opened with Dataset() correctly. Opening two files together with Dataset() gets wrong number of total time records.

Two netCDF files can be dragged from:
http://esgf.nci.org.au/thredds/fileServer/master/CMIP6/CMIP/CSIRO/ACCESS-ESM1-5/esm-hist/r2i1p1f1/Amon/co2/gn/v20191203/co2_Amon_ACCESS-ESM1-5_esm-hist_r2i1p1f1_gn_185001-194912.nc
http://esgf.nci.org.au/thredds/fileServer/master/CMIP6/CMIP/CSIRO/ACCESS-ESM1-5/esm-hist/r2i1p1f1/Amon/co2/gn/v20191203/co2_Amon_ACCESS-ESM1-5_esm-hist_r2i1p1f1_gn_195001-201412.nc

Use the following code to reproduce the bug:
##########################
using NCDatasets

files = ["co2_Amon_ACCESS-ESM1-5_esm-hist_r2i1p1f1_gn_185001-194912.nc","co2_Amon_ACCESS-ESM1-5_esm-hist_r2i1p1f1_gn_195001-201412.nc"]

ds = Dataset(files)

time = ds["time"][:]

close(ds)
##########################

Expected behavior

ERROR: LoadError: NetCDF error: NetCDF: Start+count exceeds dimension bound (NetCDF error code: -57)

Environment

Full output

ERROR: LoadError: NetCDF error: NetCDF: Start+count exceeds dimension bound (NetCDF error code: -57)
Stacktrace:
[1] check at /Users/test/.julia/packages/NCDatasets/NNX1o/src/errorhandling.jl:33 [inlined]
[2] nc_get_vars!(::Int32, ::Int32, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Float64,1}) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/netcdf_c.jl:916
[3] getindex(::NCDatasets.Variable{Float64,1,NCDataset}, ::StepRange{Int64,Int64}) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/variable.jl:386
[4] (::getfield(NCDatasets, Symbol("##57#58")){Tuple{StepRange{Int64,Int64}}})(::NCDatasets.Variable{Float64,1,NCDataset}) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/defer.jl:153
[5] (::getfield(NCDatasets, Symbol("##55#56")){getfield(NCDatasets, Symbol("##57#58")){Tuple{StepRange{Int64,Int64}}},NCDatasets.DeferVariable{Float64,1}})(::NCDataset{Nothing}) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/defer.jl:138
[6] #NCDataset#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Type, ::getfield(NCDatasets, Symbol("##55#56")){getfield(NCDatasets, Symbol("##57#58")){Tuple{StepRange{Int64,Int64}}},NCDatasets.DeferVariable{Float64,1}}, ::String, ::Vararg{String,N} where N) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/dataset.jl:286
[7] Type at /Users/test/.julia/packages/NCDatasets/NNX1o/src/dataset.jl:284 [inlined]
[8] Type at /Users/test/.julia/packages/NCDatasets/NNX1o/src/defer.jl:137 [inlined]
[9] getindex(::NCDatasets.DeferVariable{Float64,1}, ::StepRange{Int64,Int64}) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/defer.jl:152
[10] getindex(::NCDatasets.CatArrays.CatArray{Float64,1,2,NCDatasets.DeferVariable{Float64,1}}, ::Function) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/CatArrays.jl:113
[11] getindex at /Users/test/.julia/packages/NCDatasets/NNX1o/src/multifile.jl:155 [inlined]
[12] getindex(::NCDatasets.CFVariable{Dates.DateTime,1,NCDatasets.MFVariable{Float64,1,2,NCDatasets.DeferVariable{Float64,1}},NCDatasets.MFAttributes{NCDatasets.DeferAttributes},NamedTuple{(:fillvalue, :scale_factor, :add_offset, :calendar, :time_origin, :time_factor),Tuple{Nothing,Nothing,Nothing,String,DateTimeProlepticGregorian,Int64}}}, ::Colon) at /Users/test/.julia/packages/NCDatasets/NNX1o/src/cfvariable.jl:518
[13] top-level scope at none:0
[14] include at ./boot.jl:317 [inlined]
[15] include_relative(::Module, ::String) at ./loading.jl:1044
[16] include(::Module, ::String) at ./sysimg.jl:29
[17] exec_options(::Base.JLOptions) at ./client.jl:266
[18] _start() at ./client.jl:425

@melodyjulia melodyjulia changed the title Can't use Dataset() to open mutiple files Can't use Dataset() to open multiple files Aug 12, 2020
@melodyjulia melodyjulia changed the title Can't use Dataset() to open multiple files Problem on opening multiple files Aug 12, 2020
@Alexander-Barth
Copy link
Member

Thank you for the bug report. I could reproduce the issue and committed a fix in the master branch. I will make a new release shortly.

Fell free to reopen the issue if the fix does not resolve your problem.

@melodyjulia
Copy link
Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants