Skip to content

Commit

Permalink
derConsumer.html: Specified larger plot size \ derConsumer.py: Demand…
Browse files Browse the repository at this point in the history
… and temperature traces on plot
  • Loading branch information
astronobri committed May 5, 2024
1 parent cf0136f commit 55e5657
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion omf/models/derConsumer.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
</div>

<p class="reportTitle" style="page-break-before:always">Plotly Test Plot</p>
<div id="plotlyPlot" class="tightContent"></div>
<div id="plotlyPlot" class="tightContent" style="width: 1000px; height: 600px;"></div>

{% endif %}
</body>
39 changes: 27 additions & 12 deletions omf/models/derConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def work(modelDir, inputDict):

## Convert temperature data from str to float
temperatures = [float(value) for value in inputDict['tempCurve'].split('\n') if value.strip()]
demand = np.asarray([float(value) for value in inputDict['demandCurve'].split('\n') if value.strip()])


## Run vbatDispatch
Expand All @@ -73,26 +74,40 @@ def work(modelDir, inputDict):


## Test plot

plotData = []
testPlot = go.Scatter(x=timestamps,
y=temperatures,
mode='lines',
line=dict(color='red',width=1),
name='Average Temperature'
)

layout = go.Layout(
title='Plotly Test Plot',
xaxis=dict(title='X Axis Title'),
yaxis=dict(title='Y Axis Title')
title='Residential Data',
xaxis=dict(title='Timestamp'),
yaxis=dict(title='Energy (kW)')
)

## Temperature curve
trace1 = go.Scatter(x=timestamps,
y=temperatures,
mode='lines',
line=dict(color='red',width=1),
name='Average Temperature'
)
plotData.append(testPlot)

plotData.append(trace1) ## Add to plotData collection

## Demand curve
trace2 = go.Scatter(x=timestamps,
y=demand,
mode='lines',
line=dict(color='black'),
name='Demand'
)
plotData.append(trace2)
print(plotData)

## Encode plot data as JSON for showing in the HTML side
outData['plotlyPlot'] = 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.electric_to_load_series_kw'].tolist()
outData["stdout"] = "Success"
outData["stderr"] = ""

Expand Down

0 comments on commit 55e5657

Please sign in to comment.