From 92ea831893afe3ccee2dc84f144f850e1913f239 Mon Sep 17 00:00:00 2001 From: jenny Date: Wed, 29 Jan 2025 20:09:24 -0500 Subject: [PATCH] HostingCapacity: Fix for logger file. Sandia's Fix for handling no q value --- omf/models/hostingCapacity.py | 4 ++-- omf/solvers/mohca_cl/sandia.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/omf/models/hostingCapacity.py b/omf/models/hostingCapacity.py index 6fa22c862..6988cff5d 100644 --- a/omf/models/hostingCapacity.py +++ b/omf/models/hostingCapacity.py @@ -213,9 +213,9 @@ def run_ami_algorithm( modelDir, inputDict, outData ): AMI_start_time = time.time() if inputDict[ "algorithm" ] == "sandia1": if inputDict["dgInverterSetting"] == 'constantPF': - mohca_cl.sandia1( in_path=inputPath, out_path=outputPath, der_pf= float(inputDict['der_pf']), vv_x=None, vv_y=None, load_pf_est=inputDict['load_pf_est'] ) + mohca_cl.sandia1( in_path=inputPath, out_path=outputPath, der_pf= float(inputDict['der_pf']), vv_x=None, vv_y=None, load_pf_est=float(inputDict['load_pf_est'] )) elif inputDict["dgInverterSetting"] == 'voltVar': - mohca_cl.sandia1( in_path=inputPath, out_path=outputPath, der_pf= float(inputDict['der_pf']), vv_x=vv_x, vv_y=vv_y, load_pf_est=inputDict['load_pf_est'] ) + mohca_cl.sandia1( in_path=inputPath, out_path=outputPath, der_pf= float(inputDict['der_pf']), vv_x=vv_x, vv_y=vv_y, load_pf_est=float(inputDict['load_pf_est'] )) else: errorMessage = "DG Error - Should not happen. dgInverterSetting is not either of the 2 options it is supposed to be." raise Exception(errorMessage) diff --git a/omf/solvers/mohca_cl/sandia.py b/omf/solvers/mohca_cl/sandia.py index f40b2d0bf..fb9c6b219 100644 --- a/omf/solvers/mohca_cl/sandia.py +++ b/omf/solvers/mohca_cl/sandia.py @@ -54,8 +54,7 @@ def hosting_cap( """ # logging Setup - - logging.basicConfig(filename=Path(input_csv_path.parent.absolute(), 'mohca_sandia.log'), encoding="utf-8", level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') + logging.basicConfig(filename=Path(input_csv_path).parent.absolute() / 'mohca_sandia.log', encoding="utf-8", level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') logger = logging.getLogger(__name__) input_data = pd.read_csv(input_csv_path) @@ -92,7 +91,12 @@ def hosting_cap( # ensure numeric values numeric_cols = ['v_reading', 'kw_reading', 'kvar_reading'] for numeric_col in numeric_cols: - input_data[numeric_col] = pd.to_numeric(input_data[numeric_col]) + if numeric_col in input_data.columns: + input_data[numeric_col] = pd.to_numeric(input_data[numeric_col]) + + if 'kvar_reading' not in input_data.columns: + # handle case where kvar reading is not provided. + input_data['kvar_reading'] = np.nan # ensure datetime column input_data['datetime'] = pd.to_datetime(input_data['datetime'], utc=True) @@ -250,7 +254,8 @@ def hosting_cap( if ~has_input_q or has_static_pf: # static_pf_val from static PF - static_pf_val = fixed_data['pf_diff'].mean() + if has_static_pf: + static_pf_val = fixed_data['pf_diff'].mean() # skip processing warning_str = (