From 6078bfa1ca95db9a8d4605d0f9f0a3757980d903 Mon Sep 17 00:00:00 2001 From: "tristan.harmel" <tristan.harmel@get.omp.eu> Date: Tue, 30 Apr 2019 17:54:07 +0200 Subject: [PATCH] add legend in plots --- trios/process.py | 4 ++-- trios/run_awr.py | 39 +++++++++++++++++++++++++++++++-------- trios/run_swr.py | 13 +++++++++---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/trios/process.py b/trios/process.py index c8148da..51898d7 100644 --- a/trios/process.py +++ b/trios/process.py @@ -139,8 +139,8 @@ class swr_process: # TODO add particulate and dissolved component to a and bb values # a,bb = aux.get_iop(..., withwater=True) acdom = ua.cdom(0.5, wl).get_acdom() - a = a + acdom + 0.4 - bb = bb + 0.05 + a = a + acdom + bb = bb if shade_corr: Rrs = self.shade_corr(Rrs, R, ang_w, a, bb, wl) # Rrs.columns = pd.MultiIndex.from_product([['Rrs(swr)'], Rrs.columns], names=['param', 'wl']) diff --git a/trios/run_awr.py b/trios/run_awr.py index 467436d..0b4dd83 100644 --- a/trios/run_awr.py +++ b/trios/run_awr.py @@ -12,8 +12,9 @@ import utils.utils as u import utils.auxdata as ua from trios.process import * +plot=True #False odir = os.path.abspath('/DATA/OBS2CO/data/trios/above_water') -dirfig = os.path.abspath('/DATA/OBS2CO/data/trios/fig') +dirfig = os.path.join(odir,'fig') awrfiles = glob.glob("/DATA/OBS2CO/data/trios/raw/aw*idpr*.csv") @@ -110,13 +111,35 @@ for idpr in idprs: Rrs_stat = Rrs_stat.T Rrs_stat.to_csv(ofile,mode='a') - #------------------------------- - # for Mobley values : - # rho15 = awr.get_rho_mobley(awr.rhoM2015, [df.sza.mean()], [vza], [azi], [ws])[0] - # rho99 = awr.get_rho_mobley(awr.rhoM1999, [df.sza.mean()], [vza], [azi], [ws])[0] - # - # Rrs15 = (df.loc[:, 'Lt'] - rho15 * df.loc[:, 'Lsky']) / df.loc[:, 'Ed'] - # Rrs99 = (df.loc[:, 'Lt'] - rho99 * df.loc[:, 'Lsky']) / df.loc[:, 'Ed'] + if plot: + import matplotlib.pyplot as plt + plt.rcParams.update({'font.size': 18}) + # ------------------------------- + # for Mobley values : + rho15 = awr.get_rho_mobley(awr.rhoM2015, [df.sza.mean()], [vza], [azi], [ws])[0] + rho99 = awr.get_rho_mobley(awr.rhoM1999, [df.sza.mean()], [vza], [azi], [ws])[0] + + Rrs15 = (df.loc[:, 'Lt'] - rho15 * df.loc[:, 'Lsky']) / df.loc[:, 'Ed'] + Rrs99 = (df.loc[:, 'Lt'] - rho99 * df.loc[:, 'Lsky']) / df.loc[:, 'Ed'] + + fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 8)) + fig.subplots_adjust(left=0.16, right=0.9, hspace=.5, wspace=0.65) + add_curve(ax, wl, Rrs15.transpose().mean(axis=1), Rrs15.transpose().std(axis=1), + label='M2015 (' + str('%.4f' %rho15) + ')') + add_curve(ax, wl, Rrs99.transpose().mean(axis=1), Rrs99.transpose().std(axis=1), c='orange', + label='M1999(' + str('%.4f' %rho99) + ')') + add_curve(ax, wl, Rrs_h.transpose().mean(axis=1), Rrs_h.transpose().std(axis=1), c='grey', + label='h(' + str('%.4f' %rho_h.mean()) + ')') + info = str(header.Meteo_obs)+' / '+str(header.TRIOS_obs) + info = info.replace('nan','') + ax.set_title(info+'\n azi=' + str(azi) + ', vza=' + str(vza) + ', sza=' + str('%.2f' %sza)) + + ax.legend(loc='best', frameon=False) + ax.set_ylabel(r'$R_{rs}\ (sr^{-1})$') + ax.set_xlabel(r'$Wavelength (nm)$') + fig.savefig(os.path.join(dirfig, 'trios_awr_'+date.values[0]+'_'+ name + '_idpr' + idpr + '.png')) + plt.close() + diff --git a/trios/run_swr.py b/trios/run_swr.py index 9c1b462..d59dd0b 100644 --- a/trios/run_swr.py +++ b/trios/run_swr.py @@ -12,9 +12,9 @@ import utils.utils as u import utils.auxdata as ua from trios.process import * -plot=False +plot=True #False odir = os.path.abspath('/DATA/OBS2CO/data/trios/surface_water') -dirfig = os.path.abspath('/DATA/OBS2CO/data/trios/fig') +dirfig = os.path.join(odir,'fig') swrfiles = glob.glob("/DATA/OBS2CO/data/trios/raw/Lu0*idpr*.csv") @@ -76,9 +76,14 @@ for idpr in idprs: Rrs_stat.to_csv(ofile,mode='a') if plot: import matplotlib.pyplot as plt - + plt.rcParams.update({'font.size': 18}) fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 8)) - fig.subplots_adjust(left=0.1, right=0.9, hspace=.5, wspace=0.65) + fig.subplots_adjust(left=0.16, right=0.9, hspace=.5, wspace=0.65) add_curve(ax, wl_swr, Rrs_swr.transpose().mean(axis=1), Rrs_swr.transpose().std(axis=1), label='swr', c='black') Rrs_swr = swr.call_process(shade_corr=True) add_curve(ax, wl_swr, Rrs_swr.transpose().mean(axis=1), Rrs_swr.transpose().std(axis=1), label='swr', c='red') + ax.legend(loc='best', frameon=False) + ax.set_ylabel(r'$R_{rs}\ (sr^{-1})$') + ax.set_xlabel(r'$Wavelength (nm)$') + fig.savefig(os.path.join(dirfig, 'trios_swr_'+date.values[0]+'_'+ name + '_idpr' + idpr + '.png')) + plt.close() \ No newline at end of file -- GitLab