import numpy from scipy.io import netcdf # open a new netCDF file for writing. ncfile = netcdf.netcdf_file('timeinfo_184912-210001_bad.nc','w') # create time dimension. ncfile.createDimension('time',None) # create variables. date_out = ncfile.createVariable('date',numpy.dtype('int32').char,('time',)) date_out.long_name = 'current date (YYYYMMDD)' datesec_out = ncfile.createVariable('datesec',numpy.dtype('int32').char,('time',)) datesec_out.long_name = 'current seconds of current date' count=0 for y in [1849] + range(1849,2099): m1 = 1 m2 = 12 if y == 2098: m2 = 2 for m in range(m1,m2+1): d = 16 if m == 2: d = 15 datestr = [ "%4.4i"%y + "%2.2i"%m + "%2.2i"%d ] dateint = y*10000 + m*100 + d date_out[count] = dateint datesec_out[count] = 0 count = count + 1 print count # close the file. ncfile.close()