Skip to content

Commit

Permalink
Minor organizing to make code look better
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-nyx committed Mar 15, 2024
1 parent 1ecd654 commit f92238f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 8 additions & 2 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def createColorCSV(modelDir, df):

def work(modelDir, inputDict):
outData = {}

if inputDict['runAmiAlgorithm'] == 'on':
run_ami_algorithm(modelDir, inputDict, outData)
if inputDict.get('optionalCircuitFile', outData) == 'on':
Expand All @@ -61,13 +62,16 @@ def run_ami_algorithm(modelDir, inputDict, outData):
# mohca data-driven hosting capacity
inputPath = Path(modelDir, inputDict['AMIDataFileName'])
inputAsString = inputPath.read_text()

outputPath = Path(modelDir, 'AMI_output.csv')
AMI_output = []

try:
csvValidateAndLoad(inputAsString, modelDir=modelDir, header=0, nrows=None, ncols=5, dtypes=[str, pd.to_datetime, float, float, float], return_type='df', ignore_nans=False, save_file=None, ignore_errors=False )
except:
errorMessage = "AMI-Data CSV file is incorrect format. Please see valid format definition at <a target='_blank' href='https://github.com/dpinney/omf/wiki/Models-~-hostingCapacity#meter-data-input-csv-file-format'>OMF Wiki hostingCapacity</a>"
raise Exception(errorMessage)
outputPath = Path(modelDir, 'AMI_output.csv')
AMI_output = []

AMI_start_time = time.time()
if inputDict[ "algorithm" ] == "sandia1":
AMI_output = mohca_cl.sandia1( inputPath, outputPath )
Expand All @@ -77,13 +81,15 @@ def run_ami_algorithm(modelDir, inputDict, outData):
errorMessage = "Algorithm name error"
raise Exception(errorMessage)
AMI_end_time = time.time()

AMI_results = AMI_output[0].rename(columns={'kW_hostable': 'voltage_cap_kW'})
histogramFigure = px.histogram( AMI_results, x='voltage_cap_kW', template="simple_white", color_discrete_sequence=["MediumPurple"] )
histogramFigure.update_layout(bargap=0.5)
# TBD - Needs to be modified when the MoHCA algorithm supports calculating thermal hosting capacity
min_value = 5
max_value = 8
AMI_results['thermal_cap_kW'] = np.random.randint(min_value, max_value + 1, size=len(AMI_results))

AMI_results['max_cap_allowed_kW'] = np.minimum( AMI_results['voltage_cap_kW'], AMI_results['thermal_cap_kW'])
barChartFigure = px.bar(AMI_results, x='busname', y=['voltage_cap_kW', 'thermal_cap_kW', 'max_cap_allowed_kW'], barmode='group', color_discrete_sequence=["green", "lightblue", "MediumPurple"], template="simple_white" )
barChartFigure.add_traces( list(px.line(AMI_results, x='busname', y='max_cap_allowed_kW', markers=True).select_traces()) )
Expand Down
7 changes: 3 additions & 4 deletions omf/models/transformerPairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def work(modelDir, inputDict):

outData = {}
useTrueLabels = True
outData["useTrueLabels"] = useTrueLabels

saveResultsPath = modelDir
test_data_file_path = Path(omf.omfDir,'static','testFiles', 'transformerPairing')

outData["useTrueLabels"] = useTrueLabels

voltageInputPathCSV = Path( modelDir, inputDict['voltageDataFileName'])
realPowerInputPathCSV = Path( modelDir, inputDict['realPowerDataFileName'])
custIDInputPathCSV = Path( modelDir, inputDict['customerIDDataFileName'])
Expand All @@ -44,8 +45,6 @@ def work(modelDir, inputDict):
shutil.copyfile( Path( test_data_file_path, transformer_labels_true_file_name ), Path(modelDir, transformer_labels_true_file_name) )
transformerLabelsTruePath = Path(modelDir, transformer_labels_true_file_name)

saveResultsPath = modelDir

if inputDict['algorithm'] == 'reactivePower':
sdsmc.MeterTransformerPairing.TransformerPairing.run( voltageInputPathCSV, realPowerInputPathCSV, reactivePowerInputPathCSV, custIDInputPathCSV, transformerLabelsErrorsPathCSV, transformerLabelsTruePath, saveResultsPath, useTrueLabels )

Expand Down

0 comments on commit f92238f

Please sign in to comment.