def group(self, data, merger, drop_grouper=True): """Data should have same or higher frequency than merger.""" grouped = read.merge_series(data, self.instr['pluvio'].grouper()) result = pd.merge(grouped, pd.DataFrame(merger), left_on='group', right_index=True) if drop_grouper: return result.drop('group', axis=1) return result
hextent = np.array(bnds) + (-0.1, 0.1, -0.1, 0.1) kws = { 'separate': True, 'source_style': 'hex', 'source_kws': { 'gridsize': 26, 'extent': hextent }, 'unfiltered': True } fitargs = {'force_flip': False, 'try_flip': False, 'fitclass': fit.PolFit} limslist = sf.limitslist(rholimits) data = param_table(e=e, debug=debug) data.index = data.index.droplevel() vdata = read.merge_series(e.pluv_grouper(), e.vel_data()) vtable = pd.merge(vdata, pd.DataFrame(data.rhomin), left_on='group', right_index=True) # TODO: check duplicates vfits = dict() for rhomin in rholimits[:-1]: pipv = read.PipV(data=vtable.query('rhomin=={0}'.format(rhomin))) vfits[rhomin], std, etc = pipv.pickler('v-d_rho_range', pipv.find_fit, **fitargs) fig, axarr = sf.plot_vfits_rho_intervals(dict2tuple(vfits), limslist, **kws) axarr[0].axis(bnds) for ax in axarr: ax.tick_params(direction='out', top=False)
def scatterplot(x, y, c=None, kind='scatter', **kwargs): """scatter plot of two Series objects""" plotdata = read.merge_series(x, y) if c is not None: kwargs['c'] = c return plotdata.plot(kind=kind, x=x.name, y=y.name, **kwargs)
#plt.close('all') plt.ioff() hextent = np.array(bnds)+(-0.1,0.1,-0.1,0.1) kws = {'separate': True, 'source_style': 'hex', 'source_kws': {'gridsize': 26, 'extent': hextent}, 'unfiltered': True} fitargs = {'force_flip': False, 'try_flip': False, 'fitclass': fit.PolFit} limslist=sf.limitslist(rholimits) data = param_table(e=e, debug=debug) data.index = data.index.droplevel() vdata = read.merge_series(e.pluv_grouper(), e.vel_data()) vtable = pd.merge(vdata, pd.DataFrame(data.rhomin), left_on='group', right_index=True) # TODO: check duplicates vfits = dict() for rhomin in rholimits[:-1]: pipv = read.PipV(data=vtable.query('rhomin=={0}'.format(rhomin))) vfits[rhomin], std, etc = pipv.pickler('v-d_rho_range', pipv.find_fit, **fitargs) fig, axarr = sf.plot_vfits_rho_intervals(dict2tuple(vfits), limslist, **kws) axarr[0].axis(bnds) for ax in axarr: ax.tick_params(direction='out', top=False) pc = pd.DataFrame(index=rholimits[:-1], columns=['count_all', 'count_hwfm', 'r_sq']) for rhomin in vfits: vfit = vfits[rhomin] pc.loc[rhomin] = vfit.x_unfiltered.size, vfit.x.size, vfit.rsq(filtered=False)