[R] Problem in put.var.ncdf

David William Pierce dpierce at ucsd.edu
Mon Sep 12 23:24:07 CEST 2011


On Mon, Sep 12, 2011 at 1:32 PM, Claudia Stocker
<cstocker at climate.unibe.ch> wrote:
> Dear all,
>
> I have a problem in writing a variable to a NetCDF-File.
> My code works pretty well until the step put.var.ncdf():
>
>
[...code omitted...]
> R prints the following error:
> #---------------------
>
> Error in put.var.ncdf(spi, var.spi.24.03.me, spi24.me) :   NA/NaN/Inf in
> foreign function call (arg 5)
>
> I can exclude an error in length (dim.time.spi and spi24.me have the same
> length) or NA (there are no NA in the spi24.me vector). Where is the
> error?? The code seems so simple..

Hi Claudia,

could you put the following code in right before the put.var.ncdf call
and see what it prints:

print(paste('num of NAs in time:", sum(is.na(dim.time)) ))
print(paste("length of time:", length(dim.time) ))
print(paste("num of NAs in spi24.me:", sum(is.na(spi24.me)) ))
print(paste("length of spi24.me:", length(spi24.me) ))

If that doesn't show anything wrong, you can email me the data and
your code and I can give it a try. Or, you can try the newest version
of the ncdf/ncdf4 packages, which you can download from:

http://cirrus.ucsd.edu/~pierce/ncdf/

it may be a bug that I've already fixed.

Regards,

--Dave

-- 
David W. Pierce
Division of Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography
(858) 534-8276 (voice)  /  (858) 534-8561 (fax)    dpierce at ucsd.edu



More information about the R-help mailing list