mirror of
https://gitea.psi.ch/APOG/acsm-fairifier.git
synced 2025-07-14 11:11:48 +02:00
Extend pipelines/steps/adjust_uncertainty_column_in_nas_file.py to handle list of variables.
This commit is contained in:
@ -93,8 +93,28 @@ def generate_missing_value_code(max_val, num_decimals):
|
||||
|
||||
return missing_code
|
||||
|
||||
def compute_uncertainty_estimate(x,x_err):
|
||||
return ((0.5*x_err)**2+(0.5*x)**2)**0.5
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
def compute_uncertainty_estimate(x, x_err):
|
||||
"""
|
||||
Computes uncertainty estimate: sqrt((0.5 * x_err)^2 + (0.5 * x)^2)
|
||||
for scalar inputs. Prints errors if inputs are invalid.
|
||||
"""
|
||||
try:
|
||||
x = float(x)
|
||||
x_err = float(x_err)
|
||||
|
||||
if math.isnan(x) or math.isnan(x_err):
|
||||
print(f"Warning: One or both inputs are NaN -> x: {x}, x_err: {x_err}")
|
||||
return np.nan
|
||||
|
||||
return math.sqrt((0.5 * x_err)**2 + (0.5 * x)**2)
|
||||
|
||||
except (ValueError, TypeError) as e:
|
||||
print(f"Error computing uncertainty for x: {x}, x_err: {x_err} -> {e}")
|
||||
return np.nan
|
||||
|
||||
|
||||
|
||||
def generate_error_dataframe(df: pd.DataFrame, datetime_var):
|
||||
|
Reference in New Issue
Block a user