Created
October 29, 2019 00:19
-
-
Save roguephysicist/8afdf7142d7cd84b028e980f47f39246 to your computer and use it in GitHub Desktop.
Python NetCDF4: read kpts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
A simple script for reading the "kpts.nc" NetCDF file generated by ABINIT, for | |
determining the generated kpt grid. | |
''' | |
import netCDF4 | |
import numpy as np | |
def kpts_abi(infile): | |
''' | |
Reads "infile" using netCDF4 and loads the kpt grid into a numpy array. | |
''' | |
rootgrp = netCDF4.Dataset(infile, mode="r") | |
return np.array((rootgrp.variables["reduced_coordinates_of_kpoints"])) | |
GRID = kpts_abi("kpts.nc") | |
np.savetxt('kpts.out', GRID, fmt='% 10.8E % 10.8E % 10.8E') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment