Skip to content

Commit

Permalink
Moved clip_vars from AWS.getL2 to L1toL2.toL2
Browse files Browse the repository at this point in the history
  • Loading branch information
ladsmund committed Sep 25, 2023
1 parent 9eae0eb commit 4c68745
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/pypromice/process/L1toL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
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
Parameters
----------
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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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


Expand Down
5 changes: 1 addition & 4 deletions src/pypromice/process/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4c68745

Please sign in to comment.