diff --git a/src/pypromice/process/L1toL2.py b/src/pypromice/process/L1toL2.py index ba8693c1..1510a757 100644 --- a/src/pypromice/process/L1toL2.py +++ b/src/pypromice/process/L1toL2.py @@ -9,7 +9,10 @@ import os import xarray as xr -def toL2(L1, T_0=273.15, ews=1013.246, ei0=6.1071, eps_overcast=1., +from pypromice.process.value_clipping import clip_values + + +def toL2(L1, vars_df: pd.DataFrame, T_0=273.15, ews=1013.246, ei0=6.1071, eps_overcast=1., eps_clear=9.36508e-6, emissivity=0.97): '''Process one Level 1 (L1) product to Level 2 @@ -17,6 +20,8 @@ def toL2(L1, T_0=273.15, ews=1013.246, ei0=6.1071, eps_overcast=1., ---------- L1 : xarray.Dataset Level 1 dataset + vars_df : pd.DataFrame + Metadata dataframe T_0 : float, optional Ice point temperature in K. The default is 273.15. ews : float, optional @@ -144,7 +149,9 @@ def toL2(L1, T_0=273.15, ews=1013.246, ei0=6.1071, eps_overcast=1., if hasattr(ds,'t_i'): if ~ds['t_i'].isnull().all(): # Instantaneous msg processing ds['rh_i_cor'] = correctHumidity(ds['rh_i'], ds['t_i'], # Correct relative humidity - T_0, T_100, ews, ei0) + T_0, T_100, ews, ei0) + + ds = clip_values(ds, vars_df) return ds def flagNAN(ds_in, @@ -205,7 +212,8 @@ def flagNAN(ds_in, print('---> flagging',t0, t1, v) ds[v] = ds[v].where((ds['time'] < t0) | (ds['time'] > t1)) else: - print('---> could not flag', v,', not in dataset') + print('---> could not flag', v,', not in dataset') + return ds diff --git a/src/pypromice/process/aws.py b/src/pypromice/process/aws.py index d201d1a0..66cdfde0 100644 --- a/src/pypromice/process/aws.py +++ b/src/pypromice/process/aws.py @@ -11,8 +11,6 @@ import numpy as np import warnings -from pypromice.process.value_clipping import clip_values - warnings.simplefilter(action='ignore', category=FutureWarning) import pandas as pd import xarray as xr @@ -98,8 +96,7 @@ def getL1(self): def getL2(self): '''Perform L1 to L2 data processing''' logger.info('Level 2 processing...') - self.L2 = toL2(self.L1A) - self.L2 = clip_values(self.L2, self.vars) + self.L2 = toL2(self.L1A, vars_df=self.vars) def getL3(self): '''Perform L2 to L3 data processing, including resampling and metadata