lib/urbanopt/reopt/scenario_report_adapter.rb in urbanopt-reopt-0.5.5 vs lib/urbanopt/reopt/scenario_report_adapter.rb in urbanopt-reopt-0.5.6
- old
+ new
@@ -1,23 +1,33 @@
# *********************************************************************************
-# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
+# URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
-#
+
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
-#
+
# Redistributions of source code must retain the above copyright notice, this list
# of conditions and the following disclaimer.
-#
+
# Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
-#
+
# Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
-#
+
+# Redistribution of this software, without modification, must refer to the software
+# by the same designation. Redistribution of a modified version of this software
+# (i) may not refer to the modified version by the same designation, or by any
+# confusingly similar designation, and (ii) must refer to the underlying software
+# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
+# the term “URBANopt”, or any confusingly similar designation may not be used to
+# refer to any modified version of this software or any modified version of the
+# underlying software originally provided by Alliance without the prior written
+# consent of Alliance.
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
@@ -155,11 +165,11 @@
end
if reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_active_timesteps].nil?
n_top_values = 100
tmp1 = reopt_inputs[:Scenario][:Site][:LoadProfile][:loads_kw]
- tmp2 = tmp1.each_index.max_by(n_top_values*reopt_inputs[:Scenario][:time_steps_per_hour]){|i| tmp1[i]}
+ tmp2 = tmp1.each_index.max_by(n_top_values*reopt_inputs[:Scenario][:time_steps_per_hour]){|i| tmp1[i]}
for i in (0...tmp2.count)
tmp2[i] += 1
end
reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_active_timesteps] = tmp2
end
@@ -208,11 +218,11 @@
def update_scenario_report(scenario_report, reopt_output, timeseries_csv_path=nil, resilience_stats=nil)
if reopt_output['outputs']['Scenario']['status'] != 'optimal'
@@logger.info("Warning cannot Feature Report #{scenario_report.name} #{scenario_report.id} - REopt optimization was non-optimal")
return scenario_report
end
-
+
# Update location
scenario_report.location.latitude_deg = reopt_output['inputs']['Scenario']['Site']['latitude']
scenario_report.location.longitude_deg = reopt_output['inputs']['Scenario']['Site']['longitude']
# Update distributed generation sizing and financials
@@ -233,11 +243,11 @@
scenario_report.distributed_generation.resilience_hours_min = resilience_stats['resilience_hours_min']
scenario_report.distributed_generation.resilience_hours_max = resilience_stats['resilience_hours_max']
scenario_report.distributed_generation.resilience_hours_avg = resilience_stats['resilience_hours_avg']
scenario_report.distributed_generation.probs_of_surviving = resilience_stats['probs_of_surviving']
scenario_report.distributed_generation.probs_of_surviving_by_month = resilience_stats['probs_of_surviving_by_month']
- scenario_report.distributed_generation.probs_of_surviving_by_hour_of_the_day = resilience_stats['probs_of_surviving_by_hour_of_the_day']
+ scenario_report.distributed_generation.probs_of_surviving_by_hour_of_the_day = resilience_stats['probs_of_surviving_by_hour_of_the_day']
end
if reopt_output['outputs']['Scenario']['Site']['PV'].class == Hash
reopt_output['outputs']['Scenario']['Site']['PV'] = [reopt_output['outputs']['Scenario']['Site']['PV']]
elsif reopt_output['outputs']['Scenario']['Site']['PV'].nil?
@@ -260,14 +270,14 @@
storage = reopt_output['outputs']['Scenario']['Site']['Storage']
if !storage['size_kw'].nil? and storage['size_kw'] != 0
scenario_report.distributed_generation.add_tech 'storage', URBANopt::Reporting::DefaultReports::Storage.new( {size_kwh: (storage['size_kwh'] || 0), size_kw: (storage['size_kw'] || 0) })
end
-
+
reopt_resolution = reopt_output['inputs']['Scenario']['time_steps_per_hour']
generation_timeseries_kwh = Matrix[[0] * (8760 * scenario_report.timesteps_per_hour)]
-
+
reopt_output['outputs']['Scenario']['Site']['PV'].each do |pv|
if (pv['size_kw'] || 0) > 0
if !pv['year_one_power_production_series_kw'].nil?
generation_timeseries_kwh += Matrix[convert_powerflow_resolution(pv['year_one_power_production_series_kw'], reopt_resolution, scenario_report.timesteps_per_hour)]
end
@@ -460,14 +470,14 @@
x[$wind_to_grid_col] = $wind_to_grid[i] || 0
return x
end
old_data = CSV.open(scenario_report.timeseries_csv.path).read
- start_date = Time.parse(old_data[1][0]) # Time is the end of the timestep
+ start_date = Time.parse(old_data[1][0]) # Time is the end of the timestep
start_ts = (
(
- ((start_date.yday - 1) * 60.0 * 60.0 * 24) +
- (((start_date.hour) - 1) * 60.0 * 60.0) +
+ ((start_date.yday - 1) * 60.0 * 60.0 * 24) +
+ (((start_date.hour) - 1) * 60.0 * 60.0) +
(start_date.min * 60.0) + start_date.sec ) /
(( 60 / scenario_report.timesteps_per_hour ) * 60)
).to_int
mod_data = old_data.map.with_index do |x, i|
if i > 0