Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/various cleanup #186

Merged
merged 12 commits into from
Sep 29, 2023
Merged
2 changes: 1 addition & 1 deletion bin/getL0tx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if __name__ == '__main__':
typ, accountDetails = mail_server.login(account, password)
if typ != 'OK':
print('Not able to sign in!')
raise
raise Exception('Not able to sign in!')
ladsmund marked this conversation as resolved.
Show resolved Hide resolved

# Grab new emails
result, data = mail_server.select(mailbox='"[Gmail]/All Mail"', readonly=True)
Expand Down
16 changes: 12 additions & 4 deletions bin/getL3
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
import logging
import os
import sys
from argparse import ArgumentParser
from pypromice.process import AWS

Expand All @@ -24,16 +26,22 @@ if __name__ == '__main__':
"""Executed from the command line"""
args = parse_arguments()

logging.basicConfig(
format="%(asctime)s; %(levelname)s; %(name)s; %(message)s",
level=logging.INFO,
stream=sys.stdout,
)

station_name = args.config_file.split('/')[-1].split('.')[0]
station_path = os.path.join(args.inpath, station_name)

if os.path.exists(station_path):
pAWS = AWS(args.config_file, station_path, args.variables, args.metadata)
aws = AWS(args.config_file, station_path, args.variables, args.metadata)
else:
pAWS = AWS(args.config_file, args.inpath, args.variables, args.metadata)
aws = AWS(args.config_file, args.inpath, args.variables, args.metadata)

pAWS.process()
pAWS.write(args.outpath)
aws.process()
aws.write(args.outpath)

else:
"""Executed on import"""
Expand Down
9 changes: 9 additions & 0 deletions src/pypromice/process/L0toL1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import xarray as xr
import re

from pypromice.process.value_clipping import clip_values
ladsmund marked this conversation as resolved.
Show resolved Hide resolved


def toL1(L0, vars_df, T_0=273.15, tilt_threshold=-100):
'''Process one Level 0 (L0) product to Level 1
Expand Down Expand Up @@ -113,6 +115,13 @@ def toL1(L0, vars_df, T_0=273.15, tilt_threshold=-100):
ds['z_boom_l'] = _reformatArray(ds['z_boom_l']) # Reformat boom height
ds['z_boom_l'] = ds['z_boom_l'] * ((ds['t_l'] + T_0)/T_0)**0.5 # Adjust sonic ranger readings for sensitivity to air temperature

ds = clip_values(ds, vars_df)
for key in ['format', 'hygroclip_t_offset', 'dsr_eng_coef', 'usr_eng_coef',
'dlr_eng_coef', 'ulr_eng_coef', 'pt_z_coef', 'pt_z_p_coef',
'pt_z_factor', 'pt_antifreeze', 'boom_azimuth', 'nodata',
'conf', 'file']:
ds.attrs.pop(key, None)

return ds

def addTimeShift(ds, vars_df):
Expand Down
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
Loading
Loading