import os
import json
import traceback
import gspy
import numpy as np

_DIR = os.path.dirname(os.path.abspath(__file__))
DATA_FILE = os.path.join(_DIR, "web_data.json")

_DEFAULTS = {
    "SNF_Total_Mass": 0.0,
    "SNF_Mass_per_WP": 0.0,
    "Releasable_SNF": 0.0,
    "ModDegRate_SNF": 0.0,
    "EnableCombinedSFDegRate": 0.0,
    "sMOX_Total_Mass": 0.0,
    "sMOX_Mass_per_WP": 0.0,
    "Releasable_sMOX": 0.0,
    "ModDegRate_sMOX": 0.0,
    "EnableCombinedSMDegRate": 0.0,
    "HLWg_Total_Mass": 0.0,
    "HLWg_Mass_per_WP": 0.0,
    "Releasable_HLWg": 0.0,
    "ModDegRate_HLWg": 0.0,
    "HLWc_Total_Mass": 0.0,
    "HLWc_Total_Mass_per_WP": 0.0,
    "Releasable_HLWc": 0.0,
    "ModDegRate_HLWc": 0.0,
    "Switch_WP_Material": 0.0,
    "Switch_WP_Thickness": 0.0,
    "UD_WP_Thickness": 0.0,
    "Switch_Enable_GC": 0.0,
    "Switch_Enable_LC": 0.0,
    "WP_InternalWaterVolume": 0.0,
    "GC_FractionAreaBreach_Min": 0.0,
    "GC_FractionAreaBreach_Max": 0.0,
    "Switch_HS_Corrosion": 0.0,
    "HS_Conc_Factor": 0.0,
    "f1_HumidAirCorrosion_Factor": 0.0,
    "f2_HumidAirCorrosion_Factor": 0.0,
    "t1_TransitionTime_AqueousCorr": 0.0,
    "t2_TransitionTime_AqueousCorr": 0.0,
    "BF_Model_Type": 0.0,
    "BF_Length": 0.0,
    "BF_InnerRadius": 0.0,
    "BF_Height": 0.0,
    "BF_FlowFactor": 0.0,
    "f1_BFOpenFractionInitial": 0.0,
    "f2_BFOpenFractionInitial": 0.0,
    "f1_BFOpenFractionResidual": 0.0,
    "f2_BFOpenFractionResidual": 0.0,
    "t1_BF_DegradationTime": 0.0,
    "t2_BF_DegradationTime": 0.0,
    "f1_BFOpenFractionLate": 0.0,
    "f2_BFOpenFractionLate": 0.0,
    "t1_BF_SaturationTime": 0.0,
    "t2_BF_SaturationTime": 0.0,
    "Switch_BFtoFrac_ZeroLength": 0.0,
    "Swtch_FractCell_ZeroConc": 0.0,
    "Switch_SorptionBFtoFract": 0.0,
    "BFtoFrac_CrossSectionFactor": 0.0,
    "BFtoFrac_FlowFactor": 0.0,
    "Switch_EnableAlternativePaths": 0.0,
    "BF_Height_Top": 0.0,
    "AP_Length": 0.0,
    "AP_CrossSection": 0.0,
    "Switch_EnableSorption_AP": 0.0,
    "Switch_Feature_ZeroConc": 0.0,
    "AP_Switch_UD_Flow": 0.0,
    "AP_UD_Flow": 0.0,
    "AP_FlowFactor": 0.0,
    "Capture_Fraction": 0.0,
    "Alternative_Failure_Mode": 0.0,
    "StartTime_WPFailRate": 0.0,
    "EndTime_WPFailRate": 0.0,
    "Min_WPFailRate_Plateau": 0.0,
    "Max_WPFailRate_Plateau": 0.0,
    "Min_WPFailRate_BreachFraction": 0.0,
    "Max_WPFailRate_BreachFraction": 0.0,
    "Single_Event_Frequency": 0.0,
    "Single_Event_WPFailFrac_Min": 0.0,
    "Single_Event_WPFailFrac_Max": 0.0,
    "Single_Event_BreachArea_Min": 0.0,
    "Single_Event_BreachArea_Max": 0.0,
    "Flag_Use_MovingAverage": 0.0,
    "Recurrence_Rate": [0.0, 0.0, 0.0, 0.0, 0.0],
    "DamageProb_WP": [0.0, 0.0, 0.0, 0.0, 0.0],
    "BreachArea_WP": [0.0, 0.0, 0.0, 0.0, 0.0],
    "Switch_FF_Medium": [0.0, 0.0, 0.0],
    "Switch_FF_Redox": [0.0, 0.0, 0.0],
    "FF_Length": [0.0, 0.0, 0.0],
    "FF_Hydraulic_Gradient": [0.0, 0.0, 0.0],
    "FF_FluidSaturation": [0.0, 0.0, 0.0],
    "Feature_Length": 0.0,
    "Feature_DispersivityFraction": 0.0,
    "Feature_Aperture": 0.0,
    "Feature_Width": 0.0,
    "Feature_Flux": 0.0,
    "Switch_FeatureEnableMatrixDif": 0.0,
    "Switch_Feature_EnableSorption": 0.0,
    "Switch_Enable_Dynamic_GC": 0.0,
}

for k, v in {
    "SNF_Total_Mass": 75000.0,
    "SNF_Mass_per_WP": 10.0,
    "Releasable_SNF": 1.0,
    "ModDegRate_SNF": 1.0,
    "sMOX_Total_Mass": 500.0,
    "sMOX_Mass_per_WP": 10.0,
    "Releasable_sMOX": 1.0,
    "ModDegRate_sMOX": 1.0,
    "HLWg_Total_Mass": 4000.0,
    "HLWg_Mass_per_WP": 1.0,
    "Releasable_HLWg": 1.0,
    "ModDegRate_HLWg": 1.0,
    "HLWc_Total_Mass": 100.0,
    "HLWc_Total_Mass_per_WP": 1.0,
    "Releasable_HLWc": 1.0,
    "ModDegRate_HLWc": 1.0,
    "Feature_Aperture": 0.1,
    "Feature_Width": 1.0,
    "Feature_Flux": 1.0,
    "f1_BFOpenFractionInitial": 0.1,
    "f2_BFOpenFractionInitial": 0.1,
    "f1_BFOpenFractionResidual": 1e-20,
    "f2_BFOpenFractionResidual": 1e-20,
    "t1_BF_DegradationTime": 10000.0,
    "t2_BF_DegradationTime": 10000.0,
    "f1_BFOpenFractionLate": 1e-20,
    "f2_BFOpenFractionLate": 1e-20,
    "t1_BF_SaturationTime": 1000.0,
    "t2_BF_SaturationTime": 1000.0,
    "f1_HumidAirCorrosion_Factor": 1.0,
    "f2_HumidAirCorrosion_Factor": 1.0,
    "t1_TransitionTime_AqueousCorr": 10.0,
    "t2_TransitionTime_AqueousCorr": 10.0,
    "BF_Length": 1.0,
    "BF_Height": 1.0,
    "BF_FlowFactor": 1.0,
    "BF_Height_Top": 1e-10,
    "Switch_WP_Material": 2.0,
    "Switch_Enable_GC": 1.0,
    "Switch_Enable_LC": 1.0,
    "WP_InternalWaterVolume": 1.0,
    "GC_FractionAreaBreach_Min": 0.5,
    "GC_FractionAreaBreach_Max": 0.5,
    "Switch_Enable_Dynamic_GC": 0.0,
    "Switch_HS_Corrosion": 0.0,
    "HS_Conc_Factor": 1.0,
    "BF_Model_Type": 1.0,
    "Swtch_FractCell_ZeroConc": 1.0,
    "BFtoFrac_CrossSectionFactor": 1.0,
    "BFtoFrac_FlowFactor": 1.0,
    "AP_Length": 1.0,
    "AP_CrossSection": 1.0,
    "AP_UD_Flow": 1.0,
    "AP_FlowFactor": 1.0,
    "Capture_Fraction": 1.0,
    "StartTime_WPFailRate": 1.0,
    "EndTime_WPFailRate": 1000000.0,
    "Min_WPFailRate_Plateau": 0.9999,
    "Max_WPFailRate_Plateau": 1.0,
    "Min_WPFailRate_BreachFraction": 0.01,
    "Max_WPFailRate_BreachFraction": 1.0,
    "Single_Event_Frequency": 1e-08,
    "Single_Event_WPFailFrac_Min": 0.9999,
    "Single_Event_WPFailFrac_Max": 1.0,
    "Single_Event_BreachArea_Min": 0.9999,
    "Single_Event_BreachArea_Max": 1.0,
    "Recurrence_Rate": [0.0001, 1e-05, 1e-06, 1e-07, 1e-08],
    "DamageProb_WP": [0.0001, 0.001, 0.01, 0.1, 1.0],
    "BreachArea_WP": [0.0001, 0.001, 0.01, 0.1, 1.0],
    "Switch_FF_Medium": [2.0, 2.0, 2.0],
    "Switch_FF_Redox": [1.0, 1.0, 1.0],
    "FF_Length": [1.67, 1.67, 1.67],
    "FF_Hydraulic_Gradient": [0.0001, 0.0001, 0.0001],
    "FF_FluidSaturation": [1.0, 1.0, 1.0],
    "Feature_Length": 1.0,
}.items():
    if k in _DEFAULTS:
        _DEFAULTS[k] = v

