How to extract for more file (theres like 100 files)
pw_201701010000.nc
pw_201701010100.nc
pw_201701010200.nc
pw_201701010300.nc
...
pw_201701022300.nc
Code:
from numpy import *
from netCDF4 import Dataset
fname = 'pw_201701010000'
f = Dataset(fname+'.nc')
print (f.variables)
data = f.variables['pw'][0][:]
data = data-0.
time = f.variables['time'][:]
lat = f.variables['latitude'][:]
lon = f.variables['longitude'][:]
f.close()
f = open(fname+'.txt','w')
for i in range(len(lat)):
for j in range(len(lon)):
if lat[i]>=-3.0 and lat[i]<=0 and lon[j]>=116.0 and lon[j]<=119.0:
#f.write(('%f\t%f\t%f\n')%(lat[i],lon[j],data[i,j]))
f.write(('%f\t')%(data[i,j]))
if lat[i]>=-3.0 and lat[i]<=0:
f.write('\n')
f.close()