Skip to content

Instantly share code, notes, and snippets.

@m1t9
Created March 28, 2017 22:57
Show Gist options
  • Save m1t9/63d8557abd945fc6ac2ddf9d036b8d4d to your computer and use it in GitHub Desktop.
Save m1t9/63d8557abd945fc6ac2ddf9d036b8d4d to your computer and use it in GitHub Desktop.
from netCDF4 import Dataset as dt
import numpy as np
fileID = 'dat_3.nc'
ncfile = dt(fileID, 'r')
# print(ncfile.variables)
# np array -> int16 u10(time, latitude, longitude)
lat = np.array(ncfile.variables['latitude'][:], dtype=np.float32) # x
long = np.array(ncfile.variables['longitude'][:], dtype=np.float32) # y
time = np.array(ncfile.variables['time'][:], dtype=np.float32)
u10 = np.array(ncfile.variables['u10'][:, :, :], dtype=np.float32)
v10 = np.array(ncfile.variables['v10'][:, :, :], dtype=np.float32)
sp = np.array(ncfile.variables['sp'][:, :, :], dtype=np.float32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment