Commit f5f00b0d authored by Martin Schrön's avatar Martin Schrön
Browse files

Added correction and conversion scripts (wip)

parent a257b2a2
......@@ -8,15 +8,34 @@ from importlib import reload
from basics import list_to_str, slice_dict, ensure_numeric, check_required_args
#reload(basics)
import corrections
import units as un
from grains.Desilets2010wrr import sm_to_N as sm_to_N_Desilets
from grains.Koehli2021fiw import sm_to_N as sm_to_N_Koehli
# %%
def clay_to_lw(clay, method='Greasen_etal_1985'):
if method == 'Franz_etal_2012':
from grains.Greasen1985x import clay_to_lw
lw = clay_to_lw(clay)
else:
print('! Unknown method to convert Clay to lattice water.')
lw = nan
return(lw)
def corg_to_owe(corg, method='Franz_etal_2012'):
if method == 'Franz_etal_2012':
from grains.Franz2015vzj import corg_to_owe
owe = corg_to_owe(corg)
else:
print('! Unknown method to convert C_org to organic water equivalent.')
owe = nan
return(owe)
# %%
def sm_to_N(sm, method='Desilets_etal_2010', from_vol=False,
err=None, err_low=None, err_upp=None, return_asym_errors=False,
**kwargs):
correct_lw=None, correct_owe=None, **kwargs):
"""
Wrapper for various methods to convert SoilMoisture to Neutrons.
1. Optional: convert volumetric to gravimettric
......@@ -36,6 +55,11 @@ def sm_to_N(sm, method='Desilets_etal_2010', from_vol=False,
else:
return(nan)
if correct_lw:
sm = corrections.correct_lw_r(sm, ensure_numeric(correct_lw))
if correct_owe:
sm = corrections.correct_owe_r(sm, ensure_numeric(correct_owe))
# initialize
N = nan
r = []
......
......@@ -7,3 +7,38 @@ from numpy import nan
def substract_offset(sm, offset):
return(sm - offset)
def correct_lattice_water(sm, lw):
if lw:
return(sm - lw)
else:
print('! No lattice water data to correct for.')
return(sm)
correct_lw = correct_lattice_water
C_lw = correct_lattice_water
def correct_lattice_water_r(sm, lw):
if lw:
return(sm + lw)
else:
print('! No lattice water data to correct for.')
return(sm)
correct_lw_r = correct_lattice_water_r
C_lw_r = correct_lattice_water_r
def correct_organic_water(sm, owe=None, corg=None):
if corg:
from grains.Franz2015vzj import corg_to_owe
owe = corg_to_owe(corg)
if owe:
return(sm - owe)
else:
print('! No organic water data to correct for.')
return(sm)
correct_owe = correct_organic_water
C_owe = correct_organic_water
......@@ -309,6 +309,15 @@ Auxillary_data:
default:
# Default value for biomass (in kg/m²)
0
Other_data:
# Integrate other external data from csv files.
filename:
# filename
use_as:
# Choose which variable this file aims to represent
######
Clean:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment