En raison du déménagement des baies serveurs, les services gitlab.irstea.fr et mattermost.irstea.fr seront interrompus le samedi 2 octobre 2021 au matin. Ils devraient revenir à la normale dans la journée.

Commit 5910f101 authored by Harmel Tristan's avatar Harmel Tristan
Browse files

package construction, executable 'trios_processing'

parent e37126f9
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# Water color TriOS package
Package to help process TriOS radiometer data for various above-water or in-water setups.
Package to process TriOS-like radiometer data for various acquisition protocols:
- above-water radiometry
![figure](images/above_water_system.png)
- in-water radiometry
- surface-water radiometry
![figure](images/surface_water_system.png)
This package also contains tools for interactive visualization of the radiometric data:
![animated1](images/visu_trios_data.gif)
......@@ -27,7 +34,7 @@ python setup.py install
## Running the tests
...
## Authors
......
import glob
import re
from trios.utils import utils as u
from trios.process import *
# import aeronet
# from config import *
# ------------------------------------------------
# above-water data files
dirfig = os.path.abspath('/DATA/OBS2CO/data/trios/fig')
dirout = os.path.abspath('/DATA/OBS2CO/data/trios/above_water')
awrfiles = glob.glob("/DATA/OBS2CO/data/trios/raw/aw*idpr*.csv")
iwrfiles = glob.glob("/DATA/OBS2CO/data/trios/raw/uw*idpr*.csv")
swrfiles = glob.glob("/DATA/OBS2CO/data/trios/raw/Lu0*idpr*.csv")
coordf = glob.glob("/DATA/OBS2CO/data/info/mesures_in_situ.csv")[0]
coords = pd.read_csv(coordf, sep=';')
coords
# get idpr numbers
idprs = np.unique([re.findall(r'idpr(\d+)', x)[0] for x in swrfiles])
# loop over idpr
for idpr in idprs:
# idpr=idprs[2]
print(idpr)
try:
c = coords[coords.ID_prel == int(idpr)] # .values[0]
lat = c['Lat'].values[0]
lon = c['Lon'].values[0]
alt = 0 #c['Altitude']
name = c['ID_lac'].values[0]
except:
continue
dff = pd.DataFrame()
# -----------------------------------------------
# AWR processing
# -----------------------------------------------
awr = u.awr_data(idpr, awrfiles)
if awr.file:
try:
df, wl = awr.reader(lat, lon, alt, name)
Rrs, rho = awr_process(df, wl).call_process(aot=0.05)
print(rho.mean)
# outputs saving
dff = pd.concat([df, Rrs], axis=1)
except:
pass
# -----------------------------------------------
# SWR processing
# -----------------------------------------------
swr = u.swr_data(idpr, swrfiles)
if swr.file:
df, wl = swr.reader(lat, lon, alt)
Rrs = swr_process(df, wl).call_process()
#Rrs.to_csv(os.path.join(dirout, 'trios_swr_' + name + '_idpr' + idpr + '.csv'))
dff = pd.concat([dff, Rrs], axis=1)
# -----------------------------------------------
# IWR processing
# -----------------------------------------------
# iwr = u.iwr_data(idpr, iwrfiles)
# if iwr.file:
# df, wl = iwr.reader(c[1], c[2], c[3])
# Rrs = iwr_process(df, wl).trios()
# dff = pd.concat([dff, Rrs], axis=1)
# writing output file
dff.to_csv(os.path.join(dirout, 'trios_awr_' + name + '_idpr' + idpr + '.csv'))
from setuptools import setup, find_packages
from grs import __version__
from trios import __version__
setup(
name='trios',
......@@ -13,7 +13,7 @@ setup(
},
include_package_data=True,
url='https://gitlab.irstea.fr/ETL-TELQUEL/etl/tree/dev/preprocessing/trios',
url='https://gitlab.irstea.fr/telquel-obs2co/insitu/trios',
license='MIT',
author='T. Harmel',
author_email='tristan.harmel@gmail.com',
......@@ -24,7 +24,7 @@ setup(
entry_points={
'console_scripts': [
'trios = main:main',
'trios_processing = trios.main:main',
'visu_trios = visu.data_visu:main'
]}
)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
DateTime;309.49853121559;312.81600290688;316.13426959625;319.45331989672;322.77314242131;326.09372578304;329.41505859493;332.73712947;336.05992702127;339.38343986176;342.70765660449;346.03256586248;349.35815624875;352.68441637632;356.01133485821;359.33890030744;362.66710133703;365.99592656;369.32536458937;372.65540403816;375.98603351939;379.31724164608;382.64901703125;385.98134828792;389.31422402911;392.64763286784;395.98156341713;399.31600429;402.65094409947;405.98637145856;409.32227498029;412.65864327768;415.99546496375;419.33272865152;422.67042295401;426.00853648424;429.34705785523;432.68597568;436.02527857157;439.36495514296;442.70499400719;446.04538377728;449.38611306625;452.72717048712;456.06854465291;459.41022417664;462.75219767133;466.09445375;469.43698102567;472.77976811136;476.12280362009;479.46607616488;482.80957435875;486.15328681472;489.49720214581;492.84130896504;496.18559588543;499.53005152;502.87466448177;506.21942338376;509.56431683899;512.90933346048;516.25446186125;519.59969065432;522.94500845271;526.29040386944;529.63586551753;532.98138201;536.32694195987;539.67253398016;543.01814668389;546.36376868408;549.70938859375;553.05499502592;556.40057659361;559.74612190984;563.09161958763;566.43705824;569.78242647997;573.12771292056;576.47290617479;579.81799485568;583.16296757625;586.50781294952;589.85251958851;593.19707610624;596.54147111573;599.88569323;603.22973106207;606.57357322496;609.91720833169;613.26062499528;616.60381182875;619.94675744512;623.28945045741;626.63187947864;629.97403312183;633.3159;636.65746872617;639.99872791336;643.33966617459;646.68027212288;650.02053437125;653.36044153272;656.69998222031;660.03914504704;663.37791862593;666.71629157;670.05425249227;673.39179000576;676.72889272349;680.06554925848;683.40174822375;686.73747823232;690.07272789721;693.40748583144;696.74174064803;700.07548096;703.40869538037;706.74137252216;710.07350099839;713.40506942208;716.73606640625;720.06648056392;723.39630050811;726.72551485184;730.05411220813;733.38208119;736.70941041047;740.03608848256;743.36210401929;746.68744563368;750.01210193875;753.33606154752;756.65931307301;759.98184512824;763.30364632623;766.62470528;769.94501060257;773.26455090696;776.58331480619;779.90129091328;783.21846784125;786.53483420312;789.85037861191;793.16508968064;796.47895602233;799.79196625;803.10410897667;806.41537281536;809.72574637909;813.03521828088;816.34377713375;819.65141155072;822.95811014481;826.26386152904;829.56865431643;832.87247712;836.17531855277;839.47716722776;842.77801175799;846.07784075648;849.37664283625;852.67440661032;855.97112069171;859.26677369344;862.56135422853;865.85485091;869.14725235087;872.43854716416;875.72872396289;879.01777136008;882.30567796875;885.59243240192;888.87802327261;892.16243919384;895.44566877863;898.72770064;902.00852339097;905.28812564456;908.56649601379;911.84362311168;915.11949555125;918.39410194552;921.66743090751;924.93947105024;928.21021098673;931.47963933;934.74774469307;938.01451568896;941.27994093069;944.54400903128;947.80670860375;951.06802826112;954.32795661641;957.58648228264;960.84359387283;964.09928;967.35352927717;970.60633031736;973.85767173359;977.10754213888;980.35593014625;983.60282436872;986.84821341931;990.09208591104;993.33443045693;996.57523567;999.81449016327;1003.05218254976;1006.28830144249;1009.52283545448;1012.75577319875;1015.98710328832;1019.21681433621;1022.44489495544;1025.67133375903;1028.89611936;1032.11924037137;1035.34068540616;1038.56044307739;1041.77850199808;1044.99485078125;1048.20947803992;1051.42237238711;1054.63352243584;1057.84291679913;1061.05054409;1064.25639292147;1067.46045190656;1070.66270965829;1073.86315478968;1077.06177591375;1080.25856164352;1083.45350059201;1086.64658137224;1089.83779259723;1093.02712288;1096.21456083357;1099.40009507096;1102.58371420519;1105.76540684928;1108.94516161625;1112.12296711912;1115.29881197091;1118.47268478464;1121.64457417333;1124.81446875;1127.98235712767;1131.14822791936;1134.31206973809;1137.47387119688;1140.63362090875
2018-05-30 11:48:49;-NAN;-NAN;-NAN;-NAN;-NAN;-0.00399356882946705;-0.00391080888439925;-0.00379062126773989;-0.00368924040505404;-0.00357262529952962;-0.00350269808818495;-0.00344436529156562;-0.00335911686966419;-0.003280354736853;-0.00320101508761066;-0.00311440995112076;-0.00305475405193983;-0.00299403508794584;-0.00291233985032574;-0.00283430680386181;-0.00276925717601596;-0.00269673682527112;-0.00261664851360065;-0.00255498223371566;-0.00250077882920908;-0.00243333091035786;-0.00237192865540858;-0.00232802645728589;-0.00228671254909772;-0.00223538883218095;-0.00218105888676575;-0.00213372394112035;-0.00208803105152627;-0.00204211870837034;-0.00199756563013454;-0.00195443596561639;-0.00191240329985367;-0.00187386669934835;-0.00183856665574868;-0.00180261901710601;-0.00176539900442966;-0.00173099977375344;-0.00169764620669591;-0.00166475793735151;-0.00163484258179581;-0.00160585383041225;-0.00157566679112439;-0.00154652585021477;-0.00151981744129021;-0.00149240922208943;-0.00146657856812793;-0.00144157495837674;-0.0014146277729321;-0.00139041529793272;-0.00136987924614559;-0.00135299162229012;-0.00133362661075742;-0.00131198177753614;-0.00129062916616708;-0.00127372353612408;-0.00125617808710479;-0.00123541240281865;-0.0012145820900502;-0.00119817595281374;-0.00118453046098815;-0.00116734340601396;-0.00115132872424927;-0.00113625526391856;-0.00111985161637434;-0.00110374427560438;-0.00108965630473532;-0.00107772910281634;-0.00106608821128324;-0.00105396641464818;-0.00104070067248267;-0.00102788392611351;-0.00101549056275259;-0.00100327908623087;-0.00099194973606422;-0.000983121359006884;-0.000976379980578816;-0.000972169325525645;-0.000967834621833294;-0.000959567245747377;-0.000951661749573108;-0.000949631820193886;-0.000951277356678732;-0.000952648909762847;-0.000951022198165076;-0.000946051830175248;-0.000939545380571315;-0.000933168386959902;-0.000927941792486691;-0.000922866508522995;-0.000916591909471702;-0.000908978433559237;-0.000901834819045833;-0.000896173258205268;-0.000891460046237845;-0.00088615678606298;-0.000879358401273406;-0.000871984766015982;-0.000864452775923181;-0.000857621430916988;-0.000850662563393008;-0.000845640781382901;-0.000842350330048002;-0.000837178334938711;-0.000831156423565209;-0.00082488368767861;-0.000819311712118154;-0.00081334948734239;-0.000805026439868189;-0.000796290231828417;-0.000789984321123641;-0.000786917037857703;-0.000784845003479883;-0.000783415887086804;-0.000782777965089158;-0.000782841748768715;-0.0007797098598541;-0.000769661075199039;-0.000757088546791509;-0.000748423689482475;-0.000745479780007816;-0.000743506324133517;-0.000746422981129642;-0.000752748075903713;-0.000755613275798385;-0.000755922153234437;-0.000755968131714029;-0.000754736585259919;-0.000755617147972719;-0.000752754366285122;-0.000733275767514058;-0.00070258840793056;-0.000696784826254272;-0.000716613529905071;-0.000727409285700738;-0.000724924442161169;-0.000719200819204045;-0.000712517203395008;-0.000705875006539622;-0.000699686887894837;-0.000694812637000559;-0.000692494154481246;-0.000688050819808846;-0.000684614412013163;-0.000681370942421143;-0.000678603038755734;-0.000670413314205263;-0.000657335120368158;-0.000647900525460835;-0.000643348685853783;-0.000643182271764726;-0.000643865339947311;-0.000641864465171878;-0.000640226167532754;-0.000640848390124417;-0.000642742082574235;-0.000642598811518669;-0.000640462837577579;-0.000639010231747386;-0.00063649953717023;-0.000634051586979176;-0.000631324772890396;-0.000629510880275707;-0.00062875619288004;-0.000625374951531878;-0.000623397798670744;-0.000620189639785713;-0.000617135444249118;-0.000613896630349573;-0.000612217371644496;-0.000609988129480608;-0.000600422163686439;-0.000587367524371659;-0.00057470461977974;-0.000571786670367136;-0.000571800804370094;-0.000559627176576909;-0.00055821148609134;-0.000551024184631335;-0.000553074905387588;-0.000557485713258386;-0.00055720852483278;-0.00054477074566011;-0.000515628013819566;-0.000507255394928924;-0.000504164542263857;-0.000524923778923856;-0.000495396872759203;-0.00051708164313987;-0.000544362124488387;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN;-NAN
OBJECTID,ID_lac,ID_station,ID_camp,Date_camp,IDGPS,ID_prel,Date_prel,h_debut,h_fin,Meteo_obs,Meteo_supp,Etat_surf,Carac_sta,Press_atmo,T_air,T_eau_surf,T_eau_fond,Profondeur,Secchi,Secchi_dis,Secchi_app,Filtr,Filtr_VolA,Filtr_VolB,Filtr_VolC,Filtr_obs,HPLC,HPLC_VolA,HPLC_VolB,HPLC_VolC,HPLC_obs,Cdom,Cdom_Vol,Cdom_run,Cdom_obs,Mes,Mes_obs,Cops,Cops_h_deb,Cops_h_fin,Cops_run_o,Cops_run_e,Cops_obs,Cage,Cage_run,Cage_h_deb,Cage_h_fin,Cage_obs,Comment,POINT_X,POINT_Y,Lat,Lon,TRIOS,TRIOS_type,TRIOS_obs,,
153,ALE2B,1,16,mai_2018,,150,30/05/2018,11:07,11:50,nuageux avec éclaircies,vent NE,vaguelettes 5 cm,tributaire,,31,22,19,7,oui,6.25,5.75,oui,400,400,400,,non,,,,,oui,,,,oui,,non,,,,,,oui,261,,,,,1233206.526,6155548.538,42.30351823,9.462897398,oui,Lu0+, above water, underwater,nombreuses feuilles en surface
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
__package__ = 'trios'
__version__ = '1.0.0'
\ No newline at end of file
''' Executable to process L1C images from Sentinel-2 and Landsat mission series
Usage:
trios_processing <input_dir> <IDpr> <measurement_type> --lat <lat> --lon <lon> \
[--altitude=alt] [--ofile <ofile>] [--odir <odir>] [--plot] [--figdir <figdir>]
trios_processing -h | --help
trios_processing -v | --version
Options:
-h --help Show this screen.
-v --version Show version.
<input_dir> Input directory where the trios.csv files are located
<IDpr> IDpr label of the measurement sequence to process
<measurement_type> awr, swr, iwr
--lat <lat> Latitude in decimal degrees
--lon <lon> Longitude in decimal degrees
--altitude=alt altitude of the scene to be processed in meters
[default: 0]
--odir odir Path to the output directory [default: ./]
--ofile ofile basename of the output file.
--plot Plot output data and save figure in <figdir>
--figdir figdir Directory where figures are saved [default: ./]
--no_clobber Do not process <input_dir> <IDpr> files if <output_file> already exists.
'''
from docopt import docopt
import glob
import re
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
from trios.utils.utils import plot as up
from trios.utils import utils as u
from trios.process import *
from trios import __package__, __version__
type_list = {'awr': 'aw', 'iwr': 'uw', 'swr': 'Lu0+'}
type_description = {'awr': 'Above-Water Radiometry', 'iwr': 'In-Water Radiometry',
'swr': 'Surface-Water Radiometry'}
def main():
args = docopt(__doc__, version=__package__ + ' ' + __version__)
print(args)
idir = os.path.abspath(args['<input_dir>'])
idpr = args['<IDpr>']
meas_type = args['<measurement_type>']
lat = float(args['--lat'])
lon = float(args['--lon'])
alt = float(args['--altitude'])
odir = os.path.abspath(args['--odir'])
ofile = args['--ofile']
name = ""
plot = args['--plot']
figdir = os.path.abspath(args['--figdir'])
try:
type_ = type_list[meas_type]
except:
raise SyntaxError('ERROR: bad request for <measurement_type>, should be either awr, iwr or swr')
files = glob.glob(os.path.join(idir, type_ + '*' + idpr + '*.csv'))
if not files:
raise IOError('No file available for IDpr ' + idpr + ' in ' + idir + ' for ' + type_description[meas_type])
if meas_type == 'swr':
# -----------------------------------------------
# SWR processing
# -----------------------------------------------
uswr = u.swr_data(idpr, files)
if uswr.file:
df, wl = uswr.reader(lat, lon, alt)
date = df.index[0].date().__str__()
if ofile:
ofile = os.path.join(odir, ofile)
else:
ofile = os.path.join(odir, 'Rrs_swr_' + date + '_idpr' + idpr + name + '.csv')
swr = swr_process(df, wl)
Rrs = swr.call_process(ofile)
if plot:
mpl.rcParams.update({'font.size': 18})
fig, ax = plt.subplots(figsize=(7, 6))
up.add_curve(ax, wl, Rrs.transpose().mean(axis=1), Rrs.transpose().std(axis=1), label='swr',
c='black')
ax.set_ylabel(r'$R_{rs}\ (sr^{-1})$')
ax.set_xlabel(r'Wavelength (nm)')
ax.set_title('ID: ' + idpr + ', ' + date + ', sza=' + str(round(df.sza.mean(), 2)))
fig.savefig(os.path.join(figdir, 'trios_swr_' + date + '_idpr' + idpr + '.png'), bbox_inches='tight')
plt.close()
elif meas_type == 'awr':
# -----------------------------------------------
# AWR processing
# -----------------------------------------------
azi = 135
vza = 40
ws = 2
method = 'M99'
uawr = u.awr_data(idpr, files)
if uawr.Edf:
df, wl = uawr.reader(lat, lon, alt)
date = df.index[0].date().__str__()
if ofile:
ofile = os.path.join(odir, ofile)
else:
ofile = os.path.join(odir, 'Rrs_awr_' + date + '_idpr' + idpr + name + '.csv')
awr = awr_process(df, wl, name, idpr)
if plot:
figfile = os.path.join(figdir, 'trios_awr_' + date + '_idpr' + idpr + '.png')
else:
figfile=""
Rrs = awr.call_process(method, ofile, vza=vza, azi=azi,plot_file=figfile)
elif meas_type == 'iwr':
pass
if __name__ == "__main__":
main()
......@@ -4,6 +4,12 @@ import scipy.optimize as so
import plotly.graph_objs as go
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
from trios.utils.utils import plot as up
import trios.utils.utils as uu
from trios.utils.utils import reshape as r
import trios.utils.auxdata as ua
......@@ -11,11 +17,12 @@ from trios.config import *
class awr_process:
def __init__(self, df=None, wl=None):
def __init__(self, df=None, wl=None, name="", idpr=""):
self.df = df
self.aot = 0.1
self.ws = 2
self.wl = wl
self.name = name
self.idpr = idpr
self.rhosoaa_fine_file = rhosoaa_fine_file
self.rhosoaa_coarse_file = rhosoaa_coarse_file
self.M1999_file = M1999_file
......@@ -82,63 +89,119 @@ class awr_process:
rho_mobley = calc().spline_4d(grid, rho_, (ws, sza, vza, azi))
return rho_mobley
# def call_process(self, vza=[40], azi=[135], ws=2, aot=0.1):
# wl = self.wl
# Lt = self.df.loc[:, ("Lt")]
# Lsky = self.df.loc[:, ("Lsky")]
# Ed = self.df.loc[:, ("Ed")]
# sza = self.df.loc[:, ("sza")].values.mean()
# Rrs = self.process(wl, Lt, Lsky, Ed, sza, vza, azi, ws, aot)
# Rrs.columns = pd.MultiIndex.from_product([['Rrs(awr)'], self.Rrs.columns], names=['param', 'wl'])
# self.Rrs = Rrs
# return self.Rrs
#
# def process(self, wl, Lt, Lsky, Ed, sza, vza=[40], azi=[135], ws=[2], aot=[0.1]):
# '''
#
# :param wl:
# :param Lt:
# :param Lsky:
# :param Ed:
# :param sza:
# :param vza:
# :param azi:
# :param ws:
# :param aot:
# :return:
# '''
#
# # ------------------
# # filtering
# # ------------------
# ind_Ed, notused = calc.spectra_median_filter(Ed)
# ind_sky, notused = calc.spectra_median_filter(Lsky)
# ind = ind_Ed & ind_sky
# Lt, Lsky, Ed, sza = Lt[ind], Lsky[ind], Ed[ind], sza[ind]
#
# rho = self.get_rho_values(np.median(sza), vza, azi, wl=wl, ws=ws, aot=aot)
# self.Rrs = (Lt - rho * Lsky.values) / Ed.values
# self.Rrs.columns = pd.MultiIndex.from_product([['Rrs(awr)'], wl], names=['param', 'wl'])
# return self.Rrs, rho
def call_process(self, method='M99', ofile="", vza=40, azi=135, ws=2, aot=0.1, plot_file=""):
@staticmethod
def filtering(Lt, Lsky, Ed, **kargs):
'''
wl = self.wl
vza, azi, ws = [vza], [azi], [ws] # formatting for interpolation functions
:param Lt:
:param Lsky:
:param Ed:
:param kargs:
:return:
'''
# ------------------
# filtering
# ------------------
ind = self.filtering(self.df.Lt, self.df.Lsky, self.df.Ed)
clean = self.df[ind]
Lt, Lsky, Ed, sza = clean.Lt.values, clean.Lsky.values, clean.Ed.values, clean.sza.values
ind_Ed, notused = calc.spectra_median_filter(Ed, kargs)
ind_sky, notused = calc.spectra_median_filter(Lsky, kargs)
ind = ind_Ed & ind_sky
return ind
# -----------------------------
# data processing
# -----------------------------
if method == 'M99':
Rrs, rho = self.process_wrapper(wl, clean, clean.sza, vza=vza, azi=azi, ws=ws, aot=aot, method=method)
elif method == 'M15':
Rrs, rho = self.process_wrapper(wl, clean, clean.sza, vza=vza, azi=azi, ws=ws, aot=aot, method=method)
elif method == 'osoaa':
Rrs, rho = self.process_wrapper(wl, clean, clean.sza, vza=vza, azi=azi, ws=ws, aot=aot, method=method)
elif method == 'temp_opt':
Rrs, Rrs_opt_std = self.process_optimization(wl, Lt, Lsky, Ed, sza, vza=vza, azi=azi)
def process_wrapper(self, wl, df, sza, vza=[40], azi=[135], ws=[2], aot=[0.1], method='M99'):
self.Rrs = Rrs
if ofile:
Rrs_stat = Rrs.describe()
Rrs_stat.columns = Rrs_stat.columns.droplevel()
Rrs_stat = Rrs_stat.T
Rrs_stat.to_csv(ofile)
if plot_file:
# ------------------
# plotting
# ------------------
Ltm = Lt.mean(axis=0)
Edm = Ed.mean(axis=0)
mpl.rcParams.update({'font.size': 18})
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(20, 12))
fig.subplots_adjust(left=0.1, right=0.9, hspace=.5, wspace=0.45)
# ---- Ed
ax = axs[0, 0]
up.add_curve(ax, wl, Ed.mean(axis=0),
label=r'$L_{sky}$', c='red') # just to put the two labels
up.add_curve(ax, wl, Ed.mean(axis=0), Ed.std(axis=0),
label=r'$E_s$', c='black')
ax.set_ylabel(r'$E_{d}(0^{+})$')
# ---- Lsky
ax2 = ax.twinx()
up.add_curve(ax2, wl, Lsky.mean(axis=0), Lsky.std(axis=0),
label=r'$L_{sky}$', c='red')
ax2.set_ylabel(r'$L_{sky}$', color='r')
ax2.tick_params('y', colors='r')
ax.set_xlabel(r'Wavelength (nm)')
ax.legend(loc='best', frameon=False)
# ---- Lt vs Lsurf
ax = axs[0, 1]
up.add_curve(ax, wl, Lt.mean(axis=0), Lt.std(axis=0),
label=r'$L_t$', c='black')
up.add_curve(ax, wl, Lsky.mean(axis=0) * rho, Lsky.std(axis=0) * rho,
label=method+' (' + str(round(rho, 4)) + ')', c='violet')
ax.set_ylabel(r'$L_t\ or L_{surf}$')
ax.set_xlabel(r'Wavelength (nm)')
# ---- Proportion o(Lt - Lsurf ) /Lt
ax = axs[0, 2]
up.add_curve(ax, wl, Lsky.mean(axis=0) * rho / Ltm, Lsky.std(axis=0) * rho,
label=method+' (' + str(round(rho, 4)) + ')', c='violet')
ax.set_ylabel(r'$L_{surf}/L_t$')
ax.set_xlabel(r'Wavelength (nm)')
# ---- Lw
ax = axs[1, 0]
up.add_curve(ax, wl, Rrs.mean(axis=0) * Edm, Rrs.std(axis=0) * Edm,
label=method+' (' + str(round(rho, 4)) + ')', c='violet')
ax.set_ylabel(r'$L_{w}\ (sr^{-1})$')
ax.set_xlabel(r'Wavelength (nm)')
# ---- Rrs
ax = axs[1, 1]
up.add_curve(ax, wl, Rrs.transpose().mean(axis=1), Rrs.transpose().std(axis=1),
label=method+' (' + str(round(rho, 4)) + ')', c='violet')
ax.set_ylabel(r'$R_{rs}\ (sr^{-1})$')
ax.set_xlabel(r'Wavelength (nm)')
ax.set_title('azi=' + str(azi) + ', vza=' + str(vza) + ', sza=' + str(round(sza.mean(), 2)))
fig.suptitle('trios_awr ' + self.name + ' idpr' + self.idpr, fontsize=16)
fig.savefig(plot_file)
plt.close()
return self.Rrs
def process_wrapper(self, wl, df, sza, vza=[40], azi=[135], ws=[2], aot=[0.1], method='M99'):
'''
Wrapper to call standard processing upon pandas multiindex dataframe format
:param wl: