def recordobs(obs): # record the provided observation dict ct = datetime.datetime.fromtimestamp(int(obs['timestamp'])+18000) # cst to utc storagepath='/ldm/var/data/aggregate/qualitycontrol/' # location fprefix = 'anl-qc-' # file class prefix filename = fprefix+ct.strftime('%Y')+'-'+ct.strftime('%m')+'-'+ct.strftime('%d')+'-'+ct.strftime('%H')+'00.nc' if filename not in qcfiles.keys(): rootcdf = mynetcdf(storagepath, filename) stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id) qcfiles[filename]=rootcdf else: rootcdf = qcfiles[filename] stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id) filename = fprefix+"".join(x for x in obs['stn'] if x.isalnum())+".nc" # http://stackoverflow.com/a/295152 fast and nice if filename not in stnfiles.keys(): stncdf = mynetcdf(storagepath+'Last5ByStation/', filename, rtype='stn') stn_id = rootcdf.addstn(obs) stncdf.addobs(obs,'0') stncdf.close() #stnfiles[filename]=stncdf else: stncdf = stnfiles[filename] stncdf.addobs(obs,'0')
def recordobs(obs): # take a observation dictionary and record it in a netcdf file ct = datetime.datetime.utcnow() storagepath = PATH fprefix = "anl-realtime-" # file class prefix filename = ( fprefix + ct.strftime("%Y") + "-" + ct.strftime("%m") + "-" + ct.strftime("%d") + "-" + ct.strftime("%H") + "00.nc" ) if filename not in rtfiles.keys(): rootcdf = mynetcdf(storagepath, filename) stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id) rtfiles[filename] = rootcdf else: rootcdf = rtfiles[filename] stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id)
def recordobs(obs): # take a observation dictionary and record it in a netcdf file ct = datetime.datetime.utcnow() storagepath = PATH fprefix = 'anl-realtime-' # file class prefix filename = fprefix + ct.strftime('%Y') + '-' + ct.strftime( '%m') + '-' + ct.strftime('%d') + '-' + ct.strftime('%H') + '00.nc' if filename not in rtfiles.keys(): rootcdf = mynetcdf(storagepath, filename) stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id) rtfiles[filename] = rootcdf else: rootcdf = rtfiles[filename] stn_id = rootcdf.addstn(obs) rootcdf.addobs(obs, stn_id)