breezeintopl breezeintopl - 1 year ago 98
Python Question

how to read netcdf4 data if I only have netcdf3 tool?

    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
      file, which is a netcdf4 file, I think and I need to load it in R.

    1. In R on our cluster, only
      package is installed. And it cannot read the above .nc file. The
      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

    1. In python, (I don't know why) I can load
      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
    package in R.

  • Some of the
    data are directly downloaded from some website, and some of the
    files are from the output of the
    package in python (and the netcdf output of xarray is in version 4).

Answer Source

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')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download