[R] ncdf size error
Hernan A. Moreno Ramirez
hmorenor at uwyo.edu
Tue Sep 16 23:01:58 CEST 2014
Hi Professor,
Thanks for you valuable help. I did change my code to use ncdf4 package and still I get the same error:
##### Exporting to NETCDF files #################################################################
# define the netcdf coordinate variables -- note these have values!
library(ncdf4)
cat("--Exporting final NETCDF file to Outputfolder",fill=TRUE)
dim1 = ncdim_def( "Nodes","", seq(1,19000))
dim2= ncdim_def( "Time","Hours since 2005-01-01 00:00:00",seq(1:2190)) #final[1,2,]))
#dim2= dim.def.ncdf( "Time","",as.data.frame(final[1,2,]))
# define the EMPTY (elevation) netcdf variable
varT2 = ncvar_def("T2","celsius", list(dim1,dim2), -99999, longname="T2")
varQ2 = ncvar_def("Q2","kg kg-1", list(dim1,dim2), -99999, longname="Q2")
varQVAPOR = ncvar_def("QVAPOR","kg kg-1", list(dim1,dim2), -99999, longname="QVAPOR")
varQCLOUD = ncvar_def("QCLOUD","kg kg-1", list(dim1,dim2), -99999, longname="QCLOUD")
varPSFC = ncvar_def("PSFC","Pa", list(dim1,dim2), -99999, longname="PSFC")
varW10 = ncvar_def("W10","ms-1", list(dim1,dim2), -99999, longname="W10")
varW = ncvar_def("W","ms-1", list(dim1,dim2), -99999, longname="W")
varVEGFRA = ncvar_def("VEGFRA","", list(dim1,dim2), -99999, longname="VEGFRA")
varMAXVEGFRA = ncvar_def("MAXVEGFRA","", list(dim1,dim2), -99999, longname="MAXVEGFRA")
varTPREC = ncvar_def("TPREC","mm", list(dim1,dim2), -99999, longname="TPREC")
varFRAC_FROZ_PREC = ncvar_def("FRAC_FROZ_PREC","mm", list(dim1,dim2), -99999, longname="FRAC_FROZ_PREC")
varSWDOWN = ncvar_def("SWDOWN","W m-2", list(dim1,dim2), -99999, longname="SWDOWN")
varGLW = ncvar_def("GLW","W m-2", list(dim1,dim2), -99999, longname="GLW")
varPBLH = ncvar_def("PBLH","m", list(dim1,dim2), -99999, longname="PBLH")
varTSLB = ncvar_def("TSLB","Celsius", list(dim1,dim2), -99999, longname="TSLB")
nc.ex = nc_create("/media/D/output.nc",list(varT2, varQ2, varQVAPOR, varQCLOUD, varPSFC, varW10, varW, varVEGFRA, varMAXVEGFRA, varTPREC, varFRAC_FROZ_PREC, varSWDOWN, varGLW, varPBLH, varTSLB))
Error in R_nc4_enddef: NetCDF: One or more variable sizes violate format constraints
Error in R_nc4_sync: NetCDF: Operation not allowed in define mode
Thanks a lot for more help
---------------------------------------------------------------------------------------
Hernan A. Moreno, Ph.D.
Postdoctoral Research Associate
Department of Civil & Architectural Engineering
Room 3038, Engineering Building
University of Wyoming
Phone: 480-3990571
http://www.public.asu.edu/~hamoreno/
________________________________________
From: davidwilliampierce at gmail.com <davidwilliampierce at gmail.com> on behalf of David W. Pierce <dpierce at ucsd.edu>
Sent: Tuesday, September 16, 2014 2:21 PM
To: Hernan A. Moreno Ramirez
Cc: r-help at r-project.org
Subject: Re: [R] ncdf size error
On Tue, Sep 16, 2014 at 11:36 AM, Hernan A. Moreno Ramirez
<hmorenor at uwyo.edu> wrote:
> Sure, here it is. Thanks for any help with this Dr. Pierce:
>
>
> ##### Exporting to NETCDF files #################################################################
> # define the netcdf coordinate variables
> library(ncdf)
... rest of example omitted ...
Hi Hernan,
The file you are trying to make is violating size constraints imposed
by the netcdf library/R interface, which is 2 GB in the R ncdf
package. To get around this switch to the R ncdf4 package, which is
the replacement for the ncdf package (I stopped supporting the ncdf
package in 2010) and set force_v4=TRUE in the nc_create() call. This
requires a modern version of the netcdf library to be installed on
your machine, which it probably is, since the netcdf version 4 library
has been out for many years now.
Regards,
--Dave
> http://www.public.asu.edu/~hamoreno/
>
> ________________________________________
> From: davidwilliampierce at gmail.com <davidwilliampierce at gmail.com> on behalf of David W. Pierce <dpierce at ucsd.edu>
> Sent: Monday, September 15, 2014 7:00 PM
> To: Hernan A. Moreno Ramirez
> Cc: r-help at r-project.org
> Subject: Re: [R] ncdf size error
>
> On Mon, Sep 15, 2014 at 4:20 PM, Hernan A. Moreno Ramirez
> <hmorenor at uwyo.edu> wrote:
>>
>> Hi I am using both ncdf and ncdf4 libraries and with both I keep getting the
>> same error: Error in R_nc_enddef: NetCDF: One or more variable sizes violate
>> format constraints. Error in R_nc_sync: NetCDF: Operation not allowed in
>> define mode. This happens when I try to create.ncdf() a file with more than
>> 13 variables. I think is a problem of memory size. What would you recommend?
>> Any help will be appreciated
>
> Hi Hernan,
>
> can you supply an example that shows the problem?
>
> Regards,
>
> --Dave
>
> -------------------
> David W. Pierce
> Division of Climate, Atmospheric Science, and Physical Oceanography
> Scripps Institution of Oceanography, La Jolla, California, USA
> (858) 534-8276 (voice) / (858) 534-8561 (fax) dpierce at ucsd.edu
--
David W. Pierce
Division of Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography, La Jolla, California, USA
(858) 534-8276 (voice) / (858) 534-8561 (fax) dpierce at ucsd.edu
More information about the R-help
mailing list