1
    1. My school cluster admin said: if we load netcdf4 module, then we cannot load netcdf3 module. So he refused to update netcdf4
    1. I have a .nc file, which is a netcdf4 file, I think and I need to load it in R.
    1. In R on our cluster, only RNetCDF package is installed. And it cannot read the above .nc file. The ncdf4 package is not there. (I try to install it, it says it requires netcdf library of version 4. And of course I do not have sudo)
    1. In python, (I don't know why) I can load netcdf4 file. I don't know if I can use this to (save it in netcdf 3 format?) help me load that data in R.

So, how should I do?

  • The admin don't want to switch to netcdf4 module, and so it seems I(or he) cannot install ncdf4 package in R.
  • Some of the nc data are directly downloaded from some website, and some of the nc files are from the output of the xarray package in python (and the netcdf output of xarray is in version 4).
2
  • hdf5 can read netCDF4 ... Commented Nov 17, 2016 at 6:27
  • Thanks @DavidLeBauer ! This helps. I googled this post: r-bloggers.com/… , which uses the rhdf5 package in R to read nc4 file. Commented Nov 17, 2016 at 13:37

1 Answer 1

4

With xarray you can control the version of files saved by specifying format='NETCDF3_CLASSIC' when calling to_netcdf. So a simple solution might be to use xarray, e.g.,

ds = xarray.open_dataset(path)
ds.to_netcdf(dest, format='NETCDF3_CLASSIC')
Sign up to request clarification or add additional context in comments.

3 Comments

Well, I got an error message: RuntimeError: NetCDF: One or more variable sizes violate format constraints. So, maybe it is because the dataset is too large(5.2G)?
Indeed, netCDF3 is a very old (32 bit) file format -- it doesn't support variable sizes larger than 4GB under any circumstances.
Thanks! This helps, because even though I could load this data with the above rhdf5 package, the time (date) is missing, and only shows "0,1,2,3,4,5 ...", which shows some error like "using 64 bit without losing information"...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.