def load_ncs(run_name): fname = '{}-{}.nc'.format ALL_OBS_DATA = nc2df(os.path.join(run_name, fname(run_name, 'OBS_DATA'))) index = ALL_OBS_DATA.index dfs = dict(OBS_DATA=ALL_OBS_DATA) for fname in glob(os.path.join(run_name, "*.nc")): if 'OBS_DATA' in fname: continue else: model = fname.split('.')[0].split('-')[-1] df = nc2df(fname) # FIXME: Horrible work around duplicate times. if len(df.index.values) != len(np.unique(df.index.values)): kw = dict(subset='index', take_last=True) df = df.reset_index().drop_duplicates(**kw).set_index('index') kw = dict(method='time', limit=30) df = df.reindex(index).interpolate(**kw).ix[index] dfs.update({model: df}) return Panel.fromDict(dfs).swapaxes(0, 2)
log.info('[{}]: {}'.format(mod_name, url)) # #### Load saved files and interpolate to the observations time interval # In[ ]: from glob import glob from operator import itemgetter from pandas import Panel from utilities import nc2df fname = '{:%Y-%m-%d}-OBS_DATA.nc'.format(stop) OBS_DATA = nc2df(fname) index = OBS_DATA.index dfs = dict(OBS_DATA=OBS_DATA) for fname in glob("*.nc"): if 'OBS_DATA' in fname: continue else: model = fname.split('.')[0].split('-')[-1] df = nc2df(fname) kw = dict(method='time', limit=30) df = df.reindex(index).interpolate(**kw).ix[index] dfs.update({model: df}) dfs = Panel.fromDict(dfs).swapaxes(0, 2)
ax.set_extent([bbox[0], bbox[2], bbox[1], bbox[3]]) log.info('[{}]: {}'.format(mod_name, url)) # #### Load saved files and interpolate to the observations time interval # In[ ]: from glob import glob from operator import itemgetter from pandas import Panel from utilities import nc2df fname = '{:%Y-%m-%d}-OBS_DATA.nc'.format(stop) OBS_DATA = nc2df(fname) index = OBS_DATA.index dfs = dict(OBS_DATA=OBS_DATA) for fname in glob("*.nc"): if 'OBS_DATA' in fname: continue else: model = fname.split('.')[0].split('-')[-1] df = nc2df(fname) kw = dict(method='time', limit=30) df = df.reindex(index).interpolate(**kw).ix[index] dfs.update({model: df}) dfs = Panel.fromDict(dfs).swapaxes(0, 2)