Skip to content

Commit

Permalink
Add Dispatch result tab with stacked area plots for power to load
Browse files Browse the repository at this point in the history
  • Loading branch information
mjprilliman committed May 16, 2024
1 parent eabad59 commit 37d497b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
90 changes: 89 additions & 1 deletion src/results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ ResultsViewer::ResultsViewer(wxWindow* parent, int id)
if (CaseWindow* cw = static_cast<CaseWindow*>(this->GetParent()->GetParent()))
{
wxString tech_model = cw->GetCase()->GetConfiguration()->TechnologyFullName;
wxString fin_model = cw->GetCase()->GetFinancing();
if (tech_model == "Wind Power")
{
m_uncertaintiesViewer = new UncertaintiesViewer(this);
Expand All @@ -538,6 +539,12 @@ ResultsViewer::ResultsViewer(wxWindow* parent, int id)
m_spatialLayout = new wxSnapLayout(this, wxID_ANY);
AddPage(m_spatialLayout, "Spatial", true);
}

if (tech_model == "PV Battery")
{
m_battVisualization = new wxDVTimeSeriesCtrl(this, wxID_ANY, wxDV_RAW, wxDV_AVERAGE);
AddPage(m_battVisualization, "Dispatch");
}
}
//m_durationCurve = new wxDVDCCtrl( this, wxID_ANY );
//AddPage( m_durationCurve, "Duration curve" );
Expand All @@ -558,6 +565,12 @@ wxDVPlotCtrlSettings ResultsViewer::GetDViewState()
settings.SetProperty(wxT("tsTopSelectedNames"), m_timeSeries->GetDataSelectionList()->GetSelectedNamesInCol(0));
settings.SetProperty(wxT("tsBottomSelectedNames"), m_timeSeries->GetDataSelectionList()->GetSelectedNamesInCol(1));

//***TimeSeries Properties***
settings.SetProperty(wxT("tsAxisMin"), m_battVisualization->GetViewMin());
settings.SetProperty(wxT("tsAxisMax"), m_battVisualization->GetViewMax());
settings.SetProperty(wxT("tsTopSelectedNames"), m_battVisualization->GetDataSelectionList()->GetSelectedNamesInCol(0));
settings.SetProperty(wxT("tsBottomSelectedNames"), m_battVisualization->GetDataSelectionList()->GetSelectedNamesInCol(1));

//settings.SetProperty(wxT("tsDailyAxisMin"), m_dailySeries->GetViewMin());
//settings.SetProperty(wxT("tsDailyAxisMax"), m_dailySeries->GetViewMax());
//settings.SetProperty(wxT("tsDailyTopSelectedNames"), m_dailySeries->GetDataSelectionList()->GetSelectedNamesInCol(0));
Expand Down Expand Up @@ -649,6 +662,56 @@ void ResultsViewer::SetDViewState(wxDVPlotCtrlSettings& settings)
if (settings.GetProperty(wxT("tsAxisMax")).ToDouble(&max))
m_timeSeries->SetViewMax(max);

long j;
settings.GetProperty(wxT("tabIndex")).ToLong(&i);
SetSelection(i);

//Battery visualization test
int batt_index = -1;
int load_index = -1;
int gen_index = -1;
int grid_index = -1;
for (size_t j = 0; j < m_tsDataSets.size(); j++)
{
if (m_tsDataSets[j]->GetMetaData() == "batt_to_load") {
batt_index = j;
}
if (m_tsDataSets[j]->GetMetaData() == "grid_to_load") {
grid_index = j;
}
if (m_tsDataSets[j]->GetMetaData() == "system_to_load") {
gen_index = j;
}
if (m_tsDataSets[j]->GetMetaData() == "load") {
load_index = j;
}
}



//***TimeSeries Properties***
m_battVisualization->SetStackingOnYLeft(true); //Turn on stacked area plot
m_battVisualization->SetTopSelectedNames(settings.GetProperty(wxT("tsTopSelectedNames")));
m_battVisualization->SetBottomSelectedNames(settings.GetProperty(wxT("tsBottomSelectedNames")));

