-
Notifications
You must be signed in to change notification settings - Fork 28
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
Writing values into unlimited dimension variable #62
Comments
Thanks for the report. I can not seem to reproduce the issue. The following works as expected, it writes the time variable as well as the actual data: using NetCDF
x=[0.1*i for i=1:100];nx=length(x)
y=[0.1*i for i=1:200];ny=length(y)
xdim = NcDim("x",nx,values=x)
ydim = NcDim("y",ny,values=y)
tdim = NcDim("t",0,unlimited=true)
uvar = NcVar("u",[xdim,ydim,tdim],t=Float32)
tvar = NcVar("t",tdim,t=Int64)
fn=tempname()
ncu = NetCDF.create(fn,[uvar,tvar],mode=NC_NETCDF4)
for i=1:10
u=rand(nx,ny)
NetCDF.putvar(ncu,"u",Float32.(u),start=[1,1,i],count=[-1,-1,1])
NetCDF.putvar(ncu,"t",Int64[i*5],start=[i]) #Write the time
end
NetCDF.close(ncu)
ncread(fn,"t") which I think reflects your workflow. In case you read the NetCDF file from an external resource, make sure to call |
Thanks for your input, indeed your example also works for me. In my slightly more extensive version of that code (see output.jl) the variable t gets correctly written in some cases (that means if I write the variable η), but in others (for writing u and v) a fill value of -9223372036854775806 appears. Any idea whether this is actually me misusing the package? |
Okay, I think I found the issue. Let's extend your code so that two variables u,v with same dimensions get written to two different files, both with the same dimensions. using NetCDF
x = [0.1*i for i=1:100];nx=length(x)
y = [0.1*i for i=1:200];ny=length(y)
xdim = NcDim("x",nx,values=x)
ydim = NcDim("y",ny,values=y)
tdim = NcDim("t",0,unlimited=true)
uvar = NcVar("u",[xdim,ydim,tdim],t=Float32)
vvar = NcVar("v",[xdim,ydim,tdim],t=Float32)
tvar = NcVar("t",tdim,t=Int64)
fn1=tempname()
fn2=tempname()
ncu = NetCDF.create(fn1,[uvar,tvar],mode=NC_NETCDF4)
ncv = NetCDF.create(fn2,[vvar,tvar],mode=NC_NETCDF4)
for i=1:10
u = rand(nx,ny)
v = rand(nx,ny)
NetCDF.putvar(ncu,"u",Float32.(u),start=[1,1,i],count=[-1,-1,1])
NetCDF.putvar(ncv,"v",Float32.(v),start=[1,1,i],count=[-1,-1,1])
NetCDF.putvar(ncu,"t",Int64[i*5],start=[i]) #Write the time
NetCDF.putvar(ncv,"t",Int64[i*5],start=[i]) #Write the time
end
NetCDF.close(ncu)
NetCDF.close(ncv)
t1 = ncread(fn1,"t")
t2 = ncread(fn2,"t") now |
Ah thanks, this is definitely a bug. Will fix as soon as possible. |
If I create dimensions like
and the variables as
I can write the
u
variable for a given timestepi
withHowever, no matter how I try to write the values into the unlimited dimension variable "t" (either all at once
where
t
is an integer array, or consequitively everytime I also write "u")the values do not get written into the nc file (but also no error is thrown)
The text was updated successfully, but these errors were encountered: