Skip to content

Commit

Permalink
Transformer Pairing new upload file lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-nyx committed Feb 29, 2024
1 parent b64d3fd commit bc36b77
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
30 changes: 14 additions & 16 deletions omf/models/transformerPairing.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
<script src="https://cdn.plot.ly/plotly-1.50.1.min.js"></script>

<!--
file_upload('voltageDataFile', 'userInputVoltage', 'voltageDataFileName')
input for the actual file
the name of the file the user is using/inputting in
allInputDataDict[voltageDataFileName] = .csv name
-->
{% macro file_upload(fileInputID, displayNameID, fileNameID) -%}
<input type="file" id="{{fileInputID}}" name="{{ allInputDataDict[fileNameID] }}" accept=".csv" class="fileButton" onchange="updateFileNameDisplay('{{fileInputID}}', '{{displayNameID}}', '{{fileNameID}}')" style="display:none"><br>
file_upload('fileInputID', 'userInputVoltage', 'voltageDataFileName')
<input> line 1: input for the actual file.
the name of the file the user is using/inputting in. We wanna save this for display. Originally it's set as the default.
This is hidden. This is the name of the file we want always = .csv name <- default naming convention
-->
{% macro file_upload(fileInputID, userFileDisplayNameID, dataFileNameID) -%}
<input type="file" id="{{fileInputID}}" name="{{ allInputDataDict[dataFileNameID] }}" accept=".csv" class="fileButton" onchange="updateFileNameDisplay('{{fileInputID}}', '{{userFileDisplayNameID}}', '{{dataFileNameID}}')" style="display:none"><br>
<label for="{{fileInputID}}" class="fileButton">Choose File</label>
<input id="{{displayNameID}}" name="{{displayNameID}}" value="{{ allInputDataDict[fileNameID] }}" readonly class="uploadFileName">
<input id="{{fileNameID}}" name= {{fileNameID}} type="hidden" value="{{ allInputDataDict[fileNameID] }}">
<input id="{{userFileDisplayNameID}}" name="{{userFileDisplayNameID}}" value="{{ allInputDataDict[userFileDisplayNameID] }}" readonly class="uploadFileName">
<input id="{{dataFileNameID}}" name= {{dataFileNameID}} type="hidden" value="{{ allInputDataDict[dataFileNameID] }}">
{% endmacro %}

</style>
</head>
<body>
{{ omfModelTitle }}
Expand Down Expand Up @@ -51,15 +49,15 @@
<br>
<div class="shortInput">
<label class="tooltip">Voltage AMI - Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('voltageDataFile', 'userInputVoltage', 'voltageDataFileName' )}}</div>
<div>{{ file_upload('voltageDataFile', 'userInputVoltageDisplayName', 'voltageDataFileName' )}}</div>
</div>
<div class="shortInput">
<label class="tooltip">Real Power - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('realPowerDataFile', 'userInputReal', 'realPowerDataFileName') }}</div>
<div>{{ file_upload('realPowerDataFile', 'userInputRealDisplayName', 'realPowerDataFileName') }}</div>
</div>
<div class="shortInput">
<label class="tooltip">Customer ID Data - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('customerIDDataFile', 'userInputCustID', 'customerIDDataFileName') }}</div>
<div>{{ file_upload('customerIDDataFile', 'userInputCustIDDisplayName', 'customerIDDataFileName') }}</div>
</div>
<br>
<div class="shortInput">
Expand All @@ -72,11 +70,11 @@
<br>
<div class="shortInput" id="customerLatLong">
<label class="tooltip">Customer Latitude & Longitutde - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('customerLatLongDataFile', 'userInputCustLatLong', 'customerLatLongDataFileName') }}</div>
<div>{{ file_upload('customerLatLongDataFile', 'userInputCustLatLongDisplayName', 'customerLatLongDataFileName') }}</div>
</div>
<div class="shortInput" id="reactivePower">
<label class="tooltip">Reactive Power - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('reactivePowerDataFile', 'userInputReactive', 'reactivePowerDataFileName') }}</div>
<div>{{ file_upload('reactivePowerDataFile', 'userInputReactiveDisplayName', 'reactivePowerDataFileName') }}</div>
</div>
<hr>
{{ omfModelButtons }}
Expand Down
44 changes: 24 additions & 20 deletions omf/models/transformerPairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,20 @@ def work(modelDir, inputDict):
reactivePowerInputPathCSV = Path( modelDir, inputDict['reactivePowerDataFileName'])
custLatLongInputPathCSV = Path( modelDir, inputDict['customerLatLongDataFileName'])

