Skip to content

Commit

Permalink
Set hdr elev to 0 when not provided in solar resource data; add error
Browse files Browse the repository at this point in the history
checks for solar_resource_data where required
  • Loading branch information
mjprilliman committed Oct 21, 2024
1 parent f4f431a commit 86383b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions shared/lib_pv_io_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Irradiance_IO::Irradiance_IO(compute_module* cm, std::string cmName)
}
else if (cm->is_assigned("solar_resource_data")) {
weatherDataProvider = std::unique_ptr<weather_data_provider>(new weatherdata(cm->lookup("solar_resource_data")));
if (!weatherDataProvider->ok()) throw exec_error(cmName, weatherDataProvider->message());
if (weatherDataProvider->has_message()) cm->log(weatherDataProvider->message(), SSC_WARNING);
}
else {
Expand Down
2 changes: 2 additions & 0 deletions ssc/cmod_pvwattsv5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ class cm_pvwattsv5 : public cm_pvwattsv5_base
else if (is_assigned("solar_resource_data"))
{
wdprov = std::unique_ptr<weather_data_provider>(new weatherdata(lookup("solar_resource_data")));
if (!wdprov->ok()) throw exec_error("pvwattsv5", wdprov->message());
if (wdprov->has_message()) log(wdprov->message(), SSC_WARNING);
}
else
throw exec_error("pvwattsv5", "no weather data supplied");
Expand Down
2 changes: 2 additions & 0 deletions ssc/cmod_pvwattsv7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class cm_pvwattsv7 : public compute_module
else if (is_assigned("solar_resource_data"))
{
wdprov = std::unique_ptr<weather_data_provider>(new weatherdata(lookup("solar_resource_data")));
if (!wdprov->ok()) throw exec_error("pvwattsv7", wdprov->message());
if (wdprov->has_message()) log(wdprov->message(), SSC_WARNING);
}
else
throw exec_error("pvwattsv7", "No weather data supplied.");
Expand Down
4 changes: 3 additions & 1 deletion ssc/cmod_pvwattsv8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ class cm_pvwattsv8 : public compute_module
else if (is_assigned("solar_resource_data"))
{
wdprov = std::unique_ptr<weather_data_provider>(new weatherdata(lookup("solar_resource_data")));
if (!wdprov->ok()) throw exec_error("pvwattsv8", wdprov->message());
if (!wdprov->ok()) {
throw exec_error("pvwattsv8", wdprov->message());
}
if (wdprov->has_message()) log(wdprov->message(), SSC_WARNING);
}
else
Expand Down
2 changes: 2 additions & 0 deletions ssc/cmod_swh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class cm_swh : public compute_module
else if (is_assigned("solar_resource_data"))
{
wdprov = std::unique_ptr<weather_data_provider>(new weatherdata(lookup("solar_resource_data")));
if (!wdprov->ok()) throw exec_error("swh", wdprov->message());
if (wdprov->has_message()) log(wdprov->message(), SSC_WARNING);
}
else
throw exec_error("swh", "no weather data supplied");
Expand Down
7 changes: 4 additions & 3 deletions ssc/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,12 +1547,13 @@ weatherdata::weatherdata( var_data *data_table )
m_message = "missing time zone: could not find tz";
m_ok = false;
}

m_hdr.elev = get_number( data_table, "elev" );
if (std::isnan(m_hdr.elev)) {
m_message = "missing elevation: could not find elev";
m_ok = false;
m_hdr.elev = 0;
//m_message = "missing elevation: could not find elev. Setting to 0 meters.";
}

// make sure two types of irradiance are provided
size_t nrec = 0;
int n_irr = 0;
Expand Down

0 comments on commit 86383b0

Please sign in to comment.