def plot_01(axs, x, y, c, xlabel, ylabel): r, p = get_pearsonr(x, y) p = axs.scatter(x, y, c=c, cmap='jet', marker='.', label='r= %.2f' % r + funcs_lzh.funcstar(p)) axs.set_xlabel(xlabel) axs.set_ylabel(ylabel) axs.legend() return p
def scatterplot(ax,x,y,c,xlim_range,ylim_range): r, p = get_pearsonr(x, y) label = 'r= %.2f' % r + funcs_lzh.funcstar(p) p=ax.scatter(x, y, c=c, vmin=0, vmax=1, cmap='jet', marker='o', label=label) ax.set_xlim(xlim_range) ax.set_ylim(ylim_range) return p
def plot_02(axs, x, y, color, llabel): r, p = get_pearsonr(x, y) axs.scatter(x, y, color=color, marker='.', label=llabel + 'r= %.2f' % r + funcs_lzh.funcstar(p))
def scatterplot1(ax, x, y, xlim_range, ylim_range, color): r, p = get_pearsonr(x, y) label = 'r= %.2f' % r + funcs_lzh.funcstar(p) p = ax.scatter(x, y, marker='.', facecolor='', edgecolor=color, label=label) ax.set_xlim(xlim_range) ax.set_ylim(ylim_range) return p
def scatterplot1(ax,x,y,xlim_range,ylim_range,marker,color,range_label): reg = linreg.fit(x.values.reshape(-1, 1), y) a, b = linreg.coef_, linreg.intercept_ pred = reg.predict(x.values.reshape(-1, 1)) text = 'y=' + '%.2f' % a + 'x' + '+' + '%.2f' % b ax.plot(x.values.reshape(-1, 1), pred, color=color, linewidth=1, label='') r, p = get_pearsonr(x, y) label = 'R$^2$= %.2f' % np.square(r) + funcs_lzh.funcstar(p) p=ax.scatter(x, y, marker=marker, facecolor='',edgecolor=color,label=label+', '+range_label) ax.set_xlim(xlim_range) ax.set_ylim(ylim_range) return p
temp.loc[i, 'r'] = r temp.loc[i, 'p'] = p box_data.append(daymean.loc[idx, box_label]) print(temp) axs[flag].bar(temp['idx'], temp['r'], bottom=0, color='k', width=0.5, alpha=0.5, label='r of SIF$_{yield}$-LUE') for num in temp['idx']: axs[flag].text(temp.loc[num - 1, 'idx'], 0.5, funcs_lzh.funcstar(temp.loc[num - 1, 'p']), color='r', horizontalalignment='center') axs[flag].set_ylabel('r of SIF$_{yield}$-LUE', **axis_font) axs[flag].set_ylim([-0.5, 2]) axs[flag].set_yticklabels(['-0.5', '0', '0.5', '1', '', '']) par = axs[flag].twinx() bp1 = par.boxplot(box_data, labels=temp['idx'], showmeans=True) par.set_ylabel(box_label, **axis_font) par.set_ylim([-2, 1.5]) par.set_yticklabels(['', '', '', '', '0', '0.5', '1', '1.5']) for ax in [axs[flag], par]: ax.tick_params(labelsize=ticklabelsize) labels = ax.get_xticklabels() + ax.get_yticklabels() [label.set_fontname('Arial') for label in labels]
daymean['scaled_Ta'] = MaxMinNormalization(daymean['Ta'], np.max(daymean['Ta']), np.min(daymean['Ta'])) daymean['eci'] = daymean['scaled_APAR'] + daymean['scaled_VPD'] + daymean['scaled_Ta'] daymean['ECI'] = MaxMinNormalization(daymean['eci'], np.max(daymean['eci']), np.min(daymean['eci'])) daymean['sify'] = daymean['SIFyieldgndvi'] daymean['lue'] = daymean['LUEgndvi'] # 分阶段 vege = daymean[daymean['doy'] <= a2] repro = daymean[(daymean['doy'] > a2) & (daymean['doy'] <= a3)] ripen = daymean[daymean['doy'] > a3] fig, axs = plt.subplots(2, 4, figsize=(30, 8.5)) fig.subplots_adjust(left=0.07,right=0.85) r,p=get_pearsonr(vege['GPP'],vege['SFM']) label='r= %.2f'%r+funcs_lzh.funcstar(p) axs[0, 0].scatter(vege['GPP'], vege['SFM'], c=vege['ECI'],vmin=0, vmax=1, cmap='jet', marker='o',label=label) axs[0,0].set_xlabel('GPP $[μmol CO_2/m^2/s]$',**axis_font) axs[0,0].set_ylabel('SIF $[mW/m^2/nm/sr]$',**axis_font) axs[0,0].set_xlim([0,100]) axs[0,0].set_ylim([0,2.5]) r,p=get_pearsonr(repro['GPP'],repro['SFM']) label='r= %.2f'%r+funcs_lzh.funcstar(p) axs[0, 1].scatter(repro['GPP'], repro['SFM'], c=repro['ECI'],vmin=0, vmax=1, cmap='jet', marker='o',label=label) axs[0,1].set_xlabel('GPP $[μmol CO_2/m^2/s]$',**axis_font) axs[0,1].set_xlim([0,100]) axs[0,1].set_ylim([0,2.5]) r,p=get_pearsonr(ripen['GPP'],ripen['SFM']) label='r= %.2f'%r+funcs_lzh.funcstar(p) axs[0, 2].scatter(ripen['GPP'], ripen['SFM'], c=ripen['ECI'],vmin=0, vmax=1, cmap='jet', marker='o',label=label) axs[0,2].set_xlabel('GPP $[μmol CO_2/m^2/s]$',**axis_font)
PAR = data['PARd_North'] NetPAR = data['NetRad_North'] LAIgreen_from_NDVI = data['LAI_green_fromNDVI'] # plt.subplots(figsize=(10, 5)) temp = pd.concat([SIF_A_ifld, GPP], axis=1) # print(temp) temp = temp.dropna() x = temp['SIF_A_ifld_mean'] y = temp['GPP_MR_f_Subcanopy'] a, b, pred_y = funcs_lzh.get_lingre(x.values.reshape(-1, 1), y) r, p = pearsonr(x, y) r2 = '%.2f' % np.square(r) text_line = 'y=' + '%.2f' % a + 'x' + '+' + '%.2f' % b text_rsqu = '$R^2$= ' + r2 + funcs_lzh.funcstar(p) plt.scatter(SIF_A_ifld, GPP, edgecolors='k', facecolors='', label='SIFA_ifld ' + text_rsqu) plt.plot(x, pred_y, label=text_line, color='k') # temp = pd.concat([SIF_A_sfm, GPP], axis=1) temp = temp.dropna() x = temp['SIF_A_sfm_mean'] y = temp['GPP_MR_f_Subcanopy'] a, b, pred_y = funcs_lzh.get_lingre(x.values.reshape(-1, 1), y) r, p = pearsonr(x, y) r2 = '%.2f' % np.square(r) text_line = 'y=' + '%.2f' % a + 'x' + '+' + '%.2f' % b
a1 = 192 a2 = 205 a3 = 255 a4 = 283 # daymean filepath=r'D:\Shared_Folder\Lzh py\SifAnalysis\SIF_GPP_reviewer\data' data = pd.ExcelFile( filepath + '\\' + r'leaf data_top and canopy_20180311_corn.xlsx') data = data.parse(0) data=pd.concat([data['Canopy_SIF'],data['Canopy_GPP'] ,data['PAR'],data['LAI'],data['Cab'] # chl a+b(mg/cm2) ,data['SIFyield760']],axis=1) data=data.dropna() print(data) data['psify']=data['Canopy_SIF']/data['PAR'] data['plue']=data['Canopy_GPP']/data['PAR'] data['leafsify']=data['SIFyield760']*1000 ## fig fig,axs=plt.subplots(2,4,figsize=(15,8)) r,p=get_pearsonr(data['plue'],data['psify']) label='r= '+'%.2f'%r+funcs_lzh.funcstar(p) axs[0,0].scatter(data['plue'],data['psify'],edgecolors='k' ,facecolors='',marker='.',label=label) axs[0,0].yaxis.set_major_formatter(fromatter) axs[0,0].set_ylabel('psify [-]') axs[0,0].set_xlabel('plue [-]') axs[0,0].legend() plt.show()
axis=1) daymean = daymean.dropna() # 去掉structural and pigment effects meanMTVI2 = np.mean(daymean['MTVI2']) daymean['scaled_MTVI2'] = daymean['MTVI2'] / meanMTVI2 daymean['rsify'] = daymean['sify'] / daymean['scaled_MTVI2'] daymean['rpri'] = daymean['PRI'] / daymean['scaled_MTVI2'] # 分阶段 vege = daymean[daymean['DOY'] <= a2] repro = daymean[(daymean['DOY'] > a2) & (daymean['DOY'] <= a3)] ripen = daymean[daymean['DOY'] > a3] ## SIFyield-LUE & PRI-LUE的关系 fig, axs = plt.subplots(1, 2, figsize=(8, 3.5)) fig.subplots_adjust(left=0.1, bottom=0.15, right=0.92, top=0.92, wspace=0.33) r, p = get_pearsonr(daymean['lue'], daymean['sify']) label = 'R$^2$= %.2f' % np.square(r) + funcs_lzh.funcstar(p) p = axs[0].scatter(daymean['lue'], daymean['sify'], c=daymean['ECI'], vmin=0, vmax=1, cmap='jet', marker='o', label=label, edgecolor='k') axs[0].set_ylim([-0.001, 0.003]) axs[0].set_ylabel('$SIF_{yield}$', **axis_font) r, p = get_pearsonr(daymean['lue'], daymean['PRI']) label = 'R$^2$= %.2f' % np.square(r) + funcs_lzh.funcstar(p) p = axs[1].scatter(daymean['lue'], daymean['PRI'],