if voltageInputPathCSV.exists() == False:
voltageInputPathCSV = Path( test_data_file_path, inputDict['voltageDataFileName'])

if realPowerInputPathCSV.exists() == False:
realPowerInputPathCSV = Path( test_data_file_path, inputDict['realPowerDataFileName'])

if custIDInputPathCSV.exists() == False:
custIDInputPathCSV = Path( test_data_file_path, inputDict['customerIDDataFileName'])

transformer_labels_errors_file_name = 'TransformerLabelsErrors_AMI.csv'
transformerLabelsErrorsPathCSV = Path( test_data_file_path, transformer_labels_errors_file_name )
transformerLabelsErrorsPathCSV = Path( modelDir, transformer_labels_errors_file_name )

if useTrueLabels:
transformer_labels_true_file_name = 'TransformerLabelsTrue_AMI.csv'
transformerLabelsTruePath = Path( test_data_file_path, transformer_labels_true_file_name )
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':
if reactivePowerInputPathCSV.exists() == False:
reactivePowerInputPathCSV = Path( test_data_file_path, inputDict['reactivePowerDataFileName'])
sdsmc.MeterTransformerPairing.TransformerPairing.run( voltageInputPathCSV, realPowerInputPathCSV, reactivePowerInputPathCSV, custIDInputPathCSV, transformerLabelsErrorsPathCSV, transformerLabelsTruePath, saveResultsPath, useTrueLabels )

elif inputDict['algorithm'] == 'customerLatLong':
if custLatLongInputPathCSV.exists() == False:
custLatLongInputPathCSV = Path( test_data_file_path, inputDict['customerLatLongDataFileName'])
sdsmc.MeterTransformerPairing.TransformerPairingWithDist.run( voltageInputPathCSV, realPowerInputPathCSV, custIDInputPathCSV, transformerLabelsErrorsPathCSV, custLatLongInputPathCSV, transformerLabelsTruePath, saveResultsPath, useTrueLabels )

else:
Expand Down Expand Up @@ -93,29 +81,45 @@ def runtimeEstimate(modelDir):
def new(modelDir):
''' Create a new instance of this model. Returns true on success, false on failure. '''

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

# Default file names from static/testFiles/
voltage_file_name = 'voltageData_AMI.csv'
real_power_file_name = 'realPowerData_AMI.csv'
customer_ids_file_name = 'CustomerIDs_AMI.csv'

reactive_power_file_name = 'reactivePowerData_AMI.csv'
customer_latlong_file_name = 'CustomerLatLon.csv'
reactive_power_file_name = 'reactivePowerData_AMI.csv'

transformer_labels_errors_file_name = 'TransformerLabelsErrors_AMI.csv'

# Default options: reactivePower, customerLatLong
defaultAlgorithm = "reactivePower"

defaultInputs = {
"modelType": modelName,
"algorithm": defaultAlgorithm,
"userInputVoltageDisplayName": voltage_file_name,
"voltageDataFileName": voltage_file_name,
"userInputRealDisplayName": real_power_file_name,
"realPowerDataFileName": real_power_file_name,
"userInputCustIDDisplayName": customer_ids_file_name,
"customerIDDataFileName": customer_ids_file_name,
"reactivePowerDataFileName": reactive_power_file_name,
"customerLatLongDataFileName": customer_latlong_file_name
"userInputCustLatLongDisplayName": customer_latlong_file_name,
"customerLatLongDataFileName": customer_latlong_file_name,
"userInputReactiveDisplayName": reactive_power_file_name,
"reactivePowerDataFileName": reactive_power_file_name
}

creationCode = __neoMetaModel__.new(modelDir, defaultInputs)

try:
shutil.copyfile( Path( test_data_file_path, voltage_file_name), Path(modelDir, voltage_file_name))
shutil.copyfile( Path( test_data_file_path, real_power_file_name), Path(modelDir, real_power_file_name))
shutil.copyfile( Path( test_data_file_path, customer_ids_file_name), Path(modelDir, customer_ids_file_name))
shutil.copyfile( Path( test_data_file_path, customer_latlong_file_name), Path(modelDir, customer_latlong_file_name))
shutil.copyfile( Path( test_data_file_path, reactive_power_file_name), Path(modelDir, reactive_power_file_name))
shutil.copyfile( Path( test_data_file_path, transformer_labels_errors_file_name ), Path(modelDir, transformer_labels_errors_file_name) )
except:
return False
return creationCode

@neoMetaModel_test_setup
Expand Down

0 comments on commit bc36b77

Please sign in to comment.