siesta netcdf4 file output

Asked by GuodongYu

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

Best,
Guodong Yu

Question information

Language:
English Edit question
Status:
Solved
For:
Siesta Edit question
Assignee:
No assignee Edit question
Solved by:
GuodongYu
Solved:
Last query:
Last reply:
Revision history for this message
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 noncompressed.nc compressed.nc
(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.

Revision history for this message
GuodongYu (ibeam) said :
#2

Thanks, I converted the DMHS.nc 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):
(compressed.nc is the netcdf4 converted from dmhs.nc file)

In [9]: f = Dataset('compressed.nc')

In [10]: v = f.variables

In [11]: v['h']
Out[11]:
<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

best,
Guodong

Revision history for this message
Nick Papior (nickpapior) said :
#3

1) Python-netcdf4 is capable of reading the DMHS.nc 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.

Revision history for this message
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.

Revision history for this message
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.

Best,
Guodong

Revision history for this message
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).

Revision history for this message
GuodongYu (ibeam) said :
#7

Thanks Nick, It works now.