def d0_nw_paper(data, rholimits): rhopairs = sf.limitslist(rholimits) fig, axarr = plt.subplots(nrows=1, ncols=3, dpi=150, figsize=(11, 4), sharex=True, sharey=True, tight_layout=True) for i, (rhomin, rhomax) in enumerate(rhopairs): limitstr = rhorangestr % (rhomin * read.RHO_SCALE, rhomax * read.RHO_SCALE) ax = axarr[i] datarho = data[data.rhomin == rhomin] #.loc['second'] datarho.plot.scatter(x=d0_col, y='log_nw', c='', ax=axarr[i]) lfit = fit.LinFit(x=datarho[d0_col], y=datarho.log_nw, xname='D_0') lfit.find_fit() lfit.plot(source_style=None, ax=ax) #efit = fit.ExponentialFit(x=datarho.D_0, y=datarho.N_w) #efit.find_fit() #efit.plot(source_style='raw', ax=ax) ax.legend() ax.set_title(limitstr) ax.set_xlabel('') axarr[0].set_ylabel('$log(N_w)$') axarr[1].set_xlabel('$D_0$, mm') axarr[-1].set_title('$\\rho > %s$' % (rhomin * read.RHO_SCALE)) plt.axis([0, 5, 1, 6]) #remove_subplot_gaps(fig, axis='row') return fig, axarr
def d0_nw_paper(data, rholimits): rhopairs = sf.limitslist(rholimits) fig, axarr = plt.subplots(nrows=1, ncols=3, dpi=150, figsize=(11,4), sharex=True, sharey=True, tight_layout=True) for i, (rhomin, rhomax) in enumerate(rhopairs): limitstr = rhorangestr % (rhomin*read.RHO_SCALE, rhomax*read.RHO_SCALE) ax = axarr[i] datarho = data[data.rhomin==rhomin]#.loc['second'] datarho.plot.scatter(x=d0_col, y='log_nw', c='', ax=axarr[i]) lfit = fit.LinFit(x=datarho[d0_col], y=datarho.log_nw, xname='D_0') lfit.find_fit() lfit.plot(source_style=None, ax=ax) #efit = fit.ExponentialFit(x=datarho.D_0, y=datarho.N_w) #efit.find_fit() #efit.plot(source_style='raw', ax=ax) ax.legend() ax.set_title(limitstr) ax.set_xlabel('') axarr[0].set_ylabel('$log(N_w)$') axarr[1].set_xlabel('$D_0$, mm') axarr[-1].set_title('$\\rho > %s$' % (rhomin*read.RHO_SCALE)) plt.axis([0, 5, 1, 6]) #remove_subplot_gaps(fig, axis='row') return fig, axarr
import snowfall as sf import read import numpy as np import matplotlib.pyplot as plt from os import path import fit from scr_snowfall import param_table plt.close('all') plt.ioff() debug = False rholims = (0, 100, 200, 800) #rholims = (0, 150, 300, 800) limslist = sf.limitslist(rholims) n_ranges = len(limslist) separate = False d0_col = 'D_0_gamma' resultspath = '../results/pip2015' paperpath = read.ensure_dir(path.join(resultspath, 'paper')) savepath = path.join(resultspath, 'psd') rhorangestr = '$%s < \\rho \leq %s$' def d0_nw_paper(data, rholimits): rhopairs = sf.limitslist(rholimits) fig, axarr = plt.subplots(nrows=1, ncols=3,
else: e = pip2015events() #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'])