My code:
y = nc.createDimension("y", 950) #y x = nc.createDimension("x", 1000) #x time = nc.createDimension("time", 87648) #time latitude=nc.createVariable("y", "f8", ("y", )) longitude=nc.createVariable("x", "f8", ("x", )) time = nc.createVariable("time","f8",("time",)) countries = nc.createVariable("countries", "f8", ("y", "x")); energy = nc.createVariable("energy", "f8", ("time", "y", "x"), fill_value=-9999, chunksizes=(1, 950, 1000)); time.standard_name='time' time.units ='hours since 2006-01-01 00:00:00.0' time.calendar='proleptic_gregorian' lats = np.arange(5497500,747500,-5000) #y lons = np.arange(2502500,7502500,5000) #x # Fill variables latitude[:] = lats longitude[:] = lons countries [:]=value
UNTIL HERE WORKS FINE I have my 2d country but then it does not give any result for energy:
for i in xrange(0,950): #rows for j in xrange(0,1000): #columns for n in xrange(0,87648): #rows for m in xrange(0,1): #columns if data[1,m] == countries[i,j]: #correspondance nc.variables["energy"][n]=data[n,m]
Any idea how to fix this so I can have in country.netcdf file time dimension with energy values at each time step? Thanks a lot!!