Skip to content

Commit

Permalink
adjust_hourly remove from vartable as in develop
Browse files Browse the repository at this point in the history
Fixes ETES, PTES equation issue when loading case
adjust_hourly functionality kept for scripting but was removed from UI in previous release
  • Loading branch information
sjanzou committed Apr 25, 2023
1 parent 87a2927 commit 3fa2278
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions ssc/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,12 @@ var_info vtab_adjustment_factors[] = {
"'adjust' and 'en_timeindex' separated by _ instead of : after SAM 2022.12.21", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "adjust_en_periods" , "Enable period-based adjustment factors", "0/1",
"'adjust' and 'en_periods' separated by _ instead of : after SAM 2022.12.21", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "adjust_en_hourly" , "Enable hourly-based adjustment factors", "0/1",
/* removed from UI but still used in scripts
{ SSC_INPUT, SSC_NUMBER, "adjust_en_hourly" , "Enable hourly-based adjustment factors", "0/1",
"'adjust' and 'en_hourly' separated by _ instead of : after SAM 2022.12.21", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT,SSC_ARRAY , "adjust_hourly" , "Hourly adjustment factors" , "%",
"'adjust' and 'timeindex' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "adjust_en_hourly=1" , "LENGTH=8760" , ""},
*/
{ SSC_INPUT,SSC_ARRAY , "adjust_timeindex" , "Lifetime adjustment factors" , "%",
"'adjust' and 'timeindex' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "adjust_en_timeindex=1" , "" , ""},
{ SSC_INPUT,SSC_MATRIX , "adjust_periods" , "Period-based adjustment factors" , "%",
Expand All @@ -537,10 +539,12 @@ var_info vtab_dc_adjustment_factors[] = {
"'dc_adjust' and 'constant' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "*" , "MAX=100" , ""},
{ SSC_INPUT, SSC_NUMBER, "dc_adjust_en_timeindex" , "Enable lifetime adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "dc_adjust_en_periods" , "Enable period-based adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
/* removed from UI but still used in scripts
{ SSC_INPUT, SSC_NUMBER, "dc_adjust_en_hourly" , "Enable hourly-based adjustment factors", "0/1",
"'dc_adjust' and 'en_hourly' separated by _ instead of : after SAM 2022.12.21", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT,SSC_ARRAY , "dc_adjust_hourly" , "DC Hourly adjustment factors" , "%",
"'dc_adjust' and 'timeindex' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "dc_adjust_en_hourly=1" , "LENGTH=8760" , ""},
*/
{ SSC_INPUT,SSC_ARRAY , "dc_adjust_timeindex" , "DC Lifetime Adjustment Factors" , "%" , "" , "Adjustment Factors" , "dc_adjust_en_timeindex=1" , "" , ""},
{ SSC_INPUT,SSC_MATRIX , "dc_adjust_periods" , "DC Period-based Adjustment Factors" , "%" , "n x 3 matrix [ start, end, loss ]" , "Adjustment Factors" , "dc_adjust_en_periods=1" , "COLS=3" , ""},
var_info_invalid };
Expand All @@ -550,10 +554,12 @@ var_info vtab_sf_adjustment_factors[] = {
"'sf_adjust' and 'constant' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "*" , "MAX=100" , ""},
{ SSC_INPUT, SSC_NUMBER, "sf_adjust_en_timeindex" , "Enable lifetime adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "sf_adjust_en_periods" , "Enable period-based adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
/* removed from UI but still used in scripts
{ SSC_INPUT, SSC_NUMBER, "sf_adjust_en_hourly" , "Enable hourly-based adjustment factors", "0/1",
"'adjust' and 'en_hourly' separated by _ instead of : after SAM 2022.12.21", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT,SSC_ARRAY , "sf_adjust_hourly" , "SF Hourly adjustment factors" , "%",
"'adjust' and 'timeindex' separated by _ instead of : after SAM 2022.12.21" , "Adjustment Factors" , "sf_adjust_en_hourly=1" , "LENGTH=8760" , ""},
*/
{ SSC_INPUT,SSC_ARRAY , "sf_adjust_timeindex" , "SF Lifetime Adjustment Factors" , "%" , "" , "Adjustment Factors" , "sf_adjust_en_timeindex=1" , "" , ""},
{ SSC_INPUT,SSC_MATRIX , "sf_adjust_periods" , "SF Period-based Adjustment Factors" , "%" , "n x 3 matrix [ start, end, loss ]" , "Adjustment Factors" , "sf_adjust_en_periods=1" , "COLS=3" , ""},
var_info_invalid };
Expand Down Expand Up @@ -1034,19 +1040,20 @@ bool adjustment_factors::setup(int nsteps, int analysis_period) //nsteps is set
f = 1.0 - f / 100.0; //convert from percentage to factor
m_factors.resize( nsteps * analysis_period, f);

if ( m_cm->as_boolean(m_prefix + "_en_hourly"))
{
size_t n;
ssc_number_t *p = m_cm->as_array( m_prefix + "_hourly", &n );
if ( p != 0 && n == 8760 )
{
for( int i=0;i<8760;i++ )
m_factors[i] *= (1.0 - p[i]/100.0); //convert from percentages to factors
}
else {
m_error = util::format("Hourly loss factor array length %d does not equal length of weather file %d", (int)n, nsteps);
if (m_cm->is_assigned(m_prefix + "_en_hourly")) {
if (m_cm->as_boolean(m_prefix + "_en_hourly")) {
size_t n;
ssc_number_t* p = m_cm->as_array(m_prefix + "_hourly", &n);
if (p != 0 && n == 8760)
{
for (int i = 0; i < 8760; i++)
m_factors[i] *= (1.0 - p[i] / 100.0); //convert from percentages to factors
}
else {
m_error = util::format("Hourly loss factor array length %d does not equal length of weather file %d", (int)n, nsteps);
}
}
}
}
if (m_cm->as_boolean(m_prefix + "_en_timeindex"))
{
size_t n;
Expand Down

0 comments on commit 3fa2278

Please sign in to comment.