[R] [ncdf] programmatically copying a netCDF file

Tom Roche Tom_Roche at pobox.com
Sat Jan 14 00:43:46 CET 2012


Tom Roche Mon, Jan 9, 2012 at 3:54 PM, 
>> I need to copy most of a source file, modifying only part, and to
>> write a target file.

David William Pierce Thu, 12 Jan 2012 09:13:53 -0800
> I'd advise against doing this. I think it's the wrong approach.
> Better to use 'cp' to make a bit-for-bit copy and then modify that.

OK. I guess I misunderstood other posts I've seen about R having value
semantics: files seem to be the exception.

>> 1 Precisions "int" and "float" not supported by var.def.ncdf(...).

> Sorry, bug. Unfortunately ncdf4 is the new and supported release

Fair enough. I just got access to a box with ncdf4, so will port scripts.

>> 2 Copying I/O API global attributes fails [with]

>> - Error in R_nc_put_att_double:
>> -   NetCDF: Name contains illegal characters
>> - [1] "Error in att.put.ncdf, while writing attribute :IOAPI_VERSION
>> -    with value 0"

> I think you *don't* want that leading colon (":"). That's the syntax
> of ncdump, not the name of the attribute.

Doh! Thanks.

>> * the target file has *new* coordinate variables for the dimensions.

> ncdf4 provides a mechanism to suppress creating a coordinate variable.

>> 4 Attribute="long_name" is missing for every original/copied data
>>  variable.

> Just a bug. Fixed in ncdf4.

on to ncdf4, Tom Roche <Tom_Roche at pobox.com>



More information about the R-help mailing list