Skip to content

Commit

Permalink
derConsumer.py and derConsumer.html
Browse files Browse the repository at this point in the history
  • Loading branch information
astronobri committed Apr 23, 2024
1 parent d5c0704 commit 78055d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
19 changes: 19 additions & 0 deletions omf/models/derConsumer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<head>
{{ omfHeaders }}
<script src="{{pathPrefix}}/static/highcharts4.src.js"></script>
<script src="https://cdn.plot.ly/plotly-1.50.1.min.js"></script>


<script type="text/javascript">
$(window).on('pageshow',function(){
Plotly.newPlot('plotDemand', JSON.parse(allOutputData['plotDemand']),JSON.parse(allOutputData['plotlyLayout']));
});
</script>

</head>
<body>
{{ omfModelTitle }}
Expand Down Expand Up @@ -197,6 +206,12 @@
</div>
{{ omfModelButtons }}
</form>






</div>
{{ omfRunDebugBlock }}
{% if modelStatus == 'finished' %}
Expand All @@ -220,5 +235,9 @@
</div>
{{ rawOutputFiles }}
</div>

<p class="reportTitle" style="page-break-before:always">Plotly Test Plot</p>
<div id="plotDemand" class="tightContent"></div>

{% endif %}
</body>
26 changes: 25 additions & 1 deletion omf/models/derConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from os.path import join as pJoin
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.utils

# OMF imports
from omf import feeder
Expand Down Expand Up @@ -61,11 +63,33 @@ def work(modelDir, inputDict):
json.dump(vbatResults, jsonFile)
outData.update(vbatResults) ## Update output file with vbat results


## Test plot
plotData = []
testPlot = go.Scatter(x=np.asarray(outData['tempData']),
y=np.asarray(outData['tempData']),
mode='lines+markers',
line=dict(color='blue'),
marker=dict(color='blue')
)
layout = go.Layout(
title='Plotly Test Plot',
xaxis=dict(title='X Axis Title'),
yaxis=dict(title='Y Axis Title')
)
plotData.append(testPlot)
outData['plotDemand'] = json.dumps(plotData, cls=plotly.utils.PlotlyJSONEncoder)
outData['plotlyLayout'] = json.dumps(layout, cls=plotly.utils.PlotlyJSONEncoder)


# Model operations typically ends here.
# Stdout/stderr.
outData['PV'] = results['outputs']['PV']
outData["stdout"] = "Success"
outData["stderr"] = ""

print(outData.keys())

return outData

def new(modelDir):
Expand Down Expand Up @@ -129,7 +153,7 @@ def _tests():
# Create New.
new(modelLoc)
# Pre-run.
__neoMetaModel__.renderAndShow(modelLoc) ## Why is there a pre-run?
#__neoMetaModel__.renderAndShow(modelLoc) ## Why is there a pre-run?
# Run the model.
__neoMetaModel__.runForeground(modelLoc)
# Show the output.
Expand Down

0 comments on commit 78055d1

Please sign in to comment.