Skip to content

Commit

Permalink
HostingCapacity: Fix for logger file. Sandia's Fix for handling no q …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
jenny-nyx committed Jan 30, 2025
1 parent 7aba76a commit 92ea831
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions omf/solvers/mohca_cl/sandia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit 92ea831

Please sign in to comment.