siesta netcdf4 file output

Asked by GuodongYu on 2018-03-26

Dear all siesta users:

I am using siesta with netcdf lib. But siesta output the netcdf3 format file. Can siesta can output netcdf4 one, or how to convert netcdf3 to netcdf4? Thanks

Guodong Yu

Question information

English Edit question
Siesta Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Nick Papior (nickpapior) said : #1

1) Compiling with NetCDF-4 support requires -DNCDF -DNCDF_4 pre-processor flags
2) The NetCDF-4 output files are only generated if CDF.Save is true.
3) If you want to convert a NetCDF-3 to NetCDF-4 using compression
    nccopy -d 3 -s
(this is also explicitly mentioned in the manual).

For further details I refer to the siesta manual.

NOTE the NetCDF-4 output files are only implemented in siesta-4.1 and above.

GuodongYu (ibeam) said : #2

Thanks, I converted the file to netcdf4 formate, and it was read by python-netcdf4 package. But I can found the Hamiltonian and overlap data.

It shows me like this (Maybe I goes to wrong place for getting the data):
( is the netcdf4 converted from file)

In [9]: f = Dataset('')

In [10]: v = f.variables

In [11]: v['h']
<type 'netCDF4._netCDF4.Variable'>
float32 h(scf_step, nspin, nnzs)
    Description: Hamiltonian (in Ry)
unlimited dimensions: scf_step
current shape = (0, 1, 749)
filling off

Does It mean nothing useful data inside or I need to deal with it further ?

Many thanks


Nick Papior (nickpapior) said : #3

1) Python-netcdf4 is capable of reading the file even if it is a netcdf3 file. No need to bother with converting to netcdf-4
2) The stored Hamiltonian is the sparse matrix.

GuodongYu (ibeam) said : #4

Thanks, maybe I don't find the right way to extract the data I want, I need to learn more about netcdf file.

GuodongYu (ibeam) said : #5

Hi Nick,

I tried to read it, but I can't
the command
v['h'][:] (following the last email from me) gives array([], shape=(0, 1, 749), dtype=float32), it seems that nothing inside. Can you give me some materials to read it. Many thanks.


Nick Papior (nickpapior) said : #6

Please consult the netcdf-package documentation.

However, You probably don't have SaveHS, because shape=(0,1,749) which means it isn't populated. (a size 0 means no elements).

GuodongYu (ibeam) said : #7

Thanks Nick, It works now.