// select something by default
if (m_battVisualization->GetNumberOfSelections() == 0) {
m_battVisualization->SelectDataSetAtIndex(batt_index,0);
m_battVisualization->SelectDataSetAtIndex(grid_index,0);
m_battVisualization->SelectDataSetAtIndex(gen_index,0);
m_battVisualization->SelectDataSetAtIndex(load_index, 1);

}

//Set min/max after setting plots to make sure there is an axis to set.
if (settings.GetProperty(wxT("tsAxisMin")).ToDouble(&min))
m_battVisualization->SetViewMin(min);
/*
if (settings.GetProperty(wxT("tsAxisMax")).ToDouble(&max))
m_battVisualization->SetViewMax(max);
*/
m_battVisualization->SetViewMax(500);

// m_dailySeries->SetTopSelectedNames(settings.GetProperty(wxT("tsDailyTopSelectedNames")));
// m_dailySeries->SetBottomSelectedNames(settings.GetProperty(wxT("tsDailyBottomSelectedNames")));

Expand Down Expand Up @@ -779,7 +842,17 @@ wxString ResultsViewer::GetCurrentContext() const
else
return "notices";
}
case 11: return "notices";
case 11:
// TODO: remove this when uncertainties available for all technologies
if (CaseWindow* cw = static_cast<CaseWindow*>(this->GetParent()->GetParent()))
{
wxString tech_model = cw->GetCase()->GetConfiguration()->TechnologyFullName;
if ( tech_model == "PV Battery")
return "dispatch";
else
return "notices";
}
case 12: return "notices";
default: return "results";
}
}
Expand Down Expand Up @@ -1368,6 +1441,19 @@ void ResultsViewer::Setup(Simulation* sim)
int pn = GetPageIndex(m_spatialLayout);
if (pn > -1) HidePage(pn);
}

if (tech_model == "PV Battery")
{
// if model was changed from another technology, the ResultsViewer was not initialized with Uncertainties
if (!m_battVisualization) {
m_battVisualization = new wxDVTimeSeriesCtrl(this, wxID_ANY, wxDV_RAW, wxDV_AVERAGE);
AddPage(m_battVisualization, "Dispatch");
}
/*
else
m_battVisualization->RemoveAllDataSets();
*/
}
}
m_tables->Setup(m_sim);

Expand Down Expand Up @@ -1617,6 +1703,7 @@ void ResultsViewer::AddDataSet(wxDVTimeSeriesDataSet* d, const wxString& group,
d->SetGroupName(group);

m_timeSeries->AddDataSet(d, update_ui);
m_battVisualization->AddDataSet(d, update_ui);
// m_dailySeries->AddDataSet(d, update_ui);
m_dMap->AddDataSet(d, update_ui);
m_profilePlots->AddDataSet(d, update_ui);
Expand Down Expand Up @@ -1896,6 +1983,7 @@ void ResultsViewer::ExportEqnExcel()
void ResultsViewer::RemoveAllDataSets()
{
m_timeSeries->RemoveAllDataSets();
m_battVisualization->RemoveAllDataSets();
//m_dailySeries->RemoveAllDataSets();
m_dMap->RemoveAllDataSets();
m_profilePlots->RemoveAllDataSets();
Expand Down
1 change: 1 addition & 0 deletions src/results.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class ResultsViewer : public wxMetroNotebook

std::vector<wxDVTimeSeriesDataSet*> m_tsDataSets;
wxDVTimeSeriesCtrl *m_timeSeries = nullptr;
wxDVTimeSeriesCtrl* m_battVisualization = nullptr;
wxDVDMapCtrl *m_dMap = nullptr;
wxDVProfileCtrl *m_profilePlots = nullptr;
wxDVStatisticsTableCtrl *m_statTable = nullptr;
Expand Down

0 comments on commit 37d497b

Please sign in to comment.