def _load_data() -> dict:
    if os.path.exists(DATA_FILE):
        try:
            with open(DATA_FILE, "r") as f:
                return json.load(f)
        except Exception:
            pass
    return dict(_DEFAULTS)

def process_data(*args):
    try:
        data = _load_data()

        SNF_Total_Mass = float(data.get("SNF_Total_Mass", _DEFAULTS["SNF_Total_Mass"]))
        SNF_Mass_per_WP = float(data.get("SNF_Mass_per_WP", _DEFAULTS["SNF_Mass_per_WP"]))
        Releasable_SNF = float(data.get("Releasable_SNF", _DEFAULTS["Releasable_SNF"]))
        ModDegRate_SNF = float(data.get("ModDegRate_SNF", _DEFAULTS["ModDegRate_SNF"]))
        EnableCombinedSFDegRate = float(data.get("EnableCombinedSFDegRate", _DEFAULTS["EnableCombinedSFDegRate"]))
        sMOX_Total_Mass = float(data.get("sMOX_Total_Mass", _DEFAULTS["sMOX_Total_Mass"]))
        sMOX_Mass_per_WP = float(data.get("sMOX_Mass_per_WP", _DEFAULTS["sMOX_Mass_per_WP"]))
        Releasable_sMOX = float(data.get("Releasable_sMOX", _DEFAULTS["Releasable_sMOX"]))
        ModDegRate_sMOX = float(data.get("ModDegRate_sMOX", _DEFAULTS["ModDegRate_sMOX"]))
        EnableCombinedSMDegRate = float(data.get("EnableCombinedSMDegRate", _DEFAULTS["EnableCombinedSMDegRate"]))
        HLWg_Total_Mass = float(data.get("HLWg_Total_Mass", _DEFAULTS["HLWg_Total_Mass"]))
        HLWg_Mass_per_WP = float(data.get("HLWg_Mass_per_WP", _DEFAULTS["HLWg_Mass_per_WP"]))
        Releasable_HLWg = float(data.get("Releasable_HLWg", _DEFAULTS["Releasable_HLWg"]))
        ModDegRate_HLWg = float(data.get("ModDegRate_HLWg", _DEFAULTS["ModDegRate_HLWg"]))
        HLWc_Total_Mass = float(data.get("HLWc_Total_Mass", _DEFAULTS["HLWc_Total_Mass"]))
        HLWc_Total_Mass_per_WP = float(data.get("HLWc_Total_Mass_per_WP", _DEFAULTS["HLWc_Total_Mass_per_WP"]))
        Releasable_HLWc = float(data.get("Releasable_HLWc", _DEFAULTS["Releasable_HLWc"]))
        ModDegRate_HLWc = float(data.get("ModDegRate_HLWc", _DEFAULTS["ModDegRate_HLWc"]))
        Switch_WP_Material = float(data.get("Switch_WP_Material", _DEFAULTS["Switch_WP_Material"]))
        Switch_WP_Thickness = float(data.get("Switch_WP_Thickness", _DEFAULTS["Switch_WP_Thickness"]))
        UD_WP_Thickness = float(data.get("UD_WP_Thickness", _DEFAULTS["UD_WP_Thickness"]))
        Switch_Enable_GC = float(data.get("Switch_Enable_GC", _DEFAULTS["Switch_Enable_GC"]))
        Switch_Enable_LC = float(data.get("Switch_Enable_LC", _DEFAULTS["Switch_Enable_LC"]))
        WP_InternalWaterVolume = float(data.get("WP_InternalWaterVolume", _DEFAULTS["WP_InternalWaterVolume"]))
        GC_FractionAreaBreach_Min = float(data.get("GC_FractionAreaBreach_Min", _DEFAULTS["GC_FractionAreaBreach_Min"]))
        GC_FractionAreaBreach_Max = float(data.get("GC_FractionAreaBreach_Max", _DEFAULTS["GC_FractionAreaBreach_Max"]))
        Switch_HS_Corrosion = float(data.get("Switch_HS_Corrosion", _DEFAULTS["Switch_HS_Corrosion"]))
        HS_Conc_Factor = float(data.get("HS_Conc_Factor", _DEFAULTS["HS_Conc_Factor"]))
        f1_HumidAirCorrosion_Factor = float(data.get("f1_HumidAirCorrosion_Factor", _DEFAULTS["f1_HumidAirCorrosion_Factor"]))
        f2_HumidAirCorrosion_Factor = float(data.get("f2_HumidAirCorrosion_Factor", _DEFAULTS["f2_HumidAirCorrosion_Factor"]))
        t1_TransitionTime_AqueousCorr = float(data.get("t1_TransitionTime_AqueousCorr", _DEFAULTS["t1_TransitionTime_AqueousCorr"]))
        t2_TransitionTime_AqueousCorr = float(data.get("t2_TransitionTime_AqueousCorr", _DEFAULTS["t2_TransitionTime_AqueousCorr"]))
        BF_Model_Type = float(data.get("BF_Model_Type", _DEFAULTS["BF_Model_Type"]))
        BF_Length = float(data.get("BF_Length", _DEFAULTS["BF_Length"]))
        BF_InnerRadius = float(data.get("BF_InnerRadius", _DEFAULTS["BF_InnerRadius"]))
        BF_Height = float(data.get("BF_Height", _DEFAULTS["BF_Height"]))
        BF_FlowFactor = float(data.get("BF_FlowFactor", _DEFAULTS["BF_FlowFactor"]))
        f1_BFOpenFractionInitial = float(data.get("f1_BFOpenFractionInitial", _DEFAULTS["f1_BFOpenFractionInitial"]))
        f2_BFOpenFractionInitial = float(data.get("f2_BFOpenFractionInitial", _DEFAULTS["f2_BFOpenFractionInitial"]))
        f1_BFOpenFractionResidual = float(data.get("f1_BFOpenFractionResidual", _DEFAULTS["f1_BFOpenFractionResidual"]))
        f2_BFOpenFractionResidual = float(data.get("f2_BFOpenFractionResidual", _DEFAULTS["f2_BFOpenFractionResidual"]))
        t1_BF_DegradationTime = float(data.get("t1_BF_DegradationTime", _DEFAULTS["t1_BF_DegradationTime"]))
        t2_BF_DegradationTime = float(data.get("t2_BF_DegradationTime", _DEFAULTS["t2_BF_DegradationTime"]))
        f1_BFOpenFractionLate = float(data.get("f1_BFOpenFractionLate", _DEFAULTS["f1_BFOpenFractionLate"]))
        f2_BFOpenFractionLate = float(data.get("f2_BFOpenFractionLate", _DEFAULTS["f2_BFOpenFractionLate"]))
        t1_BF_SaturationTime = float(data.get("t1_BF_SaturationTime", _DEFAULTS["t1_BF_SaturationTime"]))
        t2_BF_SaturationTime = float(data.get("t2_BF_SaturationTime", _DEFAULTS["t2_BF_SaturationTime"]))
        Switch_BFtoFrac_ZeroLength = float(data.get("Switch_BFtoFrac_ZeroLength", _DEFAULTS["Switch_BFtoFrac_ZeroLength"]))
        Swtch_FractCell_ZeroConc = float(data.get("Swtch_FractCell_ZeroConc", _DEFAULTS["Swtch_FractCell_ZeroConc"]))
        Switch_SorptionBFtoFract = float(data.get("Switch_SorptionBFtoFract", _DEFAULTS["Switch_SorptionBFtoFract"]))
        BFtoFrac_CrossSectionFactor = float(data.get("BFtoFrac_CrossSectionFactor", _DEFAULTS["BFtoFrac_CrossSectionFactor"]))
        BFtoFrac_FlowFactor = float(data.get("BFtoFrac_FlowFactor", _DEFAULTS["BFtoFrac_FlowFactor"]))
        Switch_EnableAlternativePaths = float(data.get("Switch_EnableAlternativePaths", _DEFAULTS["Switch_EnableAlternativePaths"]))
        BF_Height_Top = float(data.get("BF_Height_Top", _DEFAULTS["BF_Height_Top"]))
        AP_Length = float(data.get("AP_Length", _DEFAULTS["AP_Length"]))
        AP_CrossSection = float(data.get("AP_CrossSection", _DEFAULTS["AP_CrossSection"]))
        Switch_EnableSorption_AP = float(data.get("Switch_EnableSorption_AP", _DEFAULTS["Switch_EnableSorption_AP"]))
        Switch_Feature_ZeroConc = float(data.get("Switch_Feature_ZeroConc", _DEFAULTS["Switch_Feature_ZeroConc"]))
        AP_Switch_UD_Flow = float(data.get("AP_Switch_UD_Flow", _DEFAULTS["AP_Switch_UD_Flow"]))
        AP_UD_Flow = float(data.get("AP_UD_Flow", _DEFAULTS["AP_UD_Flow"]))
        AP_FlowFactor = float(data.get("AP_FlowFactor", _DEFAULTS["AP_FlowFactor"]))
        Capture_Fraction = float(data.get("Capture_Fraction", _DEFAULTS["Capture_Fraction"]))
        Alternative_Failure_Mode = float(data.get("Alternative_Failure_Mode", _DEFAULTS["Alternative_Failure_Mode"]))
        StartTime_WPFailRate = float(data.get("StartTime_WPFailRate", _DEFAULTS["StartTime_WPFailRate"]))
        EndTime_WPFailRate = float(data.get("EndTime_WPFailRate", _DEFAULTS["EndTime_WPFailRate"]))
        Min_WPFailRate_Plateau = float(data.get("Min_WPFailRate_Plateau", _DEFAULTS["Min_WPFailRate_Plateau"]))
        Max_WPFailRate_Plateau = float(data.get("Max_WPFailRate_Plateau", _DEFAULTS["Max_WPFailRate_Plateau"]))
        Min_WPFailRate_BreachFraction = float(data.get("Min_WPFailRate_BreachFraction", _DEFAULTS["Min_WPFailRate_BreachFraction"]))
        Max_WPFailRate_BreachFraction = float(data.get("Max_WPFailRate_BreachFraction", _DEFAULTS["Max_WPFailRate_BreachFraction"]))
        Single_Event_Frequency = float(data.get("Single_Event_Frequency", _DEFAULTS["Single_Event_Frequency"]))
        Single_Event_WPFailFrac_Min = float(data.get("Single_Event_WPFailFrac_Min", _DEFAULTS["Single_Event_WPFailFrac_Min"]))
        Single_Event_WPFailFrac_Max = float(data.get("Single_Event_WPFailFrac_Max", _DEFAULTS["Single_Event_WPFailFrac_Max"]))
        Single_Event_BreachArea_Min = float(data.get("Single_Event_BreachArea_Min", _DEFAULTS["Single_Event_BreachArea_Min"]))
        Single_Event_BreachArea_Max = float(data.get("Single_Event_BreachArea_Max", _DEFAULTS["Single_Event_BreachArea_Max"]))
        Flag_Use_MovingAverage = float(data.get("Flag_Use_MovingAverage", _DEFAULTS["Flag_Use_MovingAverage"]))
        Recurrence_Rate = np.array([float(x) for x in data.get("Recurrence_Rate", _DEFAULTS["Recurrence_Rate"])], dtype=float)
        DamageProb_WP = np.array([float(x) for x in data.get("DamageProb_WP", _DEFAULTS["DamageProb_WP"])], dtype=float)
        BreachArea_WP = np.array([float(x) for x in data.get("BreachArea_WP", _DEFAULTS["BreachArea_WP"])], dtype=float)
        Switch_FF_Medium = np.array([float(x) for x in data.get("Switch_FF_Medium", _DEFAULTS["Switch_FF_Medium"])], dtype=float)
        Switch_FF_Redox = np.array([float(x) for x in data.get("Switch_FF_Redox", _DEFAULTS["Switch_FF_Redox"])], dtype=float)
        FF_Length = np.array([float(x) for x in data.get("FF_Length", _DEFAULTS["FF_Length"])], dtype=float)
        FF_Hydraulic_Gradient = np.array([float(x) for x in data.get("FF_Hydraulic_Gradient", _DEFAULTS["FF_Hydraulic_Gradient"])], dtype=float)
        FF_FluidSaturation = np.array([float(x) for x in data.get("FF_FluidSaturation", _DEFAULTS["FF_FluidSaturation"])], dtype=float)
        Feature_Length = float(data.get("Feature_Length", _DEFAULTS["Feature_Length"]))
        Feature_DispersivityFraction = float(data.get("Feature_DispersivityFraction", _DEFAULTS["Feature_DispersivityFraction"]))
        Feature_Aperture = float(data.get("Feature_Aperture", _DEFAULTS["Feature_Aperture"]))
        Feature_Width = float(data.get("Feature_Width", _DEFAULTS["Feature_Width"]))
        Feature_Flux = float(data.get("Feature_Flux", _DEFAULTS["Feature_Flux"]))
        Switch_FeatureEnableMatrixDif = float(data.get("Switch_FeatureEnableMatrixDif", _DEFAULTS["Switch_FeatureEnableMatrixDif"]))
        Switch_Feature_EnableSorption = float(data.get("Switch_Feature_EnableSorption", _DEFAULTS["Switch_Feature_EnableSorption"]))
        Switch_Enable_Dynamic_GC = float(data.get("Switch_Enable_Dynamic_GC", _DEFAULTS["Switch_Enable_Dynamic_GC"]))

        return (
            SNF_Total_Mass,
            SNF_Mass_per_WP,
            Releasable_SNF,
            ModDegRate_SNF,
            EnableCombinedSFDegRate,
            sMOX_Total_Mass,
            sMOX_Mass_per_WP,
            Releasable_sMOX,
            ModDegRate_sMOX,
            EnableCombinedSMDegRate,
            HLWg_Total_Mass,
            HLWg_Mass_per_WP,
            Releasable_HLWg,
            ModDegRate_HLWg,
            HLWc_Total_Mass,
            HLWc_Total_Mass_per_WP,
            Releasable_HLWc,
            ModDegRate_HLWc,
            Switch_WP_Material,
            Switch_WP_Thickness,
            UD_WP_Thickness,
            Switch_Enable_GC,
            Switch_Enable_LC,
            WP_InternalWaterVolume,
            GC_FractionAreaBreach_Min,
            GC_FractionAreaBreach_Max,
            Switch_HS_Corrosion,
            HS_Conc_Factor,
            f1_HumidAirCorrosion_Factor,
            f2_HumidAirCorrosion_Factor,
            t1_TransitionTime_AqueousCorr,
            t2_TransitionTime_AqueousCorr,
            BF_Model_Type,
            BF_Length,
            BF_InnerRadius,
            BF_Height,
            BF_FlowFactor,
            f1_BFOpenFractionInitial,
            f2_BFOpenFractionInitial,
            f1_BFOpenFractionResidual,
            f2_BFOpenFractionResidual,
            t1_BF_DegradationTime,
            t2_BF_DegradationTime,
            f1_BFOpenFractionLate,
            f2_BFOpenFractionLate,
            t1_BF_SaturationTime,
            t2_BF_SaturationTime,
            Switch_BFtoFrac_ZeroLength,
            Swtch_FractCell_ZeroConc,
            Switch_SorptionBFtoFract,
            BFtoFrac_CrossSectionFactor,
            BFtoFrac_FlowFactor,
            Switch_EnableAlternativePaths,
            BF_Height_Top,
            AP_Length,
            AP_CrossSection,
            Switch_EnableSorption_AP,
            Switch_Feature_ZeroConc,
            AP_Switch_UD_Flow,
            AP_UD_Flow,
            AP_FlowFactor,
            Capture_Fraction,
            Alternative_Failure_Mode,
            StartTime_WPFailRate,
            EndTime_WPFailRate,
            Min_WPFailRate_Plateau,
            Max_WPFailRate_Plateau,
            Min_WPFailRate_BreachFraction,
            Max_WPFailRate_BreachFraction,
            Single_Event_Frequency,
            Single_Event_WPFailFrac_Min,
            Single_Event_WPFailFrac_Max,
            Single_Event_BreachArea_Min,
            Single_Event_BreachArea_Max,
            Flag_Use_MovingAverage,
            Recurrence_Rate,
            DamageProb_WP,
            BreachArea_WP,
            Switch_FF_Medium,
            Switch_FF_Redox,
            FF_Length,
            FF_Hydraulic_Gradient,
            FF_FluidSaturation,
            Feature_Length,
            Feature_DispersivityFraction,
            Feature_Aperture,
            Feature_Width,
            Feature_Flux,
            Switch_FeatureEnableMatrixDif,
            Switch_Feature_EnableSorption,
            Switch_Enable_Dynamic_GC,
        )

    except Exception as e:
        gspy.log("Error in process_data:\n" + traceback.format_exc(), 0)
        return (
            _DEFAULTS["SNF_Total_Mass"],
            _DEFAULTS["SNF_Mass_per_WP"],
            _DEFAULTS["Releasable_SNF"],
            _DEFAULTS["ModDegRate_SNF"],
            _DEFAULTS["EnableCombinedSFDegRate"],
            _DEFAULTS["sMOX_Total_Mass"],
            _DEFAULTS["sMOX_Mass_per_WP"],
            _DEFAULTS["Releasable_sMOX"],
            _DEFAULTS["ModDegRate_sMOX"],
            _DEFAULTS["EnableCombinedSMDegRate"],
            _DEFAULTS["HLWg_Total_Mass"],
            _DEFAULTS["HLWg_Mass_per_WP"],
            _DEFAULTS["Releasable_HLWg"],
            _DEFAULTS["ModDegRate_HLWg"],
            _DEFAULTS["HLWc_Total_Mass"],
            _DEFAULTS["HLWc_Total_Mass_per_WP"],
            _DEFAULTS["Releasable_HLWc"],
            _DEFAULTS["ModDegRate_HLWc"],
            _DEFAULTS["Switch_WP_Material"],
            _DEFAULTS["Switch_WP_Thickness"],
            _DEFAULTS["UD_WP_Thickness"],
            _DEFAULTS["Switch_Enable_GC"],
            _DEFAULTS["Switch_Enable_LC"],
            _DEFAULTS["WP_InternalWaterVolume"],
            _DEFAULTS["GC_FractionAreaBreach_Min"],
            _DEFAULTS["GC_FractionAreaBreach_Max"],
            _DEFAULTS["Switch_HS_Corrosion"],
            _DEFAULTS["HS_Conc_Factor"],
            _DEFAULTS["f1_HumidAirCorrosion_Factor"],
            _DEFAULTS["f2_HumidAirCorrosion_Factor"],
            _DEFAULTS["t1_TransitionTime_AqueousCorr"],
            _DEFAULTS["t2_TransitionTime_AqueousCorr"],
            _DEFAULTS["BF_Model_Type"],
            _DEFAULTS["BF_Length"],
            _DEFAULTS["BF_InnerRadius"],
            _DEFAULTS["BF_Height"],
            _DEFAULTS["BF_FlowFactor"],
            _DEFAULTS["f1_BFOpenFractionInitial"],
            _DEFAULTS["f2_BFOpenFractionInitial"],
            _DEFAULTS["f1_BFOpenFractionResidual"],
            _DEFAULTS["f2_BFOpenFractionResidual"],
            _DEFAULTS["t1_BF_DegradationTime"],
            _DEFAULTS["t2_BF_DegradationTime"],
            _DEFAULTS["f1_BFOpenFractionLate"],
            _DEFAULTS["f2_BFOpenFractionLate"],
            _DEFAULTS["t1_BF_SaturationTime"],
            _DEFAULTS["t2_BF_SaturationTime"],
            _DEFAULTS["Switch_BFtoFrac_ZeroLength"],
            _DEFAULTS["Swtch_FractCell_ZeroConc"],
            _DEFAULTS["Switch_SorptionBFtoFract"],
            _DEFAULTS["BFtoFrac_CrossSectionFactor"],
            _DEFAULTS["BFtoFrac_FlowFactor"],
            _DEFAULTS["Switch_EnableAlternativePaths"],
            _DEFAULTS["BF_Height_Top"],
            _DEFAULTS["AP_Length"],
            _DEFAULTS["AP_CrossSection"],
            _DEFAULTS["Switch_EnableSorption_AP"],
            _DEFAULTS["Switch_Feature_ZeroConc"],
            _DEFAULTS["AP_Switch_UD_Flow"],
            _DEFAULTS["AP_UD_Flow"],
            _DEFAULTS["AP_FlowFactor"],
            _DEFAULTS["Capture_Fraction"],
            _DEFAULTS["Alternative_Failure_Mode"],
            _DEFAULTS["StartTime_WPFailRate"],
            _DEFAULTS["EndTime_WPFailRate"],
            _DEFAULTS["Min_WPFailRate_Plateau"],
            _DEFAULTS["Max_WPFailRate_Plateau"],
            _DEFAULTS["Min_WPFailRate_BreachFraction"],
            _DEFAULTS["Max_WPFailRate_BreachFraction"],
            _DEFAULTS["Single_Event_Frequency"],
            _DEFAULTS["Single_Event_WPFailFrac_Min"],
            _DEFAULTS["Single_Event_WPFailFrac_Max"],
            _DEFAULTS["Single_Event_BreachArea_Min"],
            _DEFAULTS["Single_Event_BreachArea_Max"],
            _DEFAULTS["Flag_Use_MovingAverage"],
            np.array(_DEFAULTS["Recurrence_Rate"], dtype=float),
            np.array(_DEFAULTS["DamageProb_WP"], dtype=float),
            np.array(_DEFAULTS["BreachArea_WP"], dtype=float),
            np.array(_DEFAULTS["Switch_FF_Medium"], dtype=float),
            np.array(_DEFAULTS["Switch_FF_Redox"], dtype=float),
            np.array(_DEFAULTS["FF_Length"], dtype=float),
            np.array(_DEFAULTS["FF_Hydraulic_Gradient"], dtype=float),
            np.array(_DEFAULTS["FF_FluidSaturation"], dtype=float),
            _DEFAULTS["Feature_Length"],
            _DEFAULTS["Feature_DispersivityFraction"],
            _DEFAULTS["Feature_Aperture"],
            _DEFAULTS["Feature_Width"],
            _DEFAULTS["Feature_Flux"],
            _DEFAULTS["Switch_FeatureEnableMatrixDif"],
            _DEFAULTS["Switch_Feature_EnableSorption"],
            _DEFAULTS["Switch_Enable_Dynamic_GC"],
        )