# Change the missing data to the QC flag of -9999 cbh = np.where(np.asarray(cbh) > 0, cbh/1000., -9999) #utc = pytz.UTC #lead_str = site.lower() + 'ceilocbhC1.a1.' + datetime.strftime(times[0], '%Y%m%d.%H%M%S.cdf') lead_str = out_path + '/' + site.lower() + 'ceilocbhC1.a1.' + datetime.strftime(dt, '%Y%m%d.000000.cdf') print 'Saving data for this site at: ', lead_str ncdf = Dataset(lead_str, 'w') ncdf.createDimension('time', len(times)) ncdf.description = "This file contains the lowest cloud height at any time and is used in the AERIoe retrieval algorithm." ncdf.link_to_data = string ncdf.station_id = site ncdf.station_name = name ncdf.state = state nums = date2num(times, 'seconds since 1970-01-01 00:00:00-00:00') bt = ncdf.createVariable('base_time', 'i4') bt[:] = nums[0] to = ncdf.createVariable('time_offset', 'i4', ('time',)) to[:] = nums - nums[0] la = ncdf.createVariable('lat', 'f4') la[:] = lat lo = ncdf.createVariable('lon', 'f4') lo[:] = lon al = ncdf.createVariable('alt', 'f4') al[:] = alt